Text Generation
Transformers
Safetensors
English
cma
custom_code
causal-lm
small-language-model
generalist
4k-tokenizer
Instructions to use SupraLabs/SupraCMA-8M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SupraLabs/SupraCMA-8M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SupraLabs/SupraCMA-8M", trust_remote_code=True, device_map="auto")# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("SupraLabs/SupraCMA-8M", trust_remote_code=True, dtype="auto", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use SupraLabs/SupraCMA-8M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "SupraLabs/SupraCMA-8M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "SupraLabs/SupraCMA-8M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/SupraLabs/SupraCMA-8M
- SGLang
How to use SupraLabs/SupraCMA-8M 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 "SupraLabs/SupraCMA-8M" \ --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": "SupraLabs/SupraCMA-8M", "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 "SupraLabs/SupraCMA-8M" \ --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": "SupraLabs/SupraCMA-8M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use SupraLabs/SupraCMA-8M with Docker Model Runner:
docker model run hf.co/SupraLabs/SupraCMA-8M
Benchmark-selected step 1000: Open SLM average 33.88%
Browse files- README.md +12 -12
- benchmark_results.json +18 -18
- model.safetensors +1 -1
- modeling_cma.py +7 -18
- training_config.json +1 -4
README.md
CHANGED
|
@@ -21,8 +21,8 @@ Benchmark-selected checkpoint from a 7.85M-parameter
|
|
| 21 |
Channel-Mixing Attention generalist language model using the unmodified native
|
| 22 |
GPT-S 4,096-token tokenizer. It has no arithmetic-specific token splitting,
|
| 23 |
place embeddings, role embeddings, or inference-time equation detection. It
|
| 24 |
-
was selected at step
|
| 25 |
-
|
| 26 |
and is not used for selection.
|
| 27 |
|
| 28 |
## Loading
|
|
@@ -69,7 +69,7 @@ ordinary causal-language-model text, with no task-specific model features or
|
|
| 69 |
tokenizer transformations. All four training sources are streamed natural-text
|
| 70 |
corpora.
|
| 71 |
|
| 72 |
-
## Zero-shot evaluation at step
|
| 73 |
|
| 74 |
The four lm-eval tasks use normalized accuracy when supplied by lm-eval
|
| 75 |
0.4.12, with float32 weights and softmax. ArithMark
|
|
@@ -77,17 +77,17 @@ uses float32 weights and its official raw continuation log-likelihood-sum rule.
|
|
| 77 |
|
| 78 |
| Benchmark | Accuracy |
|
| 79 |
|---|---:|
|
| 80 |
-
| HellaSwag |
|
| 81 |
-
| ARC-Easy |
|
| 82 |
-
| ARC-Challenge |
|
| 83 |
-
| PIQA |
|
| 84 |
-
| ArithMark-2 |
|
| 85 |
-
| ARC mean |
|
| 86 |
-
| Open SLM Leaderboard-style average |
|
| 87 |
|
| 88 |
The average is `(HellaSwag + mean(ARC-Easy, ARC-Challenge) + PIQA +
|
| 89 |
ArithMark-2) / 4`, matching the Open SLM Leaderboard formula.
|
| 90 |
|
| 91 |
-
WikiText-103 validation at this step: loss
|
| 92 |
-
|
| 93 |
scored tokens and 1,145,226 normalized UTF-8 bytes.
|
|
|
|
| 21 |
Channel-Mixing Attention generalist language model using the unmodified native
|
| 22 |
GPT-S 4,096-token tokenizer. It has no arithmetic-specific token splitting,
|
| 23 |
place embeddings, role embeddings, or inference-time equation detection. It
|
| 24 |
+
was selected at step 1,000 for an Open SLM Leaderboard-style average of
|
| 25 |
+
33.88%. WikiText normalized BPB is reported separately
|
| 26 |
and is not used for selection.
|
| 27 |
|
| 28 |
## Loading
|
|
|
|
| 69 |
tokenizer transformations. All four training sources are streamed natural-text
|
| 70 |
corpora.
|
| 71 |
|
| 72 |
+
## Zero-shot evaluation at step 1,000
|
| 73 |
|
| 74 |
The four lm-eval tasks use normalized accuracy when supplied by lm-eval
|
| 75 |
0.4.12, with float32 weights and softmax. ArithMark
|
|
|
|
| 77 |
|
| 78 |
| Benchmark | Accuracy |
|
| 79 |
|---|---:|
|
| 80 |
+
| HellaSwag | 27.81% |
|
| 81 |
+
| ARC-Easy | 32.11% |
|
| 82 |
+
| ARC-Challenge | 21.42% |
|
| 83 |
+
| PIQA | 55.06% |
|
| 84 |
+
| ArithMark-2 | 25.88% |
|
| 85 |
+
| ARC mean | 26.76% |
|
| 86 |
+
| Open SLM Leaderboard-style average | 33.88% |
|
| 87 |
|
| 88 |
The average is `(HellaSwag + mean(ARC-Easy, ARC-Challenge) + PIQA +
|
| 89 |
ArithMark-2) / 4`, matching the Open SLM Leaderboard formula.
|
| 90 |
|
| 91 |
+
WikiText-103 validation at this step: loss 3.5111, perplexity
|
| 92 |
+
33.48, normalized BPB 1.5875 over 358,911
|
| 93 |
scored tokens and 1,145,226 normalized UTF-8 bytes.
|
benchmark_results.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
| 1 |
{
|
| 2 |
-
"step":
|
| 3 |
"parameters": 7849161,
|
| 4 |
"lm_eval_version": "0.4.12",
|
| 5 |
"num_fewshot": 0,
|
| 6 |
"leaderboard_accuracy": {
|
| 7 |
-
"arc_easy": 0.
|
| 8 |
-
"arc_challenge": 0.
|
| 9 |
-
"hellaswag": 0.
|
| 10 |
-
"piqa": 0.
|
| 11 |
},
|
| 12 |
"lm_eval_metric_policy": "acc_norm when available, otherwise acc",
|
| 13 |
"selection_metric": "open_slm_leaderboard_average",
|
| 14 |
"arithmark_2.0": {
|
| 15 |
-
"acc": 0.
|
| 16 |
-
"correct":
|
| 17 |
"total": 2500,
|
| 18 |
"by_operator_count": {
|
| 19 |
"1": {
|
| 20 |
-
"acc": 0.
|
| 21 |
-
"correct":
|
| 22 |
"total": 1250
|
| 23 |
},
|
| 24 |
"2": {
|
| 25 |
-
"acc": 0.
|
| 26 |
-
"correct":
|
| 27 |
"total": 750
|
| 28 |
},
|
| 29 |
"3": {
|
| 30 |
-
"acc": 0.
|
| 31 |
-
"correct":
|
| 32 |
"total": 500
|
| 33 |
}
|
| 34 |
}
|
| 35 |
},
|
| 36 |
-
"arc_average": 0.
|
| 37 |
-
"open_slm_leaderboard_average": 0.
|
| 38 |
"average_formula": "(hellaswag + mean(arc_easy, arc_challenge) + piqa + arithmark_2.0) / 4",
|
| 39 |
"validation": {
|
| 40 |
-
"loss":
|
| 41 |
-
"perplexity":
|
| 42 |
-
"normalized_bpb":
|
| 43 |
"tokens": 358911,
|
| 44 |
"normalized_utf8_bytes": 1145226
|
| 45 |
}
|
|
|
|
| 1 |
{
|
| 2 |
+
"step": 1000,
|
| 3 |
"parameters": 7849161,
|
| 4 |
"lm_eval_version": "0.4.12",
|
| 5 |
"num_fewshot": 0,
|
| 6 |
"leaderboard_accuracy": {
|
| 7 |
+
"arc_easy": 0.32112794612794615,
|
| 8 |
+
"arc_challenge": 0.21416382252559726,
|
| 9 |
+
"hellaswag": 0.27813184624576776,
|
| 10 |
+
"piqa": 0.5505984766050055
|
| 11 |
},
|
| 12 |
"lm_eval_metric_policy": "acc_norm when available, otherwise acc",
|
| 13 |
"selection_metric": "open_slm_leaderboard_average",
|
| 14 |
"arithmark_2.0": {
|
| 15 |
+
"acc": 0.2588,
|
| 16 |
+
"correct": 647,
|
| 17 |
"total": 2500,
|
| 18 |
"by_operator_count": {
|
| 19 |
"1": {
|
| 20 |
+
"acc": 0.248,
|
| 21 |
+
"correct": 310,
|
| 22 |
"total": 1250
|
| 23 |
},
|
| 24 |
"2": {
|
| 25 |
+
"acc": 0.2866666666666667,
|
| 26 |
+
"correct": 215,
|
| 27 |
"total": 750
|
| 28 |
},
|
| 29 |
"3": {
|
| 30 |
+
"acc": 0.244,
|
| 31 |
+
"correct": 122,
|
| 32 |
"total": 500
|
| 33 |
}
|
| 34 |
}
|
| 35 |
},
|
| 36 |
+
"arc_average": 0.2676458843267717,
|
| 37 |
+
"open_slm_leaderboard_average": 0.33879405179438626,
|
| 38 |
"average_formula": "(hellaswag + mean(arc_easy, arc_challenge) + piqa + arithmark_2.0) / 4",
|
| 39 |
"validation": {
|
| 40 |
+
"loss": 3.511079413898325,
|
| 41 |
+
"perplexity": 33.4843918019419,
|
| 42 |
+
"normalized_bpb": 1.58748913326839,
|
| 43 |
"tokens": 358911,
|
| 44 |
"normalized_utf8_bytes": 1145226
|
| 45 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 36330428
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3afa91d8c126df0efdf49b944fee4f838aadf2f6d5681ae9b1569fc5eee2942
|
| 3 |
size 36330428
|
modeling_cma.py
CHANGED
|
@@ -171,15 +171,10 @@ class CMA(nn.Module):
|
|
| 171 |
k = F.normalize(k.float(), dim=-1).to(v.dtype)
|
| 172 |
scale = self.logit_scale.clamp(max=math.log(100.0)).exp()
|
| 173 |
scale = scale.view(1, self.h, 1, 1)
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
attn_mask=self.bias.unsqueeze(0).to(q.dtype),
|
| 179 |
-
dropout_p=0.0,
|
| 180 |
-
is_causal=False,
|
| 181 |
-
scale=1.0,
|
| 182 |
-
)
|
| 183 |
route_signal = (
|
| 184 |
torch.einsum(
|
| 185 |
"bhnd,hd->bhn", q.float(), self.route_gate_weight.float()
|
|
@@ -191,11 +186,6 @@ class CMA(nn.Module):
|
|
| 191 |
contribution = route_coeff.unsqueeze(-1) * (routed - v)
|
| 192 |
y = v + contribution
|
| 193 |
if self.record_diagnostics:
|
| 194 |
-
attn_logits = (
|
| 195 |
-
q.float() @ k.float().transpose(-2, -1)
|
| 196 |
-
) * scale.float()
|
| 197 |
-
attn_logits = attn_logits + self.bias.float().unsqueeze(0)
|
| 198 |
-
attn = F.softmax(attn_logits, dim=-1, dtype=torch.float32)
|
| 199 |
probs = attn.float().clamp_min(1e-9)
|
| 200 |
entropy = -(probs * probs.log()).sum(dim=-1) / math.log(self.n)
|
| 201 |
diagonal_mass = probs.diagonal(dim1=-2, dim2=-1).mean()
|
|
@@ -241,10 +231,9 @@ class Block(nn.Module):
|
|
| 241 |
)
|
| 242 |
|
| 243 |
def forward(self, x, cos, sin):
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
return torch.add(x, self.mix(self.n2(x)))
|
| 248 |
|
| 249 |
|
| 250 |
class CMAModel(nn.Module):
|
|
|
|
| 171 |
k = F.normalize(k.float(), dim=-1).to(v.dtype)
|
| 172 |
scale = self.logit_scale.clamp(max=math.log(100.0)).exp()
|
| 173 |
scale = scale.view(1, self.h, 1, 1)
|
| 174 |
+
attn_logits = (q @ k.transpose(-2, -1)) * scale.to(q.dtype)
|
| 175 |
+
attn_logits = attn_logits + self.bias.unsqueeze(0).to(q.dtype)
|
| 176 |
+
attn = F.softmax(attn_logits, dim=-1, dtype=torch.float32).to(v.dtype)
|
| 177 |
+
routed = attn @ v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
route_signal = (
|
| 179 |
torch.einsum(
|
| 180 |
"bhnd,hd->bhn", q.float(), self.route_gate_weight.float()
|
|
|
|
| 186 |
contribution = route_coeff.unsqueeze(-1) * (routed - v)
|
| 187 |
y = v + contribution
|
| 188 |
if self.record_diagnostics:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
probs = attn.float().clamp_min(1e-9)
|
| 190 |
entropy = -(probs * probs.log()).sum(dim=-1) / math.log(self.n)
|
| 191 |
diagonal_mass = probs.diagonal(dim1=-2, dim2=-1).mean()
|
|
|
|
| 231 |
)
|
| 232 |
|
| 233 |
def forward(self, x, cos, sin):
|
| 234 |
+
x = x + self.attn(self.n1(x), cos, sin)
|
| 235 |
+
x = x + self.mix(self.n2(x))
|
| 236 |
+
return x
|
|
|
|
| 237 |
|
| 238 |
|
| 239 |
class CMAModel(nn.Module):
|
training_config.json
CHANGED
|
@@ -51,8 +51,5 @@
|
|
| 51 |
"data_seed": 1337,
|
| 52 |
"shuffle_buffer": 50000,
|
| 53 |
"tokenize_batch_size": 64,
|
| 54 |
-
"compile": true
|
| 55 |
-
"compile_mode": "max-autotune",
|
| 56 |
-
"compile_fullgraph": true,
|
| 57 |
-
"compile_dynamic": false
|
| 58 |
}
|
|
|
|
| 51 |
"data_seed": 1337,
|
| 52 |
"shuffle_buffer": 50000,
|
| 53 |
"tokenize_batch_size": 64,
|
| 54 |
+
"compile": true
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|