MoE-tikz DPO V1
Turns a natural-language description of a figure into a complete, standalone TikZ/LaTeX document.
This is Praha-Labs/MoE-tikz (a LoRA SFT of Qwen/Qwen3.6-35B-A3B-FP8) after a first round of DPO, merged into one full bf16 checkpoint. It needs no adapter: load it directly.
Prefer MoE-tikz DPO V2. V1 draws much better than SFT, but it gets stuck in repetition loops about 3× as often. V2 fixes this and scores higher. V1 is published for comparison and reproducibility.
Results
150 prompts (100 held-out DaTikZ prompts + 50 hand-written ones), 3 samples per prompt (450 answers per model), temperature 0.7 / top_p 0.8 / top_k 20.
| Model | Compiled | Passed the anti-cheat gate | Loops (hit 4,096 tokens) | Dual judge score | Gain vs SFT [95% CI] | Solved in ≤ 3 tries |
|---|---|---|---|---|---|---|
| MoE-tikz (SFT) | 89.1% | 82.2% | 4.0% | 0.560 | baseline | 58.7% |
| MoE-tikz DPO V1 | 83.6% | 82.0% | 12.4% | 0.676 | +0.116 [+0.064, +0.170] | 68.0% |
| MoE-tikz DPO V2 | 90.2% | 88.0% | 3.3% | 0.704 | +0.144 [+0.103, +0.187] | 68.7% |
How the score works:
- Gate: every answer is compiled with
pdflatex(no shell escape, 30 s limit, exactly 1 page). It is rejected if the result is blank, tiny, a text dump, or copies the prompt or judge-bait text. - Judges: each rendered figure that passes is scored from the image alone by two vision models, Gemma-4-26B-A4B-it and Qwen3.6-35B-A3B.
- Dual score: the average of the two judges, with 0 for answers that fail the gate.
- Confidence intervals: paired bootstrap over prompts.
These are automatic judges, not human ratings. The same two judges were also used to build the training pairs.
Known issue: repetition loops
V1 loops on 12.4% of answers: it repeats lines until the 4,096-token limit, so the output does not compile. Causes:
- Only 279 of its training pairs showed a loop as the rejected answer.
- DPO pushed the model towards long, hand-written code.
- The pull back to SFT (SFT loss weight 0.15) was weak.
Lower temperatures do not fix it: greedy decoding and temperature 0.3 looped more than 0.7. V2 targets each of these causes.
Training
| Setting | Value |
|---|---|
| Start point | MoE-tikz (SFT), merged to bf16 |
| Pairs | 8,995, one per prompt, from 8 SFT rollouts per prompt on 20k DaTikZ prompts |
| Chosen / rejected | Chosen: both judges ≥ 0.75 (mean 0.93 / 0.97). Rejected: wrong drawing or gate failure (mean 0.09 / 0.10) |
| Loss | DPO (sigmoid) + SFT loss on the chosen answer (weights 1.0 / 0.15) |
| β | 0.1 |
| LoRA (merged in) | rank 32 / alpha 32 |
| LR / batch / epochs | 4e-5 (from a sweep), global batch 32, 1 epoch |
| Held-out pair accuracy | 0.857 |
| Framework | TRL 1.15 + Unsloth, 1 × B200 |
Usage
Same as V2: non-thinking mode with this system prompt, enable_thinking=False, temperature 0.7.
from vllm import LLM, SamplingParams
SYSTEM_PROMPT = (
"You are an expert in LaTeX and TikZ. Given a description of a figure, "
"write a complete, compilable standalone LaTeX document that draws it with TikZ. "
"Output only the LaTeX code."
)
llm = LLM("Praha-Labs/MoE-tikz-DPO-V1", max_model_len=8192)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": "Draw a right triangle ABC with the right angle at C marked by a small square, and label the sides a, b and c."},
]
out = llm.chat(messages, SamplingParams(temperature=0.7, top_p=0.8, top_k=20, max_tokens=4096),
chat_template_kwargs={"enable_thinking": False})
print(out[0].outputs[0].text)
License
Follows the license of the base model, Qwen/Qwen3.6-35B-A3B-FP8.