SOURCE CODE (visual order)
MODEL INPUT SEQUENCE (PSM)
⚠ Couldn't load the 3D engineThree.js failed to load from the CDN. Check your connection and reload.

Fill-in-the-Middle: AI Code Infilling Simulator

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 simulator renders that mechanism directly: a real short function is split into a prefix, a missing middle "hole", and a suffix. The top row of blocks shows the code exactly as you'd read it; the bottom row shows the reordered token sequence — prefix/suffix wrapped in special <PRE>/<SUF>/<MID> markers — that the model actually consumes and generates from, autoregressively, one token at a time. A temperature-scaled softmax samples each middle token from a small candidate distribution, so cranking the temperature up visibly increases how often the model diverges from the ground-truth token — a live, mechanistic view of why AI code completion is sometimes confidently wrong.