File size: 1,212 Bytes
4a1a729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{# RustLean — native fill-in-the-middle (FIM) Rust completion model (Qwen2.5-Coder-1.5B base).

This model was trained with the Qwen2.5-Coder FIM objective:

    <|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>{middle}<|endoftext|>

The dominant serving mode (per the technical report) is *prefix completion*
with an empty suffix, i.e. the model is fed:

    <|fim_prefix|>{prefix}<|fim_suffix|><|fim_middle|>

and generates the missing middle. This template implements exactly that for a
single user turn: the user message content is treated as the prefix and the
FIM markers are emitted around it.

Multi-turn / suffix-aware infilling is handled natively by llama.cpp via the
auto-detected <|fim_prefix|>/<|fim_suffix|>/<|fim_middle|> special tokens
(infill endpoint / --fim-* flags), which does not use this template.

llama.cpp variable contract: `messages`, `add_generation_prompt`.
#}
{%- if messages -%}
{%- set ns = namespace(prefix="") -%}
{%- for message in messages -%}
{%- if message["role"] == "user" -%}
{%- set ns.prefix = ns.prefix + message["content"] -%}
{%- endif -%}
{%- endfor -%}
<|fim_prefix|>{{ ns.prefix }}<|fim_suffix|><|fim_middle|>
{%- else -%}
{{ prompt }}
{%- endif -%}