Prompting for text and chat

How to ask so a chat model answers well: examples, step-by-step thinking, breaking work down, checking its own answer, and what each maker recommends.

  • 1 step-by-step lesson
  • 86 techniques
  • 2 example pictures
Q: Roger has 5 tennis balls…
Let’s think step by step.
Start here · 6 min lesson

Chain of thought

Ask the model to write out its reasoning before the answer. Big gains on older models, little on reasoning models.

Start the lesson →
See the difference

Techniques you can see

Examples from each maker’s own guide: the prompt, and what it made.

Few-Shot Prompting: Zero-, one- and few-shot prompts, side by sideZero-, one- and few-shot prompts, side by side
Pictures: The Prompt Report (Schulhoff et al., 2024), after Brown et al., 2020 (arxiv.org)

Few-Shot Prompting

Show a few labelled input-output examples in the prompt; the model learns the task from them without weight updates.

'I absolutely love these headphones - sound quality is amazing!' -> Positive. 'Battery life is okay, but the ear pads feel cheap.' -> Neutral. 'Terrible customer service, I'll never buy from them again.' -> Negative. Now classify: [new review]. Only output one word.

Exemplar Ordering: Six choices about examples that change the answerSix choices about examples that change the answer
Pictures: The Prompt Report (Schulhoff et al., 2024) (arxiv.org)

Exemplar Ordering

The order of few-shot examples affects behaviour; some orderings work far better than others.

Same examples, reordered so the most similar / most representative example is last.

Every technique

All 86 text techniques

Each opens on its own slide: the plain prompt, the better one, what happened, and the source.

01

Zero-shot

No examples. Just ask.

Zero-Shot PromptingTask done with zero exemplars - instruction only.Role PromptingAssign a specific role or persona to the model in the prompt.Write a travel article about Lisbon.Act like a travel writer and write a travel article about Lisbon.Style PromptingSpecify the desired style, tone or genre in the prompt to shape the output.Write about the ocean.Write about the ocean in a lyrical, melancholic style, like a sea shanty.Emotion PromptingAdd psychologically resonant phrases (e.g. importance to the user) to the prompt.Solve this math problem: [problem]This is important to my career. Solve this math problem: [problem]System 2 Attention (S2A)Two-step: the LLM first rewrites the prompt removing information unrelated to the question, then answers the rewritten prompt.Answer the question, ignoring the distracting story around it: [long prompt]First rewrite the question removing all information unrelated to it, then answer the rewritten question.SimToMFor multi-person questions: establish what one person knows, then answer using only those facts (two-prompt process).What does Alice think is in the box? [story with several characters]First, list only what Alice knows from the story. Then, using only those facts, answer: what does Alice think is in the box?Rephrase and Respond (RaR)Instruct the LLM to rephrase and expand the question before answering.What is the capital of Australia? [ambiguous question]Rephrase and expand the question, and respond.Re-reading (RE2)Add 'Read the question again:' and repeat the question in the prompt.Solve: [complex question]Read the question again: [complex question repeated]. Now solve it.Self-AskThe LLM first decides if follow-up questions are needed; if so it generates them, answers them, then answers the original question.Who was the US president when the first iPhone was released?Decide what follow-up questions you need, answer them, then answer the original question.Prompt TemplateA prompt template is a function with variables that are replaced by media (usually text) to create a prompt; that prompt is an instance of the template.Write a new prompt for each tweet.Use one template: 'Classify this tweet as positive or negative: [tweet]' - insert each tweet in turn.Six Components of a PromptA prompt is built from: Directive, Examples, Output Formatting, Style Instructions, Role / persona, Additional Information.Write a prompt with just the question.Directive: write a poem. Examples: [one example]. Output formatting: Markdown. Style: lyrical. Role: poet. Additional info: sign it 'Muse'.Put Key Information at the Start or End (Lost in the Middle)Models use information at the beginning (primacy) or end (recency) of a long context best, and worst in the middle.Put the key document in the middle of 20 documents, then ask the question.Put the key document first or last, and put the query before AND after the documents.
02

