How to Write Effective Prompts for AIGC

In the first three articles of this series, we introduced the concept of large language models (link), training methods (link), and core capabilities (link). However, using GPT effectively is still not a simple task. The key to mastering AIGC lies in writing effective prompts.

How to Write Effective Prompts for AIGC

Prompt: Refers to a segment of text input provided to the language model to guide it in generating the corresponding output. This prompt can be a question, instruction, introduction, or any other form of text. Its purpose is to set the context, allowing the model to understand the user’s intent and generate contextually relevant answers or complete tasks.

If your application of GPT is simply for casual conversation, then you don’t need to spend too much time reading this article. Almost all online GPT services have already become quite proficient in conversation without specialized learning. However, if you want GPT to become a productivity tool to help you complete your daily tasks, then the content of this article is definitely worth reading and saving.The knowledge and skills related to prompts provided in this article are applicable to all GPT-based products, including ChatGPT, Claude, Tongyi Qianwen, Wenxin Yiyan, Llama, ChatGLM, etc.

How to Write Effective Prompts for AIGC
Basic Elements of a Prompt

A well-designed prompt should contain four basic elements: instruction, context, input data, and output indication.

  • Instruction: The specific task assigned to GPT or the question that needs to be answered. The instruction must be clear, explicit, and detailed, without ambiguity, allowing GPT to truly understand your intent.

  • Context: Additional information needed to better complete the task or answer the question. The text in the following image intuitively illustrates the concept and value of context: as the context becomes clearer, the responses from the model will increasingly meet the requirements.

How to Write Effective Prompts for AIGC
  • Input Data: The raw content that you want GPT to process. For example, meeting notes that need summarizing, news articles that need polishing, or emails that need replies. In the prompt, input data is generally enclosed with “` (three backticks, a character rarely used, accessible via the top left key on the keyboard) to indicate that this text is not an instruction but content that needs processing. For example, in the prompt below, the original email that needs a reply is enclosed with “`.

How to Write Effective Prompts for AIGC
  • Output Indicator:: Specifies the format of the output from GPT. The output indicator can clearly state the format, outline, and length requirements for the output to obtain content that better meets your needs.

How to Write Effective Prompts for AIGC
Key Techniques for Prompts
  • Let GPT Assume a Specific Role

When using GPT, you can have it assume a specific role, even setting its personality and style, and GPT will respond according to the established role and style. For example:

You are a travel enthusiast, adept at using words to record the scenery and culture encountered during travels. You enjoy using beautiful, lyrical language in your travelogues, focusing on expressing your personal feelings during the trip rather than simply introducing the sights. Now, please write a travelogue about Huangshan.
You are an event planner whose daily work involves drafting event plans based on goals. You like to consider things in detail and provide comprehensive plans to ensure the orderly progress of event preparations. Now, please write an event plan for xxx.

In fact, some copywriting assistants and smart agents in certain AIGC platforms on the internet preset specific “roles” to ensure that the text output aligns with the style of certain scenarios. Understanding this technique allows you to flexibly set role styles in your prompt according to your needs, rather than relying solely on the preset roles in the platform.

  • Learn to Provide Examples

In the previous article, we discussed one of the core capabilities of GPT, scenario learning. We can use examples in conversations to help GPT understand the tasks it needs to perform. This is an important technique for writing prompts: adding examples to the instructions helps GPT better understand our requirements, leading to outputs that align more closely with our expectations. For example:

You are a copywriter skilled at writing product copy for social media that generates buzz. You like to use emojis in the titles to create eye-catching headlines. Here are some examples:

Product: Phone Charger

Title: ⚡【Charging Revolution⚡】Say Goodbye to Battery Anxiety, The Secret Weapon That Charges Instantly🚀

Product: Robot Vacuum Cleaner

Title: 🤖【Housework Terminator🤖】One-Click Start, Enjoy a New Life of Smart Cleaning✨

Now, please provide the most suitable copy title for the newly launched “Flying Car”.

  • Encourage GPT to Think Step by Step

If you want GPT to answer a complex question, simply providing the answer may not be easy. It is better to break the question down into smaller questions and ask GPT step by step, making it easier to achieve the desired result. For instance, directly asking GPT to draft a detailed planning document can be quite challenging, but you can first ask GPT to produce a general outline for the planning document, then ask it to write the corresponding content for each section, and finally have it polish and optimize the complete document. This gradual breakdown of complex tasks makes it easier to achieve the final result.

