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

# PyraLM-50M

> PyraLM-50M - Lazyshu 在 ModelScope 开源的模型。49.81M-parameter English causal language model; official mirror of Lazyshu/PyraLM-50M on Hugging Face.

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

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

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

---

# PyraLM-50M

[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) |

**PyraLM-50M** is a **49,814,726-parameter** (`<50M`) English decoder-only language model trained **from scratch** with the **PyraLMNext** architecture: a 20-layer pyramid-tapered SwiGLU Transformer and a custom 16,384-vocabulary BPE tokenizer.

This release is a **genuine single-trajectory training checkpoint**. Its local zero-shot results are **36.47% HellaSwag, 58.92% ARC-Easy, 32.34% ARC-Challenge, and 65.45% PIQA**. The official BETU submission is listed; Open SLM verification is pending.


> **BETU update (2026-12-06):** Listed **#1 among models below 50M parameters** on the [BETU SLM Leaderboard](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard), with **Overall 35.64** and **Quality 32.40**.

![Official BETU comparison](assets/pyralm50m-betu-official.png)

---

## Model Overview

| Property | Value |
|---|---|
| **Parameters** | `49,814,726` (tied input/output embeddings) |
| **Architecture** | 20-layer pyramid-tapered decoder-only Transformer (`PyraLMNextForCausalLM`) |
| **Hidden Size (`d_model`)** | `512` |
| **Attention** | GQA (`8` query heads, `2` KV heads, `head_dim = 64`), RoPE (`theta = 10000`), per-head QK-Norm, headwise output gate; local window (`16`) on layer `0` |
| **Pyramid Tapered SwiGLU FFN** | `[1376×5, 992×5, 752×3, 736×2, 544×5]` |
| **Residual Mixing** | Block Attention Residuals (`block_attnres_size = 4`) and Layer-0 Value Residual |
| **Local Mixing** | Causal, document-masked Canon A/C depthwise convolutions (`kernel = 4`) |
| **Context Length** | `1,024` tokens |
| **Tokenizer** | Custom byte-level BPE, `16,384` vocabulary (`bos_token = null`, `pad = 0`, `eos = 1`) |
| **Checkpoint Type** | Single unaveraged training checkpoint; dense, single-pass inference |
| **Weights SHA-256** | `3b74d96cca3d5313739d551bf65f98710425a121e7d823341d6ddfd76bcf52ff` |
| **License** | MIT |

**Architecture:** PyraLMNext continues the PyraLM family's tapered FFN design, adding block-level attention residual mixing and reuse of first-layer value representations. The FFN is wider in earlier layers and narrower in later layers; every layer is evaluated once per forward pass.

---

## Evaluation Results

The following are **local zero-shot results under the Open SLM reference protocol**; Open SLM verification is pending. The Open SLM reference evaluation uses **native FP32, TF32 off, no BOS, and a 512-token context**. Two complete runs over all **16,428 items** produced identical per-item predictions.

| Model | Params | HellaSwag (`acc_norm`) | ARC-Easy (`acc_norm`) | ARC-Challenge (`acc_norm`) | PIQA (`acc_norm`) | ArithMark-3 |
|---|---:|---:|---:|---:|---:|---:|
| **PyraLM-50M (this release)** | **49.81M** | **36.47** | **58.92** | **32.34** | **65.45** | **61.80** |

### BETU SLM Leaderboard

The official-runner submission is now listed on [BETU](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard). At the **2026-12-06** snapshot, PyraLM-50M ranks **#1 below 50M parameters**, with **Overall 35.64** and **Quality 32.40**.

| BETU task | Listed accuracy (%) |
|---|---:|
| HellaSwag | **36.47** |
| ARC-Easy | **58.92** |
| PIQA | **65.45** |
| ArithMark-3 | **61.80** |
| Tiny Theory of Mind (2,000 items) | **41.45** |
| BananaMind Base Bench 1.1 (350 items) | **53.71** |