Few-shot

Show a few examples

Few-Shot PromptingShow a few labelled input-output examples in the prompt; the model learns the task from them without weight updates.Classify this review as Positive, Negative or Neutral: 'Battery life is okay, but the ear pads feel cheap.''I absolutely love these headphones - sound quality is amazing!' -> Positive. 'Battery life is okay, but the ear pads feel cheap.' -> Neutral. 'Terrible customer service, I'll never buy from them again.' -> Negative. Now classify: [new review]. Only output one word.Exemplar OrderingThe order of few-shot examples affects behaviour; some orderings work far better than others.Examples in random order.Same examples, reordered so the most similar / most representative example is last.Exemplar QuantityMore exemplars generally help, especially for larger models; benefits may diminish beyond ~20 exemplars.1 example.10-20 diverse examples in the same format.K-Nearest Neighbor (KNN) Exemplar SelectionSelect the exemplars most similar to the test input to boost performance.Random examples from the pool.The 5 examples most similar to this test input: [retrieved examples]. Now answer.Vote-K Exemplar SelectionTwo-stage: the model proposes useful unlabelled candidates for an annotator to label; the labelled pool is used for few-shot, kept diverse and representative.Label these random examples.Label these model-proposed, diverse examples, then use them as few-shot exemplars.Self-Generated In-Context Learning (SG-ICL)The model automatically generates its own exemplars.Answer with no examples.First generate your own examples of this task, then use them to answer the question.Prompt MiningDiscover optimal prompt templates by large-corpus analysis; corpus-frequent formats perform better.Q: [input] A: [label]Use the corpus-frequent format for this task instead of 'Q: / A:'.
03

Thought generation

Think step by step

Chain-of-Thought (CoT) PromptingFew-shot exemplars include a question, a reasoning path and the correct answer, so the model reasons before answering.Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now? A: The answer is 11.Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now? A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.Zero-Shot Chain-of-ThoughtAppend a thought-inducing phrase, with no exemplars.Q: [math question] A: The answer isQ: [math question] A: Let's think step by step.Step-Back PromptingFirst ask a generic high-level question about the relevant concepts or facts, then reason.Solve this physics problem: [problem]First, what are the general principles behind this kind of problem? Then use them to solve it step by step.Analogical PromptingThe model auto-generates exemplars that include chains of thought, like SG-ICL for CoT.Solve this problem: [problem]Before solving, recall three relevant example problems with their step-by-step solutions, then solve this one.Thread-of-Thought (ThoT)Improved thought inducer for CoT, for large or complex contexts.Summarise this long document and answer the question.Walk me through this context in manageable parts step by step, summarizing and analyzing as we go.Tabular Chain-of-Thought (Tab-CoT)Zero-shot CoT where the model outputs its reasoning as a Markdown table.Solve step by step: [problem]Solve step by step, showing each step as a row in a Markdown table with columns Step, Reasoning, Result.Contrastive CoT PromptingCoT exemplars include BOTH incorrect and correct explanations, showing how not to reason.Here are correct worked examples: [examples]Here are worked examples, including one with a wrong explanation and why it is wrong, and one correct: [examples]Plan-and-Solve PromptingImproved Zero-Shot-CoT: plan first, then execute the plan step by step.Q: [problem] A: Let's think step by step.Let's first understand the problem and devise a plan to solve it. Then, let's carry out the plan and solve the problem step by step.Automatic Chain-of-Thought (Auto-CoT)Use Zero-Shot-CoT to auto-generate chains of thought, then build a few-shot CoT prompt for the test sample.Solve with no examples.Generate reasoning chains for similar questions with 'Let's think step by step', then use the best ones as few-shot examples to solve this question.Complexity-based PromptingSelect complex examples for annotation, and majority-vote only among chains exceeding a length threshold.Use any CoT examples.Use only the longest, most complex reasoning examples, and vote only among the longest generated chains.Active PromptingThe LLM solves training questions; humans rewrite the exemplars with the highest uncertainty (disagreement).Annotate these random CoT examples.Annotate the examples where the model's sampled answers disagree most, then use those as exemplars.Memory-of-Thought PromptingRun CoT on unlabelled training exemplars before test time; at test time retrieve similar instances to build few-shot CoT prompts.Answer with no examples.Retrieve the most similar previously reasoned-through examples and use them as few-shot CoT exemplars.
04