Of course, another important technique is to activate GPT’s chain of thought. For complex logical problems, providing specific steps for thinking in the prompt can help GPT answer questions in a more logical manner. The simplest way to activate the chain of thought is to add a phrase in the prompt: Please think step by step before answering; this can yield surprising results.

  • Repeat the Instructions at the End of the Prompt

We usually clarify the instructions at the beginning of the prompt, but if the prompt is lengthy and contains a lot of information, it is advisable to repeat the instructions at the end. This is because GPT is more sensitive to the information provided at the end of the prompt, and reiterating the instructions will help GPT better understand what task it needs to complete.

  • Use Markdown to Format Prompts

Although many people are unfamiliar with the term Markdown, it is one of the most important document formatting languages in the world of GPT. When we see that the content output by GPT has highlighted titles and subtitles, we can be sure that Markdown has been used. Below is a brief introduction to Markdown.

Markdown is a lightweight document formatting syntax that allows you to define the structure of a document, mark important text, create simple tables, etc. It is pure text but can be rendered into HTML format, allowing it to display formatted document content on web pages. Learning Markdown in its entirety is not difficult; interested readers can find a tutorial online. Here, I will introduce three of the most important syntax elements to keep in mind when writing prompts:

  • Use “#” to Define Heading Levels: In Markdown, # is used to define heading levels (which also determines the structure of the document). One # is generally used for the main title, ## for first-level subheadings, ### for second-level subheadings, and so on. If the prompt we are writing is complex, we can use ## to create a first-level directory.

  • Use “-” to Indicate Lists: When we need to express multiple instructions in the prompt, it is best to use a list format for clarity. A list is created by adding a “-” before each item.

  • Use ““`” to Introduce Text: Adding three consecutive backticks before and after a segment of text indicates that this is a quote. The purpose of this was mentioned earlier, so I won’t repeat it here.

Of course, Markdown has many powerful formatting capabilities, but they are generally not needed when writing prompts, so I won’t go into detail here.

How to Write Effective Prompts for AIGC
Reference Structure for Prompts

Having understood the elements and techniques of prompts, we still need to know what a good prompt looks like. This brings us to the most critical part of this article: a prompt that can generate productivity is essentially a well-organized integration of the elements and techniques discussed above. The following image shows a complete prompt structure and explanation that can handle the vast majority of real-world scenario needs.

How to Write Effective Prompts for AIGC

The example prompt structure shown in the image above can meet the vast majority of real-world scenario requirements. During specific usage, adjustments can be made according to your needs. For example, if you don’t have examples at hand, you can remove that section; if the problem is complex, you may need to add a paragraph for thinking steps to activate GPT’s chain of thought ability.

How to Write Effective Prompts for AIGC
Prompt Engineering

Although this article has discussed the elements, techniques, and reference structures of prompts, applying them to specific work tasks will reveal that writing a prompt capable of solving problems still requires continuous experimentation, optimizing and adjusting the prompt based on GPT’s responses until we achieve the desired results. This iterative process of optimizing prompts is known as prompt engineering.

Some may think that prompt engineering should be done by technical personnel. Indeed, technical personnel will inevitably practice this aspect when integrating GPT with business systems. However, ordinary users should also be aware of this when using GPT, as it helps accumulate the ability to master AIGC. For ordinary users, I have three suggestions:

  • Be Patient in the Process of Optimizing Prompts: Identify issues based on GPT’s output, and continuously iterate and adjust the prompt. This process is very similar to the debugging process of software developers. The difference is that software developers need to use specialized programming languages, while in the world of GPT, we only need to use natural language. As long as you remain patient, you will definitely find the right prompt to complete the task.

  • Break Down Complex Tasks and Give GPT More Thinking Time: For example, if you want GPT to help you write a 10,000-word project feasibility plan, no matter how many prompt techniques you master, expecting a single powerful prompt to produce a lengthy feasibility plan is unrealistic. Instead, we can break down the task: first ask GPT to produce a first-level outline, then a second-level outline for each paragraph, and finally write specific content according to the outline. This way, you can accomplish the complex task through a series of prompts, step by step.

  • Save Well-Written Prompts: Once a prompt successfully completes a task, be sure to save it for future use. Of course, if you are a technical person, programming or scripting the prompt will make it even more convenient to use.

By understanding the elements and techniques of prompts and practicing continuously, you will accumulate the experience and skills necessary to write effective prompts, at which point you can truly master GPT. There’s a saying that goes well: The future is here; what defeats you is not AI, but those who know how to use AI.

How to Write Effective Prompts for AIGC

How to Write Effective Prompts for AIGC

Leave a Comment