ModelRefs / Fill-in-the-Middle (FIM) — AI Glossary
Fill-in-the-Middle (FIM) — AI Glossary
A training objective where the model fills in a missing middle span given prefix and suffix context; enables code infilling.
Overview
FIM (Bavarian et al. 2022) rearranges training examples into <prefix><suffix><middle> format so the model learns to complete code or text given surrounding context. Used in Codex, StarCoder, and Claude for code completion inside existing files. FIM transforms a generative model into a bidirectional infilling model without architectural changes.
Reference details
| Topic | architecture |
|---|---|
| Also known as | code infilling, infill, FIM |
| Last reviewed | 2026-06-24 |
Related terms
Primary source
Continue your research
Use these connected ModelRefs sections to compare alternatives, inspect implementation paths, and review the evidence and governance boundaries relevant to Fill-in-the-Middle (FIM) — AI Glossary.
Frequently asked questions
What is Fill-in-the-Middle (FIM)?
A training objective where the model fills in a missing middle span given prefix and suffix context; enables code infilling.
Is Fill-in-the-Middle (FIM) the same as code infilling?
Yes — code infilling, infill, FIM are common aliases for Fill-in-the-Middle (FIM).
What concepts are related to Fill-in-the-Middle (FIM)?
Closely related concepts include code completion, decoder only, context window.