4.4.6 · D1Alignment, Prompting & RAG

Foundations — Zero-shot and few-shot prompting

2,005 words9 min readBack to topic

Before you can understand zero-shot and few-shot prompting, the parent note throws a lot of symbols at you: , , , , , , . A smart 12-year-old has seen none of these. This page builds each one from nothing, in the order they depend on each other, and anchors every one to a picture.


0. The picture behind everything: a chain of words

Figure — Zero-shot and few-shot prompting

Look at the arrow chain in the figure. Each box is a word. The pink arrow into the empty box is the model asking "given everything to my left, what word is most likely here?" That single question is the whole engine. Every symbol in the parent note is just precise notation for this arrow.


1. Token — the atom of text

Why the topic needs it. The parent note says the model is a "next-token predictor". You cannot understand that phrase until "token" means "one box in the chain." Words like shot, demo, query are all just runs of tokens the model reads.


2. Position index and the sequence

Why the topic needs it. The whole model is defined in terms of "the token at position " and "everything before position ". Without a name for position, we could not write that.


3. "Everything before" — the shorthand and range

Figure — Zero-shot and few-shot prompting

4. Probability — a number between 0 and 1 for "how likely"

Figure — Zero-shot and few-shot prompting

5. The conditional bar | — "given that"

Putting symbols 1–5 together, the parent note's central formula now reads in plain words: "the probability the model assigns to the next token, given every token so far." You can read every piece.


6. The subscript — the frozen brain


7. The product — multiply a whole row together


8. — "which choice wins?"

So the parent note's reads: "the answer is whichever output the model rates most likely, given your examples and your question." Few-shot works by making the right the tallest bar.


9. , demos, and the demo-set


How these feed the topic

Token

Position index t

Sequence x1 to xT

Context x before t

Probability 0 to 1

Conditional given bar

Parameters theta locked

P theta next token

Product chain rule

Sentence probability

Argmax picks winner

k and demo set D

Zero-shot and Few-shot Prompting

Read top to bottom: tokens give positions, positions give the sequence, the sequence gives "context so far", context plus the conditional bar plus the locked brain give the next-token probability, the product turns that into whole-sentence probability, and over the demo-conditioned distribution is the final answer — which is exactly what few-shot steers.


Equipment checklist

Test yourself — cover the right side of each line.

A token is
one small chunk of text (a word or word-piece) the model reads/writes one at a time.
The subscript in means
the position of the token, counting from the left starting at 1.
means
all tokens before position — the entire left context.
means
the whole sequence, positions 1 through .
A probability is
a number from 0 to 1 measuring how likely something is; all next-token options sum to 1.
The bar in means
"given" — is known context, is what we're guessing.
means
probabilities according to this specific trained model, whose fixed weights are .
during prompting
never changes — it stays locked; only the context changes.
means
multiply the term together for every from 1 to .
The chain rule says
a sentence's probability is the product of each next-token step's probability.
gives
the that makes largest — the winning choice, not the winning value.
in prompting means
the number of demonstrations shown (0 = zero-shot, 1 = one-shot, >1 = few-shot).
is
the set of input→output example pairs placed in the prompt's context.

If every line above felt easy, you are ready for Zero-shot and Few-shot prompting. If any felt shaky, reread its section — the parent note assumes all of them. See also Large Language Models for the machine itself and Context window for the limit on how many demos fit.