Text Generation
Transformers
Safetensors
gpt2
latent-reasoning
continuous-thought
coconut
grpo
reinforcement-learning
text-generation-inference
Instructions to use jihwan1205/svp-v-coconut-gpt2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jihwan1205/svp-v-coconut-gpt2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jihwan1205/svp-v-coconut-gpt2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jihwan1205/svp-v-coconut-gpt2") model = AutoModelForCausalLM.from_pretrained("jihwan1205/svp-v-coconut-gpt2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use jihwan1205/svp-v-coconut-gpt2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jihwan1205/svp-v-coconut-gpt2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jihwan1205/svp-v-coconut-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/jihwan1205/svp-v-coconut-gpt2
- SGLang
How to use jihwan1205/svp-v-coconut-gpt2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "jihwan1205/svp-v-coconut-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": "jihwan1205/svp-v-coconut-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
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 "jihwan1205/svp-v-coconut-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": "jihwan1205/svp-v-coconut-gpt2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use jihwan1205/svp-v-coconut-gpt2 with Docker Model Runner:
docker model run hf.co/jihwan1205/svp-v-coconut-gpt2
File size: 3,299 Bytes
0efa1f0 a996045 0efa1f0 be4cc8d 7554e05 df7cdca 4a7637d be4cc8d df7cdca 7554e05 0efa1f0 c94e146 0efa1f0 be4cc8d 0efa1f0 be4cc8d 0efa1f0 4a7637d be4cc8d c94e146 0efa1f0 be4cc8d 0efa1f0 be4cc8d 0efa1f0 be4cc8d 0efa1f0 4a7637d 0efa1f0 7554e05 0efa1f0 7554e05 4a7637d 0efa1f0 be4cc8d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ---
base_model:
- ModalityDance/latent-tts-coconut
license: mit
pipeline_tag: text-generation
library_name: transformers
tags:
- latent-reasoning
- continuous-thought
- coconut
- grpo
- reinforcement-learning
datasets:
- zen-E/GSM8k-Aug
---
# SVP-V-GRPO · COCONUT GPT-2
A [COCONUT](https://huggingface.co/ModalityDance/latent-tts-coconut) GPT-2 (124M)
latent-reasoning model post-trained with **SVP-V-GRPO** — reinforcement learning whose
rollout exploration comes from *weight-space* perturbation of the attention value
projections. For each layer and rollout, SVP independently samples Gaussian noise and
rescales coefficients in the fixed SVD basis of `W_V` as `sᵢ → sᵢ(1+αgᵢ)`.
Only the value-projection weights (the V columns of each `c_attn`) differ from the base
checkpoint. The perturbation is a training-time exploration mechanism and is **not** used
at deployment: inference is ordinary greedy decoding.
This repository contains the paper's GPT-2 SVP-V-GRPO checkpoint from epoch 9 `B=32`, `lr=6e-5` run.
## Results
Clean greedy decoding, `max_new_tokens=64`, exact-match on the final answer.
| Model (GPT-2 124M) | GSM8K | GSM-Hard | MultiArith | SVAMP | ASDiv-A | GSM-Plus |
|---|---|---|---|---|---|---|
| COCONUT (base) | 34.1 | 7.7 | 80.9 | 35.6 | 60.2 | 17.4 |
| SLPO | 34.9 | 7.6 | 82.8 | 34.3 | 58.7 | 18.2 |
| SIM-CoT | 44.7 | 9.3 | 90.5 | 40.6 | 67.2 | 21.5 |
| CoDi | 42.5 | 9.3 | 91.9 | 40.0 | 65.4 | 23.1 |
| **This model** (SVP on `W_V`, α=0.6) | **50.3** | **11.3** | **93.4** | 43.6 | **71.2** | **27.6** |
## Usage
This is a fixed-length continuous-thought model: the prompt ends with
`<|start-latent|>`, six latent steps feed each step's last hidden state back as the next
input embedding, `<|end-latent|>` closes the latent phase, and the answer is then decoded
as ordinary tokens.
```python
from transformers import AutoTokenizer, GPT2LMHeadModel
REPO = "." # path to this repository
tok = AutoTokenizer.from_pretrained(REPO)
model = GPT2LMHeadModel.from_pretrained(REPO).eval().cuda()
# then run the two-phase latent loop: 6 latent steps, then decode the answer
```
A reference implementation of the loop ships with the SVP code release; the original
COCONUT inference code works as well.
## Training
| | |
|---|---|
| Base | `ModalityDance/latent-tts-coconut` (COCONUT GPT-2, 124M) |
| Data | 383,891 eligible prompts from [GSM8K-Aug](https://huggingface.co/datasets/zen-E/GSM8k-Aug) |
| Algorithm | GRPO: `G=32` rollouts per prompt; `2B=64` candidate prompts per iteration with up to `B=32` mixed-outcome groups retained; `μ=2` optimization passes; centered advantages; symmetric clipping `ε=0.2`; k3 KL (`β=0.02`) to the frozen base |
| Exploration | SVP with `α=0.6`: independent Gaussian coefficient perturbations for each Value-projection layer and rollout, held fixed through prefill and all six latent steps; clean answer decoding; SVD factors refreshed every 50 iterations |
| Trained parameters | V columns of every `c_attn` (≈ 7M of 124M) |
| Optimizer | AdamW, constant `lr=6e-5`, seed 0, no warmup or weight decay, gradient clipping at 1.0; epoch-9 checkpoint from 15 epochs |
| Reward | Final-answer correctness only |
## License
MIT, inherited from the base checkpoint (which derives from `openai-community/gpt2`).
|