Lesson 1 of 5 in Prompt Tuning, Fine-Tuning & Reasoning · 9m

Prompting fundamentals

The system prompt

A good system prompt reads like a task spec: who the model is acting as, what it receives, exactly what to return, and what it must never do. Ambiguity in the prompt becomes inconsistency in the output.

Few-shot examples

Showing the model a few solved examples is often the single biggest gain, as the GPT-3 paper found across many tasks [1]. Choose examples that cover the hard cases and show the exact output format. Order matters too: models use information at the start and end of a long context better than information in the middle [2], so put the essentials where they'll be seen.

Asking for reasoning

Chain-of-thought prompting, which shows worked reasoning steps in the examples, substantially improved large models on arithmetic, commonsense and symbolic reasoning benchmarks [3]. Self-consistency goes further: sample several reasoning paths and take the majority answer [4]. Both cost extra tokens and latency, so use them where the task needs multi-step reasoning, not for simple classification.

You classify customer support tickets.

Input: one ticket, in any language.
Output: exactly one of billing | bug | feature_request | other.
Return only the label, lower case, nothing else.

Ticket: "I was charged twice this month."
Label: billing

Ticket: "The export button does nothing on Safari."
Label: bug

Key takeaways

  • Write the system prompt as a spec with an exact output format.
  • Few-shot examples should cover hard cases; keep key material out of the middle of long contexts.
  • Reasoning prompts help on multi-step problems and cost latency everywhere.
Sources
  • Brown, T. et al. (2020). Language Models are Few-Shot Learners. NeurIPS 2020 · arXiv:2005.14165.
  • Liu, N. F. et al. (2023). Lost in the Middle: How Language Models Use Long Contexts. TACL 2024 · arXiv:2307.03172.
  • Wei, J. et al. (2022). Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. NeurIPS 2022 · arXiv:2201.11903.
  • Wang, X. et al. (2022). Self-Consistency Improves Chain of Thought Reasoning in Language Models. ICLR 2023 · arXiv:2203.11171.

Keep going with Prompt Tuning, Fine-Tuning & Reasoning

This is one of 5 lessons in the course. Enroll to get the rest of the course, with an AI tutor that knows the material, flashcards and a certificate when you finish.

Enroll for free

Next free lesson: Automatic prompt optimisation

More free lessons from this course