Decomposition

Break it into small steps

Least-to-Most PromptingPrompt the LLM to break a problem into sub-problems (without solving), then solve them sequentially, appending each answer, until the final result.Q: 'think, machine, learning' - what are the last letters concatenated? A: [direct answer]First break the problem into sub-problems: 'think', then 'think, machine', then 'think, machine, learning'. Solve each in turn, using the previous answer.Decomposed Prompting (DECOMP)Few-shot prompt showing how to route sub-problems to functions (string splitting, web search, etc., often separate LLM calls).Solve this whole problem in one go.Break it into sub-problems and call the right function for each (e.g. split strings, search the web), then combine the results.Tree of Thoughts (ToT)Tree search: generate multiple possible next 'thoughts', evaluate progress by prompting, continue the best branches, backtrack as needed.Solve this puzzle step by step in one chain.Generate several candidate next steps, rate each (sure / likely / impossible), explore the most promising, and backtrack when a path dead-ends.Recursion-of-ThoughtLike CoT, but each complicated sub-problem mid-chain is sent to another prompt / LLM call; the answer is inserted back into the original prompt.Solve this nested problem in one chain.When a sub-problem is too complicated, solve it in a separate prompt and insert its answer back here before continuing.Program-of-Thoughts (PoT)The LLM generates programming code as its reasoning steps; a code interpreter executes them for the final answer.Solve this math problem in words.Write Python code that solves this problem step by step, then run it and report the result.Faithful Chain-of-ThoughtCoT with both natural language and symbolic language (e.g. Python) reasoning, symbolic language chosen per task.Reason in words only.Reason in words AND in symbolic code, so each step can be checked.Skeleton-of-ThoughtPrompt the LLM to create an answer skeleton (sub-problems), solve them in parallel, concatenate outputs.Answer this multi-part question in one pass.First outline the answer as a skeleton of sub-points, solve each sub-point independently, then join them.Metacognitive PromptingFive-part prompt chain mirroring human metacognition: clarify the question, preliminary judgement, evaluate the response, confirm the decision, assess confidence.Answer this question.1) Clarify the question. 2) Give a preliminary judgement. 3) Evaluate that response. 4) Confirm the decision. 5) Assess your confidence.ReAct (Reason + Act)Interleave free-form reasoning traces with actions and observations from tools, so the model can plan, act, observe, and correct itself.Answer from memory, or act without reasoning: Search[...] / Lookup[...] / Finish[...]Thought 1: I need to search for... Act 1: Search[...] Obs 1: ... Thought 2: ... Act 2: ...
05

Ensembling

Try many times, pick the best

Self-ConsistencySample multiple CoT paths at non-zero temperature and take the majority-vote final answer.Solve with one greedy chain of thought.Solve the same problem 40 times with different reasoning paths, then take the most common final answer.Demonstration Ensembling (DENSE)Multiple few-shot prompts, each with a distinct exemplar subset; aggregate the outputs.One few-shot prompt with one exemplar set.Run the same question with several different exemplar sets and aggregate the answers.Mixture of Reasoning Experts (MoRE)Diverse 'experts' via specialised prompts per reasoning type; best answer chosen by agreement score.One reasoning style for everything.Use retrieval-augmented prompts for factual parts, CoT for multi-hop/math, generated-knowledge for commonsense, then pick the answer with the highest agreement.Universal Self-ConsistencyLike Self-Consistency, but the majority answer is selected by prompting the LLM with all outputs, not by programmatic counting.Count identical answers and take the majority.Here are several candidate answers: [list]. Which answer is most consistent across them?DiVeRSeMultiple prompts per problem, Self-Consistency per prompt, score reasoning paths step-by-step, select the final response.Vote on final answers only.Generate diverse prompts, sample paths per prompt, score each reasoning step, then select the best final response.Consistency-based Self-adaptive Prompting (COSP)Run Zero-Shot-CoT + Self-Consistency on examples, pick high-agreement outputs as few-shot CoT exemplars, then run Self-Consistency again.Hand-write CoT exemplars.Use the model's own high-agreement outputs as exemplars, then answer with self-consistency.Prompt ParaphrasingReword a prompt preserving meaning - data augmentation to generate ensemble prompts.Use the same prompt 5 times.Rephrase the prompt 5 ways, preserving meaning, run each, and aggregate.
06

