File size: 4,698 Bytes
4a1a729
 
 
 
 
 
 
 
 
 
 
 
7702481
4a1a729
7702481
 
 
 
4a1a729
7702481
 
 
 
4a1a729
7702481
4a1a729
 
 
7702481
4a1a729
7702481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ac6e007
 
7702481
ac6e007
7702481
 
 
ac6e007
 
7702481
 
ac6e007
7702481
 
 
ac6e007
7702481
 
 
 
ac6e007
7702481
 
 
 
 
4a1a729
7702481
 
 
 
4a1a729
7702481
 
4a1a729
7702481
 
4a1a729
7702481
 
 
 
 
4a1a729
7702481
 
4a1a729
7702481
4a1a729
7702481
4a1a729
 
7702481
4a1a729
 
7702481
200a85b
 
7702481
 
200a85b
 
7702481
 
200a85b
 
 
7702481
 
 
200a85b
 
 
7702481
200a85b
7702481
200a85b
 
4a1a729
 
7702481
 
 
 
 
4a1a729
 
 
7702481
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
---
license: apache-2.0
tags:
- fill-in-the-middle
- code
- rust
- llama-cpp
- gguf
base_model: Qwen/Qwen2.5-Coder-1.5B
library_name: transformers
---

# RustLean v4 (GGUF)

RustLean v4 is a Rust-specialized, native fill-in-the-middle (FIM) completion
model based on
[`Qwen/Qwen2.5-Coder-1.5B`](https://huggingface.co/Qwen/Qwen2.5-Coder-1.5B).
This repository ships a merged `Q8_0` GGUF with no runtime LoRA dependency.

The release uses 50% of the selected step-1100 LoRA delta. The full adapter had
strong completion metrics but regressed deterministic HumanEvalPack-Rust. The
interpolated release retained its measured AST and out-of-distribution exact
match while recovering the base model's compiler-tested pass rate.

## Model Details

| Property | Value |
|---|---|
| Base | `Qwen/Qwen2.5-Coder-1.5B` |
| Architecture | Qwen2 decoder, 28 layers, width 1,536 |
| Attention | 12 query heads, 2 KV heads (GQA) |
| Parameters | Approximately 1.54B |
| Context | 32,768 tokens native; trained and evaluated at 1,024 |
| Adapter | Rank-32 LoRA on attention and MLP projections |
| Training | 1,200 optimizer steps, approximately 10.5M processed tokens |
| Release delta | 0.5 times the step-1100 adapter delta, merged into fp16 |
| Artifact | `rustlean-v4.Q8_0.gguf`, approximately 1.64 GB |

## Training Data

The licensed Rust corpus contains 58,407 training chunks from 1,048 repository
families and 3,044 holdout chunks from 73 unseen families. Repository families
are disjoint between training and evaluation. HumanEvalPack-Rust and MultiPL-E
prompts, tests, and canonical solutions were excluded from training.

Each source training chunk produced three FIM views and one left-to-right replay
row. The final mixture contains:

| Objective | Rows |
|---|---:|
| Total | 217,727 |
| FIM | 159,320 |
| Left-to-right | 58,407 |
| AST-boundary holes | 121,835 |
| Random editor holes | 37,485 |
| Empty-suffix prefix completions | 49,644 |

There are no duplicate FIM objectives. Exact duplicates were also removed
across the train and holdout source splits.

## Prompt Format

Use Qwen's PSM FIM format:

```text
<|fim_prefix|>{prefix}<|fim_suffix|>{suffix}<|fim_middle|>
```

For ordinary cursor completion, leave the suffix empty:

```text
<|fim_prefix|>fn add(a: i32, b: i32) -> i32 {
    <|fim_suffix|><|fim_middle|>
```

Stop at `<|endoftext|>`, `<|fim_prefix|>`, `<|fim_suffix|>`,
`<|fim_middle|>`, or `<|fim_pad|>`.

The same prefix-completion format is embedded as the GGUF chat template.

## Evaluation

All completion results below use greedy generation, a 1,024-token input crop,
a fixed 256-token generation budget, and control-token trimming. Private
results use the first 200 deterministic examples from repository-family-
disjoint holdouts.

| Model | Private AST exact | Similarity | Parse rate* |
|---|---:|---:|---:|
| Qwen2.5-Coder-1.5B | 22.5% | 0.465 | 71.88% |
| Previous RustLean | 31.5% | 0.647 | 81.25% |
| **RustLean v4** | **35.0%** | **0.680** | **84.38%** |

| Model | OOD exact, 95 tasks | Similarity | Parse rate* |
|---|---:|---:|---:|
| Previous RustLean | 30.53% | **0.793** | 95.24% |
| **RustLean v4** | **35.79%** | 0.781 | **100%** |

`*` Parse rate is measured only where the original reconstructed source is
parseable, so its denominator is smaller than the row count.

Deterministic HumanEvalPack-Rust uses 164 tasks, one greedy empty-suffix FIM
completion per task, Rust 1.95, and execution-backed tests:

| Model | Passing tasks | pass@1 |
|---|---:|---:|
| Qwen2.5-Coder-1.5B | 48/164 | 29.27% |
| Full step-1100 adapter | 35/164 | 21.34% |
| **RustLean v4, 0.5 delta** | **48/164** | **29.27%** |

HumanEvalPack is evaluation-only. No synthesis improvement over the base model
is claimed.

## Usage

### llama.cpp

```bash
llama-server -m rustlean-v4.Q8_0.gguf
```

For raw CLI completion:

```bash
llama-cli -m rustlean-v4.Q8_0.gguf --no-conversation -e \
  -p '<|fim_prefix|>fn main() {<|fim_suffix|><|fim_middle|>'
```

### llama-cpp-python

```python
from llama_cpp import Llama

llm = Llama(model_path="rustlean-v4.Q8_0.gguf", n_ctx=8192, n_gpu_layers=-1)
prompt = "<|fim_prefix|>fn add(a: i32, b: i32) -> i32 {\n    <|fim_suffix|><|fim_middle|>"
result = llm(
    prompt,
    max_tokens=96,
    temperature=0.2,
    stop=["<|endoftext|>", "<|fim_prefix|>", "<|fim_suffix|>", "<|fim_middle|>", "<|fim_pad|>"],
)
print(result["choices"][0]["text"])
```

## Files

- `rustlean-v4.Q8_0.gguf`: merged Q8_0 model with embedded FIM template.
- `rustlean-v4.jinja`: standalone copy of the FIM template.

GGUF SHA-256:
`47dc21750adee427aae050c0c44c7bd78e63c2792b9230e18bc35471453ec694`

## License

Apache-2.0, inherited from `Qwen/Qwen2.5-Coder-1.5B`.