MoE-tikz DPO V2
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 second round of DPO, merged into one full bf16 checkpoint. It needs no adapter: load it directly.
This is the recommended model. It fixes the repetition loops of MoE-tikz DPO V1 and has the best benchmark score of the three.
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. They rate faithfulness to the prompt and layout quality.
- 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, so the scores can favour their tastes.
What V2 changed vs V1
| V1 problem | V2 change |
|---|---|
| Repetition loops: 12.4% of answers vs 4.0% for SFT | 1,106 pairs whose rejected answer is a loop (V1 had 279) |
| Drift towards long, hand-drawn code | The chosen answer is the shortest of the near-best answers |
| One pair per prompt; compile failures mostly unused | Up to 3 pairs per prompt: wrong drawing, compile/gate failure, loop |
| Weak pull back to SFT | SFT loss on the chosen answer at weight 0.5 (V1: 0.15) |
| The hardest prompts had no good answer | Dataset reference code used as the chosen answer, only if it passes the gate and both judges score it ≥ 0.75 |
Training
| Setting | Value |
|---|---|
| Start point | MoE-tikz (SFT), merged to bf16 |
| Pairs | 15,781 over 10,777 prompts, from 8 SFT rollouts per prompt on 20k DaTikZ prompts + verified reference code |
| 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.904 |
| 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-V2", 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. Greedy decoding and temperature 0.3 both looped more in our tests.
Limitations
- About 6% of answers still fail to compile because of LaTeX errors that are not loops (invented TikZ keys, missing packages), and about 3% loop until the token limit.
- The scores come from two automatic judges 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.