drag to pan · scroll to zoom

Fill-in-the-Middle: AI Code Infilling (2D)

Modern code-completion models — GitHub Copilot, Cursor AI, Code Llama, StarCoder — don't just extend code forward from your cursor; they can also fill a gap you've left in the middle of a function, because they were trained on the Fill-in-the-Middle (FIM) objective. This 2D build renders the same mechanism as four coordinated panels instead of a 3D token grid: source-order code, the model's reordered PSM/SPM input sequence, a live temperature-scaled softmax bar chart for the token about to be sampled, and a running perplexity/match-rate trace. A real short function is split into a prefix, a missing middle "hole", and a suffix; dragging temperature or the added top-k truncation control visibly reshapes the candidate distribution and changes how often the model's picks diverge from the ground truth — a mechanistic view of why AI code completion is sometimes confidently wrong.