Back to list

Prompt Engineering Guide

Six Strategies for Getting Better Results

OpenAI recommends six strategies for getting better results:

  1. Write Clear Instructions: Specific instructions reduce errors. If you need brief replies or expert-level answers, mention it. For better formatting, demonstrate your preferred structure.
  2. Provide Reference Text: Language models may generate fake answers, so giving relevant reference material can increase accuracy and reduce errors.
  3. Split Complex Tasks: Breaking down tasks into simpler subtasks improves accuracy. For dialogue or summarization tasks, tackle each part sequentially.
  4. Give Models Time to Think: Asking models to explain their reasoning process improves accuracy for complex queries. Prompt them to analyze or summarize before providing a final answer.
  5. Use External Tools: Models can utilize tools for tasks beyond their native abilities, like retrieving documents or performing calculations, for more accurate and reliable outputs.
  6. Test Changes Systematically: Regularly evaluate prompt changes with representative test cases to ensure consistent performance improvements.

Few-shot Learning

Few-shot learning is a prompt engineering technique used to guide AI models in understanding specific tasks by providing a few examples of input-output pairs. By showing the model a handful of samples that demonstrate the desired format, tone, or structure, few-shot examples help the model infer the patterns it needs to follow, even when specific instructions are minimal or implicit. This approach leverages “in-context learning,” where the AI model generalizes from examples within the prompt without requiring fine-tuning.

Take a look at this instructional example utilizing few-shot learning:

[@portabletext/react] Unknown block type "codeBlock", specify a component for it in the `components.types` prop

Other References