Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- text-generation
|
| 7 |
+
- causal-lm
|
| 8 |
+
- custom-architecture
|
| 9 |
+
- slm
|
| 10 |
+
- small-language-model
|
| 11 |
+
license: mit
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Spark (7.08M Parameters)
|
| 15 |
+
|
| 16 |
+
Spark is a highly efficient, ultra-small language model developed by SurjoLabs. It demonstrates that aggressive overtraining on high-quality data combined with a custom XSA recurrent architecture can yield exceptional reasoning capabilities in tiny architectures.
|
| 17 |
+
|
| 18 |
+
## Methodology
|
| 19 |
+
|
| 20 |
+
Spark is built to prove that unique recurrent architectures can match or beat standard transformers even at the smallest scales.
|
| 21 |
+
|
| 22 |
+
* **Custom Architecture:** Built on a Llama-variant framework but features **XSA Attention** (value-subtraction projection) and **Recurrent Layers**. By reusing weights across recurrent passes, the model achieves the depth of an 11-layer model while only carrying 8 layers of unique weights.
|
| 23 |
+
* **Optimized Tokenizer:** Uses a custom 4,096-vocabulary English tokenizer. This intentionally small vocabulary prevents the embedding table from dominating the parameter count, ensuring nearly 85% of the model's 7.08M parameters are dedicated to actual transformer compute logic.
|
| 24 |
+
* **Extreme Overtraining:** Trained on **~19.9 Billion tokens** (19,000 steps × 1,048,576 tokens/step). This forces the small architecture to memorize syntax and knowledge far beyond Chinchilla-optimal limits.
|
| 25 |
+
* **Data Mixture:**
|
| 26 |
+
* 60% Finephrase (Synthetic FineWeb-Edu)
|
| 27 |
+
* 20% DCLM (Web text)
|
| 28 |
+
* 10% FineMath (Mathematics)
|
| 29 |
+
* 10% CornStack (Code)
|
| 30 |
+
* **Optimizer:** Utilizes a hybrid Muon (for 2D weight matrices) and AdamW (for embeddings/norms) optimizer setup for stable, rapid convergence.
|
| 31 |
+
|
| 32 |
+
## Benchmark Results (Open SLM Leaderboard)
|
| 33 |
+
|
| 34 |
+
| Benchmark | Score (acc_norm) |
|
| 35 |
+
| :--- | :--- |
|
| 36 |
+
| HellaSwag | 28.17% |
|
| 37 |
+
| ARC-Easy | 35.02% |
|
| 38 |
+
| ARC-Challenge | 20.99% |
|
| 39 |
+
| PIQA | 55.55% |
|
| 40 |
+
| ArithMark-3 | 36.10% |
|
| 41 |
+
| **Intelligence Index** | **7.93** |
|
| 42 |
+
|
| 43 |
+
## Note on Checkpoint
|
| 44 |
+
The model was trained for 20,000 steps, but evaluation showed that the checkpoint at **step 19,000** performed better on nearly all benchmarks. The final step (20,000) was discarded, and step 19,000 is the version hosted in the root of this repository.
|
| 45 |
+
|
| 46 |
+
## Usage
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 50 |
+
import torch
|
| 51 |
+
|
| 52 |
+
model_id = "SurjoLabs/Spark"
|
| 53 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 54 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 55 |
+
model_id,
|
| 56 |
+
trust_remote_code=True,
|
| 57 |
+
torch_dtype=torch.bfloat16
|
| 58 |
+
).cuda()
|
| 59 |
+
|
| 60 |
+
prompt = "The capital of France is"
|
| 61 |
+
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 62 |
+
outputs = model.generate(**inputs, max_new_tokens=20)
|
| 63 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 64 |
+
```
|