How to write a good prompt? A step-by-step guide to using prompts to master AI (1) Today, AI is everywhere, from chatbots, content creation, program development, to various auxiliary tools in work and study. But have you ever encountered such a situation? • The answer given by AI is irrelevant to the question? • The output is a mess? • The generated text is not specific enough and cannot be used directly? The root of these problems is often not AI, but the "prompt" you wrote is not clear enough. You must know that AI cannot really understand what you are thinking in your mind. It can only guess your needs based on the prompt you input. This article will guide you step by step to learn how to write high-quality prompts, so that AI can become your good helper from now on! What is a prompt? A prompt is a description of what you tell AI to do and how to do it. A good prompt usually consists of four key elements: • Instruction: What do you want the AI to do? • Context: What background information does the AI need to complete the task? • Output Format: What format do you want the result to be output in? • Role: What role should the AI assume when performing the task? Mastering these four elements will allow you to precisely control the results generated by the AI. 1. Instruction—Clarity is key! What exactly is an instruction? An instruction is like a command or question you give the AI, such as: • "Summarize the key points of the following article." • "Write a popular science article about the history of AI." But not all instructions are good. What are good instructions? ❌ Examples of bad instructions: • Write an article • Make a game • Come up with a good name These instructions are vague and make it difficult for the AI to determine what you want. ✅ Examples of good instructions: • Write a 1,000-word article exploring the application of AI in medical diagnosis, aimed at middle school students, using simple, accessible language and a popular science style. • Write a 3D Snake game that can be run on a webpage, with smooth graphics and keyboard support. • Come up with three creative, memorable, and topic-focused names for my AI writing product. As you can see, clear and specific instructions can greatly improve AI's performance. 2. Context - Helping AI Understand You Better. What is context? Context refers to the additional background information AI needs to complete its tasks, such as a draft of your current paper, your company's past data, and relevant reference materials for the specific task. For example: • "Below is our company's sales data from the past three years. Please analyze and provide suggestions for improving sales." • "I'm writing a paper on artificial intelligence. This is my first draft. Please help me improve it and add appropriate academic references." Context can be content you provide yourself or content previously generated by the AI. Why is context important? AI doesn't know the information in your mind. Without context, it can only make blind guesses, and the content it generates will naturally be biased or even off-topic. For example, if you ask, "Write me a resume," AI doesn't know your background, skills, or job goals and can only provide general information. But if you provide it with context, such as: • Your personal information (name, education, project experience) • The cultural background of your target position and company, AI can easily write a precise and tailored resume. How can we improve the quality of context? • Check whether you've provided all the required information for the task. • Proactively ask the AI: "What else do you need to know to complete this article?" • Provide reference examples or sample papers to help the AI better understand your expectations. III. Output Format - Helping the AI deliver better results. The output format tells the AI how you want the results to be presented. For example: • "Please present the following information in a table, with columns for date, event, and impact." • "Generate a 500-word abstract divided into three sections: introduction, main points, and conclusion." • "Please output in Markdown format, using first-level and second-level headings, and ordered lists." What are some common and easy-to-use output formats? • Text: Markdown, CSV, JSON, XML • Diagram: Flowcharts (Mermaid), mind maps • Code: Code examples in various programming languages • Mathematical formulas: LaTeX How to specify the format precisely? The simplest and most effective approach: • Provide a clear example (few-shot): Show the expected output template. • Describe the content requirements for each section in detail. • Use pseudocode or type definitions to explain the structure to the AI. For example, if you want the AI to generate a JSON string: Please generate the following JSON format: { "title": "Article Title", "content": [ { "heading": "First-level Title", "paragraph": "Content Paragraph" } ] } This way, the AI can easily provide the precise formatting you need. IV. Roles – Giving AI a "Soul" A role is the identity the AI assumes when completing a task. You don't have to set a role, but the right role allows the AI to more accurately grasp your needs and provide more professional services. For example: • "You are an experienced software engineer. Please review and optimize the following code for me." • "You are a psychological counselor. Please analyze the following problem for me in a gentle and empathetic tone." • "You are a Socratic mentor. Please help me understand AI concepts through inspiring questions." The benefits of role setting include: • Clarifying the AI's task boundaries and perspectives. • Allowing the AI to more accurately apply its trained domain knowledge. Comprehensive Example: Mastering these four elements will unlock the essence of prompts. Now, let's combine all the above elements to see a complete, high-quality prompt example: Task: Write a summary of AI applications in the medical field. "You are a popular science writer skilled at explaining technology in layman's terms (role). Based on the abstracts of the two academic papers provided below (context), write a summary of under 500 words (output format) suitable for middle school students. The article should be easy to understand and provide at least two specific examples to illustrate how AI can improve medical diagnosis (instructions)." With these prompts, AI will quickly and accurately generate the content you desire. Summary: The secret to writing effective prompts is to firmly remember these four elements: ✅ Clear and specific instructions ✅ Complete and sufficient context ✅ Clear output format ✅ Precise role identification. Next time you use AI, consider practicing this method; I believe you'll achieve unexpectedly satisfying results!
Simply put: the similarity is that the context still needs to be clear; the difference is that you don't nx.com/leaferinger/st…ce model what to do; it will try to find the best path. For example, if you ask GPT-4o to translate, you might tell it to first translate literally and then paraphrase. With o1, you can simply ask it to rewrite the above content in Chinese.