Code models like Copilot, StarCoder, Code Llama and DeepSeek-Coder are trained not only to continue code left-to-right, but to infill a gap inside existing code — exactly what "accept suggestion" does when your cursor sits between two lines you already wrote. Training reformats each example as a linear sequence with special tokens, most commonly PSM (Prefix-Suffix-Middle):
<PRE> prefix_tokens <SUF> suffix_tokens <MID> middle_tokens <EOM>
or the reordered SPM variant (Suffix-Prefix-Middle), which some models mix in during training so the choice of order doesn't matter at inference time:
<SUF> suffix_tokens <PRE> prefix_tokens <MID> middle_tokens <EOM>
Either way, the model still generates autoregressively — one token at a time, left to right, only ever appending after <MID>, even though the tokens it is completing land visually in the middle of your file once the special tokens are stripped back out.
Each middle token is drawn from a probability distribution over candidates using temperature-scaled softmax:
p_i = exp(z_i / T) / Σ_j exp(z_j / T)
where z_i are the model's raw logits for candidate i. Low T (→0) collapses the distribution onto the single highest-logit token (greedy decoding); high T flattens it, giving lower-probability — sometimes wrong — candidates a real chance of being sampled. Top-k truncation (this 2D build's extra control) removes all but the k highest-logit candidates from the pool before the softmax runs, the same guard real inference servers use to stop temperature from ever picking an absurd tail candidate.
Perplexity is the exponentiated average negative log-probability of the tokens actually picked: PPL = exp(-1/n · Σ ln p_i). It is base-independent — exp(H in nats) and 2^(H in bits) are the same number — so a run of all-correct, high-confidence picks pulls it toward 1, while temperature-driven divergence pushes it up.
- Top panel — source code in visual reading order; the hole fills in green (matched) or red (diverged) as tokens are generated.
- Middle panel — the model's actual linear input sequence in PSM or SPM order, with <PRE>/<SUF>/<MID>/<EOM> special tokens.
- Bottom-left panel — the live softmax bar chart for the next token to be sampled, re-scaled instantly as you drag temperature or top-k.
- Bottom-right panel — a running trace of perplexity and match-rate across the tokens generated so far.
- Drag horizontally on the top or middle panel to pan a sequence too long to fit; scroll/pinch to zoom the token spacing.