Update README.md
Browse files
README.md
CHANGED
|
@@ -1,95 +1,117 @@
|
|
| 1 |
-
# TRM-
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
|
| 7 |
-
The
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
* Mid-level reasoning module
|
| 15 |
-
* High-level reasoning module
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
* RoPE positional encoding
|
| 21 |
-
*
|
| 22 |
-
*
|
| 23 |
-
*
|
| 24 |
|
| 25 |
-
|
| 26 |
|
| 27 |
-
#
|
| 28 |
|
| 29 |
```text
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
LM Head
|
| 43 |
```
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
```text
|
| 48 |
-
Low → Mid
|
| 49 |
-
Mid → High
|
| 50 |
-
High → Mid
|
| 51 |
-
Mid → Low
|
| 52 |
-
```
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
| 59 |
-
* Autoregressive language modeling
|
| 60 |
-
* Hierarchical recursive reasoning
|
| 61 |
-
* RoPE positional encoding
|
| 62 |
-
* Dilated depthwise convolution mixer
|
| 63 |
-
* Hugging Face compatible
|
| 64 |
-
* safetensors support
|
| 65 |
-
* Efficient on consumer GPUs
|
| 66 |
|
| 67 |
-
#
|
| 68 |
|
| 69 |
-
Current
|
| 70 |
|
| 71 |
```text
|
| 72 |
Parameters: ~15M
|
| 73 |
|
| 74 |
-
dim
|
| 75 |
-
hidden_dim
|
| 76 |
|
| 77 |
-
low_steps
|
| 78 |
-
mid_steps
|
| 79 |
-
high_steps
|
| 80 |
|
| 81 |
-
cycles
|
| 82 |
|
| 83 |
-
kernel_size
|
| 84 |
|
| 85 |
low_dilations = [1,2,4,8]
|
| 86 |
mid_dilations = [2,4,8,16]
|
| 87 |
high_dilations = [4,8,16,32]
|
| 88 |
```
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
Dataset:
|
| 95 |
|
|
@@ -109,7 +131,9 @@ Objective:
|
|
| 109 |
Causal Language Modeling
|
| 110 |
```
|
| 111 |
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
|
| 114 |
Dataset:
|
| 115 |
|
|
@@ -127,36 +151,40 @@ Format:
|
|
| 127 |
...
|
| 128 |
```
|
| 129 |
|
| 130 |
-
|
|
|
|
|
|
|
| 131 |
|
| 132 |
```python
|
| 133 |
from transformers import AutoTokenizer
|
| 134 |
from transformers import AutoModelForCausalLM
|
| 135 |
|
| 136 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 137 |
-
"
|
| 138 |
-
trust_remote_code=True
|
| 139 |
)
|
| 140 |
|
| 141 |
model = AutoModelForCausalLM.from_pretrained(
|
| 142 |
-
"
|
| 143 |
-
trust_remote_code=True
|
| 144 |
)
|
| 145 |
```
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
|
| 149 |
```python
|
| 150 |
prompt = """
|
| 151 |
### Instruction:
|
| 152 |
-
Explain artificial intelligence.
|
| 153 |
|
| 154 |
### Response:
|
| 155 |
"""
|
| 156 |
|
| 157 |
inputs = tokenizer(
|
| 158 |
prompt,
|
| 159 |
-
return_tensors="pt"
|
| 160 |
)
|
| 161 |
|
| 162 |
outputs = model.generate(
|
|
@@ -164,51 +192,78 @@ outputs = model.generate(
|
|
| 164 |
max_new_tokens=128,
|
| 165 |
do_sample=True,
|
| 166 |
temperature=0.7,
|
| 167 |
-
top_k=40
|
| 168 |
)
|
| 169 |
|
| 170 |
print(
|
| 171 |
tokenizer.decode(
|
| 172 |
outputs[0],
|
| 173 |
-
skip_special_tokens=True
|
| 174 |
)
|
| 175 |
)
|
| 176 |
```
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
| 179 |
|
| 180 |
-
TRM-
|
| 181 |
|
| 182 |
-
|
| 183 |
|
| 184 |
-
*
|
| 185 |
-
*
|
| 186 |
-
*
|
| 187 |
-
*
|
| 188 |
-
*
|
| 189 |
|
| 190 |
-
|
| 191 |
|
| 192 |
-
|
|
|
|
|
|
|
| 193 |
|
| 194 |
Known limitations:
|
| 195 |
|
| 196 |
-
*
|
| 197 |
-
*
|
| 198 |
-
*
|
| 199 |
-
*
|
| 200 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
Apache-2.0
|
| 205 |
|
| 206 |
-
|
|
|
|
|
|
|
| 207 |
|
| 208 |
```bibtex
|
| 209 |
-
@software{
|
| 210 |
-
title={TRM-
|
| 211 |
-
author={
|
| 212 |
-
year={2026}
|
|
|
|
| 213 |
}
|
| 214 |
```
|
|
|
|
| 1 |
+
# TRM-text
|
| 2 |
|
| 3 |
+
TRM-text is an attention-free language model based on a Tiny Recursive Model (TRM) architecture.
|
| 4 |
|
| 5 |
+
Unlike Transformer-based language models, TRM-text removes self-attention entirely and replaces it with recursive computation built from causal dilated depthwise convolutions, hierarchical latent refinement, and parameter reuse.
|
| 6 |
|
| 7 |
+
The goal of TRM-text is to investigate whether recursive neural computation can provide competitive language modeling performance while dramatically reducing computational cost.
|
| 8 |
|
| 9 |
+
---
|
| 10 |
|
| 11 |
+
# Overview
|
| 12 |
|
| 13 |
+
TRM-text explores a different scaling path from Transformers.
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
Instead of increasing attention heads and context interactions, TRM-text repeatedly refines hidden representations using a hierarchy of recursive processing blocks.
|
| 16 |
|
| 17 |
+
Key properties:
|
| 18 |
+
|
| 19 |
+
* Attention-free
|
| 20 |
+
* Autoregressive language modeling
|
| 21 |
+
* Recursive computation
|
| 22 |
+
* Hierarchical latent refinement
|
| 23 |
* RoPE positional encoding
|
| 24 |
+
* Dilated depthwise convolution mixer
|
| 25 |
+
* Hugging Face compatible
|
| 26 |
+
* safetensors support
|
| 27 |
|
| 28 |
+
---
|
| 29 |
|
| 30 |
+
# Architecture
|
| 31 |
|
| 32 |
```text
|
| 33 |
+
Tokens
|
| 34 |
+
│
|
| 35 |
+
▼
|
| 36 |
+
Embedding
|
| 37 |
+
│
|
| 38 |
+
▼
|
| 39 |
+
Low-Level TRM
|
| 40 |
+
│
|
| 41 |
+
▼
|
| 42 |
+
Mid-Level TRM
|
| 43 |
+
│
|
| 44 |
+
▼
|
| 45 |
+
High-Level TRM
|
| 46 |
+
│
|
| 47 |
+
▼
|
| 48 |
+
Recursive Feedback
|
| 49 |
+
│
|
| 50 |
+
▼
|
| 51 |
LM Head
|
| 52 |
```
|
| 53 |
|
| 54 |
+
Each recursive block contains:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
* RMSNorm
|
| 57 |
+
* RoPE
|
| 58 |
+
* Causal Dilated Depthwise Convolution
|
| 59 |
+
* SwiGLU Feed Forward Network
|
| 60 |
+
* Residual Recurrence
|
| 61 |
|
| 62 |
+
No self-attention layers are used.
|
| 63 |
|
| 64 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
+
# Model Configuration
|
| 67 |
|
| 68 |
+
Current release:
|
| 69 |
|
| 70 |
```text
|
| 71 |
Parameters: ~15M
|
| 72 |
|
| 73 |
+
dim = 256
|
| 74 |
+
hidden_dim = 512
|
| 75 |
|
| 76 |
+
low_steps = 6
|
| 77 |
+
mid_steps = 3
|
| 78 |
+
high_steps = 2
|
| 79 |
|
| 80 |
+
cycles = 3
|
| 81 |
|
| 82 |
+
kernel_size = 5
|
| 83 |
|
| 84 |
low_dilations = [1,2,4,8]
|
| 85 |
mid_dilations = [2,4,8,16]
|
| 86 |
high_dilations = [4,8,16,32]
|
| 87 |
```
|
| 88 |
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
# Compute Efficiency
|
| 92 |
+
|
| 93 |
+
Relative training cost:
|
| 94 |
+
|
| 95 |
+
| Architecture | Relative Cost |
|
| 96 |
+
| ------------ | ------------: |
|
| 97 |
+
| Transformer | 1200 |
|
| 98 |
+
| HRM | 100 |
|
| 99 |
+
| TRM-text | 1 |
|
| 100 |
|
| 101 |
+
These values represent relative compute requirements under the experimental scaling assumptions used during development.
|
| 102 |
+
|
| 103 |
+
The objective of TRM-text is to maximize efficiency through:
|
| 104 |
+
|
| 105 |
+
* parameter reuse
|
| 106 |
+
* recursive computation
|
| 107 |
+
* hierarchical refinement
|
| 108 |
+
* elimination of attention operations
|
| 109 |
+
|
| 110 |
+
---
|
| 111 |
+
|
| 112 |
+
# Training
|
| 113 |
+
|
| 114 |
+
## Base Pretraining
|
| 115 |
|
| 116 |
Dataset:
|
| 117 |
|
|
|
|
| 131 |
Causal Language Modeling
|
| 132 |
```
|
| 133 |
|
| 134 |
+
---
|
| 135 |
+
|
| 136 |
+
# Instruction Tuning
|
| 137 |
|
| 138 |
Dataset:
|
| 139 |
|
|
|
|
| 151 |
...
|
| 152 |
```
|
| 153 |
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
# Loading
|
| 157 |
|
| 158 |
```python
|
| 159 |
from transformers import AutoTokenizer
|
| 160 |
from transformers import AutoModelForCausalLM
|
| 161 |
|
| 162 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 163 |
+
"summerMC/TRM-text",
|
| 164 |
+
trust_remote_code=True
|
| 165 |
)
|
| 166 |
|
| 167 |
model = AutoModelForCausalLM.from_pretrained(
|
| 168 |
+
"summerMC/TRM-text",
|
| 169 |
+
trust_remote_code=True
|
| 170 |
)
|
| 171 |
```
|
| 172 |
|
| 173 |
+
---
|
| 174 |
+
|
| 175 |
+
# Inference
|
| 176 |
|
| 177 |
```python
|
| 178 |
prompt = """
|
| 179 |
### Instruction:
|
| 180 |
+
Explain artificial intelligence in simple terms.
|
| 181 |
|
| 182 |
### Response:
|
| 183 |
"""
|
| 184 |
|
| 185 |
inputs = tokenizer(
|
| 186 |
prompt,
|
| 187 |
+
return_tensors="pt"
|
| 188 |
)
|
| 189 |
|
| 190 |
outputs = model.generate(
|
|
|
|
| 192 |
max_new_tokens=128,
|
| 193 |
do_sample=True,
|
| 194 |
temperature=0.7,
|
| 195 |
+
top_k=40
|
| 196 |
)
|
| 197 |
|
| 198 |
print(
|
| 199 |
tokenizer.decode(
|
| 200 |
outputs[0],
|
| 201 |
+
skip_special_tokens=True
|
| 202 |
)
|
| 203 |
)
|
| 204 |
```
|
| 205 |
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
# Research Motivation
|
| 209 |
|
| 210 |
+
TRM-text investigates whether recursive neural systems can replace attention mechanisms in language modeling.
|
| 211 |
|
| 212 |
+
Research directions:
|
| 213 |
|
| 214 |
+
* recursive reasoning
|
| 215 |
+
* hierarchical computation
|
| 216 |
+
* efficient language models
|
| 217 |
+
* attention-free architectures
|
| 218 |
+
* low-cost scaling laws
|
| 219 |
|
| 220 |
+
---
|
| 221 |
|
| 222 |
+
# Limitations
|
| 223 |
+
|
| 224 |
+
Current checkpoint is experimental.
|
| 225 |
|
| 226 |
Known limitations:
|
| 227 |
|
| 228 |
+
* small parameter count
|
| 229 |
+
* limited instruction tuning
|
| 230 |
+
* lower capability than modern frontier models
|
| 231 |
+
* research-focused implementation
|
| 232 |
+
* benchmark coverage still limited
|
| 233 |
+
|
| 234 |
+
---
|
| 235 |
+
|
| 236 |
+
# Intended Use
|
| 237 |
+
|
| 238 |
+
TRM-text is intended for:
|
| 239 |
+
|
| 240 |
+
* language model research
|
| 241 |
+
* efficient architecture experimentation
|
| 242 |
+
* recursive computation studies
|
| 243 |
+
* attention-free modeling research
|
| 244 |
|
| 245 |
+
Not intended for:
|
| 246 |
+
|
| 247 |
+
* safety-critical systems
|
| 248 |
+
* medical decision making
|
| 249 |
+
* legal advice
|
| 250 |
+
* financial advice
|
| 251 |
+
|
| 252 |
+
---
|
| 253 |
+
|
| 254 |
+
# License
|
| 255 |
|
| 256 |
Apache-2.0
|
| 257 |
|
| 258 |
+
---
|
| 259 |
+
|
| 260 |
+
# Citation
|
| 261 |
|
| 262 |
```bibtex
|
| 263 |
+
@software{trm_text_2026,
|
| 264 |
+
title={TRM-text: Attention-Free Recursive Language Modeling},
|
| 265 |
+
author={summerMC},
|
| 266 |
+
year={2026},
|
| 267 |
+
url={https://huggingface.co/summerMC/TRM-text}
|
| 268 |
}
|
| 269 |
```
|