Provenance
- Base:
Qwen/Qwen3.5-4B, revision 851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a.
- Training: 9,000 LLM-silver examples; 200 validation examples for checkpoint selection; 800 held-out test examples.
- LoRA: rank 32, alpha 64, dropout 0.05; 248 text-backbone Linear modules, 64,929,792 trainable parameters. Vision and lm_head were not trained.
- BF16, maximum total sequence length 40,960; microbatch 1, accumulation 16; lr 1e-4, cosine schedule; activation checkpointing and fused Liger Linear+CE over graph/EOS tokens.
- Selected checkpoint: step 1100, epoch 1.9547, validation CE 0.6670205593. Early stopping at step 1400 (epoch 2.4871), maximum 3 epochs.
- All 248 LoRA layers merged through PEFT safe_merge on CPU after exact adapter-tensor verification. BF16 merging can differ numerically from separate adapter application.
- Adapter revision:
khafizovfanis/qwen3.5-4b-discourse-e006-lora@6d34a5a51b8eb78c81136decf2bc0d0d5ba7eabb (private).
- Frozen data revision:
khafizovfanis/reasoning-traces-discourse-e006@e02e304072e688d466f3f22e59254da1948eede7 (private).
- Weights SHA256:
6cf4996be9b0a5946f4526f68e99c50916fb625c3bb5677c3e7244cbf3698545.
Inference
Tested with vLLM 0.31.0, PyTorch 2.13.0, Transformers 5.17.0. The full tested dependency lock is included as requirements-vllm.lock.txt. Use a compatible Linux/CUDA environment and sufficient GPU memory. This example mirrors the experiment's inference settings and runs text-only; multimodal use was not evaluated.
Download the complete snapshot and pin the returned commit SHA in your pipeline:
from huggingface_hub import HfApi, snapshot_downloadrepo = "khafizovfanis/qwen3.5-4b-discourse-e006-merged"revision = HfApi().model_info(repo).shapath = snapshot_download(repo, revision=revision)print("Pinned revision:", revision)
import jsonfrom pathlib import Pathfrom transformers import AutoTokenizerfrom vllm import LLM, SamplingParams # `path` is the complete downloaded snapshot directory above.tokenizer = AutoTokenizer.from_pretrained(path, local_files_only=True)record = {"prompt": "Your original task", "reasoning_trace": "Your full reasoning trace"}messages = [ {"role": "system", "content": (Path(path) / "parser_prompt.txt").read_text()}, {"role": "user", "content": "Annotate this input record:\n" + json.dumps(record, ensure_ascii=False)},]text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True, enable_thinking=False)ids = tokenizer.encode(text, add_special_tokens=False)if len(ids) + 8192 > 65536: raise ValueError("Input exceeds the evaluated context budget; do not silently truncate")llm = LLM( model=path, tokenizer=path, dtype="bfloat16", language_model_only=True, max_model_len=65536, max_num_seqs=8, max_num_batched_tokens=4096, kv_cache_memory_bytes=12 * 2**30, gpu_memory_utilization=0.22, enforce_eager=True, enable_prefix_caching=False, seed=42, generation_config="vllm",)params = SamplingParams( temperature=0, max_tokens=8192, seed=42, stop_token_ids=[tokenizer.eos_token_id],)result = llm.generate([{"prompt_token_ids": ids}], params)[0].outputs[0]if result.finish_reason == "length": raise ValueError("Generation hit the token limit")print(result.text) # Parse and validate against the discourse schema before use.
For schema validation and batch/resume handling, see sft/generate_vllm.py and sft/common.py. Do not assume JSON parseability alone establishes graph validity or semantic correctness. When using the parser in an RL pipeline, define and test graph-to-reward conversion separately.
Evaluation
On all 800 held-out examples, base produced 225 schema-valid outputs (28.125%); SFT produced 800 (100%). Base failures: 558 invalid graphs, 13 invalid JSON outputs, 4 length-limit outputs. Both arms used identical prompt text policy and greedy decoding with thinking disabled and an 8192-token output limit.
A stratified subset of 100 test examples was judged with 200 independent, anonymous, single-answer Codex subagents. Each answer was judged in a fresh context; no judge saw the other model's response. Four 0–4 dimensions (faithfulness, coverage, relations, types/order) were summed and multiplied by 6.25. Source traces take precedence over the LLM-silver reference. Non-valid outputs receive zero by policy.
Table with columns: Subset, n, Base /100, SFT /100| Subset | n | Base /100 | SFT /100 |
|---|
| All selected, including policy zeros | 100 | 14.3125 | 82.8125 |
| Same examples where both outputs are valid | 26 | 55.0481 | 84.8558 |
SFT scored higher on all 100 examples. There were 74 base policy zeros and none for SFT. All 200 judgments passed structural, identity and verbatim-evidence checks; these checks do not establish semantic correctness.
Limitations
This is a research parser trained on LLM-silver labels, not human gold. The overall score improvement is strongly affected by the strict failure-zero policy. Only 100/800 examples received semantic judgments; no confidence interval was computed. One training seed was tested. Exact runtime judge model/effort metadata were unavailable. Twelve earlier pilot samples were excluded, but rubric-development exposure remains a limitation. A tokenizer audit found identical serialized input text on all 100 judged examples but a two-token difference on one example between base and merged tokenizer snapshots. Use this repository's tokenizer. Graph errors and omissions remain possible. No downstream RL benefit, general-purpose reasoning improvement or multimodal quality is established.
Full experiment report (Russian).
License
Apache-2.0, following the base model. This repository contains model weights and inference instructions; it does not redistribute the training corpus or private evaluation traces.