Fundamentals of Prompt Engineering
Modern AI language models require well-crafted prompts to unlock their full potential. Therefore, mastering the skill of writing effective prompts is crucial.
Generative AI is incredibly useful, but it needs human guidance. In many ways, generative AI can be likened to a highly capable new intern at a company—possessing great potential but requiring clear instructions to perform optimally. The ability to properly guide generative AI is a powerful skill. You can direct generative AI by sending a prompt, which is typically a text-based instruction. A prompt is the input provided to the AI assistant, and it significantly influences the output. An effective prompt should be structured, clear, concise, and purposeful.
How to Craft a Well-Structured Prompt
A structured prompt refers to one that is constructed with a clear logic and organization. For example, if you want the model to generate an article, your prompt might need to include information such as:
The article's main topic
An outline of the article
The desired writing style
Let's examine a basic example of a discussion question:
"What are the most pressing environmental issues facing our planet, and what measures can individuals take to help address these problems?"
We can transform this into a simple assistant prompt by prefacing it with "Answer the following question:"
Since the results generated from this prompt are inconsistent, with some responses consisting of only one or two sentences, they are not ideal. A typical discussion answer should comprise multiple paragraphs. An effective prompt should provide specific instructions for format and content. To improve consistency and quality, you need to eliminate ambiguity in the language. Here's an improved prompt:
The second prompt generated a longer output with an improved structure. The use of the term "essay" in the prompt was intentional, as the assistant understands the definition of an essay and is therefore more likely to produce a coherent, structured response.
How to Improve Quality and Effectiveness
There are several key methods to enhance the quality and effectiveness of prompts:
Clearly define your requirements: The model's output will strive to meet your needs as closely as possible. If your requirements are ambiguous, the output may not meet your expectations.
Use correct grammar and spelling: The model tends to mimic your language style, so if there are issues with your language, the output may reflect those problems.
Provide sufficient context: The model generates output based on the contextual information you provide. If the context is insufficient, it may be challenging to produce the desired results.
After crafting effective prompts for discussing issues, you'll need to refine the generated results. This may involve adjusting the output to meet specific constraints, such as word count limitations, or combining concepts from different generated results.
A simple method for iteration is to generate multiple outputs and review them to understand the concepts and structures being used. Once you've evaluated the outputs, you can select the most suitable ones and combine them into a coherent response. Another iterative approach is to start small and gradually expand. This requires more than one prompt: an initial prompt to write the first paragraph or two, followed by additional prompts to expand on what has already been written.
Here's a potential philosophical discussion question:
"Is mathematics invented or discovered? Explain your answer with careful reasoning."
Add this to a simple prompt as follows:
I generated several responses and found one I liked:
This is a good starting point. I then used another prompt to expand:
I used this prompt to generate several expansions and selected one I liked, ultimately resulting in the following:
By using expanded prompts, we can write incrementally and iterate on each step. This approach is particularly useful in scenarios where generating higher quality output is required and step-by-step modifications are desired.
Last updated