SLPO
Collection
Checkpoints for the paper SLPO: Scaling Latent Reasoning with Surrogate Policy Optimization. • 2 items • Updated
How to use ModalityDance/slpo-codi-gpt2 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="ModalityDance/slpo-codi-gpt2") # Load model directly
from transformers import AutoTokenizer, LatentCODIGPT2
tokenizer = AutoTokenizer.from_pretrained("ModalityDance/slpo-codi-gpt2")
model = LatentCODIGPT2.from_pretrained("ModalityDance/slpo-codi-gpt2", device_map="auto")How to use ModalityDance/slpo-codi-gpt2 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "ModalityDance/slpo-codi-gpt2"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ModalityDance/slpo-codi-gpt2",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/ModalityDance/slpo-codi-gpt2
How to use ModalityDance/slpo-codi-gpt2 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "ModalityDance/slpo-codi-gpt2" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ModalityDance/slpo-codi-gpt2",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "ModalityDance/slpo-codi-gpt2" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "ModalityDance/slpo-codi-gpt2",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use ModalityDance/slpo-codi-gpt2 with Docker Model Runner:
docker model run hf.co/ModalityDance/slpo-codi-gpt2
Surrogate Latent Policy Optimization (SLPO) checkpoint on top of CODI (GPT-2 124M). This is the CODI+SLPO model reported in the paper SLPO: Scaling Latent Reasoning with Surrogate Policy Optimization.
ModalityDance/latent-tts-codi)<|latent|>, <|start-latent|>, <|end-latent|>0.712Deterministic accuracy with dropout disabled and learned stop gate:
| Benchmark | Acc | Mean latent length |
|---|---|---|
| GSM8K | 42.76 | 11.83 |
| GSM-Hard | 9.71 | 11.94 |
| MultiArith | 90.52 | 11.44 |
https://arxiv.org/abs/XXXX.XXXXXhttps://huggingface.co/papers/XXXX.XXXXXgit clone https://github.com/ModalityDance/SLPO.git
cd SLPO
pip install -r requirements.txt # plus a CUDA PyTorch build
hf download ModalityDance/slpo-codi-gpt2 --local-dir checkpoints/slpo-codi-gpt2
Batched eval (paper Acc settings):
CKPT=checkpoints/slpo-codi-gpt2 \
MODEL_TYPE=codi STOP_POLICY=gate \
STOP_GATE_THRESHOLD=0.7 MAX_LATENT_LENGTH=12 \
DATA=data/gsm_test.json \
bash scripts/eval.sh
Minimal Python (from the repo root; needs the SLPO latent generation stack):
import torch
from transformers import AutoTokenizer
from src.models.generation import LatentGenerationMixin, LatentGenerationConfig
from src.paths import get_model_class
model_id = "ModalityDance/slpo-codi-gpt2"
backbone_cls = get_model_class("codi")
class LatentModel(backbone_cls, LatentGenerationMixin):
pass
tokenizer = AutoTokenizer.from_pretrained(model_id)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
model = LatentModel.from_pretrained(model_id)
model.eval()
question = (
"Janet's ducks lay 16 eggs per day. She eats three for breakfast every morning "
"and bakes muffins for her friends every day with four. She sells the remainder "
"at the farmers' market daily for $2 per fresh duck egg. "
"How much in dollars does she make every day at the farmers' market?"
)
prompt = question + "<|start-latent|>"
inputs = tokenizer(prompt, return_tensors="pt")
gen_cfg = LatentGenerationConfig(
stop_policy="gate",
max_latent_length=12,
stop_gate_threshold=0.7,
max_new_tokens=128,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
bos_token_id=tokenizer.bos_token_id,
)
with torch.no_grad():
output = model.generate(**inputs, generation_config=gen_cfg)
sequences = output.sequences if hasattr(output, "sequences") else output
print(tokenizer.decode(sequences[0], skip_special_tokens=True))
@misc{you2026slpo,
title = {SLPO: Scaling Latent Reasoning with Surrogate Policy Optimization},
author = {You, Runyang and Liu, Zhiyuan and Li, Yongqi and Li, Wenjie},
year = {2026},
note = {Code: https://github.com/ModalityDance/SLPO}
}