Downloads · 30 days
7
24% of all-time downloads
Pradheep1647/qwen2.5-coder-1.5b-lean-language-sft
qwen2.5-coder-1.5b-lean-language-sft is a text generation model from Pradheep1647. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This repository contains a LoRA adapter for Qwen/Qwen2.5-Coder-1.5B-Instruct. It is a small syntax warm-up trained to follow introductory Lean 4 programming instructions. It is not a theorem-proving model and was not…
Downloads · 30 days
7
24% of all-time downloads
All-time downloads
29
Public
Repo size
159 MB
Likes
0
Public
Click a slice to open those files.
.safetensors73.9 MB · 82%
From the Hugging Face model README
This repository contains a LoRA adapter for
Qwen/Qwen2.5-Coder-1.5B-Instruct.
It is a small syntax warm-up trained to follow introductory Lean 4 programming
instructions. It is not a theorem-proving model and was not trained on proof generation.
This revision replaces the original 99-row experiment with 285 training examples and a 34-example held-out evaluation split. All 319 dataset answers were independently recompiled before training.
Evaluation uses the deterministic, section-stratified validation split from dataset
revision 8ba4ea4.
Both conditions use greedy decoding with a 256-token generation cap. Every generated
answer is checked by Lean 4.31.0-rc2 with Mathlib through the official
leanprover-community/repl backend.
| Metric | Base model | SFT adapter | Change |
|---|---|---|---|
| Lean compilation | 7/34 (20.6%) | 26/34 (76.5%) | +55.9 pp |
| Section-topic contract | 20/34 (58.8%) | 33/34 (97.1%) | +38.3 pp |
| Compilation and topic contract | 6/34 (17.6%) | 25/34 (73.5%) | +55.9 pp |
| Validation loss | 1.1739 | 0.1859 | -84.2% |
| Validation perplexity | 3.2345 | 1.2043 | -62.8% |

Compilation results by documentation section:
| Section | Base model | SFT adapter |
|---|---|---|
| Additional Conveniences | 1/3 | 1/3 |
| Datatypes and Patterns | 0/4 | 3/4 |
| Evaluating Expressions | 2/6 | 6/6 |
| Functions and Definitions | 1/6 | 4/6 |
| Polymorphism | 0/3 | 1/3 |
| Structures | 1/5 | 5/5 |
| Types | 2/7 | 6/7 |
The adapter improved substantially on this split, but the section breakdown matters. Tuple and convenience syntax did not improve in compilation rate, and polymorphism remains weak. The eight remaining failures include type mismatches, missing type-class instances, invalid field projections, and an unknown identifier.

Pradheep1647/lean-language-docs-sft1e-4Validation loss reached 0.1921, 0.1859, 0.1971, and 0.2025 across epochs 1-4.
The trainer restored epoch 2 because later epochs began to overfit.
The dataset contains novel, Lean-verified lessons grounded in seven introductory sections of Functional Programming in Lean. Proof content, unsafe constructs, disallowed imports, exact code duplicates, normalized instruction duplicates within each section, and verbatim source examples were filtered before training.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_id = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
adapter_id = "Pradheep1647/qwen2.5-coder-1.5b-lean-language-sft"
tokenizer = AutoTokenizer.from_pretrained(base_id)
model = AutoModelForCausalLM.from_pretrained(base_id, device_map="auto")
model = PeftModel.from_pretrained(model, adapter_id)
messages = [
{
"role": "system",
"content": "You write concise Lean 4 code for language-learning exercises. Return only Lean code.",
},
{
"role": "user",
"content": "Define a function that doubles a natural number.",
},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(inputs, max_new_tokens=256, do_sample=False)
print(tokenizer.decode(outputs[0, inputs.shape[-1]:], skip_special_tokens=True))
Generated Lean must still be checked with the same Lean and Mathlib toolchain used by the target project.
adapter_model.safetensors: LoRA adapter weights restored from the best checkpointtraining_metrics.json: baseline, training, and restored-best loss metricstrainer_state.json: optimizer-step and epoch historybaseline_eval.json: base-model generations and Lean diagnosticspost_sft_eval.json: adapter generations and Lean diagnosticsevaluation_comparison.{png,svg}: before/after evaluation figuretraining_dynamics.{png,svg}: training and validation loss figureThis remains an exploratory adapter trained on 285 synthetic, documentation-grounded examples. The 34-example validation split is substantially better than the original six-example split but remains too small for broad claims. It covers introductory Lean language syntax rather than repository-scale code, Mathlib API recall, formal proof search, or verifier-guided repair. Use it as a syntax initialization experiment, not as a reliable Lean assistant.
The base model and this adapter are licensed under Apache 2.0. The source documentation used to ground the dataset is licensed CC BY 4.0.