Self-criticism

Check your own answer

Self-RefineIterative: the same LLM gives feedback on its initial answer, then improves it from the feedback, until a stopping condition.Give your answer once.Give an initial answer, then give yourself feedback on it, then improve it from that feedback. Repeat until it is good.Self-CalibrationAnswer first; then a new prompt (question + answer + 'is this correct?') gauges confidence.Answer the question.Answer the question. Then, in a new prompt: here is the question and your answer - is this correct? How confident are you?Chain-of-Verification (CoVE)Generate an answer; create verification questions; answer them; give all info back to the LLM for a final revised answer.Answer the question.Answer, then list verification questions about your answer, answer those, then revise your original answer using the verification results.Self-VerificationGenerate multiple CoT candidate solutions; score each by masking parts of the question and asking the LLM to predict them from the rest + the solution.Pick the first solution.Generate several candidate solutions, then for each, mask part of the question and check whether the solution lets you recover it. Pick the best-scoring one.Reversing Chain-of-Thought (RCoT)Reconstruct the problem from the generated answer; compare original vs reconstructed problem for inconsistencies; feed back as a revision signal.Answer the problem.From your answer, reconstruct the original problem. Compare it with the real problem - if they differ, revise your answer.Cumulative ReasoningGenerate several potential steps; the LLM accepts or rejects each; repeat until the final answer is reached.Follow one chain to the end.Propose several next steps, accept only the valid ones, reject the rest, and repeat until the answer is reached.
08

Text and chat

How to talk to chat AI

