File size: 7,248 Bytes
0755ba8
8ac9ce9
 
0755ba8
8ac9ce9
 
 
 
 
 
 
 
 
0755ba8
8ac9ce9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
---
license: apache-2.0
base_model: Tesslate/OmniCoder-9B
tags:
  - code
  - assembly
  - cobol
  - c
  - low-level
  - continued-pretraining
  - qlora
language:
  - en
---

# Flare-9B — Low-Level Programming

**Flare-9B** is a continued-pretrained version of
[**Tesslate/OmniCoder-9B**](https://huggingface.co/Tesslate/OmniCoder-9B),
adapted toward low-level and legacy programming languages:

- x86-64 assembly
- COBOL
- C

The goal of this experiment was to improve performance on niche, low-resource
programming languages while retaining the base model's general coding capability.

Flare-9B is primarily a **code-completion model** rather than a chat model. It works
best when given a function signature, partial implementation, or program skeleton.

## Training

| Property | Value |
|---|---|
| Base model | `Tesslate/OmniCoder-9B` |
| Parameters | 9.6B |
| Method | QLoRA |
| Quantization | 4-bit NF4 |
| LoRA rank | 64 |
| LoRA alpha | 128 |
| Trainable parameters | 173M (1.81%) |
| Training data | [`DarkKnighToS223/Assm-cobol-c-c`](https://huggingface.co/datasets/DarkKnighToS223/Assm-cobol-c-c) |
| Training file | `train-cpt.jsonl` |
| Tokens processed | ~35M |
| Training progress | 0.5 epoch |
| Sequence length | 2048 |
| Hardware | 1× NVIDIA RTX 5090 |
| Training time | ~3.3 hours |
| Framework | Unsloth + PEFT |

## Evaluation

### Methodology

The low-level evaluation uses code execution rather than text similarity.

Generated completions are:

1. inserted into the corresponding test harness;
2. compiled using GCC or GnuCOBOL;
3. executed against assertions;
4. counted as correct only when compilation and all runtime checks succeed.

Evaluation settings:

| Setting | Value |
|---|---|
| Metric | pass@1 |
| Decoding | Greedy |
| Sampling | Disabled |
| Prompting mode | Code completion |
| Low-level tasks | 10 per language |
| Validation | Compilation and execution |

The low-level suites are intentionally small and should be treated as
**diagnostic evaluations**, not comprehensive measurements of language proficiency.

### Low-level programming

| Suite | Passed | pass@1 |
|---|---:|---:|
| C low-level | 10/10 | **100.0%** |
| COBOL | 6/10 | **60.0%** |
| x86-64 Assembly | 2/10 | **20.0%** |
| **Overall** | **18/30** | **60.0%** |

### General coding

| Benchmark | Score |
|---|---:|
| HumanEval (Python) | **77.5% pass@1** |

Flare-9B achieved strong results on the diagnostic C suite and passed six of ten
executed COBOL tasks. Assembly remained the weakest evaluated area, particularly
for tasks involving conditionals, loops, and memory traversal.

An interesting outcome is that COBOL produced the stronger diagnostic result even
though assembly comprised most of the continued-pretraining corpus and the training
dataset contained only 143 COBOL examples.

A directly comparable evaluation of the unmodified base checkpoint is required
before drawing strong conclusions about improvement or regression caused by CPT.

## Usage

Flare-9B was continued-pretrained primarily on raw code. For best results, use
completion-style prompts containing concrete code context instead of long
conversational instructions.

Good prompt formats include:

- function signatures;
- partial implementations;
- program skeletons;
- comments immediately followed by code;
- explicit architecture, ABI, or compiler constraints.

### Transformers

```python
import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer

model_id = "DarkKnighToS223/Flare-9B-low-level-programming"

tokenizer = AutoTokenizer.from_pretrained(
    model_id,
    trust_remote_code=True,
)

model = AutoModelForImageTextToText.from_pretrained(
    model_id,
    device_map="auto",
    torch_dtype="auto",
    trust_remote_code=True,
)

prompt = """/* x86-64 System V ABI: return a + b */
.intel_syntax noprefix
.global add_asm
add_asm:
"""

inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.inference_mode():
    outputs = model.generate(
        **inputs,
        max_new_tokens=128,
        do_sample=False,
    )

generated_tokens = outputs[0, inputs["input_ids"].shape[1]:]
completion = tokenizer.decode(generated_tokens, skip_special_tokens=True)

print(completion)
```

> Verify that your installed Transformers version supports the model architecture.
> If the checkpoint configuration maps to a causal language model instead, replace
> `AutoModelForImageTextToText` with `AutoModelForCausalLM`.

### Prompt example: C

```c
#include <stdint.h>

/* Rotate a 32-bit unsigned integer left by r bits. */
uint32_t rotate_left(uint32_t value, unsigned int r) {
```

### Prompt example: COBOL

```cobol
       IDENTIFICATION DIVISION.
       PROGRAM-ID. SUM-TO-TEN.

       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 TOTAL-VALUE PIC 9(4) VALUE 0.
       01 LOOP-INDEX  PIC 9(2) VALUE 0.

       PROCEDURE DIVISION.
```

### Prompt example: x86-64 Assembly

```asm
.intel_syntax noprefix
.text

# System V AMD64 ABI
# int max_asm(int a, int b)

.global max_asm
max_asm:
```

For assembly prompts, explicitly specify:

- Intel or AT&T syntax;
- target architecture;
- calling convention;
- expected symbol name;
- input and return types.

## GGUF

GGUF quantizations are available for use with `llama.cpp`:

- `Q8_0`
- `Q6_K`
- `Q5_K_M`
- `Q4_K_M`
- `Q2_K`

`Q4_K_M` or higher is recommended for more reliable code generation. `Q2_K`
substantially reduces model size but may noticeably degrade output quality,
especially for syntax-sensitive languages.

## Limitations

- The low-level evaluation contains only 10 tasks per language.
- The reported results are preliminary and may have high variance.
- Assembly performance is currently limited.
- The model may generate code that does not compile or that violates the requested ABI.
- Generated code may contain security vulnerabilities or undefined behavior.
- HumanEval and the low-level suites measure only a limited subset of coding ability.
- Completion-oriented prompting generally works better than chat-style prompting.
- Quantization can reduce accuracy, especially at very low bit widths.
- No claim is made that the model is suitable for production-critical systems.

Always inspect, compile, test, and review generated code before use.

## Reproducibility

For fully reproducible low-level results, the following should be published alongside
the model:

- benchmark prompts;
- test harnesses and assertions;
- generation configuration;
- output-extraction logic;
- compiler versions and flags;
- raw model completions;
- base-model results produced with the same evaluation pipeline.

## Intended use

Flare-9B is intended for:

- research on low-resource programming languages;
- code-completion experiments;
- legacy-code exploration;
- low-level programming assistance;
- continued-pretraining and parameter-efficient fine-tuning research.

It is not intended to replace compiler diagnostics, testing, static analysis,
security review, or expert verification.

## License

This model is released under the **Apache License 2.0**, following the license of
the base model.

Users are responsible for reviewing the licenses and usage conditions of the base
model, training dataset, dependencies, and generated outputs.