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.

Level: advancedTopic: Transformers LLM architecture

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.