Be Clear and Direct (Anthropic)Give clear, explicit instructions - specific output format and constraints, sequential numbered steps when order matters.Write something about our product.Write a 150-word product description for our wireless earbuds, in a friendly tone, with three bullet points: battery life, comfort, price. Do not mention competitors.Structure Prompts with XML Tags (Anthropic)Wrap each content type in its own tag (<instructions>, <context>, <input>) so the model parses complex mixed prompts unambiguously.Here is a document and a question. Answer it. [document pasted inline]<instructions>Answer the question using only the documents below.</instructions><documents><document index='1'>[text]</document></documents><question>[question]</question>Give the Model a Role (Anthropic)Set a role in the system prompt to focus behaviour and tone; even a single sentence makes a difference.Answer this customer complaint.You are a calm, empathetic customer-support agent for a bank. Answer this customer complaint in that voice.Long-Context Prompting (Anthropic)For 20k+ token inputs: put long-form data at the top (above query / instructions / examples), structure documents with XML, and ground responses in quotes.Put the question first, then paste 50 pages of documents.Paste the documents first, then: 'Quote the relevant parts of the documents first before carrying out the task.'Control Output Format (Anthropic)Steer output format by telling the model what to do (not what not to do), using XML format indicators, and matching prompt style to desired output style.Do not use markdown in your response.Your response should be composed of smoothly flowing prose paragraphs. Write the prose sections in <smoothly_flowing_prose_paragraphs> tags.Ask the Model to Self-Check (Anthropic)Append 'Before you finish, verify your answer against [test criteria]' to catch errors, especially coding and math.Write the function and finish.Write the function. Before you finish, verify your answer against the test criteria: [criteria].Chain Complex Prompts (Anthropic)Break a task into sequential API calls so intermediate outputs can be inspected / logged / branched; most common pattern is self-correction: draft, review against criteria, refine.Do the whole task in one call.Call 1: generate a draft. Call 2: review it against the criteria. Call 3: refine it based on the review.Prefill - Retired Technique (Anthropic)Prefilled responses (partial assistant message for the model to continue from) are no longer supported on Claude 4.6+ - requests return a 400 error.Prefill the assistant turn with a partial sentence / JSON skeleton and let Claude continue it.Write the same output with an explicit instruction instead: 'Start your answer with the JSON skeleton {...} and fill it in.'Developer Message as Instructions (OpenAI)Developer messages are high-priority rules / business logic (like a function definition); user messages are inputs (like arguments).Are semicolons optional in JavaScript?Developer: 'Talk like a pirate.' User: 'Are semicolons optional in JavaScript?'Developer Message Anatomy (OpenAI)Order a developer message: Identity, Instructions, Examples, Context (context last, since it varies per request).Flat unstructured prompt with identity, rules, examples and context mixed together.# Identity: You are a coding assistant that enforces snake_case in JavaScript. # Instructions: use snake_case (e.g. my_variable), not camelCase; declare variables with 'var'; return code only, no Markdown. # Examples: <user_query>How do I declare a string variable for a first name?</user_query> <assistant_response>var first_name = 'Anna';</assistant_response> # Context: [codebase notes]Reasoning vs GPT Models - Different Prompting (OpenAI)Reasoning models generate an internal chain of thought and do best with high-level guidance; GPT models are fast / cheap but need precise explicit instructions.Give the junior model a vague goal and expect it to plan.Reasoning model: give it a goal and let it plan. GPT model: give explicit step-by-step instructions.Agent Prompt: Plan and Persist (OpenAI)Instruct the agent to keep going until the query is completely resolved, decompose into sub-requests, plan extensively before tool calls, and reflect after each call.Do this task.Remember, you are an agent - please keep going until the user's query is completely resolved, before ending your turn. Decompose the query into all required sub-requests, and confirm that each is completed. Plan extensively before making function calls, and reflect on the outcomes of each call.Specify Constraints (Gemini)Tell the model what to do and not to do, e.g. a hard limit on summary length.Summarize this text: [150-word quantum computing passage]Summarize this text in one sentence: [150-word quantum computing passage]Partial-Input Completion (Gemini)Give the model a partial output to continue, so it follows the started pattern / format exactly.For the given order, return a JSON object with the fields cheeseburger, hamburger, fries, or drink. Order: I want two burgers, a drink, and fries.Valid fields are cheeseburger, hamburger, fries, and drink. Order: Give me a cheeseburger and fries / Output: {"cheeseburger": 1, "fries": 1} / Order: I want two burgers, a drink, and fries. / Output:Add Grounding Context (Gemini)Include the information the model needs instead of assuming it has it; e.g. paste the device's troubleshooting guide into the prompt.What should I do to fix my disconnected wifi? The light on my Google Wifi router is yellow and blinking slowly.Answer the question using the text below. Respond with only the text provided. [pasted LED-status guide: slowly pulsing yellow = network error, check Ethernet cable...] What should I do to fix my disconnected wifi?Break Down Prompts (Gemini)Split complex prompts: (1) one prompt per instruction, (2) chain prompts sequentially, (3) aggregate responses (parallel sub-tasks, then combine).One mega-prompt with many instructions.Prompt 1: extract the key facts. Prompt 2 (using Prompt 1 output): draft the answer. Prompt 3: combine the parallel drafts into one.Recast as Multiple Choice (Gemini)Recast a categorisation task as multiple choice to constrain the model to one of the options.Which category does The Odyssey belong to: thriller / sci-fi / mythology / biographyMultiple choice problem: Which of the following options describes the book The Odyssey? Options: - thriller - sci-fi - mythology - biographyCue / Prime the Output (Microsoft)A few words or phrases at the end of the prompt that jump-start the output into the desired form.Summarize the above email message: [long email]Summarize the above email message. Key Points: -Supporting Content (Microsoft)Extra information that influences the output but isn't the main target (date, user name, preferences, 'my important topics').Summarize the workshops above, grouped by topic: [workshop list]My Important Topics: prompt engineering, search, GPT models. Summarize the workshops above, grouped by my important topics: [workshop list]Start with Clear Instructions (Microsoft)Put the task at the beginning of the prompt, before context or examples - sequence matters because of how GPT models process input.Paste snippets, then at the end: verify if this statement is supported.Your task is to verify if the statement 'Several sources mention a chance of another large eruption' is supported by a specific quote from the following set of snippets. [snippets]Repeat Instructions at the End (Microsoft)Repeat key instructions at the end of the prompt to counter recency bias (end-of-prompt information has outsized influence).Instructions only at the start of a long prompt.Instructions at the start AND repeated at the end of the prompt.Add Clear Syntax (Microsoft)Use separators (---), section headings, UPPERCASE variables to delineate sources / steps; --- can also serve as a stop condition.Unseparated prompt: read a paragraph and issue search queries to fact-check it.You'll read a paragraph, and then issue queries to a search engine in order to fact-check it. Also explain the queries. --- PARAGRAPH [text] --- QUERIESSpecify Output Structure with Citations (Microsoft)Ask for citations and a defined output structure (e.g. BEHAVIOR('reason'), or a JSON schema) - this forces grounding and makes compound claims verifiable.Only write true facts. Don't fabricate. [system message alone]List the different behaviors exhibited by the Customer Support agent. Classify and list them, citing the reason, using the format BEHAVIOR('reason').Give the Model an Out (Microsoft)Include 'respond with not found if the answer isn't present' to avoid false responses.Answer this question from the text: [question]Answer this question from the text. Respond with 'not found' if the answer isn't present.Use Affordances / Tools Instead of Memory (Microsoft)Let the model call an affordance (e.g. SEARCH) instead of answering from parameters; stop generation, paste results back in, and continue.Answer this fact-check from memory.Call SEARCH('John Smith Microsoft') to fact-check, then: Given the snippets, fact check each of the factual claims above.How Teaching Sites Present It (PromptingGuide / Learn Prompting)PromptingGuide.ai (DAIR.AI) is research-first: every technique page cites the original paper, shows the exact prompt and the model's output, and states limitations. Learn Prompting (Schulhoff) organises Basics -> Applications -> Intermediate -> Advanced, with a difficulty rating per article.Copy a technique page wholesale.Use their structure (definition + exact prompt + model output + cited paper + limitations) with your own prompts and results.
07

