AI engineering glossary · Transformers LLM architecture
What is FIM (fill-in-the-middle)?
Fill-in-the-middle (also called FIM, Infilling): A training method in which a document is split into prefix, middle and suffix and reordered so a left-to-right model learns to generate the missing middle given both sides. It lets decoder-only models perform code completion inside existing files without hurting normal generation.
Fill-in-the-middle: an example
An editor sends the code before and after the cursor, and the model writes the function body between them.
Related terms
More Transformers LLM architecture terms
- FlashAttention
- Frequency and presence penalty
- GPT
- Greedy decoding
- Grouped-query attention
- Head dimension
- Hidden states
- Induction head
Where you learn it
Fill-in-the-middle is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.