Hence 1

Fill-in-the-middle models: dedicated FIM tokens versus cursor-in-context prompting

Fill-in-the-middle models complete code between the text before and after the cursor. Qwen2.5-Coder-32B uses FIM tokens; Hence 1 uses cursor-in-context prompting.

Fill-in-the-middle, or FIM, is how an editor completes code when text exists on both sides of the cursor. The model reads the code before and after the insertion point and writes what belongs between them. Two designs are in use. Qwen2.5-Coder-32B and StarCoder2 use dedicated FIM tokens that mark the prefix, the suffix and the hole. Hence 1 uses cursor-in-context prompting and handles FIM as one task among several. Its weights and documented prompt formats are on Hugging Face.

Coline builds Hence 1 and writes this page.

The comparison

ModelPrompt designSAFIM raw (17,720 cases)SAFIM trimmed to editor displayReal-FIM-Eval, add (perplexity)Real-FIM-Eval, edit (perplexity)
Hence 1Cursor-in-context69.8%63.9%1.2111.182
Qwen2.5-Coder-32BDedicated FIM tokens72.8%63.9%1.2961.231
Qwen3.8-27B (Hence 1's base)Base model, not a FIM design63.9%Not measured1.2501.200
StarCoder2Dedicated FIM tokensNot measuredNot measuredNot measuredNot measured

Lower perplexity is better on Real-FIM-Eval. Scores are from our execution harness and perplexity runs. The harness reads two to three points above public leaderboards for every model, so compare numbers within this table only.

Two ways to say where the hole is

With dedicated FIM tokens, the prompt contains special tokens that mark the prefix, the suffix and the position to generate. The model is trained on that layout, and the output is the middle. The design is precise, and it is specific to completing code between a prefix and a suffix.

With cursor-in-context prompting, the prompt is the surrounding text with the cursor position marked inside it. The model is trained to produce the completion at that position. The layout is a general format, and the same format also carries prose completion and next-edit prediction. Hence 1 needs one model for all of them, and that is the reason for the design.

The practical difference is scope. A FIM-token model is a code specialist. A cursor-in-context model is a generalist that does code well. The numbers below show where each one lands.

What SAFIM measures

SAFIM has 17,720 fill-in-the-middle cases. Each completion is executed, and the score is pass@1, averaged across three hole types. The raw score is the model's full output with no gate, since a test needs an answer on every case.

The trimmed score is closer to what a user sees. It cuts the completion down to what an editor displays. On the raw score, Qwen2.5-Coder-32B leads by 3.0 points. On the trimmed score, the two are level at 63.9%, a difference of 0.07 points that is not meaningful.

That is the honest result, and it matters for a buyer. A raw leaderboard lead can disappear once you measure what the editor shows.

What Real-FIM-Eval measures

Real-FIM-Eval uses 3,000 real developer edits and measures character-level perplexity. Perplexity asks how well the model predicts the exact text a developer wrote, and lower is better.

On this benchmark, Hence 1 leads both Qwen2.5-Coder-32B and Qwen3.8-27B. It scores 1.211 for add edits against 1.296 for Qwen2.5-Coder-32B, and 1.182 for edit operations against 1.231. The two benchmarks disagree, and both are informative. SAFIM rewards code that passes tests. Real-FIM-Eval rewards code that matches what developers actually typed. A model can lead on one and trail on the other.

Single-line and block mode

Single-line completion finishes the rest of the current line. Block completion writes a multi-line body, such as the implementation of a function you just declared. Hence 1 supports both through the same prompt.

The cost of block mode is length. A block has more tokens than a line, so it takes longer to finish. Since Hence 1's gate waits for the full suggestion before deciding whether to show it, the whole-suggestion time is the number to watch for blocks. Coline's production endpoint measures a code suggestion on a new prompt at 1.11 seconds at p50 and 2.13 seconds at p90 for the whole suggestion.

Choosing between them

  • Code completion only, with memory to spare: Qwen2.5-Coder-32B has the highest raw SAFIM score in our table, and dedicated FIM tokens are a clean, specific design.
  • Code, next-edit and prose in one model: Hence 1. It gives up 3.0 raw SAFIM points for coverage across tasks and lower real-edit perplexity. The training is covered in the Hence 1 release post.
  • Smaller hardware: a 7B or 8B model. These are faster on code on the same GPU, and their quality is measured in next-edit prediction models compared.
  • StarCoder2: we have not measured it, so check its own benchmarks and its license before choosing it.

How to test a FIM model on your own code

A SAFIM score is a fixed set of 17,720 cases, and your code is not in that set. To choose between two FIM models, take a sample of recent functions from your repository, delete the body of each, and ask both models to fill it in. Run your tests against each result and count the passes, not the exact matches. A completion can differ from your original code and still be correct.

Compare each model in its documented format. Dedicated FIM tokens and cursor-in-context prompting are different inputs, so a fair comparison runs each model the way its authors run it, not one prompt pasted into both.

If you want a measure closer to what a team actually typed, use perplexity on real edits, which is what Real-FIM-Eval measures. It can disagree with pass rates, and both views are worth keeping.

Trade-offs and limitations

  • Raw code score. Qwen2.5-Coder-32B leads raw SAFIM, 72.8% to 69.8%. Trimmed to editor display, they tie.
  • Scope. Hence 1 is not a code-only model. Its code strength is shared with next-edit and prose. A specialist on one task can beat it on that task.
  • Memory. Hence 1 needs about 60 GB of VRAM at bf16. Qwen2.5-Coder-32B is in the same class of server hardware.
  • Speed. Block completions are slower to finish than single lines, and the 27B path is slower than a 7B model on code.

Related: Hence 1 vs Qwen2.5-Coder, Hence 1 vs StarCoder2, open-source autocomplete models, Hence 1 benchmarks explained, AI autocomplete: how modern models work

Frequently asked questions

What is fill-in-the-middle code completion?

Fill-in-the-middle, or FIM, completes code when text exists on both sides of the cursor. The model sees the prefix and the suffix and writes the missing middle, such as a function body between an opening line and the code that follows it. Most editor ghost text works this way.

Which FIM model has the best raw score?

Qwen2.5-Coder-32B has the highest raw SAFIM score in our table, at 72.8%, against Hence 1's 69.8% across 17,720 cases. After trimming to what an editor displays, both score 63.9%. On real developer edits, Hence 1 has lower perplexity, 1.211 against 1.296 for add edits.

What is the difference between single-line and block mode?

Single-line mode completes the rest of the current line. Block mode writes a multi-line body, such as a whole function. Hence 1 supports both. Block completions take more tokens, so they finish later, and their whole-suggestion time grows with their length.