ordlibrary commited on
Commit
60e554c
·
verified ·
1 Parent(s): 1ff6f9a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +305 -3
README.md CHANGED
@@ -1,3 +1,305 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - recursive-reasoning
5
+ - tiny-model
6
+ - solana
7
+ - blockchain
8
+ - question-answering
9
+ - trm
10
+ - tiny-recursive-model
11
+ - efficient-ai
12
+ datasets:
13
+ - solana-qa
14
+ language:
15
+ - en
16
+ metrics:
17
+ - accuracy
18
+ - perplexity
19
+ library_name: pytorch
20
+ pipeline_tag: text-generation
21
+ ---
22
+
23
+ # Tiny Recursive Model for Solana Q&A
24
+
25
+ <div align="center">
26
+
27
+ **TRM-Solana** | A 3.5M parameter recursive reasoning model trained on Solana blockchain Q&A
28
+
29
+ [![Paper](https://img.shields.io/badge/Paper-arXiv-red)](https://arxiv.org/abs/2510.04871)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
31
+ [![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-ee4c2c?logo=pytorch&logoColor=white)](https://pytorch.org/)
32
+
33
+ </div>
34
+
35
+ ## Model Description
36
+
37
+ This is a **Tiny Recursive Model (TRM)** fine-tuned on Solana blockchain development Q&A data. Unlike massive language models requiring billions of parameters, TRM achieves strong performance through *recursive reasoning* with just **3.5 million parameters**.
38
+
39
+ ### Key Features
40
+
41
+ - 🔬 **Tiny Architecture**: Only 3.5M parameters (~1/1000th the size of GPT-3)
42
+ - 🧠 **Recursive Reasoning**: Iteratively refines answers through multiple reasoning cycles
43
+ - ⚡ **Efficient**: Runs on consumer hardware (CPU/MPS/small GPUs)
44
+ - 🎯 **Specialized**: Trained specifically on Solana blockchain development
45
+ - 📚 **Well-documented**: Based on peer-reviewed research
46
+
47
+ ### Architecture
48
+
49
+ ```
50
+ Model: TinyRecursiveReasoningModel (TRM)
51
+ ├── Layers (L): 1 transformer layer
52
+ ├── High-level cycles (H): 2 reasoning iterations
53
+ ├── Low-level cycles (L): 2 refinement iterations
54
+ ├── Parameters: ~3.5M
55
+ ├── Vocabulary: 258 tokens (byte-level)
56
+ ├── Max sequence length: 512 tokens
57
+ └── Embedding dim: Variable (based on architecture)
58
+ ```
59
+
60
+ ## Intended Use
61
+
62
+ ### Primary Use Cases
63
+
64
+ ✅ **Solana Development Q&A**: Answer questions about Solana blockchain, smart contracts, and development
65
+ ✅ **Educational Tool**: Learning resource for Solana developers
66
+ ✅ **Code Assistance**: Understanding Solana program architecture and best practices
67
+ ✅ **Research**: Studying recursive reasoning in small models
68
+
69
+ ### Out of Scope
70
+
71
+ ❌ General-purpose chat or conversation
72
+ ❌ Real-time transaction analysis
73
+ ❌ Production smart contract auditing (use professional auditors)
74
+ ❌ Non-Solana blockchain questions
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ - **Dataset**: Custom Solana Q&A corpus
81
+ - **Size**: 8,970 question-answer pairs
82
+ - **Split**: 90% training (8,073 examples) / 10% test (897 examples)
83
+ - **Topics**: Solana architecture, smart contracts, transactions, accounts, programs, security
84
+ - **Format**: Instruction-input-output tuples
85
+ - **Encoding**: Byte-level tokenization (UTF-8)
86
+
87
+ ### Training Procedure
88
+
89
+ - **Framework**: PyTorch 2.8+
90
+ - **Hardware**: Apple Silicon (M1/M2/M3) with MPS acceleration
91
+ - **Epochs**: 1,000 - 5,000 (varies by run)
92
+ - **Batch Size**: 64 (global batch size)
93
+ - **Learning Rate**: 1e-4
94
+ - **Optimizer**: AdamW (CPU-compatible fallback)
95
+ - **Weight Decay**: 0.5
96
+ - **EMA**: Enabled (rate: 0.999)
97
+ - **Gradient Clipping**: Standard
98
+ - **Training Time**: ~2-4 hours on Apple Silicon
99
+
100
+ ### Hyperparameters
101
+
102
+ ```yaml
103
+ Architecture:
104
+ L_layers: 1
105
+ H_cycles: 2
106
+ L_cycles: 2
107
+
108
+ Training:
109
+ global_batch_size: 64
110
+ lr: 1e-4
111
+ puzzle_emb_lr: 1e-4
112
+ weight_decay: 0.5
113
+ ema: true
114
+ ema_rate: 0.999
115
+
116
+ Data:
117
+ max_seq_len: 512
118
+ vocab_size: 258
119
+ encoding: byte-level (UTF-8)
120
+ ```
121
+
122
+ ## Performance
123
+
124
+ ### Evaluation Metrics
125
+
126
+ | Metric | Value | Notes |
127
+ |--------|-------|-------|
128
+ | Training Loss | ~2.3 | Final epoch |
129
+ | Test Loss | ~2.5 | Held-out set |
130
+ | Parameters | 3.5M | Extremely lightweight |
131
+ | Inference Speed | Fast | CPU-compatible |
132
+ | Memory Usage | <1GB | During inference |
133
+
134
+ ### Comparison
135
+
136
+ | Model | Parameters | Solana Q&A | Hardware Needed |
137
+ |-------|-----------|------------|-----------------|
138
+ | GPT-3 | 175B | Good | Expensive |
139
+ | LLaMA-7B | 7B | Good | GPU required |
140
+ | **TRM-Solana** | **3.5M** | **Specialized** | **CPU/MPS** |
141
+
142
+ ## How to Use
143
+
144
+ ### Installation
145
+
146
+ ```bash
147
+ # Install dependencies
148
+ pip install torch transformers huggingface_hub
149
+
150
+ # Or clone the full repo
151
+ git clone https://github.com/AlexiaJM/TinyRecursiveModels
152
+ cd TinyRecursiveModels
153
+ pip install -r requirements.txt
154
+ ```
155
+
156
+ ### Download Model
157
+
158
+ ```python
159
+ from huggingface_hub import hf_hub_download
160
+ import torch
161
+
162
+ # Download checkpoint
163
+ checkpoint_path = hf_hub_download(
164
+ repo_id="ordlibrary/trm-solana-v1",
165
+ filename="model.pt"
166
+ )
167
+
168
+ # Load checkpoint
169
+ checkpoint = torch.load(checkpoint_path, map_location='cpu')
170
+ model_state = checkpoint['model_state_dict']
171
+ config = checkpoint['config']
172
+
173
+ print(f"Model trained for {checkpoint['epoch']} epochs")
174
+ print(f"Training loss: {checkpoint['train_loss']:.4f}")
175
+ print(f"Test loss: {checkpoint['test_loss']:.4f}")
176
+ ```
177
+
178
+ ### Inference (Requires TRM Code)
179
+
180
+ ```python
181
+ # Note: You need the TRM model code from the repository
182
+ from models.recursive_reasoning.trm import TinyRecursiveReasoningModel_ACTV1
183
+
184
+ # Initialize model with config
185
+ model = TinyRecursiveReasoningModel_ACTV1(**config['arch'])
186
+
187
+ # Load weights
188
+ model.load_state_dict(model_state)
189
+ model.eval()
190
+
191
+ # Encode question (byte-level)
192
+ def encode_text(text, max_len=512):
193
+ bytes_arr = np.frombuffer(text.encode('utf-8'), dtype=np.uint8)
194
+ tokens = (bytes_arr + 2).astype(np.uint8) # Shift for PAD/EOS
195
+
196
+ # Pad sequence
197
+ seq = np.zeros(max_len, dtype=np.uint8)
198
+ seq[:len(tokens)] = tokens[:max_len-1]
199
+ seq[min(len(tokens), max_len-1)] = 1 # EOS token
200
+
201
+ return torch.tensor(seq).unsqueeze(0)
202
+
203
+ # Inference
204
+ question = "What is a Program Derived Address (PDA) in Solana?"
205
+ input_tensor = encode_text(question)
206
+
207
+ with torch.no_grad():
208
+ output = model(input_tensor)
209
+ # Decode output bytes back to text
210
+ # (implementation depends on your decoding strategy)
211
+ ```
212
+
213
+ ### Example Questions
214
+
215
+ The model can answer questions like:
216
+
217
+ - "What is a Program Derived Address (PDA) in Solana?"
218
+ - "How do Solana transactions differ from Ethereum?"
219
+ - "What is the purpose of the System Program?"
220
+ - "Explain Solana's account model"
221
+ - "How does rent work in Solana?"
222
+ - "What are cross-program invocations (CPI)?"
223
+
224
+ ## Limitations and Biases
225
+
226
+ ### Limitations
227
+
228
+ 1. **Specialized Domain**: Only trained on Solana-related content
229
+ 2. **Small Model**: Limited capacity compared to large language models
230
+ 3. **Byte-level Encoding**: May struggle with very long responses
231
+ 4. **Training Data Cutoff**: Knowledge limited to training data timeframe
232
+ 5. **No Real-time Updates**: Does not know about post-training Solana changes
233
+
234
+ ### Potential Biases
235
+
236
+ - **Documentation Bias**: Reflects common patterns in Solana documentation
237
+ - **English Only**: Trained exclusively on English Q&A pairs
238
+ - **Developer-focused**: Biased toward technical development questions
239
+ - **Format Bias**: Optimized for Q&A format, not conversation
240
+
241
+ ### Risks and Mitigations
242
+
243
+ | Risk | Mitigation |
244
+ |------|------------|
245
+ | Outdated information | Always verify with official Solana docs |
246
+ | Security advice | Never rely solely on model for security audits |
247
+ | Code generation | Review and test all generated code |
248
+ | General blockchain questions | Model specializes in Solana only |
249
+
250
+ ## Ethical Considerations
251
+
252
+ - **Transparency**: Training data and methodology fully documented
253
+ - **Open Source**: Model weights and code freely available
254
+ - **Educational Purpose**: Designed for learning, not production deployment
255
+ - **Verification**: Always cross-reference model outputs with official sources
256
+
257
+ ## Citation
258
+
259
+ If you use this model in your research, please cite:
260
+
261
+ ```bibtex
262
+ @misc{jolicoeurmartineau2025morerecursivereasoningtiny,
263
+ title={Less is More: Recursive Reasoning with Tiny Networks},
264
+ author={Alexia Jolicoeur-Martineau},
265
+ year={2025},
266
+ eprint={2510.04871},
267
+ archivePrefix={arXiv},
268
+ primaryClass={cs.LG},
269
+ url={https://arxiv.org/abs/2510.04871},
270
+ }
271
+ ```
272
+
273
+ ## Model Card Authors
274
+
275
+ **Model**: Trained and fine-tuned by OrdLibrary
276
+ **Architecture**: Based on TRM by Alexia Jolicoeur-Martineau
277
+ **Dataset**: Custom Solana Q&A corpus
278
+
279
+ ## Additional Resources
280
+
281
+ - 📄 **Paper**: [Less is More: Recursive Reasoning with Tiny Networks](https://arxiv.org/abs/2510.04871)
282
+ - 💻 **Code**: [TinyRecursiveModels GitHub](https://github.com/AlexiaJM/TinyRecursiveModels)
283
+ - 🌐 **Solana Docs**: [docs.solana.com](https://docs.solana.com)
284
+ - 🤗 **Model**: [huggingface.co/ordlibrary/trm-solana-v1](https://huggingface.co/ordlibrary/trm-solana-v1)
285
+
286
+ ## License
287
+
288
+ MIT License - See repository for full details
289
+
290
+ ## Acknowledgments
291
+
292
+ - **Alexia Jolicoeur-Martineau** for the TRM architecture
293
+ - **Solana Foundation** for comprehensive documentation
294
+ - **HuggingFace** for hosting infrastructure
295
+ - **Community contributors** to Solana Q&A data
296
+
297
+ ---
298
+
299
+ <div align="center">
300
+
301
+ **Built with ❤️ for the Solana developer community**
302
+
303
+ [Report Issues](https://github.com/AlexiaJM/TinyRecursiveModels/issues) • [Get Help](https://docs.solana.com)
304
+
305
+ </div>