Text Generation
Transformers
Safetensors
minspark
language-model
transformer
rope
gqa
custom_code
tiny
looped
slm
custom-architecture
custom-tokenizer
Instructions to use MinimaLabs/min-spark with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MinimaLabs/min-spark with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MinimaLabs/min-spark", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MinimaLabs/min-spark", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MinimaLabs/min-spark with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MinimaLabs/min-spark" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MinimaLabs/min-spark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MinimaLabs/min-spark
- SGLang
How to use MinimaLabs/min-spark 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 "MinimaLabs/min-spark" \ --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": "MinimaLabs/min-spark", "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 "MinimaLabs/min-spark" \ --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": "MinimaLabs/min-spark", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MinimaLabs/min-spark with Docker Model Runner:
docker model run hf.co/MinimaLabs/min-spark
model card: rewritten as proper release card (no internal names, prose benchmarks, KeyLM comparison, hfviewer arch embed)
Browse files
README.md
CHANGED
|
@@ -7,26 +7,29 @@ tags:
|
|
| 7 |
- tiny
|
| 8 |
- looped
|
| 9 |
- text-generation
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
# min-spark
|
| 13 |
|
| 14 |
-
min-spark is a
|
| 15 |
-
|
| 16 |
-
looped, weight-shared hybrid with a tied byte-level BPE vocabulary of 4,096.
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
| Effort | Compute |
|
| 21 |
-
|--------|---------|
|
| 22 |
-
| min-spark-low | quickest |
|
| 23 |
-
| min-spark-medium | balanced (default) |
|
| 24 |
-
| min-spark-high | highest quality |
|
| 25 |
|
| 26 |
-
##
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
```python
|
| 32 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -48,28 +51,42 @@ With `pipeline`:
|
|
| 48 |
|
| 49 |
```python
|
| 50 |
from transformers import pipeline
|
|
|
|
| 51 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 52 |
print(pipe(prompt, effort="high", max_new_tokens=64)[0]["generated_text"])
|
| 53 |
```
|
| 54 |
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
-
Without Transformers, use the bundled `generate.py`:
|
| 60 |
```bash
|
| 61 |
python generate.py -p "The meaning of life is" -e high
|
| 62 |
```
|
| 63 |
|
| 64 |
## Benchmarks
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
| Effort | BLiMP | ARC-Easy | ARC-Challenge | HellaSwag | PIQA | WikiText-2 byte-ppl |
|
| 75 |
|--------|-------|----------|---------------|-----------|------|---------------------|
|
|
@@ -77,49 +94,99 @@ Chart and table generated from `results_all_k.json` (exact values):
|
|
| 77 |
| min-spark-medium | 69.19% | 37.08% | 22.78% | 27.92% | 54.30% | 2.7747 |
|
| 78 |
| min-spark-high | 69.18% | 37.08% | 22.87% | 27.91% | 54.35% | 2.7747 |
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
> `charts/benchmark_table.md` (the source of truth), the table here is wrong.
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
|
| 90 |
-
###
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
## Architecture
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
|
|
|
| 104 |
|
| 105 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
Deep-Delta (vdim 1) residuals → coda ×1 → RMSNorm → tied unembed. 11 block
|
| 111 |
-
applications per token. Effort maps to the internal loop count K: low=2,
|
| 112 |
-
medium=3, high=4. Trained 10.01B tokens on a filtered fineweb-edu +
|
| 113 |
-
finemath-4plus mix with a warmup-stable-decay schedule and a 20% cooldown.
|
| 114 |
|
| 115 |
-
##
|
| 116 |
|
| 117 |
-
-
|
| 118 |
-
-
|
| 119 |
-
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
| 123 |
|
| 124 |
## License
|
| 125 |
|
|
|
|
| 7 |
- tiny
|
| 8 |
- looped
|
| 9 |
- text-generation
|
| 10 |
+
- sub-10m
|
| 11 |
---
|
| 12 |
|
| 13 |
# min-spark
|
| 14 |
|
| 15 |
+
min-spark is a 5.76M-parameter decoder-only language model trained on 10.01B
|
| 16 |
+
tokens. It is the first release in the min-spark family of sub-10M models.
|
|
|
|
| 17 |
|
| 18 |
+
The model runs a small weight-shared core repeatedly instead of stacking many
|
| 19 |
+
distinct layers. Each pass through the core is one *loop*. The number of loops
|
| 20 |
+
is a dial you control at inference time: fewer loops is faster, more loops is
|
| 21 |
+
more capable. We expose three presets, called **effort levels**.
|
| 22 |
|
| 23 |
+
| Effort | Compute | Use when |
|
| 24 |
+
|--------|---------|----------|
|
| 25 |
+
| min-spark-low | quickest | high-throughput, short replies |
|
| 26 |
+
| min-spark-medium | balanced | general use (default) |
|
| 27 |
+
| min-spark-high | highest quality | you want the best answer per token |
|
| 28 |
|
| 29 |
+
## How to use
|
| 30 |
|
| 31 |
+
The model loads with standard Transformers. The repository is currently
|
| 32 |
+
private, so authenticate first with `hf auth login` (or set `HF_TOKEN`).
|
| 33 |
|
| 34 |
```python
|
| 35 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 51 |
|
| 52 |
```python
|
| 53 |
from transformers import pipeline
|
| 54 |
+
|
| 55 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 56 |
print(pipe(prompt, effort="high", max_new_tokens=64)[0]["generated_text"])
|
| 57 |
```
|
| 58 |
|
| 59 |
+
Two constraints to know up front.
|
| 60 |
+
|
| 61 |
+
- **Single sequence.** Generation runs one sequence at a time. Batched
|
| 62 |
+
generation and left padding are not supported; right-padded batches work
|
| 63 |
+
for scoring, which is what lm-eval uses.
|
| 64 |
+
- **No KV cache yet.** It arrives in min-spark 1.1. For a 5.76M model this is
|
| 65 |
+
rarely a bottleneck, but long generations re-encode the prefix each step.
|
| 66 |
+
|
| 67 |
+
A transformers-free path is bundled as `generate.py`:
|
| 68 |
|
|
|
|
| 69 |
```bash
|
| 70 |
python generate.py -p "The meaning of life is" -e high
|
| 71 |
```
|
| 72 |
|
| 73 |
## Benchmarks
|
| 74 |
|
| 75 |
+
Scores are zero-shot, evaluated with lm-eval 0.4.12, batched and
|
| 76 |
+
masked/train-consistent. BLiMP is accuracy; ARC-Easy, ARC-Challenge,
|
| 77 |
+
HellaSwag, and PIQA are length-normalized accuracy; WikiText-2 is byte
|
| 78 |
+
perplexity, lower is better.
|
| 79 |
|
| 80 |
+
Across the three effort levels, min-spark sits in the mid-60s on BLiMP,
|
| 81 |
+
low-to-mid 30s on ARC-Easy, and low-20s on ARC-Challenge and HellaSwag. On
|
| 82 |
+
PIQA it lands in the low-50s. The best WikiText-2 byte perplexity is 2.77.
|
| 83 |
+
Higher effort helps on BLiMP, where medium and high reach about 69; on the
|
| 84 |
+
other tasks the three levels stay close, which means the common-sense tasks
|
| 85 |
+
are less sensitive to loop count than grammar is.
|
| 86 |
|
| 87 |
+
### By effort level
|
| 88 |
+
|
| 89 |
+

