Concepts / Prompting Strategies for Large Language Models

Prompting Strategies for Large Language Models

GPT-like large language models are designed and trained first and foremost for text completion.

  • Programming

A Question Before the Theory

Suppose you type a single line into a large language model: an instruction to translate the English word breakfast into German, followed by the word and an arrow, with nothing solved above it. The model has never been shown a worked translation inside this particular input. Yet it is expected to complete that line correctly. How can a model do a job that its input never demonstrated?

What do you think happens?

Given only the line 'Translate breakfast into German: breakfast ->' and no solved examples, what should the model write next?

Reveal answer
Answer:

Frühstück

The model's job is to continue the line with the German word for breakfast. The instruction alone tells it what kind of continuation is wanted, and its general training supplies the answer. The rest of this article explains how a model is built to do exactly this kind of continuation, and how the content of the input changes what it produces.

Text Completion as the Base Ability

GPT-like large language models are designed and trained first and foremost for text completion. Given the beginning of a passage, they produce text that plausibly comes next. The source emphasizes that this single ability turns out to stretch much further. The same model can be steered into doing jobs it was never explicitly set up for, simply by changing what goes into its input. Translation, answering a question, or sorting items into categories can all be reframed as a continuation of a partial text.

It helps to see how the continuation is produced. The model does not write a whole response in one stroke. It generates a next piece of text, adds that piece to the end of the input, and then uses the extended input to decide the piece after that. The diagram below traces this loop. Each new output becomes part of the input for the following prediction, so the continuation grows step by step.

Partial inputthe text so farPredict next piecemost plausible continuationAppend to inputthe new piece joins thetextExtended inputnow used for the next stepreademitextendrepeat
What happens to the piece the model just produced, and how does that change the input for the next prediction?

Zero-Shot: An Instruction With No Demonstration

Definition

Zero-shot behavior means completing a task that the input describes but does not demonstrate with an explicit example. The model handles a task it was given no demonstration of. The input states what is wanted, but it does not show a worked case of that exact job.

The ability is described as generalizing to completely unseen tasks. The model relies on what it learned during its general training rather than on examples supplied in the prompt at that moment. So in a zero-shot input, the only guidance is the instruction itself. Nothing solved appears above the query, and the model must complete the line from the instruction alone.

Worked example

Reading a zero-shot input

Look at the input 'Translate breakfast into German: breakfast ->' and describe exactly what it contains and what it lacks.

  1. 1
    Identify the instruction

    The line states the job: translate the English word breakfast into German.

  2. 2
    Identify the query

    The word breakfast followed by an arrow is the unsolved item the model must complete.

  3. 3
    Check for demonstrations

    No solved translation appears anywhere in the input. The input is an instruction and nothing else.

  4. 4
    State the expectation

    The model is expected to complete the line correctly from the instruction alone, relying on what it learned in general training.

Result

This is a zero-shot input: an instruction with a query and no worked example.

Few-Shot: Solved Pairs That Set the Pattern

Definition

Few-shot behavior means learning from a minimal number of examples the user provides in the input, without retraining or fine-tuning. The user places a small number of solved cases inside the input, and the model continues the pattern they establish.

No retraining happens. The model's weights are not changed. The examples simply sit in the input and shape what the model writes next. The examples do two jobs at once. They show the format of the answer, and they reveal the rule linking inputs to outputs. Once both are visible, the final unsolved line is the only thing left for the model to complete. This is why providing examples of the target within the input can be helpful.

dogHundcatKatzehouseHausbookto be completedsame format and rulesame format and rulesame format and rule
Which parts of the example pairs correspond to the new query, and where does the predicted continuation come from?

Predicting a Few-Shot Continuation

Before reading the solution, trace the pattern yourself. The input below holds three solved English-to-German pairs and one unsolved entry. Each pair shows an English word, an arrow, and its German equivalent. The model's job is to continue the final line.

Worked example

Continuing a few-shot pattern

Input: dog -> Hund; cat -> Katze; house -> Haus; book -> ?. What should the model produce for the final line?

  1. 1
    Read the format

    Every solved line has the shape English word, arrow, German word. The answer must follow that same shape.

  2. 2
    Read the rule

    Each English word is mapped to its German equivalent. The examples establish that the task is translation word by word.

  3. 3
    Locate the query

    The final line book -> has no German word after the arrow, so it is the only unsolved item.

  4. 4
    Predict the continuation

    Applying the same mapping, the model continues the line with the German word for book.

Result

The predicted continuation is Buch, so the completed final line reads book -> Buch.

