MoE-tikz DPO V3
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 third round of DPO, merged into one full bf16 checkpoint. It needs no adapter: load it directly.
What V3 is for: cleaner layouts and reliability. It has the fewest overlapping labels and shapes and almost no repetition loops of all versions. MoE-tikz DPO V2 still scores slightly higher on content with the judges.
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 gate | Loops | Overlap rate | Dual judge score | Gain vs SFT [95% CI] | Independent judge (Qwen3.8-27B) | Solved in ≤ 3 tries |
|---|---|---|---|---|---|---|---|---|
| MoE-tikz (SFT) | 89.1% | 82.2% | 4.0% | 41.4% | 0.560 | baseline | 0.602 | 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% | 38.1% | 0.704 | +0.144 [+0.103, +0.188] | 0.774 | 68.7% |
| MoE-tikz DPO V3 | 92.0% | 89.1% | 0.9% | 31.2% | 0.679 | +0.119 [+0.075, +0.163] | 0.728 | 69.3% |
V3 against V2, paired over prompts (95% CI):
| V3 − V2 | |
|---|---|
| Overlap rate | −5.4 points [−10.5, −0.5] (fewer overlaps) |
| Dual judge score | −0.026 [−0.057, +0.006] (not significant) |
| Independent judge (Qwen3.8) | −0.046 [−0.083, −0.009] |
How the scores work:
- 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. - Overlap rate: share of gate-passed answers where a PDF-based detector finds text on text, a line through text, text hidden under a fill, a legend or labelled box over data, or mostly tiny text.
- Dual judge score: Gemma-4-26B-A4B-it and Qwen3.6-35B-A3B rate each rendered figure (faithfulness and layout); the average of the two, 0 for answers that fail the gate. Kept unchanged so V1–V3 are comparable.
- Independent judge: Qwen3.8-27B with the same prompt; it was not used to build any training data.
- Confidence intervals: paired bootstrap over prompts.
These are automatic judges, not human ratings.
What V3 changed vs V2
V2's preference signal could barely see layout: a third of the answers it trained on as "good" had overlapping labels or shapes, and no pair taught the model to avoid them. V3 rebuilds the signal:
| V2 | V3 | |
|---|---|---|
| Judges | Gemma-4-26B + Qwen3.6-35B, one 1–5 faithfulness and layout score | Gemma-4-26B + Inkling 2 Mini, each with a checklist: every requirement of the prompt marked ok / wrong / missing, and 8 yes/no layout defects |
| Overlap detection | none | PDF detector (text on text, line through text, hidden text, legend or box over data) or both judges agreeing on an overlap |
| Overlapping answers that could still be "chosen" (hand-labelled check) | 53% | 2% |
| Overlaps caught (hand-labelled check) | 26% | 88% |
| Pairs | 15,781 over 10,777 prompts | 19,287 over 12,163 prompts |
| Pairs that teach "avoid overlap" | 0 | 9,791 |
| Other rejected kinds | wrong drawing 6,973 · compile/gate 7,702 · loop 1,106 | compile/gate 7,607 · loop 1,111 · wrong content 778 |
Everything else is the same as V2: same SFT start point, same rollouts (8 per prompt on 20k DaTikZ prompts, rescored), verified dataset reference code where no rollout was good, and the same training recipe.
Training
| Setting | Value |
|---|---|
| Start point | MoE-tikz (SFT), merged to bf16 |
| Pairs | 19,287 over 12,163 prompts (3,970 with dataset reference code as chosen) |
| Loss | DPO (sigmoid) + SFT loss on the chosen answer (weights 1.0 / 0.5) |
| β | 0.1 |
| LoRA (merged in) | rank 32 / alpha 32, same target modules as the SFT adapter |
| LR / batch / epochs | 4e-5, global batch 32, 1 epoch, 25 warmup steps |
| Held-out pair accuracy | 0.854 (harder pairs than V2's: most differ only in layout) |
| Framework | TRL 1.15 + Unsloth, 1 × B200 |
Usage
Trained in non-thinking mode with the system prompt below. Use the same prompt and enable_thinking=False.
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-V3", 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)
It also loads with transformers (AutoModelForImageTextToText / AutoProcessor, as for the Qwen3.6 base). Temperature 0.7 is recommended.
Limitations
- V3 is slightly weaker than V2 at drawing exactly what was asked (independent judge −0.046). Only 778 of its pairs taught wrong-vs-right content, against 6,973 in V2.
- About 31% of answers still have some overlap by the detector's count (V2: 38%, SFT: 41%).
- About 7% of answers still fail to compile because of LaTeX errors that are not loops (invented TikZ keys, missing packages).
- The scores come from automatic judges and a detector that also shaped training. They have not been checked against human ratings.
License
Follows the license of the base model, Qwen/Qwen3.6-35B-A3B-FP8.