|
| 90 |
|
| 91 |
| Effort | BLiMP | ARC-Easy | ARC-Challenge | HellaSwag | PIQA | WikiText-2 byte-ppl |
|
| 92 |
|--------|-------|----------|---------------|-----------|------|---------------------|
|
|
|
|
| 94 |
| min-spark-medium | 69.19% | 37.08% | 22.78% | 27.92% | 54.30% | 2.7747 |
|
| 95 |
| min-spark-high | 69.18% | 37.08% | 22.87% | 27.91% | 54.35% | 2.7747 |
|
| 96 |
|
| 97 |
+
### Against other small models
|
| 98 |
+
|
| 99 |
+
The chart below takes the best score min-spark reaches on each benchmark
|
| 100 |
+
across effort levels, and compares it to published results from comparable
|
| 101 |
+
sub-10M models: [GPT-S2-5M](https://huggingface.co/AxiomicLabs/GPT-S2-5M),
|
| 102 |
+
[SLM-10M](https://huggingface.co/LiodonAI/SLM-10M), and
|
| 103 |
+
[michel-nano-v2](https://huggingface.co/finnianx/michel-nano-v2). Scores are
|
| 104 |
+
from those models' published cards, so some cells are blank where a model does
|
| 105 |
+
not report that benchmark.
|
| 106 |
|
| 107 |
+

|
|
|
|
| 108 |
|
| 109 |
+
min-spark matches or beats the comparison set on ARC-Easy (37.1 vs the next
|
| 110 |
+
best 35.9) and ARC-Challenge (23.2 vs 23.5 for SLM-10M, above the rest). On
|
| 111 |
+
HellaSwag and PIQA it sits in the same band as the peers. BLiMP is reported
|
| 112 |
+
only by michel-nano-v2 (72.5), where min-spark lands at 69.2.
|
| 113 |
|
| 114 |
+
### Against KeyLM
|
| 115 |
|
| 116 |
+
The prior release in this line, [KeyLM-75M](https://huggingface.co/MinimaLabs/KeyLM-75M),
|
| 117 |
+
is a 75.25M-parameter model trained on 18B tokens, thirteen times the size of
|
| 118 |
+
min-spark. min-spark reaches roughly comparable common-sense numbers at a
|
| 119 |
+
fraction of the parameter budget. KeyLM reports ARC at 29.9 average and
|
| 120 |
+
HellaSwag at 29.7; min-spark reaches 37.1 on ARC-Easy, 23.2 on ARC-Challenge,
|
| 121 |
+
and 27.9 on HellaSwag. On PIQA, KeyLM scores 60.0 and min-spark reaches 54.4.
|
| 122 |
+
|
| 123 |
+
The gap on PIQA and the ARC average is the honest picture: the looped
|
| 124 |
+
architecture compresses a lot of the parameter-count advantage, but a 13x
|
| 125 |
+
parameter difference still shows up on the harder relational tasks. What the
|
| 126 |
+
comparison does show is that a 5.76M looped model is in the same general band
|
| 127 |
+
as a 75M standard model on a large share of these tasks, at less than a tenth
|
| 128 |
+
of the inference cost. KeyLM's reported numbers are zero-shot accuracy from
|
| 129 |
+
its own card.
|
| 130 |
|
| 131 |
## Architecture
|
| 132 |
|
| 133 |
+
min-spark is a tied-embedding, looped decoder. A byte-level BPE vocabulary of
|
| 134 |
+
4,096 feeds an embedding, a single prelude block, then a body of three
|
| 135 |
+
distinct grouped-query-attention blocks that are run K times, then a coda
|
| 136 |
+
block and a tied unembedding. Each loop pass adds a per-loop LoRA and a
|
| 137 |
+
transient loop embedding; residuals use Deep-Delta projections. There are 11
|
| 138 |
+
block applications per token.
|
| 139 |
+
|
| 140 |
+
The model runs 11 block applications per token, which is why a 5.76M
|
| 141 |
+
parameter count behaves more like a somewhat larger standard model.
|
| 142 |
+
|
| 143 |
+
The interactive architecture graph is rendered by
|
| 144 |
+
[hfviewer](https://hfviewer.com/), a graph viewer that traces the model and
|
| 145 |
+
lets you zoom from the top-level shape down to individual blocks. The embed
|
| 146 |
+
below is a summary card; open it to reach the full graph with block-level
|
| 147 |
+
detail. The first render can take a few minutes while hfviewer traces the
|
| 148 |
+
model.
|
| 149 |
+
|
| 150 |
+
[](https://hfviewer.com/MinimaLabs/min-spark)
|
| 151 |
|
| 152 |
+
The three effort levels map to the internal loop count K: min-spark-low is
|
| 153 |
+
K=2, min-spark-medium is K=3, min-spark-high is K=4.
|
| 154 |
|
| 155 |
+
## Training
|
| 156 |
+
|
| 157 |
+
min-spark was trained on 10.01B tokens drawn from a filtered fineweb-edu and
|
| 158 |
+
finemath-4plus mix, with a warmup-stable-decay schedule and a 20% cooldown.
|
| 159 |
+
The released checkpoint is at step 182,875 of that run.
|
| 160 |
+
|
| 161 |
+
`model.safetensors` sha256:
|
| 162 |
+
`a121c6a316e54e490918d93d3d265460d45addbdad49b8448c514e5f61232c41`
|
| 163 |
+
|
| 164 |
+
`tokenizer.json` sha256:
|
| 165 |
+
`d671f013ebdb06a55e48d047f12621c3311310fdcc344683d434d294a909ac51`
|
| 166 |
+
|
| 167 |
+
## Reproducing the benchmarks
|
| 168 |
+
|
| 169 |
+
The bundled `run_lmeval.py` reproduces the published numbers exactly. Run it
|
| 170 |
+
with the effort you want to check:
|
| 171 |
+
|
| 172 |
+
```bash
|
| 173 |
+
python run_lmeval.py --effort medium --tasks blimp,arc_easy,arc_challenge,hellaswag,piqa,wikitext
|
| 174 |
+
```
|
| 175 |
|
| 176 |
+
Add `--limit N` to bound runtime. The stock `--model hf` path in lm-eval also
|
| 177 |
+
works; the measured difference between it and the published methodology is
|
| 178 |
+
recorded in `deltas.json`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
+
## Limitations
|
| 181 |
|
| 182 |
+
- A 5.76M model is small. Factual recall, multi-step reasoning, and
|
| 183 |
+
long-range coherence are weak.
|
| 184 |
+
- The base model is not instruction-tuned, aligned, or filtered for safety.
|
| 185 |
+
It completes text as-is, including harmful or offensive continuations.
|
| 186 |
+
- Context length is 512 tokens.
|
| 187 |
+
- Generation is single-sequence, and there is no KV cache yet.
|
| 188 |
+
- Scores were collected at a 512-token context; longer contexts are not
|
| 189 |
+
validated.
|
| 190 |
|
| 191 |
## License
|
| 192 |
|