Text Generation
Transformers
Safetensors
English
mume_gpt
causal-lm
custom_code
math
base-model
Eval Results (legacy)
Run this model with HF Jobs
Run MuseMesh/mume-math-125m on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/MuseMesh/mume-math-125m. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/MuseMesh/mume-math-125m on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/MuseMesh/mume-math-125m. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/MuseMesh/mume-math-125m. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use MuseMesh/mume-math-125m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MuseMesh/mume-math-125m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MuseMesh/mume-math-125m", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MuseMesh/mume-math-125m", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MuseMesh/mume-math-125m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MuseMesh/mume-math-125m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MuseMesh/mume-math-125m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/MuseMesh/mume-math-125m
- SGLang
How to use MuseMesh/mume-math-125m 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 "MuseMesh/mume-math-125m" \ --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": "MuseMesh/mume-math-125m", "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 "MuseMesh/mume-math-125m" \ --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": "MuseMesh/mume-math-125m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use MuseMesh/mume-math-125m with Docker Model Runner:
docker model run hf.co/MuseMesh/mume-math-125m
v0.1.0: MATH0 (owm_val_clean 1.06595, GSM8K 0.91%)
Browse filesFiles changed (29)
- CHANGELOG.mdAdded+9
- LICENSEAdded+16
- LICENSE-CODEAdded+4
- README.mdAdded+280
- config.jsonAdded+35
- configuration_mume.pyAdded+79
- eval/bpb_clean_ctx1024.jsonAdded+53
- eval/bpb_ctx1024.jsonAdded+63
- eval/bpb_ctx512.jsonAdded+63
- eval/contamination_overlap.jsonAdded
- eval/english_model_bpb_clean_ctx1024.jsonAdded+53
- eval/english_model_bpb_ctx1024.jsonAdded+63
- eval/english_model_gsm8k_exact_3shot.jsonAdded
- eval/gsm8k_exact_3shot.jsonAdded
- eval/gsm8k_exact_3shot_released_weights.jsonAdded
- eval/heldout_meta.jsonAdded+23
- eval/smoke_test.jsonAdded+44
- eval/verification.jsonAdded+162
- generation_config.jsonAdded+10
- model.safetensorsAdded+3
- modeling_mume.pyAdded+281
- special_tokens_map.jsonAdded+6
- tokenization_mume.pyAdded+93
- tokenizer.jsonAdded
- tokenizer.modelAdded+3
- tokenizer_config.jsonAdded+19
- training/data_meta.jsonAdded+48
- training/slice_summary.jsonAdded+20
- training/summary.jsonAdded+165
123456789# Changelog
Versions are git tags on this repository. Load a fixed version with `from_pretrained("MuseMesh/mume-math-125m", revision="<tag>", trust_remote_code=True)`.
## v0.1.0 (2026-09-29)
- Weights of training run `math0_shared32k_d125m_ctx1024` (MATH0 (the Math expert's first run)), step 27,106, 1.33B tokens.- owm_val_clean 1.06595, math_test_clean 0.86027, gsm8k_test 1.07016 bits per byte; GSM8K exact match 0.91%.- First release. Tokenizer: MuseMesh/mume-tokenizer-32k v0.1.0 (bundled).12345678910111213141516The model weights (model.safetensors) and the tokenizer files (tokenizer.model,tokenizer.json) in this repository are licensed under the Creative CommonsAttribution-NonCommercial 4.0 International licence (CC BY-NC 4.0): https://creativecommons.org/licenses/by-nc/4.0/
You may use, share and adapt them for non-commercial purposes (research, teaching, non-profit work) withattribution to "Muse Mesh Private Limited". For commercial use contact kushal@muse-mesh.com; an Apache-2.0licensed line (a tokenizer trained without non-commercial sources, and models retrained on it) is planned asseparate repositories.
Why: the shared tokenizer's training sample includes Sanskrit text licensed for non-commercial use only(GRETIL, CC BY-NC-SA 4.0; Muktabodha, CC BY-NC 4.0) and Sanskrit text without a licence statement. The modelweights themselves were trained only on ODC-By and MIT licensed data (see README.md, Attribution).
The code is licensed separately under Apache-2.0 (see LICENSE-CODE).
Copyright 2026 Muse Mesh Private Limited1234The Python code in this repository (configuration_mume.py, modeling_mume.py, tokenization_mume.py) is licensed under theApache License, Version 2.0: https://www.apache.org/licenses/LICENSE-2.0
Copyright 2026 Muse Mesh Private Limited123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280---license: cc-by-nc-4.0language:- enlibrary_name: transformerspipeline_tag: text-generationtags:- causal-lm- custom_code- math- base-modeldatasets:- open-web-math/open-web-math- MuseMesh/mume-eval-suitesmodel-index:- name: mume-math-125m results: - task: type: text-generation name: Language modelling dataset: type: MuseMesh/mume-eval-suites name: owm_val config: owm_val split: test metrics: - type: bits_per_byte name: bits per UTF-8 byte (1,024-token windows, stride 512) value: 0.9926 - task: type: text-generation name: Language modelling dataset: type: MuseMesh/mume-eval-suites name: gsm8k_test config: gsm8k_test split: test metrics: - type: bits_per_byte name: bits per UTF-8 byte (1,024-token windows, stride 512) value: 1.0702 - task: type: text-generation name: Language modelling dataset: type: MuseMesh/mume-eval-suites name: math_test config: math_test split: test metrics: - type: bits_per_byte name: bits per UTF-8 byte (1,024-token windows, stride 512) value: 0.8462 - task: type: text-generation name: Language modelling dataset: type: MuseMesh/mume-eval-suites name: owm_val_clean config: owm_val_clean split: test metrics: - type: bits_per_byte name: bits per UTF-8 byte (1,024-token windows, stride 512) value: 1.0659 - task: type: text-generation name: Language modelling dataset: type: MuseMesh/mume-eval-suites name: math_test_clean config: math_test_clean split: test metrics: - type: bits_per_byte name: bits per UTF-8 byte (1,024-token windows, stride 512) value: 0.8603 - task: type: text-generation name: Math word problems dataset: type: openai/gsm8k name: GSM8K config: main split: test metrics: - type: exact_match name: exact match, 3-shot, greedy value: 0.91---
# Mume Math 125M
**Mume Math 125M** is a 134M-parameter language model trained from scratch on 1.33B tokens of mathematical web text (OpenWebMath), with the recipe, budget and tokenizer of Mume English 125M v0.2.0. It reads math far better than the English model of the same size (bits per byte on MATH test, clean subset: -62.6%), but solves almost no word problems (GSM8K 0.91%).
From [Muse Mesh](https://muse-mesh.com) ([Hugging Face](https://huggingface.co/MuseMesh)). Part of the Muse Mesh English and Math models ([collections](https://huggingface.co/collections/MuseMesh)). Every training run, including the ones not released, is logged at [mume.ai/sansar/runs](https://mume.ai/sansar/runs) (moving to mume.ai/lab).
## Model
| | ||---|---|| Architecture | decoder-only transformer, pre-LayerNorm (LayerNorm without bias), no biases anywhere; GPT-2-small shape || Layers / heads / width | 12 / 12 / 768 (head dim 64); MLP 4x = 3,072 || Positions | rotary (base 10,000; half-split pairing), no position table || Attention | causal SDPA; queries and keys RMS-normalised per head (QK-norm) || MLP activation | squared ReLU || Output head | separate (untied), zero-initialised || Vocabulary | 32,000 ([MuseMesh/mume-tokenizer-32k](https://huggingface.co/MuseMesh/mume-tokenizer-32k) v0.1.0, bundled) || Context | 1,024 tokens || Parameters, total | 134,105,856 || Parameters, non-embedding | 84,953,856 || Token embedding | 24,576,000 || Output head | 24,576,000 || Weights in this repo | bfloat16 safetensors (trained as fp32 master weights under bf16 autocast) |
Why this run: The English winner's recipe and budget, unchanged, on mathematical web text.
## Evaluation
**Metric**: bits per UTF-8 byte (lower is better): the model's negative log-likelihood of a text divided by the text's UTF-8 byte count, so models with different tokenizers share a denominator. Each set's records are joined with `</s>` into one stream and scored teacher-forced in 1,024-token windows with stride 512 (every scored token after the first window has at least 512 tokens of context); `</s>` carries loss but no bytes. Scored with `scripts/train/eval_bpb.py` on a GPU in bf16 autocast. The sets are frozen and published as [MuseMesh/mume-eval-suites](https://huggingface.co/datasets/MuseMesh/mume-eval-suites).
The English model is [MuseMesh/mume-english-125m](https://huggingface.co/MuseMesh/mume-english-125m) v0.2.0 (EN1-full): the same architecture, recipe, tokenizer and token budget, trained on FineWeb instead of OpenWebMath.
| set | what | this model | English model | change ||---|---|---:|---:|---:|| `gsm8k_test` | GSM8K test, 1,319 problems: question, blank line, worked answer (calculator annotations removed) | **1.07016** | 1.20665 | -11.3% || `owm_val` | OpenWebMath shard 113 (never trained on), the first 2,704 documents up to 20 MB | **0.99258** | 1.54392 | -35.7% || `owm_val_clean` | owm_val minus the 1,578 documents that share a copied passage with the training data (1,126 documents) | **1.06595** | 1.57023 | -32.1% || `math_test` | MATH test (Hendrycks), 5,000 problems: problem, blank line, solution | **0.84625** | 2.36162 | -64.2% || `math_test_clean` | math_test minus the 1,246 problems that share a copied passage with the training data (3,754 problems) | **0.86027** | 2.30167 | -62.6% |
There is no `gsm8k_clean`: the contamination check found no GSM8K test problem with a copied passage in the training data (0.13% of its 8-grams occur there, scattered), so `gsm8k_test` is already clean.
With 512-token windows (stride 256): owm_val 1.0198, gsm8k_test 1.0736, math_test 0.8650 (`eval/bpb_ctx512.json`).
**Contamination**, measured before training (lowercase word 8-grams of each set looked up in the whole training slice; a record has a copied passage when 5+ consecutive 8-grams hit): owm_val 1,578 of 2,704 documents (58%; the web repeats pages across shards), MATH test 1,246 of 5,000 problems (25%; solutions copied onto web pages), GSM8K test 0 of 1,319. The `_clean` sets drop every such record. On MATH the clean set moves this model by +1.7% (0.84625 -> 0.86027), so the MATH number is not memorisation. On OpenWebMath the clean subset reads +7.4% higher for this model and +1.7% for the English model, so part of the `owm_val` number does come from copies; quote the `_clean` columns. Against the English model on the clean sets: owm_val_clean -32.1%, math_test_clean -62.6%.
### GSM8K exact match
3-shot, greedy: three worked GSM8K *train* examples ("Question: ...\nAnswer: ... #### N"), then the test question and "Answer:"; up to 200 new tokens, stopping at the next "Question:" or after the `####` line. The prediction is the number after `####` (else the last number); it counts when it equals the gold number. All 1,319 test problems (`scripts/experts/math/gsm8k_exact.py`).
| model | right | exact match ||---|---:|---:|| English model (EN1-full) | 21 / 1,319 | 1.59% || **this model (MATH0)** | 12 / 1,319 | 0.91% |
These runs used the fp32 training weights (GPU, bf16 autocast). This repo's bf16 weights, same protocol and GPU: **13 / 1,319 = 0.99%** (greedy decoding of a model this small flips on near-ties, so single problems change).
Low single digits is what a 125M base model scores here; the number is the family's first capability metric. A fine-tuned version on the `sft` branch (tag `v0.1.0-sft`) reaches 2.43% and shows why the score stays low (see its card).
### Checked before release
- `modeling_mume.py` against the training code (`scripts/train/model.py`), fp32 on CPU, 6 inputs (one evaluation text per set, cropped to 1,024 tokens, and 1,024 random ids): with the same bf16 weights the logits are identical (max |difference| 0); against the fp32 training weights the bf16 storage moves logits by at most 0.205.- Bits per byte with `eval_bpb.py`'s scoring on the first 20 records of each set (each cut to 20,000 characters): 1.06580 (training checkpoint, fp32) vs 1.06587 (this repo, bf16 weights) = +0.0063%.- The whole `gsm8k_test` set through this repo's model (bf16 weights, fp32 on CPU): 1.07000, against 1.07016 in the table (training checkpoint, GPU bf16 autocast), -0.015%.- Tokenizer: `AutoTokenizer(..., trust_remote_code=True)` gives the training ids on 100/100 sample texts and decodes them back exactly on 100/100; on all 58,338 texts of the tokenizer's own check the same holds (see [MuseMesh/mume-tokenizer-32k](https://huggingface.co/MuseMesh/mume-tokenizer-32k)).- Left-padded batches give the same logits as single sequences (max |difference| 3.1e-05).
## Quick start
```pythonfrom transformers import AutoModelForCausalLM, AutoTokenizer
repo = "MuseMesh/mume-math-125m"tok = AutoTokenizer.from_pretrained(repo, revision="v0.1.0", trust_remote_code=True)model = AutoModelForCausalLM.from_pretrained(repo, revision="v0.1.0", trust_remote_code=True)
inputs = tok("Let $f(x) = x^2 + 1$. Then", return_tensors="pt")out = model.generate(**inputs, max_new_tokens=60, do_sample=True, temperature=0.8, top_k=100)print(tok.decode(out[0], skip_special_tokens=True))```
Needs `transformers` (tested with 5.18.0), `torch` and `sentencepiece`. `trust_remote_code=True` runs two small files from this repository, `modeling_mume.py` (the network; the Sansar model code with the classes renamed) and `tokenization_mume.py` (SentencePiece, so the ids are exactly the training ids); read them before you run them. Without `trust_remote_code` the tokenizer falls back to `tokenizer.json`, which agrees on short texts but splits a few near-tie words differently in long documents. The weights are stored in bfloat16; pass `dtype=torch.float32` for fp32, usually the faster choice on a CPU. The tokenizer adds no BOS/EOS: training documents were separated by `</s>` only.
What this checkpoint wrote for that prompt (CPU, `torch.manual_seed(0)`, 60 new tokens):
```textLet $f(x) = x^2 + 1$. Then $|f(x)| = |x|^2$. If $f(x) = x^2 + 1$, then $|f'(x)| = |x|^2 = |x|^2$. Thus $|f(x)| \leq |x^2 + ```
and with greedy decoding:
```textLet $f(x) = x^2 + 1$. Then $f(x) = x^2 + 1$ and $f(x) = x^2 + 1$ for all $x \in \mathbb{R}$.
Now, let $f(x) = x^2 + 1$ and $f(```
To score text instead of generating it, call the model with `labels=input_ids`; `loss` is the mean negative log-likelihood per token in nats.
## Training data
OpenWebMath shards 4-15 of 114 (12 parquet files): 662,940 web pages with mathematical content, 816M words; 1,824 pages whose URL also occurs in shard 113 (the held-out shard) were skipped. Shards 0-3 were the tokenizer's math sample and are not in the training data.
Preparation (`scripts/train/prep_data.py`): Unicode NFC; documents longer than 20,000 characters cut into parts at whitespace (774,551 records); tokenized with the shared 32k tokenizer; one `</s>` after every record. A 0.5% validation stream by hash of each record's text (3,769 records); the rest is training: 770,782 records, 1,555,523,031 tokens, 5.12 GB (3.29 bytes per token).
Every training document is listed (source file, row, id; no text) in [MuseMesh/mume-eval-suites](https://huggingface.co/datasets/MuseMesh/mume-eval-suites), config `training_manifests`, split `math_pretrain`, with the parts that went to validation, so the slice can be rebuilt from the public source.
## Training
| | ||---|---|| Optimizer, block matrices | Muon (84,934,656 params): momentum 0.95 (Nesterov), 5 Newton-Schulz steps in bf16, peak lr 0.02, update scaled by sqrt(max(1, rows/cols)), no weight decay || Optimizer, everything else | AdamW: embedding + head with weight decay 0.1, LayerNorm gains without; peak lr 0.001, betas (0.9, 0.95), eps 1e-8 || Learning-rate schedule | linear warm-up over 500 steps, then cosine decay to 0.1 x peak at step 27,106 || Batch | 12 sequences x 4 accumulation steps x 1,024 tokens = 49,152 tokens per step || Steps | 27,106 || Tokens seen | 1,332,314,112 (0.86 passes over 1,555.5M training tokens) || Gradient clipping | global norm 1.0 || Precision | bf16 autocast, fp32 master weights, torch.compile || Seed | 1337 || Data sampling | 1,024-token windows at uniformly random offsets of the token stream (documents separated by `</s>`) || Hardware | 1x NVIDIA RTX 3060 12 GB, power-capped at 150 W || Wall time | 889 min (14.8 h), 25.1k tokens/s; one power cut, resumed from a checkpoint || Compute cost | own hardware, no cloud cost || Final validation | 1.0307 bits per byte on the run's own validation stream (0.5% of documents, non-overlapping windows) |
## Limitations
- **Base model.** It continues text. It has not been instruction-tuned or aligned: it does not follow instructions, answer questions or chat, and it will not refuse anything.- **It makes things up.** Fluent text with invented facts, names, numbers, citations and proofs. Do not use it as a source of facts or of correct mathematics.- **Small and short.** 134M parameters and a 1,024-token context. This implementation has no key/value cache, so long generations are slow (each new token re-reads the context).- **Web math.** OpenWebMath is forum posts, lecture notes, blogs and Q&A pages with LaTeX; the model writes in that register, can switch into English prose, and has little arithmetic ability.- **Contamination.** Some evaluation text occurs in the training data (measured above); prefer the `_clean` sets.- **Tokenizer.** 32k pieces shared with Sanskrit (in SLP1 transliteration) and math; FineWeb text takes 13% more tokens than with GPT-2's tokenizer (1.52 vs 1.35 per word).
## Versions
Each version is a git tag on this repository; `main` is version v0.1.0. Pin one with `revision=`. A version is one training run, named by its run id in the training log.
| version | where | date | training run | key numbers ||---|---|---|---|---|| v0.1.0 | tag `v0.1.0`, `main` | 2026-09-29 | `math0_shared32k_d125m_ctx1024` (MATH0) | owm_val_clean 1.0659, GSM8K 0.91% || v0.1.0-sft | branch `sft`, tag `v0.1.0-sft` | 2026-10-01 | `math0_sft` (MATH0-SFT) | GSM8K 2.43% |
The fine-tuned model lives on its own branch, `sft`, so `main` stays the base model that the bits-per-byte numbers describe; the tag `v0.1.0-sft` pins it. A later fine-tune of this base will move the `sft` branch and get its own tag.
## Files
| file | what ||---|---|| `model.safetensors` | the weights, bfloat16 (no optimizer state) || `config.json`, `generation_config.json` | architecture and default generation settings || `configuration_mume.py`, `modeling_mume.py` | the network for transformers (`auto_map`, trust_remote_code) || `tokenizer.model`, `tokenizer.json`, `tokenization_mume.py`, `tokenizer_config.json`, `special_tokens_map.json` | the tokenizer ([MuseMesh/mume-tokenizer-32k](https://huggingface.co/MuseMesh/mume-tokenizer-32k) v0.1.0) || `eval/bpb_clean_ctx1024.json`, `eval/bpb_ctx1024.json`, `eval/bpb_ctx512.json`, `eval/contamination_overlap.json`, `eval/english_model_bpb_clean_ctx1024.json`, `eval/english_model_bpb_ctx1024.json`, `eval/english_model_gsm8k_exact_3shot.json`, `eval/gsm8k_exact_3shot.json`, `eval/gsm8k_exact_3shot_released_weights.json`, `eval/heldout_meta.json`, `eval/smoke_test.json`, `eval/verification.json` | the evaluation outputs quoted above, the release checks and the sample generations || `training/data_meta.json`, `training/slice_summary.json`, `training/summary.json` | every training argument, the validation points and the data preparation record || `LICENSE`, `LICENSE-CODE`, `CHANGELOG.md` | licences and version history |
## Attribution
| data | Hugging Face | reference | licence ||---|---|---|---|| OpenWebMath | [open-web-math/open-web-math](https://huggingface.co/datasets/open-web-math/open-web-math) | Paster et al. 2023, *OpenWebMath*, [arXiv:2310.06786](https://arxiv.org/abs/2310.06786) | ODC-By 1.0; use is also subject to the Common Crawl Terms of Use || GSM8K | [openai/gsm8k](https://huggingface.co/datasets/openai/gsm8k) | Cobbe et al. 2021, *Training Verifiers to Solve Math Word Problems*, [arXiv:2110.14168](https://arxiv.org/abs/2110.14168) | MIT || MATH | [EleutherAI/hendrycks_math](https://huggingface.co/datasets/EleutherAI/hendrycks_math) | Hendrycks et al. 2021, *Measuring Mathematical Problem Solving With the MATH Dataset*, [arXiv:2103.03874](https://arxiv.org/abs/2103.03874) | MIT |
## Licence
This release is for research and non-commercial use.
- Weights (`model.safetensors`), `tokenizer.model` and `tokenizer.json`: **CC BY-NC 4.0** (`LICENSE`). Non-commercial use (research, teaching, non-profit work) with attribution to "Muse Mesh Private Limited".- Code (`configuration_mume.py`, `modeling_mume.py`, `tokenization_mume.py`): **Apache-2.0** (`LICENSE-CODE`).- Commercial use: contact kushal@muse-mesh.com.
Why non-commercial: The weights saw only permissively licensed text: OpenWebMath (ODC-By 1.0). The tokenizer is the issue: the shared 32k tokenizer was trained on a 1.2 GB sample of which 400 MB is Sanskrit from the Sansar corpus, and part of that Sanskrit is licensed for non-commercial use only (GRETIL, CC BY-NC-SA 4.0; Muktabodha, CC BY-NC 4.0) or carries no licence statement. The tokenizer, and the weights that only work with it, are therefore released under CC BY-NC 4.0, the same terms as the Sansar Sanskrit tokenizer. An Apache-2.0 line is planned as separate repositories: a new tokenizer trained without those sources, and the models retrained on it.
## Citation
```bibtex@misc{mume_math_125m_2026, title = {Mume Math 125M}, author = {Muse Mesh}, year = {2026}, note = {v0.1.0}, url = {https://huggingface.co/MuseMesh/mume-math-125m}}```
Contact: kushal@muse-mesh.com1234567891011121314151617181920212223242526272829303132333435{ "architectures": [ "MumeForCausalLM" ], "auto_map": { "AutoConfig": "configuration_mume.MumeConfig", "AutoModelForCausalLM": "modeling_mume.MumeForCausalLM" }, "bias": false, "block_size": 1024, "bos_token_id": 1, "dtype": "bfloat16", "eos_token_id": 2, "initializer_range": 0.02, "layer_norm_eps": 1e-05, "logit_cap": 0.0, "mlp_ratio": 4, "model_type": "mume_gpt", "n_embd": 768, "n_head": 12, "n_layer": 12, "pad_token_id": 2, "qk_norm": true, "relu_sq": true, "rope": true, "rope_theta": 10000.0, "tie_word_embeddings": false, "torch_dtype": "bfloat16", "transformers_version": "5.18.0", "untied_head": true, "use_cache": false, "value_embed": false, "value_embed_layers": "", "vocab_size": 32000}12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879"""Configuration of the Muse Mesh English and Math language models (the Sansar model code, renamed).
Code licence: Apache-2.0 (LICENSE-CODE). The model weights are licensed separately (LICENSE)."""from transformers import PretrainedConfig
class MumeConfig(PretrainedConfig): """A compact pre-LayerNorm GPT. The flags select the two architectures the runs used:
- ``rope=False, qk_norm=False, untied_head=False, relu_sq=False``: learned position table, GELU (tanh) MLP, output head tied to the token embedding (mume-english-125m v0.1.0, EN0). - ``rope=True, qk_norm=True, untied_head=True, relu_sq=True``: rotary positions, RMS-normalised queries and keys, a separate output head, squared-ReLU MLP (EN1-full, MATH0 and MATH0-SFT).
``value_embed`` and ``logit_cap`` are supported for completeness; no released model uses them. """
model_type = "mume_gpt" attribute_map = { "hidden_size": "n_embd", "num_hidden_layers": "n_layer", "num_attention_heads": "n_head", "max_position_embeddings": "block_size", }
def __init__( self, vocab_size: int = 8000, block_size: int = 512, n_layer: int = 6, n_head: int = 8, n_embd: int = 512, mlp_ratio: int = 4, bias: bool = False, rope: bool = False, rope_theta: float = 10000.0, qk_norm: bool = False, untied_head: bool = False, relu_sq: bool = False, value_embed: bool = False, value_embed_layers: str = "", logit_cap: float = 0.0, layer_norm_eps: float = 1e-5, initializer_range: float = 0.02, bos_token_id: int = 1, eos_token_id: int = 2, pad_token_id: int = 2, tie_word_embeddings=None, use_cache: bool = False, **kwargs, ): self.vocab_size = vocab_size self.block_size = block_size self.n_layer = n_layer self.n_head = n_head self.n_embd = n_embd self.mlp_ratio = mlp_ratio self.bias = bias self.rope = rope self.rope_theta = rope_theta self.qk_norm = qk_norm self.untied_head = untied_head self.relu_sq = relu_sq self.value_embed = value_embed self.value_embed_layers = value_embed_layers self.logit_cap = logit_cap self.layer_norm_eps = layer_norm_eps self.initializer_range = initializer_range self.use_cache = use_cache if tie_word_embeddings is None: tie_word_embeddings = not untied_head super().__init__( bos_token_id=bos_token_id, eos_token_id=eos_token_id, pad_token_id=pad_token_id, tie_word_embeddings=tie_word_embeddings, **kwargs, )1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253{ "arm": "clean", "ckpt": "/home/kushal/sansar/data/experts/math/train/runs/math0_shared32k_d125m_ctx1024/ckpt.pt", "tokenizer": "/home/kushal/sansar/data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "vocab_size": 32000, "transliterate": "none", "strip_refs": false, "clean": "none", "text_field": "text", "denominator": "bytes_utf8", "block": 1024, "stride": 512, "step": 27106, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "method": "records joined with EOS into one stream per set; sliding window, only the last `stride` predictions of each window after the first are scored; nats / UTF-8 bytes of the frozen text / ln 2", "per_set": { "owm_val_clean": { "records": 1126, "tokens": 1437715, "tokens_scored": 1437714, "bytes_utf8": 4780645, "nll_nats": 3532240.215, "bpb": 1.06595, "nll_per_token": 2.45684, "bytes_per_token": 3.3252 }, "math_test_clean": { "records": 3754, "tokens": 1018572, "tokens_scored": 1018571, "bytes_utf8": 2418527, "nll_nats": 1442145.99, "bpb": 0.86027, "nll_per_token": 1.41585, "bytes_per_token": 2.3744 } }, "pooled": { "tokens": 2456287, "bytes_utf8": 7199172, "nll_nats": 4974386.206, "bpb": 0.99685 }, "seconds": 111.3}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263{ "arm": "shared32k_d125m_ctx1024", "ckpt": "/home/kushal/sansar/data/experts/math/train/runs/math0_shared32k_d125m_ctx1024/ckpt.pt", "tokenizer": "/home/kushal/sansar/data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "vocab_size": 32000, "transliterate": "none", "strip_refs": false, "clean": "none", "text_field": "text", "denominator": "bytes_utf8", "block": 1024, "stride": 512, "step": 27106, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "method": "records joined with EOS into one stream per set; sliding window, only the last `stride` predictions of each window after the first are scored; nats / UTF-8 bytes of the frozen text / ln 2", "per_set": { "owm_val": { "records": 2704, "tokens": 6127232, "tokens_scored": 6127231, "bytes_utf8": 20001168, "nll_nats": 13760918.543, "bpb": 0.99258, "nll_per_token": 2.24586, "bytes_per_token": 3.2643 }, "gsm8k_test": { "records": 1319, "tokens": 225351, "tokens_scored": 225350, "bytes_utf8": 652230, "nll_nats": 483810.729, "bpb": 1.07016, "nll_per_token": 2.14693, "bytes_per_token": 2.8943 }, "math_test": { "records": 5000, "tokens": 1536141, "tokens_scored": 1536140, "bytes_utf8": 3565468, "nll_nats": 2091408.281, "bpb": 0.84625, "nll_per_token": 1.36147, "bytes_per_token": 2.3211 } }, "pooled": { "tokens": 7888724, "bytes_utf8": 24218866, "nll_nats": 16336137.553, "bpb": 0.97313 }, "seconds": 359.0}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263{ "arm": "shared32k_d125m_ctx1024", "ckpt": "/home/kushal/sansar/data/experts/math/train/runs/math0_shared32k_d125m_ctx1024/ckpt.pt", "tokenizer": "/home/kushal/sansar/data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "vocab_size": 32000, "transliterate": "none", "strip_refs": false, "clean": "none", "text_field": "text", "denominator": "bytes_utf8", "block": 512, "stride": 256, "step": 27106, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "method": "records joined with EOS into one stream per set; sliding window, only the last `stride` predictions of each window after the first are scored; nats / UTF-8 bytes of the frozen text / ln 2", "per_set": { "owm_val": { "records": 2704, "tokens": 6127232, "tokens_scored": 6127231, "bytes_utf8": 20001168, "nll_nats": 14138481.944, "bpb": 1.01982, "nll_per_token": 2.30748, "bytes_per_token": 3.2643 }, "gsm8k_test": { "records": 1319, "tokens": 225351, "tokens_scored": 225350, "bytes_utf8": 652230, "nll_nats": 485360.235, "bpb": 1.07359, "nll_per_token": 2.15381, "bytes_per_token": 2.8943 }, "math_test": { "records": 5000, "tokens": 1536141, "tokens_scored": 1536140, "bytes_utf8": 3565468, "nll_nats": 2137850.962, "bpb": 0.86504, "nll_per_token": 1.3917, "bytes_per_token": 2.3211 } }, "pooled": { "tokens": 7888724, "bytes_utf8": 24218866, "nll_nats": 16761693.141, "bpb": 0.99848 }, "seconds": 360.0}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253{ "arm": "clean", "ckpt": "/home/kushal/sansar/data/experts/english/train/runs/en1_full_d125m_ctx1024/ckpt.pt", "tokenizer": "/home/kushal/sansar/data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "vocab_size": 32000, "transliterate": "none", "strip_refs": false, "clean": "none", "text_field": "text", "denominator": "bytes_utf8", "block": 1024, "stride": 512, "step": 27106, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "method": "records joined with EOS into one stream per set; sliding window, only the last `stride` predictions of each window after the first are scored; nats / UTF-8 bytes of the frozen text / ln 2", "per_set": { "owm_val_clean": { "records": 1126, "tokens": 1437715, "tokens_scored": 1437714, "bytes_utf8": 4780645, "nll_nats": 5203267.294, "bpb": 1.57023, "nll_per_token": 3.61913, "bytes_per_token": 3.3252 }, "math_test_clean": { "records": 3754, "tokens": 1018572, "tokens_scored": 1018571, "bytes_utf8": 2418527, "nll_nats": 3858500.226, "bpb": 2.30167, "nll_per_token": 3.78815, "bytes_per_token": 2.3744 } }, "pooled": { "tokens": 2456287, "bytes_utf8": 7199172, "nll_nats": 9061767.52, "bpb": 1.81595 }, "seconds": 111.6}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263{ "arm": "en1_full_on_math", "ckpt": "/home/kushal/sansar/data/experts/english/train/runs/en1_full_d125m_ctx1024/ckpt.pt", "tokenizer": "/home/kushal/sansar/data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "vocab_size": 32000, "transliterate": "none", "strip_refs": false, "clean": "none", "text_field": "text", "denominator": "bytes_utf8", "block": 1024, "stride": 512, "step": 27106, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "method": "records joined with EOS into one stream per set; sliding window, only the last `stride` predictions of each window after the first are scored; nats / UTF-8 bytes of the frozen text / ln 2", "per_set": { "owm_val": { "records": 2704, "tokens": 6127232, "tokens_scored": 6127231, "bytes_utf8": 20001168, "nll_nats": 21404534.319, "bpb": 1.54392, "nll_per_token": 3.49335, "bytes_per_token": 3.2643 }, "gsm8k_test": { "records": 1319, "tokens": 225351, "tokens_scored": 225350, "bytes_utf8": 652230, "nll_nats": 545514.931, "bpb": 1.20665, "nll_per_token": 2.42075, "bytes_per_token": 2.8943 }, "math_test": { "records": 5000, "tokens": 1536141, "tokens_scored": 1536140, "bytes_utf8": 3565468, "nll_nats": 5836495.146, "bpb": 2.36162, "nll_per_token": 3.79946, "bytes_per_token": 2.3211 } }, "pooled": { "tokens": 7888724, "bytes_utf8": 24218866, "nll_nats": 27786544.396, "bpb": 1.65522 }, "seconds": 358.7}1234567891011121314151617181920212223{ "created": "2026-09-28 11:14", "sets": { "owm_val": { "records": 2704, "bytes_utf8": 20001168, "source": "open-web-math/open-web-math train-00113-of-00114", "note": "first 2704 documents in file order up to 20,000,000 bytes" }, "gsm8k_test": { "records": 1319, "bytes_utf8": 652230, "source": "openai/gsm8k main test", "note": "question + blank line + answer; <<calculator>> annotations removed" }, "math_test": { "records": 5000, "bytes_utf8": 3565468, "source": "EleutherAI/hendrycks_math test, 7 subjects", "note": "problem + blank line + solution" } }}1234567891011121314151617181920212223242526272829303132333435363738394041424344{ "repo": "mume-math-125m", "version": "v0.1.0", "transformers": "5.18.0", "torch": "2.14.0+cu130", "dtype_loaded": "torch.bfloat16", "tokenizer_trust_remote_code": "MumeTokenizer", "tokenizer_default": "TokenizersBackend", "fast_ids_equal_on_prompt": true, "load_seconds": 0.2, "prompt": "Let $f(x) = x^2 + 1$. Then", "prompt_tokens": 15, "prompt_pieces": [ "▁Let", "▁$", "f", "(", "x", ")", "▁=", "▁x", "^", "2", "▁+", "▁", "1", "$.", "▁Then" ], "sampled_seed0": { "new_tokens": 60, "seconds": 5.1, "text": "Let $f(x) = x^2 + 1$. Then $|f(x)| = |x|^2$. If $f(x) = x^2 + 1$, then $|f'(x)| = |x|^2 = |x|^2$. Thus $|f(x)| \\leq |x^2 + ", "do_sample": true, "temperature": 0.8, "top_k": 100 }, "greedy": { "new_tokens": 60, "seconds": 4.9, "text": "Let $f(x) = x^2 + 1$. Then $f(x) = x^2 + 1$ and $f(x) = x^2 + 1$ for all $x \\in \\mathbb{R}$.\n\nNow, let $f(x) = x^2 + 1$ and $f(", "do_sample": false }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162{ "repo": "mume-math-125m", "version": "v0.1.0", "run": "math0_shared32k_d125m_ctx1024", "torch": "2.14.0+cu130", "transformers": "5.18.0", "hf_load_seconds": 0.3, "hf_param_counts": { "total": 134105856, "embedding": 24576000, "head": 24576000, "non_embedding": 84953856 }, "tokenizer_class": "MumeTokenizer", "orig_param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "hf_head_equals_wte": false, "logits": [ { "input": "owm_val", "tokens": 619, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.18924713134765625, "mean_abs_diff_vs_fp32_master": 0.02142287604510784, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 0.9983844757080078, "logit_abs_max": 30.520248413085938 }, { "input": "owm_val_clean", "tokens": 619, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.18924713134765625, "mean_abs_diff_vs_fp32_master": 0.02142287604510784, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 0.9983844757080078, "logit_abs_max": 30.520248413085938 }, { "input": "gsm8k_test", "tokens": 121, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.17910480499267578, "mean_abs_diff_vs_fp32_master": 0.02021566778421402, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 0.9834710955619812, "logit_abs_max": 22.752124786376953 }, { "input": "math_test", "tokens": 104, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.1441974639892578, "mean_abs_diff_vs_fp32_master": 0.021314028650522232, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 1.0, "logit_abs_max": 25.434036254882812 }, { "input": "math_test_clean", "tokens": 104, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.1441974639892578, "mean_abs_diff_vs_fp32_master": 0.021314028650522232, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 1.0, "logit_abs_max": 25.434036254882812 }, { "input": "random_1024", "tokens": 1024, "max_abs_diff_vs_same_bf16_weights": 0.0, "mean_abs_diff_vs_same_bf16_weights": 0.0, "max_abs_diff_vs_fp32_master": 0.2052001953125, "mean_abs_diff_vs_fp32_master": 0.024474455043673515, "argmax_agree_vs_same_bf16_weights": 1.0, "argmax_agree_vs_fp32_master": 0.994140625, "logit_abs_max": 17.417985916137695 } ], "logits_max_abs_diff_impl": 0.0, "logits_max_abs_diff_bf16_storage": 0.2052001953125, "left_padding_max_abs_diff": 3.147125244140625e-05, "tokenizer_ids_identical": "100/100", "tokenizer_roundtrip_exact": "100/100", "bpb_sample": { "records_per_set": 20, "max_chars_per_record": 20000, "block": 1024, "stride": 512, "per_set": { "owm_val": { "records": 20, "tokens": 19797, "utf8_bytes": 67807, "original_fp32_master": 1.04333, "hf_bf16_weights_fp32_compute": 1.04337, "rel_diff": 3.7595580306251906e-05 }, "owm_val_clean": { "records": 20, "tokens": 21497, "utf8_bytes": 80082, "original_fp32_master": 1.13213, "hf_bf16_weights_fp32_compute": 1.13217, "rel_diff": 3.843563384466128e-05 }, "gsm8k_test": { "records": 20, "tokens": 3636, "utf8_bytes": 10910, "original_fp32_master": 1.04602, "hf_bf16_weights_fp32_compute": 1.04612, "rel_diff": 9.461596812371703e-05 }, "math_test": { "records": 20, "tokens": 4062, "utf8_bytes": 10074, "original_fp32_master": 0.8763, "hf_bf16_weights_fp32_compute": 0.87655, "rel_diff": 0.00027754500238853655 }, "math_test_clean": { "records": 20, "tokens": 3983, "utf8_bytes": 9958, "original_fp32_master": 0.89883, "hf_bf16_weights_fp32_compute": 0.89907, "rel_diff": 0.0002619447947951707 } }, "pooled_original_fp32_master": 1.0658, "pooled_hf_bf16_weights_fp32_compute": 1.06587, "pooled_rel_diff": 6.305839549519214e-05, "seconds": 107.1 }, "full_set": { "set": "gsm8k_test", "records": 1319, "tokens": 225351, "utf8_bytes": 652230, "frozen_bytes": 652230, "hf_bpb": 1.07, "frozen_bpb_gpu_bf16_autocast": 1.07016, "rel_diff": -0.00014918026252958935, "note": "", "seconds": 217.3 }}12345678910{ "bos_token_id": 1, "eos_token_id": 2, "pad_token_id": 2, "do_sample": true, "temperature": 0.8, "top_k": 100, "max_new_tokens": 128, "use_cache": false}123version https://git-lfs.github.com/spec/v1oid sha256:0e88758438a3853052749670271f203ea234f2ccd758304bf469390165b01c24size 268219680123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281"""Muse Mesh English and Math language models as a transformers PreTrainedModel (load with trust_remote_code=True).
The same network code as the Sansar models (MuseMesh/sansar-*), renamed. The module tree and parameter names are thoseof the training code (scripts/train/model.py in the Sansar repository), so the released weights are the trainedtensors with no renaming. The forward pass reproduces the trainingmodel's logits (verified to fp32 rounding before release; see the model card).
Generation does not use a key/value cache: every step re-reads the last ``block_size`` tokens (1,024 for the Englishand Math models, which were trained on 1,024-token windows), so text longer than that is read through a sliding window.
Code licence: Apache-2.0 (LICENSE-CODE). The model weights are licensed separately (LICENSE)."""from __future__ import annotations
import math
import torchimport torch.nn as nnfrom torch.nn import functional as F
import transformersfrom transformers import PreTrainedModelfrom transformers.modeling_outputs import CausalLMOutputWithPast
try: from transformers import GenerationMixinexcept ImportError: # older transformers from transformers.generation import GenerationMixin
try: # transformers >= 5: init functions that skip tensors already loaded from the checkpoint from transformers import initialization as _initexcept ImportError: _init = nn.init
from .configuration_mume import MumeConfig
_TRANSFORMERS_V5 = int(transformers.__version__.split(".")[0]) >= 5
def rotary_cos_sin(positions: torch.Tensor, head_dim: int, base: float): """cos, sin for each position, shape positions.shape + (head_dim,): the first half of the head dim pairs with the second half (the layout of the training code).""" inv = 1.0 / (base ** (torch.arange(0, head_dim, 2, device=positions.device, dtype=torch.float32) / head_dim)) ang = positions.to(torch.float32)[..., None] * inv ang = torch.cat([ang, ang], dim=-1) return ang.cos(), ang.sin()
def apply_rotary(x: torch.Tensor, cos: torch.Tensor, sin: torch.Tensor) -> torch.Tensor: """x: (B, H, T, hs); cos/sin: (T, hs) or (B, 1, T, hs). Rotation in float32, result in x's dtype.""" hs = x.shape[-1] xf = x.float() x1, x2 = xf[..., : hs // 2], xf[..., hs // 2:] rotated = torch.cat([-x2, x1], dim=-1) return (xf * cos + rotated * sin).to(x.dtype)
def value_embed_layers(cfg: MumeConfig) -> tuple: if not cfg.value_embed: return () if cfg.value_embed_layers.strip(): return tuple(sorted({int(x) for x in cfg.value_embed_layers.split(",") if x.strip()})) k = min(3, cfg.n_layer // 2) return tuple(range(k)) + tuple(range(cfg.n_layer - k, cfg.n_layer))
class LayerNorm(nn.Module): """LayerNorm with an optional bias (the released models have none)."""
def __init__(self, ndim: int, bias: bool, eps: float = 1e-5): super().__init__() self.weight = nn.Parameter(torch.ones(ndim)) self.bias = nn.Parameter(torch.zeros(ndim)) if bias else None self.eps = eps
def forward(self, x): return F.layer_norm(x, self.weight.shape, self.weight, self.bias, self.eps)
class CausalSelfAttention(nn.Module): def __init__(self, cfg: MumeConfig, value_embed: bool = False): super().__init__() assert cfg.n_embd % cfg.n_head == 0 self.n_head = cfg.n_head self.n_embd = cfg.n_embd self.rope = cfg.rope self.qk_norm = cfg.qk_norm self.c_attn = nn.Linear(cfg.n_embd, 3 * cfg.n_embd, bias=cfg.bias) self.c_proj = nn.Linear(cfg.n_embd, cfg.n_embd, bias=cfg.bias) self.value_embed = value_embed if value_embed: self.v_scale = nn.Parameter(torch.tensor(0.5)) self.ve_scale = nn.Parameter(torch.tensor(0.5))
def forward(self, x, cos=None, sin=None, ve=None, attn_mask=None): B, T, C = x.shape hs = C // self.n_head q, k, v = self.c_attn(x).split(self.n_embd, dim=2) q = q.view(B, T, self.n_head, hs).transpose(1, 2) k = k.view(B, T, self.n_head, hs).transpose(1, 2) v = v.view(B, T, self.n_head, hs).transpose(1, 2) if self.value_embed: v = self.v_scale * v + self.ve_scale * ve.view(B, T, self.n_head, hs).transpose(1, 2).to(v.dtype) if self.qk_norm: q = F.rms_norm(q, (hs,)).to(v.dtype) k = F.rms_norm(k, (hs,)).to(v.dtype) if self.rope: q = apply_rotary(q, cos, sin) k = apply_rotary(k, cos, sin) if attn_mask is None: y = F.scaled_dot_product_attention(q, k, v, attn_mask=None, is_causal=True) else: y = F.scaled_dot_product_attention(q, k, v, attn_mask=attn_mask, is_causal=False) y = y.transpose(1, 2).contiguous().view(B, T, C) return self.c_proj(y)
class MLP(nn.Module): def __init__(self, cfg: MumeConfig): super().__init__() hidden = cfg.mlp_ratio * cfg.n_embd self.c_fc = nn.Linear(cfg.n_embd, hidden, bias=cfg.bias) self.c_proj = nn.Linear(hidden, cfg.n_embd, bias=cfg.bias) self.relu_sq = cfg.relu_sq
def forward(self, x): h = self.c_fc(x) h = F.relu(h).square() if self.relu_sq else F.gelu(h, approximate="tanh") return self.c_proj(h)
class Block(nn.Module): def __init__(self, cfg: MumeConfig, value_embed: bool = False): super().__init__() self.ln_1 = LayerNorm(cfg.n_embd, cfg.bias, cfg.layer_norm_eps) self.attn = CausalSelfAttention(cfg, value_embed=value_embed) self.ln_2 = LayerNorm(cfg.n_embd, cfg.bias, cfg.layer_norm_eps) self.mlp = MLP(cfg)
def forward(self, x, cos=None, sin=None, ve=None, attn_mask=None): x = x + self.attn(self.ln_1(x), cos, sin, ve, attn_mask) x = x + self.mlp(self.ln_2(x)) return x
class MumePreTrainedModel(PreTrainedModel): config_class = MumeConfig base_model_prefix = "mume" # no such attribute: weights load by their full names, never re-prefixed _no_split_modules = ["Block"] supports_gradient_checkpointing = False
def _init_weights(self, module): """Training-code initialisation; only used for tensors missing from a checkpoint (or a fresh model).""" std = self.config.initializer_range if isinstance(module, nn.Linear): _init.normal_(module.weight, mean=0.0, std=std) if module.bias is not None: _init.zeros_(module.bias) elif isinstance(module, nn.Embedding): _init.normal_(module.weight, mean=0.0, std=std) elif isinstance(module, LayerNorm): _init.ones_(module.weight) if module.bias is not None: _init.zeros_(module.bias)
class MumeForCausalLM(MumePreTrainedModel, GenerationMixin): if _TRANSFORMERS_V5: _tied_weights_keys = {"lm_head.weight": "transformer.wte.weight"} else: _tied_weights_keys = ["lm_head.weight"]
def __init__(self, config: MumeConfig): super().__init__(config) parts = dict(wte=nn.Embedding(config.vocab_size, config.n_embd)) if not config.rope: parts["wpe"] = nn.Embedding(config.block_size, config.n_embd) self.ve_layers = value_embed_layers(config) if config.value_embed: parts["vte"] = nn.Embedding(config.vocab_size, config.n_embd) parts.update( h=nn.ModuleList([Block(config, value_embed=i in self.ve_layers) for i in range(config.n_layer)]), ln_f=LayerNorm(config.n_embd, config.bias, config.layer_norm_eps), ) self.transformer = nn.ModuleDict(parts) self.lm_head = nn.Linear(config.n_embd, config.vocab_size, bias=False) self.post_init()
# ------------------------------------------------------------------ embeddings (for tying and resizing) def get_input_embeddings(self): return self.transformer.wte
def set_input_embeddings(self, value): self.transformer.wte = value
def get_output_embeddings(self): return self.lm_head
def set_output_embeddings(self, new_embeddings): self.lm_head = new_embeddings
# ------------------------------------------------------------------ forward def _cap(self, logits): c = self.config.logit_cap if c and c > 0: return c * torch.tanh(logits.float() / c) return logits
def forward( self, input_ids: torch.LongTensor = None, attention_mask: torch.Tensor | None = None, position_ids: torch.LongTensor | None = None, labels: torch.LongTensor | None = None, return_dict: bool | None = None, **kwargs, ): """input_ids (B, T) with T <= block_size. attention_mask (B, T) of 1/0 for padded batches (left padding for generation); without padding the model runs exactly the training forward pass. labels: as in other causal LMs (the same ids as input_ids; shifted inside; -100 is ignored).""" cfg = self.config B, T = input_ids.shape if T > cfg.block_size: raise ValueError(f"sequence length {T} > block_size {cfg.block_size}; crop the input") dev = input_ids.device
mask = None if attention_mask is not None and not bool(attention_mask.bool().all()): am = attention_mask.bool() if position_ids is None: position_ids = (attention_mask.long().cumsum(-1) - 1).clamp(min=0) causal = torch.ones(T, T, dtype=torch.bool, device=dev).tril() mask = causal[None] & am[:, None, :] mask = mask | torch.eye(T, dtype=torch.bool, device=dev)[None] # padded queries attend to themselves mask = mask[:, None] positions = position_ids if position_ids is not None else torch.arange(T, device=dev)
x = self.transformer.wte(input_ids) if not cfg.rope: x = x + self.transformer.wpe(positions) cos = sin = None if cfg.rope: cos, sin = rotary_cos_sin(positions, cfg.n_embd // cfg.n_head, cfg.rope_theta) if cos.dim() == 3: # (B, T, hs) -> (B, 1, T, hs) cos, sin = cos[:, None], sin[:, None] ve = self.transformer.vte(input_ids) if cfg.value_embed else None for i, block in enumerate(self.transformer.h): x = block(x, cos, sin, ve if i in self.ve_layers else None, mask) x = self.transformer.ln_f(x) logits = self._cap(self.lm_head(x))
loss = None if labels is not None: shift_logits = logits[:, :-1, :].float() shift_labels = labels[:, 1:].to(dev) loss = F.cross_entropy(shift_logits.reshape(-1, shift_logits.size(-1)), shift_labels.reshape(-1), ignore_index=-100) return CausalLMOutputWithPast(loss=loss, logits=logits)
# ------------------------------------------------------------------ generation (no KV cache) @classmethod def _supports_default_dynamic_cache(cls) -> bool: return False
def prepare_inputs_for_generation(self, input_ids, attention_mask=None, **kwargs): bs = self.config.block_size if input_ids.shape[1] > bs: input_ids = input_ids[:, -bs:] if attention_mask is not None: attention_mask = attention_mask[:, -bs:] return {"input_ids": input_ids, "attention_mask": attention_mask}
def num_parameters_by_kind(self) -> dict: """Parameter counts as the model cards report them (a tied head is counted once, in the embedding).""" tok = self.transformer.wte.weight.numel() pos = self.transformer.wpe.weight.numel() if "wpe" in self.transformer else 0 val = self.transformer.vte.weight.numel() if "vte" in self.transformer else 0 head = self.lm_head.weight.numel() if self.config.untied_head else 0 total = sum(p.numel() for p in self.parameters()) return {"total": total, "embedding": tok + pos + val, "head": head, "non_embedding": total - tok - pos - val - head}123456{ "unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "</s>"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293"""The Muse Mesh shared 32k tokenizer for transformers: SentencePiece itself, so the ids are exactly the ones the modelswere trained and evaluated with (load with trust_remote_code=True).
tokenizer.model is a SentencePiece unigram model (identity normaliser, byte fallback, digits split). The repositoryalso carries tokenizer.json, a `tokenizers` fast version of the same vocabulary that AutoTokenizer uses whentrust_remote_code is not set. The two agree on short texts; on long documents SentencePiece settles a few near-tiesegmentations differently (it adds piece scores along the whole document in float32, the fast tokenizer scores wordby word): 24 of 14,983 FineWeb and 34 of 2,704 OpenWebMath validation documents differ, by a token or two. This classremoves that gap.
No BOS/EOS is added to encoded text: the models were trained on documents separated by </s> (id 2), with no BOS.A literal "</s>" inside text is read as characters, as SentencePiece reads it.
Code licence: Apache-2.0 (LICENSE-CODE). tokenizer.model / tokenizer.json: see LICENSE."""from __future__ import annotations
import osimport shutil
import sentencepiece as spmfrom transformers import PreTrainedTokenizer
VOCAB_FILES_NAMES = {"vocab_file": "tokenizer.model"}
class MumeTokenizer(PreTrainedTokenizer): vocab_files_names = VOCAB_FILES_NAMES model_input_names = ["input_ids", "attention_mask"]
def __init__(self, vocab_file, unk_token="<unk>", bos_token="<s>", eos_token="</s>", pad_token="</s>", clean_up_tokenization_spaces=False, split_special_tokens=True, **kwargs): self.vocab_file = vocab_file self.sp = spm.SentencePieceProcessor(model_file=vocab_file) kwargs.setdefault("padding_side", "left") # left padding for batched generation super().__init__(unk_token=unk_token, bos_token=bos_token, eos_token=eos_token, pad_token=pad_token, clean_up_tokenization_spaces=clean_up_tokenization_spaces, split_special_tokens=split_special_tokens, **kwargs)
# ------------------------------------------------------------------ vocabulary @property def vocab_size(self) -> int: return self.sp.get_piece_size()
def get_vocab(self): vocab = {self.sp.id_to_piece(i): i for i in range(self.sp.get_piece_size())} vocab.update(self.added_tokens_encoder) return vocab
def _tokenize(self, text, **kwargs): return self.sp.encode(text, out_type=str)
def _convert_token_to_id(self, token): return self.sp.piece_to_id(token)
def _convert_id_to_token(self, index): return self.sp.id_to_piece(int(index))
def convert_tokens_to_string(self, tokens): """Pieces -> text. Control pieces (<s>, </s>, <unk>) are kept as written; byte pieces are decoded.""" specials = set(self.all_special_tokens) out, buf = [], [] for t in tokens: if t in specials: if buf: out.append(self.sp.decode_pieces(buf)) buf = [] out.append(t) else: buf.append(t) if buf: out.append(self.sp.decode_pieces(buf)) return "".join(out)
# ------------------------------------------------------------------ special tokens: none added def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None): return list(token_ids_0) + (list(token_ids_1) if token_ids_1 is not None else [])
def get_special_tokens_mask(self, token_ids_0, token_ids_1=None, already_has_special_tokens=False): if already_has_special_tokens: return super().get_special_tokens_mask(token_ids_0, token_ids_1, already_has_special_tokens=True) return [0] * (len(token_ids_0) + (len(token_ids_1) if token_ids_1 is not None else 0))
def num_special_tokens_to_add(self, pair: bool = False) -> int: return 0
def save_vocabulary(self, save_directory, filename_prefix=None): if not os.path.isdir(save_directory): os.makedirs(save_directory, exist_ok=True) out = os.path.join(save_directory, (filename_prefix + "-" if filename_prefix else "") + "tokenizer.model") if os.path.abspath(self.vocab_file) != os.path.abspath(out): shutil.copyfile(self.vocab_file, out) return (out,)123version https://git-lfs.github.com/spec/v1oid sha256:a8fce91a9fbcce711999376b291a36456b15beb62ee9d821c8cf175a67d2b409size 51797012345678910111213141516171819{ "tokenizer_class": "PreTrainedTokenizerFast", "auto_map": { "AutoTokenizer": [ "tokenization_mume.MumeTokenizer", null ] }, "unk_token": "<unk>", "bos_token": "<s>", "eos_token": "</s>", "pad_token": "</s>", "add_bos_token": false, "add_eos_token": false, "split_special_tokens": true, "model_max_length": 1024, "padding_side": "left", "clean_up_tokenization_spaces": false}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748{ "created": "2026-09-28T11:52:23", "vocab_size": 32000, "eos_id": 2, "val_split": { "method": "blake2b(cluster id), else blake2b(phase3 dedup key)", "permille": 5, "cluster_file": "/home/kushal/sansar", "cluster_memberships_loaded": 0, "clustered_records": 0, "unclustered_records": 774551, "train_clustered_records": 0, "val_clustered_records": 0 }, "records_read": 774551, "records_kept": 774551, "records_skipped": { "not_training_candidate": 0, "script": 0, "licence": 0, "empty": 0, "bad_json": 0, "excluded_heldout": 0, "records_dropped_heldout_masked": 0, "known_heldout_overlap": 0, "all_rule_lines": 0 }, "train": { "records": 770782, "tokens": 1555523031, "bytes_utf8": 5120530083, "utf8_bytes": 5120530083, "bpb_denominator": "bytes_utf8", "bytes_per_token": 3.2918, "tokens_per_byte": 0.303782 }, "val": { "records": 3769, "tokens": 7889546, "bytes_utf8": 25980528, "utf8_bytes": 25980528, "bpb_denominator": "bytes_utf8", "bytes_per_token": 3.293, "tokens_per_byte": 0.303672 }, "input": "data/experts/math/slices/train_slice_all.jsonl.gz", "record_split": "documents longer than 20,000 characters were cut into parts at whitespace (prep_data.py --max_record_chars)"}1234567891011121314151617181920{ "files": [ "train-00004-of-00114-3158c787ea8296d3.parquet", "train-00005-of-00114-c525c7efee442287.parquet", "train-00006-of-00114-c82ec070af45d226.parquet", "train-00007-of-00114-36c74b525c9694d4.parquet", "train-00008-of-00114-bf41cf8843148a70.parquet", "train-00009-of-00114-691ac94b115fea46.parquet", "train-00010-of-00114-5805e25b4884966e.parquet", "train-00011-of-00114-da8ee2fcf07be148.parquet", "train-00012-of-00114-7252b11ca4b39acd.parquet", "train-00013-of-00114-a189dcaf5ac68c7e.parquet", "train-00014-of-00114-23a118ee3aaea5c3.parquet", "train-00015-of-00114-e65817847eac684c.parquet" ], "records": 662940, "words": 816023053, "skipped_heldout_url": 1824, "seconds": 351}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165{ "run": "math0_shared32k_d125m_ctx1024", "preset": "d125m", "model_config": { "vocab_size": 32000, "block_size": 1024, "n_layer": 12, "n_head": 12, "n_embd": 768, "dropout": 0.0, "bias": false, "mlp_ratio": 4, "rope": true, "qk_norm": true, "untied_head": true, "relu_sq": true, "value_embed": false, "value_embed_layers": "" }, "param_counts": { "total": 134105856, "embedding": 24576000, "token_embedding": 24576000, "position_embedding": 0, "value_embedding": 0, "head": 24576000, "non_embedding": 84953856 }, "tokenizer": "data/experts/shared/tokenizers/spm_shared_unigram_32000_v1.model", "steps": 27106, "tokens_seen": 1332314112, "tokens_per_step": 49152, "batch_size": 12, "grad_accum": 4, "block_size": 1024, "compiled": true, "dtype": "bf16", "best_val_loss": 2.35255, "best_bpb": 1.03066, "mean_tok_s": 24948.8, "median_tok_s": 25088.9, "peak_gpu_mem_alloc_gb": 9.102, "wall_seconds": 53361.8, "evals": [ { "step": 10000, "val_loss": 2.5602, "bpb": 1.1217, "tokens_seen": 491520000, "t": 19685.4 }, { "step": 12000, "val_loss": 2.5196, "bpb": 1.1038, "tokens_seen": 589824000, "t": 23639.6 }, { "step": 14000, "val_loss": 2.4853, "bpb": 1.0888, "tokens_seen": 688128000, "t": 27574.4 }, { "step": 16000, "val_loss": 2.4527, "bpb": 1.0745, "tokens_seen": 786432000, "t": 31509.3 }, { "step": 18000, "val_loss": 2.4244, "bpb": 1.0621, "tokens_seen": 884736000, "t": 35442.3 }, { "step": 20000, "val_loss": 2.3989, "bpb": 1.051, "tokens_seen": 983040000, "t": 39378.0 }, { "step": 22000, "val_loss": 2.3804, "bpb": 1.0429, "tokens_seen": 1081344000, "t": 43312.8 }, { "step": 24000, "val_loss": 2.3654, "bpb": 1.0363, "tokens_seen": 1179648000, "t": 47247.5 }, { "step": 26000, "val_loss": 2.3561, "bpb": 1.0322, "tokens_seen": 1277952000, "t": 51183.3 }, { "step": 27106, "val_loss": 2.3525, "bpb": 1.0307, "tokens_seen": 1332314112, "t": 53361.8 } ], "args": { "data_dir": "data/experts/math/train/math0_shared32k", "runs_dir": "data/experts/math/train/runs", "run": "math0_shared32k_d125m_ctx1024", "preset": "d125m", "n_layer": 0, "n_head": 0, "n_embd": 0, "block_size": 1024, "batch_size": 12, "grad_accum": 4, "lr": 0.001, "min_lr_frac": 0.1, "warmup_steps": 500, "max_steps": 27106, "weight_decay": 0.1, "optim": "muon", "muon_lr": 0.02, "muon_momentum": 0.95, "rope": true, "qk_norm": true, "untied_head": true, "relu_sq": true, "value_embed": false, "value_embed_layers": "", "schedule": "cosine", "warmdown_frac": 0.4, "beta1": 0.9, "beta2": 0.95, "grad_clip": 1.0, "dropout": 0.0, "log_interval": 50, "eval_interval": 2000, "eval_batches": 40, "eval_batch_size": 0, "ckpt_minutes": 10.0, "time_budget_min": 1300.0, "compile": 1, "dtype": "bf16", "resume": true, "seed": 1337, "sample_tokens": 120, "sample_temperature": 0.8, "sample_top_k": 100, "prompt": "Let $f(x) = x^2 + 1$. Then", "probe_steps": 0, "device": "cuda" }, "data_dir": "data/experts/math/train/math0_shared32k"}CHANGELOG.mdAdded+9
LICENSEAdded+16
LICENSE-CODEAdded+4
README.mdAdded+280
config.jsonAdded+35
configuration_mume.pyAdded+79
eval/bpb_clean_ctx1024.jsonAdded+53
eval/bpb_ctx1024.jsonAdded+63
eval/bpb_ctx512.jsonAdded+63
eval/contamination_overlap.jsonAdded
eval/english_model_bpb_clean_ctx1024.jsonAdded+53
eval/english_model_bpb_ctx1024.jsonAdded+63
eval/english_model_gsm8k_exact_3shot.jsonAdded
eval/gsm8k_exact_3shot.jsonAdded
eval/gsm8k_exact_3shot_released_weights.jsonAdded
eval/heldout_meta.jsonAdded+23
eval/smoke_test.jsonAdded+44
eval/verification.jsonAdded+162
generation_config.jsonAdded+10
model.safetensorsAdded+3
modeling_mume.pyAdded+281
special_tokens_map.jsonAdded+6
tokenization_mume.pyAdded+93
tokenizer.jsonAdded
tokenizer.modelAdded+3
tokenizer_config.jsonAdded+19
training/data_meta.jsonAdded+48
training/slice_summary.jsonAdded+20
training/summary.jsonAdded+165