Text Generation
Transformers
Safetensors
PyTorch
English
speck
causal-lm
instruction-tuned
chat
hybrid
grouped-query-attention
causal-convolution
custom_code
conversational
Instructions to use specklabs/Speck2-140M-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use specklabs/Speck2-140M-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="specklabs/Speck2-140M-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("specklabs/Speck2-140M-Instruct", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use specklabs/Speck2-140M-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "specklabs/Speck2-140M-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "specklabs/Speck2-140M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/specklabs/Speck2-140M-Instruct
- SGLang
How to use specklabs/Speck2-140M-Instruct 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 "specklabs/Speck2-140M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "specklabs/Speck2-140M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "specklabs/Speck2-140M-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "specklabs/Speck2-140M-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use specklabs/Speck2-140M-Instruct with Docker Model Runner:
docker model run hf.co/specklabs/Speck2-140M-Instruct
Add model card
Browse files- .gitattributes +1 -0
- README.md +215 -0
- banner.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
banner.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
- openbmb/Ultra-FineWeb
|
| 11 |
+
- openbmb/Ultra-FineWeb-L3
|
| 12 |
+
- mlfoundations/dclm-baseline-1.0-parquet
|
| 13 |
+
- HuggingFaceTB/smollm-corpus
|
| 14 |
+
- HuggingFaceTB/finemath
|
| 15 |
+
- wikimedia/wikipedia
|
| 16 |
+
tags:
|
| 17 |
+
- causal-lm
|
| 18 |
+
- instruction-tuned
|
| 19 |
+
- chat
|
| 20 |
+
- hybrid
|
| 21 |
+
- grouped-query-attention
|
| 22 |
+
- causal-convolution
|
| 23 |
+
- pytorch
|
| 24 |
+
- transformers
|
| 25 |
+
- safetensors
|
| 26 |
+
- custom_code
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+

