Views
No views yet
<swi> / </swi>.Headline result. 79.3 % MATH-500 / 89.2 % GSM8K, +25.7 points above the strongest Coconut-style baseline at the same scale.
📄 Companion paper: "Demystifying Hidden-State Recurrence: Switchable Latent Reasoning with On-Policy Reinforcement Learning" — arXiv:2606.13106. 💻 Code: github.com/LARK-AI-Lab/SWITCH 📊 Training data: LARK-Lab/SWITCH-Math-Train
<swi> to enter latent mode and </swi> to exit. Inside the
latent block it performs Coconut-style hidden-state recurrence (each step's
last-layer hidden state becomes the input embedding of the next <latent>
position). Outside the block it decodes ordinary text. The boundary tokens
are ordinary discrete vocabulary items, so on-policy GRPO is well-defined at
every text position; latent positions contribute no policy-gradient term.<swi>/</swi>.<swi> blocks with
<latent> placeholders progressively (parallel schedule).<latent> positions.1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5BASE = "Qwen/Qwen3-8B"
6ADAPTER = "LARK-Lab/SWITCH-Phase3-GRPO-LoRA-Qwen3-8B"
7
8tokenizer = AutoTokenizer.from_pretrained(ADAPTER) # contains <swi>, </swi>, <latent>
9model = AutoModelForCausalLM.from_pretrained(
10 BASE, torch_dtype=torch.bfloat16, device_map="auto"
11)
12model.resize_token_embeddings(len(tokenizer))
13model = PeftModel.from_pretrained(model, ADAPTER)
14model.eval()⚠️ Important: A naïvemodel.generate(...)will treat<latent>as just another token and will not perform the hidden-state recurrence inside<swi>...</swi>blocks. To run inference exactly as in the paper, use the SWITCH inference loop insrc/model/coconut_swi_model.py, which feeds the previous latent step's last-layer hidden state back as the next input embedding and enforces theK_minminimum-dwell constraint inside the latent block.
| Benchmark | SWITCH (this checkpoint) | Strongest Coconut-style baseline | Gap |
|---|---|---|---|
| MATH-500 | 79.3 % | 53.6 % | +25.7 |
| GSM8K | 89.2 % | 78.5 % | +10.7 |
| Base model | Qwen/Qwen3-8B |
| Phase 1 | LoRA (r=32, α=64) on {q,k,v,o,gate,up,down}_proj + resized embeddings + LM head, bf16 |
| Phase 2 | LoRA continued from Phase 1; parallel curriculum schedule, c=2, K_max=8, per-sample latent cap 48 |
| Phase 3 | Switch-GRPO; group size G=5, clip ε=0.2, KL β=1e-3, lr=1e-6; reward = correctness + format + latent-usage |
| Training data | LARK-Lab/SWITCH-Math-Train |
| Hardware | 8 × NVIDIA H20 (95 GB) |
| K_min (inference) | 4 |
| Token | Purpose |
|---|---|
<swi> | Enter latent reasoning |
</swi> | Exit latent reasoning |
<latent> | Latent placeholder; no token sampled, hidden-state injection happens here |
scripts/interpret_swi.py:<swi> is a learned switching policy, not a stylistic tag.
Sharply localised (rank ≤ 2 at boundaries vs ~10³ at random positions),
forms a clean one-token spike, linearly decodable from late hidden states
(~91.9 %).p(</swi>) ≈ 1. The
K_min constraint is what protects this single computational step.<swi> block; this is a deliberate design choice
for verifiability, not a token-level efficiency claim.model.generate(...) does not activate the hidden-state
recurrence; you must use the SWITCH inference loop to reproduce the paper
numbers.1@misc{yang2026demystifyinghiddenstaterecurrenceswitchable,
2 title = {Demystifying Hidden-State Recurrence: Switchable Latent Reasoning with On-Policy Reinforcement Learning},
3 author = {Jiayu Yang and Chao Chen and Shengen Wu and Yinhong Liu and Yuxuan Fan and Lujundong Li and Songning Lai and Chengwei Qin and Zhijiang Guo},
4 year = {2026},
5 eprint = {2606.13106},
6 archivePrefix = {arXiv},
7 primaryClass = {cs.LG},
8 url = {https://arxiv.org/abs/2606.13106}
9}