qwen-3.5-babel-9b-sft-agent-multistep
Qwen3.5-9B fine-tuned to reconstruct Lean/Rocq tactic proofs from proof terms, then adapt each next tactic block to the actual hypotheses, goals, and verifier feedback. This reviewed release was trained from the original upstream model and completed on November 6, 2026. It replaces the November 3 weights on the same model repository; the previous revision remains in history.
Training and dataset review
- 795 demonstrations: 348 Lean and 447 Rocq.
- 5,212 tactic calls with recorded real verifier replies; 789 examples contain multiple calls.
- All 807 source entries were reviewed individually. Twelve entries were quarantined for semantic/provenance issues. 3,442 reasoning turns were edited across 787 retained entries to better explain the proof-term structure and reason from the actual current proof state.
- Retained tactic actions, initial prompts and recorded verifier observations are unchanged. This is an editorial revision of existing replayed traces, not newly sampled rollouts or fresh verifier replay. No observations were fabricated. Natural-language reasoning is not formally certified.
- Five epochs / 125 optimizer updates, final checkpoint
epoch_4_step_124(zero-based numbering), full-parameter BF16 SFT. - Sequence cap 12,288; global batch 32; learning rate 1e-5; 50-update warmup; retained 320-update cosine schedule horizon.
- Assistant reasoning and tool calls receive loss. Verifier replies and user/system text are context only. Long source examples were retained in full; the unchanged loader shortened reasoning in 10 entries to fit the cap while preserving all proof actions and verifier feedback.
Lean replay originally used Mathlib with Lean v4.22.0-rc4. The original Rocq checkout was unavailable, so replay used a reconstructed CORN 8.20.0 environment. This corpus primarily contains successful demonstrations, with very little recorded rejection/recovery coverage. No theorem-solving improvement is claimed for these new weights; evaluation is separate from training loss.
Dataset SHA-256: edcddee603c8fd23dc66c2070bfe7755ee8bacc5869beae5138ed32754109bb3.
Training manifest SHA-256: fe81776322095a0d8ac814c3aa44e0645e508f45346c8b4950fd67965b5e0f24.
The release manifest records training provenance, source/export hashes and
validation results.
Format and validation
This is a text-only Qwen3_5ForCausalLM with complete BF16 safetensors weights,
tokenizer, native chat template and generation configuration. It has no vision
encoder and is not an adapter. No NeMo installation or custom model code is
required for inference. Every consolidated tensor tile is compared against
the saved training checkpoint. Publication requires finite weights, standard
Transformers loading without missing/unexpected/mismatched keys, and a finite
CUDA forward pass. These checks do not measure proof quality.
Usage
Validated with Transformers 5.5.0. Install Transformers and Accelerate in a compatible PyTorch environment. The prompt below follows the training format:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "theostos/qwen-3.5-babel-9b-sft-agent-multistep"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id, dtype="auto", device_map="auto",
)
tool = {
"type": "function",
"function": {
"name": "submit_tactic",
"description": "Submit a tactic block to the Lean or Rocq verifier. The block may contain a complete proof.",
"parameters": {
"type": "object",
"properties": {
"tactic": {
"type": "string",
"description": "Tactics only, without theorem declarations or Markdown fences."
}
},
"required": [
"tactic"
]
}
}
}
messages = [{
"role": "user",
"content": (
"Derive a Lean 4 tactic proof from the following proof term. "
"Use submit_tactic to submit the next tactic block. Continue step by step until the proof is complete. "
"Do not include theorem declarations or Markdown fences in the tactic argument.\n\n"
"Proof term:\nfun (p : Prop) (h : p) => h\n\n"
"Dependencies that may be useful:\n\n"
"Initial proof state in Lean 4 (hypotheses already in context, then the goal):\n"
"p : Prop\nh : p\n⊢ p"
),
}]
inputs = tokenizer.apply_chat_template(
messages, tools=[tool], enable_thinking=True,
add_generation_prompt=True, tokenize=True,
return_tensors="pt", return_dict=True,
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=1024)
print(tokenizer.decode(outputs[0, inputs["input_ids"].shape[1]:], skip_special_tokens=False))
This generates the next assistant turn. Your host must parse Qwen's native
tool-call format, execute submit_tactic in Lean or Rocq, append the assistant
message with its structured tool_calls and reasoning, then append a tool
message with the matching tool_call_id and actual verifier response before
generating the next turn. Keep one proof state across calls: append accepted
tactic blocks, preserve Lean indentation across calls, and roll back rejected
blocks. Include real initial goals in the user prompt. Supplying the schema
alone does not run a prover; never fabricate verifier replies.
See Babel-Formal for the replay, training and export implementation. Generated proofs still require checking. Released under Apache 2.0, following the upstream Qwen3.5 model.