Multimodal

Pictures, sound, video

Prompt Modifiers (image)Words appended to a text-to-image prompt to change the resultant image - e.g. medium, lighting.a portrait of a womana portrait of a woman, on canvas, a well lit scene, oil paintingNegative Prompting (image)Numerically weight terms so the model weighs them more or less; negatively weight unwanted traits.a portrait, hands visiblea portrait, hands visible [negative: bad hands, extra digits]Paired-Image PromptingShow two images (before / after a transformation), then a new image to convert - multimodal in-context learning.Edit this image to look vintage. [image]Here is a before/after pair showing the vintage transformation: [image 1] -> [image 2]. Now apply the same transformation to this image: [image 3]Image-as-Text PromptingGenerate a textual description of an image so it can be included in a text prompt.Use this image: [image]Describe this image in detail, then use that description as part of the text prompt.Duty Distinct Chain-of-Thought (DDCoT)Extends Least-to-Most to multimodal: create sub-questions, solve them, combine the answers.Answer this question about the image.Break the question into sub-questions about the image, answer each, then combine them into the final answer.Chain-of-Images (CoI)Multimodal CoT that generates images (SVGs) as part of its thought process.Solve this geometry problem in words.Let's think image by image - generate a diagram for each step, then solve.Multimodal CoT (image + text)An image of a problem plus a textual instruction to reason step by step.Solve this. [image of a math problem]Solve this step by step. [image of a math problem]