Introduction
Prompt engineering is the art of crafting high-quality queries to elicit accurate and relevant responses from large language models (LLMs) like GPT-4o. This guide provides strategies, tactics, and techniques to improve the performance of LLMs by optimizing queries and fine-tuning their responses.
Section 1: Write Clear Instructions
- Write clear instructions: Provide context and details to help the model understand the task and reduce ambiguity.
- Include details in your query: Avoid vague requests by including specific information, such as numbers, dates, and names.
- Ask the model to adopt a persona: Specify the tone, style, and tone of the response.
- Use delimiters to clearly indicate distinct parts of the input: Define sections, such as headers, lists, and quotes, to guide the model’s output.

Section 2: Provide Reference Text
- Instruct the model to answer using a reference text: Provide trusted information for the model to use in its response.
- Instruct the model to answer with citations: Request references or citations from the provided text to verify the accuracy of the response.
Section 3: Split Complex Tasks into Simpler Subtasks
- Use intent classification: Identify the most relevant instructions for a user query and use them to guide the model’s response.
- Use a taxonomy: Define a hierarchical structure of categories and subcategories to classify user queries and provide more accurate responses.
- Use embeddings-based search: Implement efficient knowledge retrieval by using vector search algorithms to find relevant information.
Section 4: Give Models Time to “Think”
- Instruct the model to work out its own solution before rushing to a conclusion: Allow the model to reason and generate its response without interference.
- Use inner monologue or a sequence of queries: Hiding the model’s reasoning process or using multiple queries to hide the output, respectively.
- Ask the model if it missed anything on previous passes: Instruct the model to revisit previous responses and provide additional information.
Section 5: Use External Tools
- Use code execution to perform more accurate calculations or call external APIs: Instruct the model to write and execute code or interact with external APIs.
- Give the model access to specific functions: Pass function descriptions to the model and let it generate function arguments.
- Use embeddings-based search: Implement efficient knowledge retrieval to provide more accurate responses.
Section 6: Test Changes Systematically
- Evaluate model outputs with reference to gold-standard answers: Compare model responses to known facts and track the overlap and contradiction.
- Use OpenAI Evals: Utilize the open-source software framework to automate evaluation and create custom evaluation procedures.
- Consider model-based evals: Evaluate model responses using other models or AI-powered tools.
Key Takeaways
- Clear instructions and context are crucial for accurate responses.
- Providing reference text and splitting complex tasks into simpler subtasks can improve performance.
- Giving models time to “think” and using external tools can result in more accurate responses.
- Evaluating changes systematically is essential to optimize system designs.
Additional Resources
- OpenAI Cookbook: A collection of examples and recipes for implementing prompt engineering techniques.
- OpenAI Evals: An open-source software framework for creating automated evaluation procedures.
- GPT-4o documentation: Learn more about the capabilities and limitations of GPT-4o and other LLMs.
Here comming some Prompting Examples which you can use to play with:
For Summaries
- Write a 50-word summary of the meeting notes in a single paragraph.
- Summarize the text delimited by triple quotes in 2 paragraphs.
- Provide five alternatives for a thesis title based on the abstract provided.
General
- Write a paragraph summarizing the main points of the article.
- Provide a brief overview of the topic, highlighting the key points.
- Give a general description of the concept, including its definition, history, and importance.
- Create a list of 10 key points about the topic.
- Write a short essay summarizing the main points of the chapter.
- Generate a table summarizing the key findings of the study.
Specific Topics
- Write a strong opening sentence for an article about climate change.
- Generate a list of 5 potential solutions to addressing poverty in urban areas.
- Provide a brief overview of the history of artificial intelligence, highlighting key milestones and developments.
- Create a list of 10 benefits of meditation for mental health.
- Write a short paragraph summarizing the main points of the economic report.
Product Descriptions
- Write a product description for a new smartphone highlighting its features and benefits.
- Generate a list of 10 key features of the new smartphone.
- Create a table comparing the specifications of the old and new smartphones.
- Write a paragraph outlining the differences between the two versions of the software.
- Generate a list of 10 key benefits of the new software.
Dialogue
- Write a response to a customer service query, apologizing for an error and offering a solution.
- Generate a conversation between two characters about the latest fashion trends.
- Create a script for a conversation between a customer and a salesperson.
- Write a response to a user’s question about a product’s warranty.
- Generate a list of 10 tips for improving communication skills.
Creative Writing
- Write a short story about a character overcoming a challenge.
- Generate a poem about a memory from childhood.
- Create a script for a scene from a movie or play.
- Write a paragraph about a character’s motivations and goals.
- Generate a list of 20 potential plot twists for a story.
Trivia
- Write a set of questions about the history of the company.
- Generate a list of 10 key historical dates related to the topic.
- Create a table comparing the differences between species.
- Write a paragraph about the importance of the topic.
- Generate a list of 10 key findings from the study.
Technical Writing
- Write a technical description of the software’s architecture.
- Generate a list of 10 key technical features of the product.
- Create a table comparing the specifications of the old and new hardware.
- Write a paragraph outlining the security measures used in the system.
- Generate a list of 10 key benefits of the new technology.
Other
- Write a letter to the editor responding to an article.
- Generate a list of 10 potential topics for future research.
- Create a table summarizing the key points of the debate.
- Write a paragraph outlining the limitations of the study.
- Generate a list of 10 key recommendations for the company.
These are just a few examples, but you can adapt the prompts to fit your specific needs and use cases. Remember to keep your prompts clear, concise, and specific to get the most accurate and relevant responses from the language model.
Conclusion
Prompt engineering is a crucial aspect of optimizing the performance of large language models. By following the strategies and tactics outlined in this guide, you can create high-quality queries that elicit accurate and relevant responses from LLMs. Remember to test changes systematically and consider the capabilities and limitations of your model.