|
| 30 |
+
|
| 31 |
+
# Speck2-140M-Instruct
|
| 32 |
+
|
| 33 |
+
Speck2-140M-Instruct is a 140.7M parameter English instruction-tuned language model. It was initialized from [Speck2-140M](https://huggingface.co/specklabs/Speck2-140M), a hybrid model pretrained from scratch on 20B tokens with a three-phase curriculum, then fully fine-tuned for one epoch on the 500,000-conversation [SpeckChat2](https://huggingface.co/datasets/specklabs/SpeckChat2) mixture.
|
| 34 |
+
|
| 35 |
+
The Speck2 release updates the pretrained base while retaining the SpeckChat2 instruction-tuning data and one-epoch post-training recipe. The model uses a native chat template with optional system messages and was trained with assistant-only loss.
|
| 36 |
+
|
| 37 |
+
## Summary
|
| 38 |
+
|
| 39 |
+
| Property | Value |
|
| 40 |
+
|---|---:|
|
| 41 |
+
| Parameters | 140,654,208 |
|
| 42 |
+
| Base pretraining tokens | 20.0B |
|
| 43 |
+
| SFT training conversations | 499,000 |
|
| 44 |
+
| SFT validation conversations | 1,000 |
|
| 45 |
+
| Supervised assistant tokens | 319,181,221 |
|
| 46 |
+
| SFT context tokens processed (padded) | 559,284,224 |
|
| 47 |
+
| Non-padding SFT context tokens | 385,422,209 |
|
| 48 |
+
| SFT sequence lengths | 256, 512, 1,024, 2,048 |
|
| 49 |
+
| Configured max context | 4,096 (unvalidated beyond 2,048) |
|
| 50 |
+
| Vocabulary | 32,003 (Mistral v0.1 SentencePiece + 3 role tokens) |
|
| 51 |
+
| Release format | BF16 Safetensors |
|
| 52 |
+
| Final SFT validation loss / perplexity | 1.1206 / 3.067 |
|
| 53 |
+
| CPU decode, batch 1 | 55.1 tok/s (Speck2 architecture proxy) |
|
| 54 |
+
| RTX 3090 decode, batch 1 | 247.3 tok/s (Speck2 architecture proxy) |
|
| 55 |
+
|
| 56 |
+
## Architecture
|
| 57 |
+
|
| 58 |
+
The architecture is unchanged from Speck2-140M apart from 3 added role-token embeddings. It contains 18 residual blocks: 8 global attention + 10 gated causal convolution, each followed by a SwiGLU feed-forward.
|
| 59 |
+
|
| 60 |
+
| Component | Value |
|
| 61 |
+
|---|---:|
|
| 62 |
+
| Hidden width | 768 |
|
| 63 |
+
| Embedding width | 640 |
|
| 64 |
+
| SwiGLU intermediate | 2,304 |
|
| 65 |
+
| Attention heads (Q / KV) | 12 / 3 |
|
| 66 |
+
| Head dimension | 64 |
|
| 67 |
+
| Conv inner width | 384 |
|
| 68 |
+
| Conv kernel sizes | 3, 5 |
|
| 69 |
+
| RoPE theta | 10,000 |
|
| 70 |
+
| RMSNorm epsilon | 1e-5 |
|
| 71 |
+
|
| 72 |
+
Input/output embeddings (640-wide) are tied and connect to the 768-wide residual stream through learned projections.
|
| 73 |
+
|
| 74 |
+
## Chat template
|
| 75 |
+
|
| 76 |
+
Three special tokens were added to the base 32k vocabulary:
|
| 77 |
+
|
| 78 |
+
| Role | Token | ID |
|
| 79 |
+
|---|---|---:|
|
| 80 |
+
| System | `<|system|>` | 32,000 |
|
| 81 |
+
| User | `<|user|>` | 32,001 |
|
| 82 |
+
| Assistant | `<|assistant|>` | 32,002 |
|
| 83 |
+
|
| 84 |
+
A rendered conversation has the following form:
|
| 85 |
+
|
| 86 |
+
```text
|
| 87 |
+
<s><|system|>
|
| 88 |
+
{optional system message}</s>
|
| 89 |
+
<|user|>
|
| 90 |
+
{user message}</s>
|
| 91 |
+
<|assistant|>
|
| 92 |
+
{assistant response}</s>
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
The system message is optional and may appear only first. Remaining roles must alternate between user and assistant. No default system prompt is injected. During generation, the prompt ends after `<|assistant|>\n`, and `</s>` terminates the response.
|
| 96 |
+
|
| 97 |
+
## Usage
|
| 98 |
+
|
| 99 |
+
Speck2-140M-Instruct works with the Transformers Auto classes through its bundled custom model and tokenizer code. Set `trust_remote_code=True` when loading it.
|
| 100 |
+
|
| 101 |
+
```bash
|
| 102 |
+
pip install "transformers==5.1.0" torch sentencepiece safetensors
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
```python
|
| 106 |
+
import torch
|
| 107 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 108 |
+
|
| 109 |
+
model_id = "specklabs/Speck2-140M-Instruct"
|
| 110 |
+
device = "cuda" if torch.cuda.is_available() and torch.cuda.is_bf16_supported() else "cpu"
|
| 111 |
+
dtype = torch.bfloat16 if device == "cuda" else torch.float32
|
| 112 |
+
|
| 113 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 114 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 115 |
+
model_id,
|
| 116 |
+
trust_remote_code=True,
|
| 117 |
+
dtype=dtype,
|
| 118 |
+
).to(device)
|
| 119 |
+
|
| 120 |
+
messages = [
|
| 121 |
+
{"role": "system", "content": "You are a concise assistant."},
|
| 122 |
+
{"role": "user", "content": "What is the capital of France?"},
|
| 123 |
+
]
|
| 124 |
+
|
| 125 |
+
encoded = tokenizer.apply_chat_template(
|
| 126 |
+
messages,
|
| 127 |
+
tokenize=True,
|
| 128 |
+
add_generation_prompt=True,
|
| 129 |
+
return_tensors="pt",
|
| 130 |
+
)
|
| 131 |
+
input_ids = encoded["input_ids"] if hasattr(encoded, "keys") else encoded
|
| 132 |
+
input_ids = input_ids.to(device)
|
| 133 |
+
|
| 134 |
+
output = model.generate(
|
| 135 |
+
input_ids=input_ids,
|
| 136 |
+
attention_mask=torch.ones_like(input_ids),
|
| 137 |
+
max_new_tokens=64,
|
| 138 |
+
do_sample=False,
|
| 139 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 140 |
+
)
|
| 141 |
+
generated = output[0, input_ids.shape[1] :]
|
| 142 |
+
print(tokenizer.decode(generated, skip_special_tokens=True))
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
The bundled generation path is validated for single-prompt greedy decoding. Direct forward passes support right-padded batches when `use_cache=False`.
|
| 146 |
+
|
| 147 |
+
## Evaluation
|
| 148 |
+
|
| 149 |
+
The quality columns combine the
|
| 150 |
+
[Open SLM Leaderboard](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard)
|
| 151 |
+
at revision `2eafcfc647b667e67f3b0288e9b67da497a78052` and
|
| 152 |
+
[BananaMind Base Bench 1.1](https://huggingface.co/datasets/BananaMind/BananaMind-Base-Bench-1.1)
|
| 153 |
+
at revision `d4aade51312889e8580963e1ce960c6eaef1a450`. No chat template or generation was used for the six
|
| 154 |
+
completed Speck evaluations. Speck2-140M-Instruct has not yet been evaluated on either benchmark.
|
| 155 |
+
|
| 156 |
+
### Benchmarks and speed
|
| 157 |
+
|
| 158 |
+
| Model | Params | Training tokens | Open SLM Int Index | BananaMind Base Bench 1.1 Elo | CPU prefill | CPU decode | RTX 3090 prefill | RTX 3090 decode | BF16 memory @2K | BF16 state @2K |
|
| 159 |
+
|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
| 160 |
+
| BananaMind-2-Pro | 139M | 100B | 24.96 | 1131 | 2,190 tok/s | 43.0 tok/s | 64,060 tok/s | 140.3 tok/s | 325.1 MiB | 60.0 MiB |
|
| 161 |
+
| SmolLM2-135M | 135M | ~2T | 27.13 | 1119 | 2,201 tok/s | 47.4 tok/s | 64,814 tok/s | 157.7 tok/s | 301.6 MiB | 45.0 MiB |
|
| 162 |
+
| GPT-X2.5-135M | 135M | 75B | 25.17 | 1106 | 2,042 tok/s | 47.2 tok/s | 55,346 tok/s | 125.0 tok/s | 302.6 MiB | 45.0 MiB |
|
| 163 |
+
| Supra2-100M-Base | 101M | 30B | 19.41 | 1030 | **3,362 tok/s** | **56.0 tok/s** | **113,326 tok/s** | **298.1 tok/s** | **216.0 MiB** | 24.0 MiB |
|
| 164 |
+
| **Speck1-140M** | **141M** | **5B** | **18.15** | **965** | 2,252 tok/s | 55.1 tok/s | 74,323 tok/s | 247.3 tok/s | 281.3 MiB | **12.0 MiB** |
|
| 165 |
+
| **Speck1-140M-Instruct** | **141M** | **5B + 317M SFT** | **17.75** | **1001** | 2,285 tok/s | 55.3 tok/s | 73,398 tok/s | 246.7 tok/s | 280.3 MiB | **12.0 MiB** |
|
| 166 |
+
| **Speck1.1-140M-Instruct** | **141M** | **5B + 559M SFT** | **17.90** | **1002** | 2,315 tok/s | **56.9 tok/s** | 74,941 tok/s | 243.6 tok/s | 280.3 MiB | **12.0 MiB** |
|
| 167 |
+
| **Speck1.5-140M** | **141M** | **5B** | **16.61** | **980** | 2,252 tok/s | 55.1 tok/s | 74,323 tok/s | 247.3 tok/s | 281.3 MiB | **12.0 MiB** |
|
| 168 |
+
| **Speck1.5-140M-Instruct** | **141M** | **5B + 559M SFT** | **17.48** | **996** | 2,394 tok/s | 56.6 tok/s | 75,424 tok/s | 242.7 tok/s | 280.3 MiB | **12.0 MiB** |
|
| 169 |
+
| **Speck2-140M** | **141M** | **20B** | **20.01** | **953** | 2,252 tok/s | 55.1 tok/s | 74,323 tok/s | 247.3 tok/s | 281.3 MiB | **12.0 MiB** |
|
| 170 |
+
| **Speck2-140M-Instruct** | **141M** | **20B + 559M SFT** | **—** | **—** | 2,252 tok/s* | 55.1 tok/s* | 74,323 tok/s* | 247.3 tok/s* | 280.3 MiB* | **12.0 MiB*** |
|
| 171 |
+
|
| 172 |
+
`Open SLM Int Index` means the chance-normalized Intelligence Index reported by the Open SLM
|
| 173 |
+
Leaderboard. `BananaMind Base Bench 1.1 Elo` means the overall Elo reported by BananaMind Base
|
| 174 |
+
Bench 1.1. Speed and memory values are local batch-1 measurements described below. Reference
|
| 175 |
+
models saw 1.5-100x more pretraining tokens, so this is a parameter-adjacent comparison, not a
|
| 176 |
+
compute-matched one. Asterisks mark architecture-equivalent Speck2 measurements rather than new
|
| 177 |
+
checkpoint-specific measurements.
|
| 178 |
+
|
| 179 |
+
## Inference speed
|
| 180 |
+
|
| 181 |
+
Speed was measured locally at batch 1 with eager PyTorch, model-native caches, last-token logits, and tokenization excluded. Prefill uses 512 tokens. Decode measures 64 greedy cached steps after a 448-token prefix and includes argmax. CPU runs use FP32 with 16 threads; RTX 3090 runs use BF16. Reported throughput is calculated from the median duration.
|
| 182 |
+
|
| 183 |
+
Speck2-140M-Instruct has the same architecture and release implementation as Speck2-140M apart from 3 added role-token embeddings, so its speed and memory entries use the validated Speck2 measurements. The final instruct export was separately validated for Transformers Auto-class loading and single-prompt greedy generation.
|
| 184 |
+
|
| 185 |
+
Memory is unique live BF16 model tensor storage plus cache/state tensor storage after a 2,048-token prefill at batch 1. Speck2-140M-Instruct uses 268.3 MiB for unique model tensors and 12.0 MiB for state, or 280.3 MiB combined. This excludes framework RSS, CUDA allocator reservations, and temporary operator workspace. FP32 CPU tensor memory is approximately twice the reported BF16 model-tensor memory. For another context length `N`, approximate memory as `model tensor memory + State@2K x N / 2,048`; Speck's small convolution history is fixed rather than context-scaled. The BF16 Safetensors weight file is 281.3 MB.
|
| 186 |
+
|
| 187 |
+
## Limitations
|
| 188 |
+
|
| 189 |
+
- At 140.7M parameters, the model has limited knowledge, reasoning, coding, and multilingual capacity.
|
| 190 |
+
- Instruction following is inconsistent, especially for exact formatting, arithmetic, strict brevity, and system-prompt constraints.
|
| 191 |
+
- Longer generations can become repetitive or incoherent.
|
| 192 |
+
- It can hallucinate facts and produce incorrect code or calculations.
|
| 193 |
+
- Mostly English: multilingual ability is weak and unvalidated.
|
| 194 |
+
- No dedicated safety alignment, red-team evaluation, or misuse evaluation was performed.
|
| 195 |
+
- Validated only up to 2,048 tokens despite a 4,096-token config.
|
| 196 |
+
- Pretraining and instruction data are web-derived, user-authored, or synthetic and may contain bias, errors, unsafe content, personal information, or copyrighted text.
|
| 197 |
+
- The bundled Transformers generation path currently supports single-prompt greedy decoding only.
|
| 198 |
+
|
| 199 |
+
## Reproducibility
|
| 200 |
+
|
| 201 |
+
Full training and evaluation code: [github.com/alkinun/speck](https://github.com/alkinun/speck)
|
| 202 |
+
|
| 203 |
+
The released checkpoint is training step 8,534. The base model revision is `1201df613d9ee9d50909189f52e45c6fcefa3c01`; the SpeckChat2 revision is `7b497b3e0c7f4653278cc67af27722b20a5c8d10`.
|
| 204 |
+
|
| 205 |
+
## Citation
|
| 206 |
+
|
| 207 |
+
```bibtex
|
| 208 |
+
@misc{alkinun2026speck2instruct,
|
| 209 |
+
author = {alkinun},
|
| 210 |
+
title = {Speck2-140M-Instruct: Instruction Tuning a Compact Hybrid Attention-Convolution Language Model},
|
| 211 |
+
year = {2026},
|
| 212 |
+
howpublished = {\url{https://huggingface.co/specklabs/Speck2-140M-Instruct}},
|
| 213 |
+
url = {https://github.com/alkinun/speck}
|
| 214 |
+
}
|
| 215 |
+
```
|
banner.png
ADDED
|
Git LFS Details
|