---
title: PyraLM-10M
canonical_url: "https://www.modelscope.cn/models/Lazyshu/PyraLM-10M"
md_url: "https://www.modelscope.cn/models/Lazyshu/PyraLM-10M.md"
repository: Lazyshu/PyraLM-10M
chinese_name: PyraLM-10M
last_updated: 2026-12-06
license: mit
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - pyralm
architectures:
  - PyraLMForCausalLM
parameters: 10.0M
tensor_type:
  - F32
library_name:
  - pytorch
  - transformer
  - safetensors
frameworks:
  - pytorch
language:
  - en
downloads: 19
stars: 0
tags:
  - pyralm
  - text-generation
  - causal-lm
  - custom-architecture
  - custom_code
  - slm
  - small-language-model
  - open-slm-leaderboard
---

# PyraLM-10M

> PyraLM-10M - Lazyshu 在 ModelScope 开源的模型。9.99M-parameter English causal LM; official mirror of Lazyshu/PyraLM-10M on Hugging Face.

Lazyshu/PyraLM-10M 是 ModelScope 魔搭社区上的 10.0M 参数text-generation模型，采用 mit 许可。

- **Repository**: Lazyshu/PyraLM-10M
- **License**: mit
- **Tasks**: text-generation
- **Parameters**: 10.0M
- **Tags**: pyralm, text-generation, causal-lm, custom-architecture, custom_code, slm, small-language-model, open-slm-leaderboard
- **Downloads**: 19
- **Stars**: 0
- **Last updated**: 2026-12-06

Source: https://www.modelscope.cn/models/Lazyshu/PyraLM-10M

---

## ModelScope mirror / 魔搭镜像

