Add model card
Browse filesThis PR adds a model card for the paper [Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach](https://huggingface.co/papers/2502.05171).
It also adds a link to the project page, and the Github repository.
README.md
CHANGED
@@ -1,275 +1,10 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
tags:
|
4 |
-
- code
|
5 |
-
- math
|
6 |
-
- reasoning
|
7 |
-
- llm
|
8 |
-
license: apache-2.0
|
9 |
-
language:
|
10 |
-
- en
|
11 |
pipeline_tag: text-generation
|
12 |
-
|
13 |
-
# - HuggingFaceTB/smollm-corpus
|
14 |
-
# - jon-tow/starcoderdata-python-edu
|
15 |
-
# - ubaada/booksum-complete-cleaned
|
16 |
-
# - euirim/goodwiki
|
17 |
-
# - togethercomputer/RedPajama-Data-1T
|
18 |
-
# - allenai/dolma
|
19 |
-
# - bigcode/the-stack-v2-train-smol-ids
|
20 |
-
# - bigcode/starcoderdata
|
21 |
-
# - m-a-p/Matrix
|
22 |
-
# - cerebras/SlimPajama-627B
|
23 |
-
# - open-phi/textbooks
|
24 |
-
# - open-phi/textbooks_grounded
|
25 |
-
# - open-phi/programming_books_llama
|
26 |
-
# - nampdn-ai/tiny-strange-textbooks
|
27 |
-
# - nampdn-ai/tiny-textbooks
|
28 |
-
# - nampdn-ai/tiny-code-textbooks
|
29 |
-
# - nampdn-ai/tiny-orca-textbooks
|
30 |
-
# - SciPhi/textbooks-are-all-you-need-lite
|
31 |
-
# - vikp/textbook_quality_programming
|
32 |
-
# - EleutherAI/proof-pile-2
|
33 |
-
# - open-web-math/open-web-math
|
34 |
-
# - biglam/blbooks-parquet
|
35 |
-
# - storytracer/LoC-PD-Books
|
36 |
-
# - GAIR/MathPile
|
37 |
-
# - tomg-group-umd/CLRS-Text-train
|
38 |
-
# - math-ai/AutoMathText
|
39 |
-
# - bigcode/commitpackft
|
40 |
-
# - bigcode/stack-dedup-python-fns
|
41 |
-
# - vikp/python_code_instructions_filtered
|
42 |
-
# - mlabonne/chessllm
|
43 |
-
# - Waterhorse/chess_data
|
44 |
-
# - EleutherAI/lichess-puzzles
|
45 |
-
# - chargoddard/WebInstructSub-prometheus
|
46 |
-
# - Locutusque/hercules-v5.0
|
47 |
-
# - nvidia/OpenMathInstruct-1
|
48 |
-
# - meta-math/MetaMathQA
|
49 |
-
# - m-a-p/CodeFeedback-Filtered-Instruction
|
50 |
-
# - nvidia/Daring-Anteater
|
51 |
-
# - nvidia/sft_datablend_v1
|
52 |
-
# - BAAI/Infinity-Instruct
|
53 |
-
# - anthracite-org/Stheno-Data-Filtered
|
54 |
-
# - Nopm/Opus_WritingStruct
|
55 |
-
# - xinlai/Math-Step-DPO-10K
|
56 |
-
# - bigcode/self-oss-instruct-sc2-exec-filter-50k
|
57 |
-
# - HuggingFaceTB/everyday-conversations
|
58 |
-
# - hkust-nlp/gsm8k-fix
|
59 |
-
# - HuggingFaceH4/no_robots
|
60 |
-
# - THUDM/LongWriter-6k
|
61 |
-
# - THUDM/webglm-qa
|
62 |
-
# - AlgorithmicResearchGroup/ArXivDLInstruct
|
63 |
-
# - allenai/tulu-v2-sft-mixture-olmo-4096
|
64 |
-
# - bigscience/P3
|
65 |
-
# - Gryphe/Sonnet3.5-SlimOrcaDedupCleaned
|
66 |
-
# - Gryphe/Opus-WritingPrompts
|
67 |
-
# - nothingiisreal/Reddit-Dirty-And-WritingPrompts
|
68 |
-
# - nothingiisreal/Kalomaze-Opus-Instruct-25k-filtered
|
69 |
-
# - internlm/Lean-Github
|
70 |
-
# - pkuAI4M/LeanWorkbook
|
71 |
-
# - casey-martin/multilingual-mathematical-autoformalization
|
72 |
-
# - AI4M/leandojo-informalized
|
73 |
-
# - casey-martin/oa_cpp_annotate_gen
|
74 |
-
# - l3lab/ntp-mathlib-instruct-st
|
75 |
-
# - ajibawa-2023/Maths-College
|
76 |
-
# - ajibawa-2023/Maths-Grade-School
|
77 |
-
# - ajibawa-2023/General-Stories-Collection
|
78 |
-
# - XinyaoHu/AMPS_mathematica
|
79 |
-
# - XinyaoHu/AMPS_khan
|
80 |
-
# - Magpie-Align/Magpie-Pro-MT-300K-v0.1
|
81 |
-
# - Magpie-Align/Magpie-Reasoning-150K
|
82 |
-
# - gair-prox/FineWeb-pro
|
83 |
-
# - gair-prox/c4-pro
|
84 |
-
# - gair-prox/RedPajama-pro
|
85 |
-
# - gair-prox/open-web-math-pro
|
86 |
-
# - togethercomputer/Long-Data-Collections
|
87 |
-
# - emozilla/pg19
|
88 |
-
# - MathGenie/MathCode-Pile
|
89 |
-
# - KingNish/reasoning-base-20k
|
90 |
-
# - nvidia/OpenMathInstruct-2
|
91 |
-
# - LLM360/TxT360
|
92 |
-
# - neuralwork/arxiver
|
93 |
---
|
94 |
|
95 |
-
|
96 |
-
This is Huginn, version 01/25. This is a latent recurrent-depth model with 3.5B parameters, trained for 800B tokens on AMD MI250X machines. This is a proof-of-concept model, but surprisingly capable in reasoning and code given its training budget and size.
|
97 |
-
All details on this model can be found in the tech report: "Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach."
|
98 |
-
|
99 |
-
8 intermediate checkpoints of the model can be found in its collection. Additional intermediate checkpoints are available upon request while we find a place to host all ~350 of them. The data used to train
|
100 |
-
this model is publicly available (entirely on Hugging Face), and scripts provided with the pretraining code at https://github.com/seal-rg/recurrent-pretraining can be used to repeat our preprocessing and our entire training run.
|
101 |
-
|
102 |
-
<img src="asset2.jpeg" width="60%">
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
## Table of Contents
|
107 |
-
|
108 |
-
1. [How to Use](#downloading-and-using-the-model)
|
109 |
-
2. [Advanced Usage](#advanced-features)
|
110 |
-
3. [Model Summary](#model-summary)
|
111 |
-
4. [Limitations](#limitations)
|
112 |
-
5. [Technical Details](#training)
|
113 |
-
6. [License](#license)
|
114 |
-
7. [Citation](#citation)
|
115 |
-
|
116 |
-
|
117 |
-
## Downloading and Using the Model
|
118 |
-
Load the model like this:
|
119 |
-
```python
|
120 |
-
import torch
|
121 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
122 |
-
|
123 |
-
model = AutoModelForCausalLM.from_pretrained("tomg-group-umd/huginn-0125", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
124 |
-
tokenizer = AutoTokenizer.from_pretrained("tomg-group-umd/huginn-0125")
|
125 |
-
```
|
126 |
-
### Modifying the Model's Depth at Test Time:
|
127 |
-
By providing the argument `num_steps`, the model will execute a forward pass with that amount of compute:
|
128 |
-
```python
|
129 |
-
input_ids = tokenizer.encode("The capital of Westphalia is", return_tensors="pt", add_special_tokens=True).to(device)
|
130 |
-
model.eval()
|
131 |
-
model.to(device)
|
132 |
-
|
133 |
-
model(input_ids, num_steps=32)
|
134 |
-
```
|
135 |
-
The model has about 1.5B parameters in non-recurrent code, 0.5B parameters in the embedding, and 1.5B recurrent parameters, so, as a guideline,
|
136 |
-
the number of materialized parameters is `num_steps * 1.5B + 2B`. Playing with this parameter is what makes this model interesting, and different from fixed-depth transformers!
|
137 |
-
The model is trained to accept an arbitrary number of steps. However, using fewer than 4 steps will result in very coarse answers. If given enough context to reason about, benchmarks show the model improving up to around `num_steps=64`. Beyond that, more steps generally do not hurt, but we see no further improvements.
|
138 |
-
|
139 |
-
*Note*: Due to an upload issue the model is currently stored on HF with 2 copies of the tied embedding, instead of just one. This will be fixed in a future release.
|
140 |
-
|
141 |
-
### Inference
|
142 |
-
The model was trained with bfloat16-mixed precision, so we recommend using `bfloat16` to run inference (or AMP bfloat16-mixed precision, if you really want). All benchmarks were evaluated in pure `bfloat16`.
|
143 |
-
|
144 |
-
### Sampling
|
145 |
-
The model can be used like a normal HF model to generate text with KV-caching working as expected. You can provide `num_steps` directly to the `generate` call, for example:
|
146 |
-
```
|
147 |
-
model.eval()
|
148 |
-
config = GenerationConfig(max_length=256, stop_strings=["<|end_text|>", "<|end_turn|>"],
|
149 |
-
use_cache=True,
|
150 |
-
do_sample=False, temperature=None, top_k=None, top_p=None, min_p=None,
|
151 |
-
return_dict_in_generate=True,
|
152 |
-
eos_token_id=65505,bos_token_id=65504,pad_token_id=65509)
|
153 |
-
|
154 |
-
|
155 |
-
input_ids = tokenizer.encode("The capital of Westphalia is", return_tensors="pt", add_special_tokens=True).to(device)
|
156 |
-
outputs = model.generate(input_ids, config, tokenizer=tokenizer, num_steps=16)
|
157 |
-
```
|
158 |
-
|
159 |
-
*Note*: `num_steps` and other model arguments CANNOT be included in the `GenerationConfig`, they will shadow model args at runtime.
|
160 |
-
|
161 |
-
|
162 |
-
### Chat Templating
|
163 |
-
|
164 |
-
The model was not finetuned or post-trained, but due to inclusion of instruction data during pretraining, natively understand its chat template. You can chat with the model like so
|
165 |
-
```
|
166 |
-
messages = []
|
167 |
-
messages.append({"role": "system", "content" : You are a helpful assistant."}
|
168 |
-
messages.append({"role": "user", "content" : What do you think of Goethe's Faust?"}
|
169 |
-
chat_input = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
170 |
-
print(chat_input)
|
171 |
-
input_ids = tokenizer.encode(chat_input, return_tensors="pt", add_special_tokens=False).to(device)
|
172 |
-
|
173 |
-
model.generate(input_ids, config, num_steps=64, tokenizer=tokenizer)
|
174 |
-
```
|
175 |
-
|
176 |
-
### KV-cache Details
|
177 |
-
The model requires its own KV-cache implementation `HuginnDynamicCache`, otherwise the KV-caches of later calls to the recurrent block will overwrite the earlier ones.
|
178 |
-
The current implementation will always try to inject this Cache implementation, but that may break with huggingface updates. If you do not use generate, but implement your own generation, use a pattern like this:
|
179 |
-
|
180 |
-
```python
|
181 |
-
# first step:
|
182 |
-
past_key_values = None
|
183 |
-
outputs = model(input_ids=input_ids, use_cache=True, past_key_values=past_key_values)
|
184 |
-
past_key_values = outputs.past_key_values # Should be an instance of HuginnDynamicCache
|
185 |
-
# next step
|
186 |
-
outputs = model(input_ids=input_ids, use_cache=True, past_key_values=past_key_values)
|
187 |
-
```
|
188 |
-
|
189 |
-
## Advanced Features
|
190 |
-
|
191 |
-
### Per-Token Adaptive Compute
|
192 |
-
When generating, you can also a variable amount of compute per-token. The model is not trained for this, so this is a proof-of-concept, that can do this task zero-shot.
|
193 |
-
You can pick between a few sane stopping rules, `entropy-diff`, `latent-diff`,`kl` and `argmax-stability`, via `criterion=kl`. The exit threshold can be modified via `exit_threshold=5e-4`.
|
194 |
-
We suggest using `kl` for interesting exits and `argmax-stability` for conservative exits. Note that using these variables overrides the default generation function. Not all arguments that are valid for the normal `generate` call are valid here. To make this more explicit, you can also directly call `generate_with_adaptive_compute`:
|
195 |
-
|
196 |
-
```python
|
197 |
-
from transformers import TextStreamer
|
198 |
-
streamer = TextStreamer(tokenizer)
|
199 |
-
|
200 |
-
model.generate_with_adaptive_compute(input_ids, config, num_steps=64, tokenizer=tokenizer, streamer=streamer,
|
201 |
-
continuous_compute=False, criterion="kl", exit_threshold=5e-4, cache_kwargs={"lookup_strategy": "latest-m4"})
|
202 |
-
|
203 |
-
```
|
204 |
-
Your cache strategy should be set to `"latest-m4"` if using adaptive compute.
|
205 |
-
|
206 |
-
### KV-cache Sharing
|
207 |
-
To reduce KV cache memory requirements, the model can be run with fewer KV-caches, with later iterations in the recurrence overwriting earlier caches. To use this feature, set
|
208 |
-
the cache argument `lookup_strategy` to include `compress-s16` (where the last number determine the size of the cache).
|
209 |
-
```
|
210 |
-
model.generate_with_adaptive_compute(input_ids, config, num_steps=64, tokenizer=tokenizer, streamer=streamer,
|
211 |
-
continuous_compute=False, cache_kwargs={"lookup_strategy": "compress-s16"})
|
212 |
-
```
|
213 |
-
You can combine this per-token adaptive compute. In that case your lookup strategy should be `latest-m4-compress-s16`.
|
214 |
-
|
215 |
-
### Warmstart / Continuous CoT
|
216 |
-
At each generation step, the recurrence can be warmstarted with the final state from the previous token by setting `continuous_compute=True`, like so
|
217 |
-
```
|
218 |
-
model.generate_with_adaptive_compute(input_ids, config, num_steps=64, tokenizer=tokenizer, streamer=streamer, continuous_compute=True)
|
219 |
-
```
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
## Model Summary
|
224 |
-
The model is primarily structured around decoder-only transformer blocks. However these blocks are structured into three functional groups, the __prelude__ \\(P\\),
|
225 |
-
which embeds the input data into a latent space using multiple transformer layers, then the core __recurrent block__ \\(R\\), which is the central unit of recurrent
|
226 |
-
computation modifying states \\(\mathbf{s} \in \mathbb{R}^{n \times h }\\), and finally the __coda__ \\(C\\), which un-embeds from latent space using several layers and
|
227 |
-
also contains the prediction head of the model.
|
228 |
-
|
229 |
-
Given a number of recurrent iterations \\(r\\), and a sequence of input tokens \\(\mathbf{x} \in V^n\\) these groups are used in the following way to produce output
|
230 |
-
probabilities \\(\mathbf{p} \in \mathbb{R}^{n \times |V|}\\).
|
231 |
-
|
232 |
-
$$\mathbf{e} = P(\mathbf{x})$$
|
233 |
-
|
234 |
-
$$\mathbf{s}_0 \sim \mathcal{N}(\mathbf{0}, \sigma^2 I_{n\cdot h})$$
|
235 |
-
|
236 |
-
$$\mathbf{s}_i = R(\mathbf{e}, \mathbf{s}_{i-1}) \; \textnormal{for} \; i \in \lbrace 1, \dots, r \rbrace$$
|
237 |
-
|
238 |
-
$$\mathbf{p} = R(\mathbf{s}_r)$$
|
239 |
-
where \\(\sigma\\) is the standard deviation of the initial random state. Given an init random state \\(\mathbf{s}_0\\), the model repeatedly applies the core
|
240 |
-
block \\(R\\), which accepts the latent state \\(\mathbf{s}_{i-1}\\) and the embedded input \\(\mathbf{e}\\) and outputs a new latent state \\(\mathbf{s}_i\\).
|
241 |
-
After finishing all iterations, the coda block processes the last state and produces the probabilities of the next token.
|
242 |
-
|
243 |
-
Please refer to the paper for benchmark performance on standard benchmarks.
|
244 |
-
|
245 |
-
## Limitations
|
246 |
-
Our checkpoint is trained for only 47000 steps on a broadly untested data mixture with a constant learning rate. As an academic project, the model is trained only on publicly available data and the 800B token count, while large in comparison to older fully open-source models such as the Pythia series, is small in comparison to modern open-source efforts such as OLMo, and tiny in comparison to the datasets used to train industrial open-weight models.
|
247 |
-
|
248 |
-
## Technical Specifications
|
249 |
-
This model was trained on 21 segments of 4096 AMD MI-250X GPUs on the OLCF Frontier Supercomputer in early December 2024. The model was trained using ROCM 6.2.0, and PyTorch 2.6 nightly pre-release 24/11/02. The code used to train the model can be found at https://github.com/seal-rg/recurrent-pretraining.
|
250 |
-
|
251 |
-
## License
|
252 |
-
This model is released under the [apache-2.0](https://choosealicense.com/licenses/apache-2.0/) licence.
|
253 |
-
|
254 |
-
## Citation
|
255 |
-
```
|
256 |
-
@article{geiping_scaling_2025,
|
257 |
-
title = {Scaling up {{Test-Time Compute}} with {{Latent Reasoning}}: {{A Recurrent Depth Approach}}},
|
258 |
-
shorttitle = {Scaling up {{Test-Time Compute}} with {{Latent Reasoning}}},
|
259 |
-
author = {Geiping, Jonas and McLeish, Sean and Jain, Neel and Kirchenbauer, John and Singh, Siddharth and Bartoldson, Brian R. and Kailkhura, Bhavya and Bhatele, Abhinav and Goldstein, Tom},
|
260 |
-
year = {2025},
|
261 |
-
month = feb,
|
262 |
-
eprint = {2502.05171},
|
263 |
-
primaryclass = {cs},
|
264 |
-
publisher = {arXiv},
|
265 |
-
doi = {10.48550/arXiv.2502.05171},
|
266 |
-
url = {http://arxiv.org/abs/2502.05171},
|
267 |
-
urldate = {2025-02-10},
|
268 |
-
archiveprefix = {arXiv},
|
269 |
-
keywords = {Computer Science - Computation and Language,Computer Science - Machine Learning},
|
270 |
-
journal = {arxiv:2502.05171[cs]}
|
271 |
-
}
|
272 |
-
```
|
273 |
|
274 |
-
|
275 |
-
|
|
|
1 |
---
|
2 |
library_name: transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
pipeline_tag: text-generation
|
4 |
+
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
---
|
6 |
|
7 |
+
This repository contains the model described in the paper [Scaling up Test-Time Compute with Latent Reasoning: A Recurrent Depth Approach](https://huggingface.co/papers/2502.05171).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
Project page: https://sites.google.com/view/eagle-llm
|
10 |
+
Code: https://github.com/seal-rg/recurrent-pretraining
|