A C-language coding specialist built on Qwen3-4B-Instruct-2507, fine-tuned with QLoRA
(rank 32, all linear layers) on ~23k curated C instruction pairs. This is SFT v1 — the
first stage of a larger pipeline (synthetic execution-filtered data and GRPO with a
compiler/sanitizer reward are planned follow-ups).
The headline improvement is instruction compliance for C: the model follows exact
function signatures and emits compilable code far more reliably than its base.
Results
All benchmarks are execution-based: generated C is compiled with gcc and run against hidden
tests in a sandboxed container. safe-pass@1 additionally requires zero ASan/UBSan reports.
CEval-priv: base vs SFT v1
Benchmark
Metric
Base Qwen3-4B
This model
Δ
CEval-priv (161 tasks)
pass@1
36.6%
59.0%
+22.4
CEval-priv
compile rate
41%
80%
+39
McEval-C (50 tasks)
pass@1
52.0%
48.0%
−4 (within ±14 pt CI)
McEval-C
compile rate
72%
90%
+18
CEval-priv is a private, contamination-proof eval set: 161 tasks machine-translated from
HumanEval+/MBPP+ to C with deterministic type mapping, kept only if the reference solution
compiles, passes its own tests, and runs sanitizer-clean. It was never trained on and all
training data was decontaminated against it (10-gram overlap).
McEval-C is the public McEval C-generation split. The pass@1 delta is within noise at
n=50, single-sample; the compile-rate gain is the real signal.
Sanitizer-clean pass rates equalled pass@1 for both models on both benchmarks.
Interpretation: one epoch of public C data (StackOverflow Q&A, curated instruction sets)
teaches behavior — signature compliance, compilable output — not new algorithmic ability.
Exactly what you'd expect, and what the later pipeline stages are for.
Training
Base
Qwen/Qwen3-4B-Instruct-2507 (non-thinking)
Method
QLoRA via Unsloth: r=32, α=64, dropout 0.05, all linear layers (66M trainable, 1.62%)
Data
22,913 train / 467 valid; max seq 2048; loss on assistant tokens only
All slices were exact-deduplicated and decontaminated (word-level 10-gram overlap) against
McEval, MdEval, HumanEval(+), MBPP(+), and the private eval set.
Usage
Non-thinking model — use Qwen's recommended sampling: temperature=0.7, top_p=0.8, top_k=20.
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
23model_id ="harshpreet931/Qwen3-4B-C-Coder-SFT-v1"4tok = AutoTokenizer.from_pretrained(model_id)5model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")67messages =[{"role":"user","content":8"Write a C function `int popcount32(unsigned int x)` that counts set bits."}]9inputs = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)10out = model.generate(inputs, max_new_tokens=512, temperature=0.7, top_p=0.8, top_k=20)11print(tok.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
Algorithmic ability is unchanged from the base model. This stage improved format/signature
compliance and compile rates, not problem-solving. Don't expect gains on hard competitive tasks.
English-only instruction data; C17/glibc-flavored; not tuned for embedded/kernel dialects.
Inherits base-model limitations and possible biases; generated code should be reviewed and
tested — compile-and-run verification (ideally with -fsanitize=address,undefined) is cheap, use it.
Provenance
Built as part of an open, $0-compute project (MacBook M4 Pro + Kaggle free T4s): six-agent
research sweep → sandboxed compile/run/sanitizer harness → data pipeline → this SFT run.
Fun fact surfaced by the harness: one of McEval-C's own canonical solutions fails
LeakSanitizer.