The chart above compares the current top three entries below 50M parameters. Rankings, indices and reference-model results are from the [dated official leaderboard snapshot](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard/blob/9effc2b7f57a9575873eafd96e4f2afb6323808e/data/models.jsonl). BETU uses the model's native **1,024-token context**; its Overall Index includes a model-size adjustment and differs from Open SLM's Intelligence Index. Index values can change as the reference population changes.

### 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

- **Pretraining:** Trained from random initialization on approximately **24.6B tokens** of English web, educational, textbook, encyclopedia, science, commonsense, and math text, using Muon-based optimization and a 1,024-token training context.
- **Post-training:** **82,500 examples**, **1,600 updates**, learning rate **3e-5**. The data includes `SocialIQA`, `CommonsenseQA`, `SciQ`, `QASC`, `GSM8K`, `ASDiv`, `SVAMP`, `Orca-Math`, and generated step-by-step arithmetic. Non-math multiple-choice examples use a contrastive objective with a positive-answer CE anchor; math examples use generative CE. Pretraining next-token replay is retained with **loss weight 0.4**.

The released weights come from one continuous training lineage, without weight averaging or model merging.

---

## Usage

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

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

prompt = (
    "Problem: Maya bought 4 notebooks for $6 each and a pen for $3. "
    "How much did she spend in total?\nSolution:"
)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)
with torch.inference_mode():
    out = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
```

- `generation_config.json` supplies `eos_token_id = 1` and `pad_token_id = 0`.
- For batched generation, use `tokenizer.padding_side = "left"`.
- For sampled text continuation, use `do_sample=True`, `temperature=0.7`, and `top_k=40`.

### Public-task Reproduction

Use FP32, no BOS, zero-shot prompts, and a **512-token evaluation context**, even though the model supports 1,024 tokens. The examples below run on CPU.

```bash
# Four public tasks via lm-evaluation-harness
lm_eval --model hf \
  --model_args pretrained=Lazyshu/PyraLM-50M,trust_remote_code=True,dtype=float32,add_bos_token=False,max_length=512 \
  --tasks hellaswag,arc_easy,arc_challenge,piqa \
  --num_fewshot 0 --device cpu --batch_size 8

# Official ArithMark-3 script from AxiomicLabs/Arithmark-3.0
# Script revision: 6f6e59dd9b7e2c63455f7af7f838f9ecc3d0a746
python bencharithmark-3.py \
  --model Lazyshu/PyraLM-50M \
  --dtype float32 --device cpu --max-context 512 --save-predictions
```

**Reference evaluation environment:** Python `3.12.12`, PyTorch `2.12.0.dev20260220+cu126`, Transformers `4.57.1`, tokenizers `0.22.1`, safetensors `0.6.2`, lm-eval `0.4.13`. The official arithmetic script is available in [AxiomicLabs/Arithmark-3.0](https://huggingface.co/datasets/AxiomicLabs/Arithmark-3.0/tree/6f6e59dd9b7e2c63455f7af7f838f9ecc3d0a746).

---

## Limitations

- **Small model capacity:** Intended for small-language-model research and efficient inference; it is not a general-purpose chat assistant.
- **Short context:** Native model context is 1,024 tokens; the Open SLM reference evaluation uses 512.
- **English-focused:** Pretraining and post-training primarily use English text. The checkpoint has not undergone chat or safety alignment.

---

## License & Acknowledgments

Released under the **MIT License**. See [LICENSE](LICENSE).

- Thanks to the **[PyTRIO](https://pytrio.com/home)** team for providing training compute.
- PyraLM-50M continues the [PyraLM-10M](https://huggingface.co/Lazyshu/PyraLM-10M) model family. We acknowledge [Ethoric-10M](https://huggingface.co/techdotus/Ethoric-10M) for the attention/Peri-LN/Canon foundation used in that line.
- Thanks to [AxiomicLabs](https://huggingface.co/spaces/AxiomicLabs/Open_SLM_Leaderboard) and [BananaMind](https://huggingface.co/spaces/BananaMind/BETU-SLM-Leaderboard) for maintaining the public benchmarks and leaderboards.