What do you think happens?

If the three solved pairs were removed and only 'book ->' remained, what would change about what the input tells the model?

Reveal answer
Answer:

The input would no longer show the format or the rule, so it would become a zero-shot style input that relies only on the model's general training.

The examples carry the format and the rule. Removing them leaves the model with less direct guidance from the input itself.

Zero-Shot and Few-Shot Side by Side

The three behaviors are easiest to compare when laid next to one another. Each one has an input, and the question is what the model is expected to produce from it. In plain text completion, the input is an unfinished sentence and the model continues it. In the zero-shot setting, the input is an instruction with no example. In the few-shot setting, the input holds several solved pairs followed by one unsolved entry. The diagram sets the two prompting strategies in parallel columns.

Instructionstates the taskInstructionstates the taskUnsolved queryno example shownSolved pairsseveral worked casesUnsolved queryto be completedfollowed byfollowed byfollowed by
How does the content of the prompt differ between zero-shot (instruction only) and few-shot (instruction plus worked examples)?
FeatureZero-shotFew-shot
What the input containsAn instruction and the queryAn instruction, several solved pairs, and the query
Demonstration of the taskNoneExplicit worked cases inside the input
Source of guidanceGeneral training plus the instructionThe examples in the input establish format and rule
Retraining or fine-tuningNoneNone; the weights are not changed
Example from this articleTranslate breakfast into German: breakfast ->dog -> Hund; cat -> Katze; house -> Haus; book ->

Both strategies use the same model; the difference lies in the content of the input.

Mistakes Beginners Make with Zero-Shot and Few-Shot

  • Common mistake

    Thinking that few-shot prompting retrains the model

    What it looks like

    Believing that adding three solved pairs changes the model's weights for later users.

    Why it fails

    Few-shot behavior learns only from examples the user provides in the input, without retraining or fine-tuning. The model's weights are not changed.

    Do this instead

    Treat the examples as text in the input that shapes the next continuation, and nothing more.

  • Common mistake

    Assuming a zero-shot input contains an example

    What it looks like

    Reading 'Translate breakfast into German: breakfast ->' and assuming a solved translation is hidden somewhere above it.

    Why it fails

    Zero-shot means the input describes the task but does not demonstrate it with an explicit example.

    Do this instead

    Check the input for solved pairs. If none appear, the model must rely on the instruction and its general training.

  • Common mistake

    Believing the model switches to a different mode for each task

    What it looks like

    Thinking translation uses one mechanism and classification uses another.

    Why it fails

    The source says the same model can serve all these behaviors, and what changes is the content of the input.

    Do this instead

    Ask what the input looks like and what continuation it invites, not which special feature to turn on.

  • Common mistake

    Forgetting that examples must show the format as well as the rule

    What it looks like

    Writing solved pairs with inconsistent shapes, such as sometimes using an arrow and sometimes using a colon.

    Why it fails

    The examples do two jobs: they show the format of the answer and reveal the rule linking inputs to outputs. Inconsistent examples blur both.

    Do this instead

    Keep every solved pair in the same shape so the final unsolved line clearly follows the pattern.

Practice Predicting a Continuation

MEDIUM

The input below contains three solved pairs and one unsolved entry: cup -> Tasse; table -> Tisch; window -> Fenster; door -> ? Predict the model's continuation from the pattern in the input, then state whether this is a zero-shot or a few-shot input and explain how you know.

Hints
  • Look at the shape of each solved pair before deciding what the final line should look like.
  • Ask whether the input contains any solved examples, not whether the task is hard.
  • The unsolved line is the only item the model has to complete.

What do you think happens?

Predict the completed final line for 'door -> ?' using the three solved pairs above.

Reveal answer
Answer:

door -> Tür

The solved pairs show the same format and the same English-to-German mapping. Applying that pattern to door gives Tür.

Key Takeaways

  • GPT-like large language models are built first for text completion: given a partial input, they produce text that plausibly comes next, and they do this one piece at a time, feeding each output back into the input.
  • Zero-shot behavior handles a task the input describes but does not demonstrate with an explicit example, relying on general training rather than examples in the prompt.
  • Few-shot behavior learns from a small number of solved examples placed in the input, without retraining or fine-tuning; the examples show both the answer format and the rule linking inputs to outputs.
  • The same model serves all these behaviors; what changes is the content of the input, so the input itself is the lever for steering the model.
  • When predicting a continuation, identify whether the input contains solved pairs, and use their shared format and rule to complete the unsolved final line.

Related concepts

More concepts starting with P