← Master Index
Vol. 11 Module 11.3 Lecture

Prompt

GPT Family

How This Lesson Fits the Module & Volume

GPT models generate from context. The prompt is that context—instructions, examples, retrieved docs, and chat history. From GPT-2 zero-shot framing through GPT-3 few-shot and chat messages, prompting is how products program frozen weights. The next lecture covers the model’s reply: Completion.

Learning Objectives

By the end of this lesson, students should be able to:

  • Define a prompt as the conditioning prefix for an LM.
  • Distinguish completion prompts vs. chat message lists.
  • Apply zero-, one-, and few-shot patterns.
  • Use system messages and structured instructions effectively.
  • Recognize failure modes: ambiguity, conflicting orders, overlong context.
  • Connect prompting to RAG and tool-calling wrappers.
Definition

A prompt is the input text (and optionally multimodal context) provided to a language model that conditions its next-token distribution—including instructions, demonstrations, user questions, and conversation history.

Prompt Patterns

Instruction

  • “Summarize in 3 bullets”
  • Clear constraints
  • Chat system role

Few-shot

  • Show input/output pairs
  • Fix the format
  • GPT-3 style

Grounded

  • Paste retrieved context
  • “Answer only from...”
  • RAG pattern
StyleShapeTypical use
Raw completionOne string prefixBase LMs, code infilling demos
Chat messagessystem / user / assistant turnsInstruction-tuned models
TemplateVariables filled into a scaffoldProduction apps
from transformers import AutoTokenizer, AutoModelForCausalLM tok = AutoTokenizer.from_pretrained("openai-community/gpt2") model = AutoModelForCausalLM.from_pretrained("openai-community/gpt2") prompt = """Translate English to French. sea otter => loutre de mer cheese =>""" ids = tok(prompt, return_tensors="pt") out = model.generate(**ids, max_new_tokens=5) print(tok.decode(out[0]))

Design Checklist

Goal

What success looks like.

Constraints

Format, length, safety.

Evidence

Context the model may use.

Eval

Automate checks on outputs.

Common Misconception

“Longer prompts are always better.” Extra tokens cost latency/money and can distract. Prefer concise instructions plus the minimum necessary evidence.

Strengths and Tradeoffs

Strengths

  • No weight updates required.
  • Fast iteration for products.
  • Composes with retrieval/tools.

Tradeoffs

  • Brittle to wording changes.
  • Context window limits.
  • Not a substitute for evals / fine-tunes always.

Knowledge Check

  1. Short Answer: What is a prompt? Answer: The conditioning input prefix for the LM.
  2. True/False: Few-shot prompts include demonstrations. Answer: True.
  3. Multiple Choice: Chat APIs typically use: (a) role-tagged messages, (b) only raw pixels, (c) Fortran COMMON blocks. Answer: (a).
  4. Short Answer: Name one grounded prompting strategy. Answer: RAG / provide documents and restrict answers to them.
  5. True/False: Prompting always updates model weights. Answer: False.
  6. Multiple Choice: A risk of huge prompts: (a) cost and distraction, (b) guaranteed perfection, (c) free unlimited context always. Answer: (a).
  7. Short Answer: What GPT-3 idea made prompting central? Answer: In-context few-shot learning.
  8. Short Answer: Why use a system message? Answer: To set durable behavior/policy for the assistant.
  9. Multiple Choice: Prompt templates help: (a) consistent production scaffolding, (b) remove tokenization, (c) train CNNs. Answer: (a).
  10. True/False: Ambiguous instructions often cause unreliable completions. Answer: True.

Key Takeaways

  • Prompts program frozen LMs via context.
  • Patterns: instructions, few-shot, grounded RAG.
  • Chat roles structure modern interfaces.
  • Keep prompts clear, minimal, and evaluated.
  • Next: Completion.
Trainer’s Guide

Hands-on idea: A/B test two phrasings of the same task; measure format compliance rate.

Discussion prompt: When should you stop prompt-tuning and start fine-tuning / PEFT?

Recap: Prompts are the control surface for GPT-style models. Finish with Completion.