This repository mirrors [`Lazyshu/PyraLM-10M` on Hugging Face](https://huggingface.co/Lazyshu/PyraLM-10M/tree/39d4ea895a07dc5fedb72077a6a0e333c5b5609c), pinned at `39d4ea895a07dc5fedb72077a6a0e333c5b5609c`. Weights, tokenizer, model configuration and custom Python code are identical; only documentation is adapted for this mirror. The weight SHA256 is `457f89e1606e066b70e9e0f4724a4a588c17a041acc3839da0334f2eed923fa2`.

本仓库是同一发布版的魔搭镜像，权重、词表、模型配置和自定义代码与上述 HF 固定版本完全一致。无需重新训练或转换格式。请先从魔搭下载到本地，再通过 Transformers 加载；`trust_remote_code=True` 用于加载本仓库附带的 PyraLM 架构代码。

```bash
pip install modelscope "transformers==4.57.1" torch safetensors
```

```python
from modelscope import snapshot_download
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_dir = snapshot_download("Lazyshu/PyraLM-10M")
tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_dir, trust_remote_code=True, dtype=torch.float32
).eval()
inputs = tokenizer("78 + 27 =", return_tensors="pt", add_special_tokens=False)
with torch.inference_mode():
    outputs = model.generate(**inputs, max_new_tokens=16, do_sample=False)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

---

# PyraLM-10M

[English](README.md) | [简体中文](README_zh.md)

**[PyraLM family](https://huggingface.co/collections/Lazyshu/pyralm-6b1511eb1966063404be1688):**

| Model | Role | Hugging Face | ModelScope |
|---|---|---|---|
| **PyraLM-10M** | Original, 18-layer tapered model | [HF](https://huggingface.co/Lazyshu/PyraLM-10M) | [MS](https://modelscope.cn/models/Lazyshu/PyraLM-10M) |
| PyraLM-10M-v2 | Latest <10M, 12 layers | [HF](https://huggingface.co/Lazyshu/PyraLM-10M-v2) | [MS](https://modelscope.cn/models/Lazyshu/PyraLM-10M-v2) |
| PyraLM-50M | Larger capacity, 20 layers | [HF](https://huggingface.co/Lazyshu/PyraLM-50M) | [MS](https://modelscope.cn/models/Lazyshu/PyraLM-50M) |

> **BETU leaderboard update (2026-12-04):** PyraLM-10M ranks **#1 in the `<10M` category** of the [BETU SLM Leaderboard](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard), with **Overall Index 22.64** and **Quality 20.28** ([accepted submission](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard/discussions/35)). BETU combines six benchmarks; its Overall Index is a separate metric from the Open SLM Intelligence Index below.

> **Open SLM Leaderboard update (2026-12-05):** Officially verified and listed on the [Open SLM Leaderboard](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard) ([submission #359](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard/discussions/359)): **Official Int Index 9.59 under the ArithMark-4 formula**, ranking **#3 overall in `<10M`** as of that date, with **30.06% on ArithMark-4 (#1 in `<10M`)** and **57.90% on ArithMark-3**.

**PyraLM-10M** is a **9,987,600-parameter** (`<10M`) English decoder-only language model trained **from scratch** with a pyramid-tapered 18-layer FFN architecture and a compact 5,120-vocab BPE tokenizer.

This release is a **genuine single-trajectory training checkpoint** (no model merging, no model soups, no SWA/EMA), officially verified on the Open SLM Leaderboard with an **Intelligence Index of `9.59` under the current ArithMark-4 formula**.

![PyraLM released model comparison](assets/pyralm-family-public-benchmarks.png)

Local comparison of the released PyraLM models. Official ArithMark-4 results are reported separately below.

---

## Model Overview

| Property | Value |
|---|---|
| **Parameters** | `9,987,600` (tied input/output embeddings) |
| **Architecture** | 18-layer pyramid-tapered decoder-only Transformer (`PyraLMForCausalLM`) |
| **Hidden Size (`d_model`)** | `256` |
| **Attention** | GQA (`8` query heads, `2` KV heads, `head_dim = 32`), RoPE (`theta = 10000`), per-head QK-Norm, headwise output gate, local window (`16`) on layer `0` |
| **Pyramid Tapered SwiGLU FFN** | `[624×5, 408×5, 312×4, 232×4]` |
| **Local Mixing & Norm** | Peri-LN (RMSNorm), causal depthwise Canon-A/C convolutions (`kernel = 4`, document-masked) |
| **Context Length** | `512` tokens |
| **Tokenizer** | Custom `5,120`-vocab BPE (`bos_token = null`, `pad = 0`, `eos = 1`) |
| **Checkpoint Type** | Single unaveraged training checkpoint (no merging / soup / SWA / EMA) |
| **Weights SHA-256** | `457f89e1606e066b70e9e0f4724a4a588c17a041acc3839da0334f2eed923fa2` |
| **License** | MIT |

**Architecture Attribution:** The custom attention/Peri-LN/Canon modeling code is adapted from [Ethoric-10M](https://huggingface.co/techdotus/Ethoric-10M) (MIT License). On top of that foundation, PyraLM-10M introduces an 18-layer pyramid-tapered FFN allocation (`12L uniform 721` → `18L tapered [624..232]`), a custom `5,120`-vocab BPE tokenizer, and an independent 20B pretraining + non-benchmark post-training pipeline trained completely from scratch.

---

## Evaluation Results

> **Officially verified on 2026-12-05.** Official scores: [Open SLM Leaderboard](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard) / [submission #359](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard/discussions/359). The Intelligence Index below uses the current ArithMark-4 formula only.

Our original public-benchmark evaluation covered `16,428` items and was independently repeated with identical per-item predictions; its arithmetic task is ArithMark-3. ArithMark-4 is a separate held-out evaluation run by the leaderboard team, with official results reported below.

| Model | Params | **Official Int Index (AM4)** | HellaSwag (`acc_norm`) | ARC-Easy (`acc_norm`) | ARC-Challenge (`acc_norm`) | PIQA (`acc_norm`) | **Official ArithMark-4** | ArithMark-3 (`acc_norm`) |
|---|---:|---:|---:|---:|---:|---:|---:|---|
| **PyraLM-10M (this release, seed 31)** | **9.99M** | **9.59** | **28.44** | **40.36** | **24.15** | **58.32** | **30.06%** | **57.90% official / 58.00% local** |
| *PyraLM-10M (local 3-seed Stage 2 mean, s19/s23/s31; same 20B base)* | *9.99M* | — | *28.46* | *40.43* | *24.03* | *58.63* | — | *56.97% local* |
| Ethoric-10M (upstream reference, official leaderboard) | 9.97M | 9.51 | 28.75 | 37.58 | 24.66 | 59.85 | 27.81% | 41.60% official |

*Multi-seed note:* The three independent Stage 2 seeds start from the same 20B pretrained base. Their individual-benchmark means above are local results; the official AM4 score applies only to the released seed-31 checkpoint.

### Additional Local Evaluations: PyraLM Family

The table compares the three **released checkpoints** on the same fixed text and task subsets. PyraLM-10M-v1 denotes the original [PyraLM-10M release](https://huggingface.co/Lazyshu/PyraLM-10M). These are local evaluations; the table specifies the evaluated subsets.

![PyraLM family: language modeling, reading and commonsense](assets/pyralm-family-language-quality.png)

| Benchmark | Items / text size | PyraLM-10M-v1 | PyraLM-10M-v2 | PyraLM-50M |
|---|---:|---:|---:|---:|
| WikiText-2 — language modeling (byte PPL ↓) | 1,292,008 bytes | 2.9075 | 2.8282 | **2.3925** |
| LAMBADA — contextual word prediction | 5,153 | 23.56 | 25.54 | **34.74** |
| SWAG — commonsense continuation | 2,000 | 33.55 | 34.70 | **41.95** |
| RACE-Middle — reading comprehension | 1,311 | 32.88 | 33.79 | **41.27** |
| RACE-High — reading comprehension | 1,500 | 28.33 | 27.60 | **32.13** |
| BoolQ — yes/no reading comprehension | 2,195 | 46.97 | 57.86 | **60.05** |
| OpenBookQA — elementary science | 454 | 26.21 | 27.75 | **34.58** |
| SciQ — science knowledge | 993 | 51.96 | 57.40 | **72.51** |
| Quartz — qualitative reasoning with a passage | 784 | 51.40 | 52.55 | **56.63** |
| COPA — causal commonsense | 100 | 55.00 | 55.00 | **64.00** |
| WinoGrande — pronoun resolution | 1,267 | **49.96** | 49.57 | 49.72 |
| RTE — textual entailment | 272 | 48.16 | **51.84** | 51.10 |
| WiC — word sense in context | 635 | **50.24** | 45.20 | 49.61 |
| CB — textual entailment | 48 | **56.25** | 54.17 | 43.75 |

Accuracy is reported in percent. FP32, TF32 off, no BOS, context 512. SWAG, RACE, BoolQ, RTE, WiC and CB use summed continuation log-likelihood; OpenBookQA, SciQ, Quartz, COPA and WinoGrande use character-normalized scores; LAMBADA uses exact next-word completion. BoolQ includes 54 context-truncated candidates for 10M-v1 and 18 for 50M. SciQ uses a test subset; its training split is included in SFT.

WikiText-2 uses the same raw text and 256-token prediction windows. **Byte PPL = exp(total NLL / UTF-8 bytes)** is reported across different tokenizers; token-level PPL is not compared directly.

---

## Training Summary & Contamination Control

1. **Stage 1 — Pretraining from Scratch (`20.0B` tokens):**
   - Trained from random initialization (`15.4B` main stage + `4.6B` annealing stage) on open English web, encyclopedia, textbook, and math corpora (`FineWeb-Edu`, `Cosmopedia-v2`, `TxT360-v2`, `DCLM-Baseline`, `FineMath-4plus`, `FineWiki`, `Tiny-Strange-Textbooks`, `OpenMathInstruct-2`, `FinePhrase`, `Orca-Math`, `QA-Commonsense`).
   - All pretraining documents were filtered with a frozen Aho-Corasick lexical filter to **remove matches against the train, validation, and test splits of all five official leaderboard benchmarks** (`HellaSwag`, `ARC-Easy`, `ARC-Challenge`, `PIQA`, `ArithMark-3.0`).
2. **Stage 2 — Post-Training on Non-Benchmark QA & Math (`112,644` examples, `2,081` steps):**
   - Single-trajectory post-training starting from the final `20.0B` checkpoint (`lr = 5e-5`, global batch `128`, no EMA/SWA/weight merging).
   - Composed strictly of non-leaderboard public QA/math training sets (`SocialIQA`, `CommonsenseQA`, `SciQ`, `QASC`, `GSM8K`, `Orca-Math`, `ASDiv`, `SVAMP`) plus `24,000` programmatically verified abstract symbolic & quantitative arithmetic exercises (no ArithMark names, objects, or story templates).
   - **None of the train, validation, or test splits of HellaSwag, ARC-Easy, ARC-Challenge, PIQA, or ArithMark-3.0 were used** (`0` hits under the frozen lexical guard).
3. **Note on Public Web Data:**
   - Automated lexical filtering was applied across both stages to exclude all splits of the five official benchmarks. As with any model trained on large public web corpora, text-level filtering cannot completely rule out occasional paraphrased or near-duplicate web passages.

---

## Usage

```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

repo_id = "Lazyshu/PyraLM-10M"
tokenizer = AutoTokenizer.from_pretrained(repo_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    repo_id,
    trust_remote_code=True,
    dtype=torch.float32,
).eval()

inputs = tokenizer("78 + 27 =", return_tensors="pt")
with torch.inference_mode():
    out = model.generate(**inputs, max_new_tokens=16)
print(tokenizer.decode(out[0], skip_special_tokens=True))
# 78 + 27 = 105
```

- `generate()` reads `eos_token_id` (`1`) and `pad_token_id` (`0`) automatically from `generation_config.json` / `config.json`, supports greedy and `top_k` sampling, and supports batched generation with `tokenizer.padding_side = "left"`.
- `forward(..., labels=...)` follows standard Hugging Face causal LM next-token shift semantics (`logits[:, :-1]` vs `labels[:, 1:]`, `ignore_index=-100`).

### Public-task reproduction (four tasks + ArithMark-3)

Evaluate in FP32 with `add_bos_token=False` and context length `512`:

```bash
# HellaSwag, ARC-Easy, ARC-Challenge, PIQA via lm-evaluation-harness
lm_eval --model hf \
  --model_args pretrained=Lazyshu/PyraLM-10M,trust_remote_code=True,dtype=float32,add_bos_token=False,max_length=512 \
  --tasks hellaswag,arc_easy,arc_challenge,piqa \
  --num_fewshot 0 --batch_size auto

# ArithMark-3.0 via the official script from AxiomicLabs/Arithmark-3.0
# (verified against commit 6f6e59dd9b7e2c63455f7af7f838f9ecc3d0a746; remote code is trusted by default)
python bencharithmark-3.py \
  --model Lazyshu/PyraLM-10M \
  --dtype float32 --max-context 512 --save-predictions
```

**Verified local environment:** `Python 3.12.12`, `torch 2.12.0.dev20260220+cu126`, `transformers 4.57.1`, `safetensors 0.6.2`, `tokenizers 0.22.1`, `lm-eval 0.4.13`, `AxiomicLabs/Arithmark-3.0` (`6f6e59dd9b7e2c63455f7af7f838f9ecc3d0a746`).

---

## Limitations

- **Ultra-small capacity (`9.99M` parameters):** Intended as a research small language model for studying architecture efficiency, tokenization, and small-scale reasoning; not a general-purpose assistant.
- **Short context (`512` tokens):** RoPE and training context are fixed at `512` tokens.
- **English only & unaligned:** Trained on English data without safety/chat alignment.
- **Custom `generate()` subset:** Supports greedy decoding and `do_sample` / `temperature` / `top_k` with unpadded or left-padded inputs; unsupported generation kwargs raise `ValueError` explicitly.

---

## License & Acknowledgments

Released under the **MIT License**.

- Special thanks to the **[PyTRIO](https://pytrio.com/home)** team for providing the compute resources for training.
- We gratefully acknowledge the [Ethoric-10M](https://huggingface.co/techdotus/Ethoric-10M) authors (Tech.us Team) for releasing their clean MIT-licensed attention/Peri-LN/Canon implementation.
- Thanks to [AxiomicLabs](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard) for maintaining the Open SLM Leaderboard and ArithMark-3.0.
