|
Download README.md from edededdy/LittleKedi-medium-wide-sparse-base: direct link, hf CLI and curl.
- Browser
- Download file 17.7 kB
-
https://huggingface.co/edededdy/LittleKedi-medium-wide-sparse-base/resolve/main/README.md
- Command line
-
hf download hf://edededdy/LittleKedi-medium-wide-sparse-base/README.md
-
curl -L -o README.md https://huggingface.co/edededdy/LittleKedi-medium-wide-sparse-base/resolve/main/README.md
17.7 kB
| license: apache-2.0 | |
| language: | |
| - en | |
| pipeline_tag: text-generation | |
| datasets: | |
| - HuggingFaceFW/fineweb-edu | |
| - HuggingFaceTB/smollm-corpus | |
| - HuggingFaceTB/finemath | |
| - HuggingFaceGECLM/REDDIT_comments | |
| - codeparrot/github-code-clean | |
| - HuggingFaceTB/smoltalk | |
| - wikimedia/wikipedia | |
| tags: | |
| - mixture-of-experts | |
| - moe | |
| - deepseek | |
| - multi-head-latent-attention | |
| - mla | |
| - from-scratch | |
| - tiny | |
| - littlekedi | |
| - base | |
| <p align="center"><img src="little_kedi.jpg" alt="LittleKedi logo" width="640"></p> | |
| # LittleKedi-medium-wide-sparse-base | |
| `LittleKedi-medium-wide-sparse-base` is a **small DeepSeek-V3-style Mixture-of-Experts language model trained from scratch**. It has | |
| **305.4M parameters** in total, of which **31.7M are active per token** | |
| (23.29M excluding the embedding table). It was pretrained on a 20,400M-token mix (FineWeb-Edu, Cosmopedia v2 (SmolLM-Corpus), FineMath 4+, Reddit comments, github-code-clean, SmolTalk, Wikipedia (English, 2023-11-01)). | |
| *Part of the LittleKedi family. Not affiliated with DeepSeek.* | |
| This is the **base model**, before any instruction tuning. It continues text; it doesn't follow instructions. It's an educational and research artifact: it writes fluent, on-topic English but **knows few facts and confidently makes things up**. Don't use it for anything that matters. | |
| ## The LittleKedi family | |
| LittleKedi is a family of small DeepSeek-V3-style Mixture-of-Experts language models trained from | |
| scratch. Every size comes in three variants that differ in **how sparse** they are: how many routed experts | |
| they have, and what share of their parameters a token actually passes through. | |
| | Variant | Routed experts | | |
| |---|---| | |
| | **standard** (`<size>`) | a few wide experts; the densest variant | | |
| | **sparse** (`<size>-sparse`) | many narrower, fine-grained experts, more of them active per token | | |
| | **wide-sparse** (`<size>-wide-sparse`) | more experts again; the largest total and smallest active share | | |
| More experts means more total capacity to store knowledge, but each expert | |
| sees fewer tokens (tokens Γ top-k Γ· experts per layer), so sparser variants need more training data before | |
| their experts are well trained. The variants of a size share a tokenizer and dataset, so they can be | |
| compared directly. Shapes change as the family scales; the table below is generated from the current | |
| presets. | |
| This card is for **`medium-wide-sparse`**, the **wide-sparse** medium model: 31.7M of its 305.4M parameters (10%) are active per token. Its siblings are `medium` and `medium-sparse`. | |
| | Model | Variant | Vocab | Total | Active | Active non-emb. | Active % | Routed experts | | |
| |---|---|---|---|---|---|---|---| | |
| | `tiny` | standard | 8K | 2.0M | 1.5M | 0.5M | 78% | 8 Γ 64, top-2 | | |
| | `tiny-sparse` | sparse | 8K | 2.6M | 1.6M | 0.5M | 60% | 32 Γ 32, top-4 | | |
| | `tiny-wide-sparse` | wide-sparse | 8K | 3.8M | 1.6M | 0.5M | 42% | 64 Γ 32, top-4 | | |
| | `mini` | standard | 8K | 9.4M | 4.8M | 3.2M | 51% | 12 Γ 128, top-3 | | |
| | `mini-sparse` | sparse | 8K | 19.8M | 4.8M | 3.2M | 24% | 64 Γ 64, top-6 | | |
| | `mini-wide-sparse` | wide-sparse | 8K | 36.4M | 4.9M | 3.3M | 13% | 128 Γ 64, top-6 | | |
| | `small` | standard | 8K | 12.2M | 6.3M | 4.2M | 52% | 16 Γ 128, top-4 | | |
| | `small-sparse` | sparse | 8K | 24.1M | 6.4M | 4.3M | 27% | 80 Γ 64, top-8 | | |
| | `small-wide-sparse` | wide-sparse | 8K | 43.9M | 6.5M | 4.4M | 15% | 160 Γ 64, top-8 | | |
| | `moderate` | standard | 16K | 45.5M | 18.9M | 12.6M | 42% | 24 Γ 192, top-4 | | |
| | `moderate-sparse` | sparse | 16K | 93.5M | 19.1M | 12.8M | 20% | 120 Γ 96, top-8 | | |
| | `moderate-wide-sparse` | wide-sparse | 16K | 173.4M | 19.4M | 13.1M | 11% | 240 Γ 96, top-8 | | |
| | `medium` | standard | 16K | 78.2M | 31.0M | 22.6M | 40% | 24 Γ 256, top-4 | | |
| | `medium-sparse` | sparse | 16K | 163.4M | 31.3M | 22.9M | 19% | 120 Γ 128, top-8 | | |
| | **`medium-wide-sparse` β this model** | **wide-sparse** | **16K** | **305.4M** | **31.7M** | **23.3M** | **10%** | **240 Γ 128, top-8** | | |
| | `base` | standard | 32K | 258.7M | 105.4M | 80.2M | 41% | 32 Γ 256, top-6 | | |
| | `base-sparse` | sparse | 32K | 542.8M | 106.3M | 81.2M | 20% | 160 Γ 128, top-12 | | |
| | `base-wide-sparse` | wide-sparse | 32K | 1015.9M | 107.6M | 82.4M | 11% | 320 Γ 128, top-12 | | |
| "Active" counts everything a token passes through: embeddings, attention, the dense layer, shared | |
| experts and its top-k routed experts. "Active non-embedding" leaves out the embedding table (tied with the | |
| output head), which costs memory but almost no compute; it's the fair number for comparing compute | |
| between models. | |
| ## Architecture | |
| | Component | This model | | |
| |---|---| | |
| | Parameters | 305.36M total, 31.68M active per token (10%), 23.29M active non-embedding | | |
| | Layers / hidden size | 8 / 512 (the first 2 layers have a dense SwiGLU FFN of 1408; layers 2β7 are MoE) | | |
| | Attention | **Multi-head Latent Attention (MLA)**: 8 heads, KV latent 128, query latent 256, decoupled RoPE dim 32, head dims 64+32 (q/k) and 64 (v). The KV cache stores only the 128-dim latent plus a 32-dim RoPE key per token | | |
| | MoE | **DeepSeekMoE**: 240 routed experts (SwiGLU, 128 hidden), top-8, plus 2 shared experts; sigmoid gating; group-limited routing (8 groups, top-4) | | |
| | Load balancing | **Auxiliary-loss-free** bias balancing (update speed 0.001) plus a small sequence-wise loss (Ξ± = 0.0001). Over the second half of training the median batch put 1.92Γ the mean load on the busiest expert (2.28Γ in the worst layer), and 0.26% of expert assignments were dropped for capacity. | | |
| | Expert dispatch | Training: fixed capacity (capacity factor 2.0; overflow assignments are dropped). Inference is always dropless | | |
| | Embeddings | Input embedding and output head **tied** | | |
| | Context | 2,048 tokens | | |
| ## Training | |
| | | | | |
| |---|---| | |
| | Data | 20,400M tokens, 27,145,344 documents (~67 tokens per parameter, ~644 per active parameter), one pass, sources interleaved throughout (mix below) | | |
| | Tokenizer | Byte-level BPE, 16,384 tokens (~4.00 bytes/token on this mix); digits split individually; chat special tokens built in | | |
| | Steps | 311,279 Γ 65,536 tokens (batch 16 Γ 2048 Γ 2 accumulation) | | |
| | Optimizer | **Muon** (momentum 0.95, Nesterov, 5 Newton-Schulz steps; each expert's matrix orthogonalized separately) for hidden matrices, AdamW (Ξ² = 0.9, 0.95) for embeddings, norms and the router; weight decay 0.1, gradient clipping 1.0 | | |
| | Learning rate | 2e-3 peak; **WSD**: 200 warm-up steps, constant, then linear decay to 0 over the last 20% of steps (schedule set for 311,279 steps) | | |
| | Precision | bf16 autocast, `torch.compile` | | |
| | Compute | ~2.9e18 FLOPs (6 Γ active non-embedding parameters Γ tokens) | | |
| | Hardware | One rented NVIDIA GPU at a time on RunPod (Secure cloud), resumed across several pods; the second half on an A40 and RTX 3090s: about 76.7 hours at a median ~73.9K tokens/s | | |
| | Source | What it is | Tokens | Share | | |
| |---|---|---|---| | |
| | FineWeb-Edu `sample/100BT` | educational web pages | 11,820M | 58% | | |
| | Cosmopedia v2 (SmolLM-Corpus) | synthetic textbooks and stories | 2,446M | 12% | | |
| | FineMath 4+ | maths web pages | 1,875M | 9% | | |
| | Reddit comments | forum comments | 1,630M | 8% | | |
| | github-code-clean | source code | 958M | 5% | | |
| | SmolTalk | chat conversations | 917M | 4% | | |
| | Wikipedia (English, 2023-11-01) | encyclopedia articles | 754M | 4% | | |
| ## Evaluation | |
| | Metric | Value | | |
| |---|---| | |
| | Validation loss (nats/token, held-out mix) | **2.340** | | |
| | Perplexity | 10.4 | | |
| | Bits per byte | 0.854 | | |
| | Validation loss: code | 1.160 | | |
| | Validation loss: cosmo-v2 | 1.823 | | |
| | Validation loss: finemath | 1.842 | | |
| | Validation loss: fineweb-edu-100bt | 2.641 | | |
| | Validation loss: reddit | 2.907 | | |
| | Validation loss: smoltalk | 1.344 | | |
| | Validation loss: wikipedia | 2.604 | | |
| | Experts never chosen on the validation sample | 0 | | |
| Validation loss over training: 5.05 (16M tok) β 2.78 (2,933M tok) β 2.75 (5,849M tok) β 2.74 (8,766M tok) β 2.73 (11,665M tok) β 2.73 (14,582M tok) β 2.66 (17,498M tok) β 2.34 (20,400M tok) | |
| ### Zero-shot benchmarks (`evals.py`) | |
| | Task | acc_norm | acc | Items | Chance | | |
| |---|---|---|---|---| | |
| | SciQ | 72.2% Β± 1.4% | 78.8% | 1,000 | 25% | | |
| | ARC-Easy | 47.1% Β± 1.0% | 53.2% | 2,376 | 25% | | |
| | HellaSwag | 36.0% Β± 0.5% | 31.3% | 10,042 | 25% | | |
| Each answer choice is scored by the log-probability of its text after the prompt, using lm-evaluation-harness | |
| prompts (SciQ includes its supporting passage). **acc_norm** divides by the answer's length in characters; | |
| **acc** doesn't. Splits: SciQ test, ARC-Easy test, HellaSwag validation. | |
| ### MMLU (`mmlu_eval.py`) | |
| | Format | Accuracy | Questions scored | Average few-shot examples | | |
| |---|---|---|---| | |
| | letter | 24.5% | 14,042 (skipped 0) | 4.9 | | |
| | cloze | 27.8% | 14,042 (skipped 0) | 0.0 | | |
| | Category | Subjects | Questions | Letter | Cloze | | |
| |---|---|---|---|---| | |
| | STEM | 19 | 3,153 | 23.8% | 25.9% | | |
| | Humanities | 13 | 4,705 | 25.1% | 26.1% | | |
| | Social Sciences | 12 | 3,077 | 23.2% | 29.9% | | |
| | Other | 13 | 3,107 | 25.5% | 30.4% | | |
| **Biology & medicine (cloze): 29.9% on 2,094 questions**, +4.9 points against 25% chance (about 5.2 standard errors, significant). This pools the 10 life-science and health subjects; it isn't an official MMLU category. | |
| In the **letter** format the model compares " A"β" D", with same-subject examples added while they fit the | |
| context. In the **cloze** format each answer's text is scored by log-probability per byte; at this size the | |
| cloze results are the meaningful ones. Chance is 25%. | |
| ### Compared with its siblings and other small models | |
| | | **This model** | `moderate-wide-sparse` | [Pythia-70M](https://huggingface.co/EleutherAI/pythia-70m) | [GPT-2](https://huggingface.co/openai-community/gpt2) | [Supra-50M](https://huggingface.co/SupraLabs/Supra-50M-Base) | | |
| |---|---|---|---|---|---| | |
| | Parameters (total) | 305.4M | 173.4M | 70.4M | 124.4M | 51.8M | | |
| | Active non-embedding parameters | 23.3M | 13.1M | 18.9M | 85.1M | 35.4M | | |
| | Training tokens | 20,400M | 12,500M | 300B (the Pile) | undisclosed (WebText) | 20B (FineWeb-Edu) | | |
| | SciQ (acc_norm) | 72.2% | 68.6% | 55.2% | 53.2% | 77.2% | | |
| | ARC-Easy (acc_norm) | 47.1% | 45.2% | 35.0% | 42.0% | 52.2% | | |
| | HellaSwag (acc_norm) | 36.0% | 32.8% | β | 29.5% | 31.8% | | |
| | MMLU (cloze) | 27.8% | 27.4% | β | β | β | | |
| | MMLU biology & medicine (cloze) | 29.9% | 29.1% | β | β | β | | |
| | Validation loss (held-out mix) | 2.340 | 2.478 | β | β | β | | |
| LittleKedi columns are measured with this repo's `evals.py` and `mmlu_eval.py` on the checkpoints named. Validation | |
| losses are only comparable between models that share a tokenizer and validation set. The other columns are | |
| **published figures**: Pythia-70M from EleutherAI's evaluations as quoted on the | |
| [Wisp-15M card](https://huggingface.co/DedeProGames/Wisp-15M), GPT-2 and Supra-50M from the | |
| [Supra-50M-Base card](https://huggingface.co/SupraLabs/Supra-50M-Base). Their prompts may differ from ours, | |
| so treat gaps of a few points as noise. | |
| ## What it can and can't do | |
| The sparsest medium model: about 23.3M active non-embedding parameters per token, spread over 240 narrow experts | |
| (305M parameters in total), trained on 20.4B tokens. It's the strongest LittleKedi so far: validation loss | |
| **2.340** (moderate-wide-sparse: 2.478; the validation sets differ slightly), and better than `moderate-wide-sparse` | |
| on every benchmark. The gains are about what ~2.9x the training compute should buy, not a jump in kind: it gets the | |
| most common facts right reliably now, but it's still a model of **the form of text more than its content**, and | |
| specific facts, numbers and code are usually wrong. A research artifact for studying sparsity in small MoE models, | |
| not a source of information. | |
| Most of its quality arrived in the last 20% of training. Validation loss sat on a plateau of ~2.73 for most of the | |
| run and fell by ~0.39 during the learning-rate decay, about three times the usual cooldown gain, which suggests the | |
| peak learning rate (2e-3) was higher than it needed to be. | |
| **What it does** | |
| - β Writes fluent, well-organised paragraphs in the register of textbooks, encyclopedias and educational web text, | |
| staying on topic for a paragraph or more. | |
| - β Gets the most common facts right reliably: *"The French Revolution began in"* β *"1789"*, *"World War II ended | |
| in"* β *"1945"* and *"The first person to walk on the Moon was"* β *"Neil Armstrong"* (each 3 of 3 seeds; the | |
| Moon landing's *"1969"* on 2 of 3), *"The capital of France is"* β *"Paris"* (2 of 3), *"Photosynthesis is the | |
| process by which"* β *"plants convert light energy into chemical energy"* (2 of 3), *"The heart pumps"* β | |
| *"blood through the body to supply oxygen and nutrients to all cells"*. Einstein is *"born in 1879"* on 2 of 3 | |
| seeds and *"a German-born physicist"* on the third. | |
| - β Occasionally writes correct short code: one seed of *"def is_prime(n):"* produced the standard trial-division | |
| loop up to `int(n**0.5) + 1`. It knows the shape of common functions (docstrings, base cases, recursion) even | |
| when the logic is wrong (below). | |
| - β The best benchmark scores in the family (zero-shot): **SciQ 72.2%** (acc_norm; 78.8% acc), **ARC-Easy 47.1%** | |
| (53.2% acc), **HellaSwag 36.0%**, **PIQA 64.7%**, **ARC-Challenge 26.3%**, **ArithMark-3 37.8%**, up from | |
| 68.6 / 45.2 / 32.8 / 62.0 / 25.4 / 36.2 for `moderate-wide-sparse`. On the Open SLM Leaderboard's Intelligence | |
| Index that's **~19.4**, against ~15.9 for moderate. | |
| - β Above chance on MMLU in the cloze format: **27.8%** overall, ~30% on the social sciences and "other" | |
| categories. STEM (25.9%) and the humanities (26.1%) are still at about chance, and the multiple-choice letter | |
| format is at chance too (24.5%). | |
| **What it can't do** | |
| - β **Less common facts.** *"The chemical symbol for gold is"* β *"Cu"* or *"Pt"*; *"The largest planet in the | |
| solar system is"* β *"Ganymede"*, *"the Earth"* or a comparison with Mercury; *"Water boils at"* β *"100Β°C"* on | |
| one seed, *"100 degrees Fahrenheit"* and *"103.6 degrees Fahrenheit"* on the others. Around a right answer the | |
| details are made up: Einstein *"born in Budapest, Hungary"* or *"in St. Petersburg, Russia"*, France *"ruled by | |
| King Louis XVI⦠a monarchy under Napoleon III"*. Right and wrong answers come with the same confidence. | |
| - β **Arithmetic beyond the very simplest.** *"2 + 2 ="* β *"4"* on 2 of 3 seeds (*"5"* on the third), but | |
| *"7 + 6 ="* β *"14"*, *"15"* or a multiple-choice question whose marked answer is *"45"*. | |
| - β **Working code, most of the time.** Its Fibonacci is wrong on every seed (*"return 2 * fibonacci(n - 1) + | |
| fibonacci(n - 2)"*, or the triangle-number formula), and two of three `is_prime` completions are just | |
| *"return n % 2 == 0"*. | |
| - β **Instructions or questions.** It's a base model: it continues text. Asked *"What is the largest planet in the | |
| solar system?"* in a `User:` / `Assistant:` exchange, it repeats the question, writes a quiz page, or continues | |
| a dialogue that names Mercury or Pluto. | |
| - β **Long-range coherence.** A paragraph holds together; beyond that it drifts and repeats. | |
| **Decoding** | |
| Greedy decoding still loops, though later than the smaller models (*"The heart is a muscle that pumps blood | |
| throughout the body. It is a muscle that is made up of two parts⦠The heart is a muscle that is made up"*). Use | |
| sampling with **temperature β 0.7, top-p β 0.9 and a repetition penalty of about 1.15**. | |
| ## Usage | |
| **PyTorch** (needs the `littlekedi` package from [the training code](https://github.com/EdmundMartin/LittleKedi)): | |
| ```python | |
| import json, torch | |
| from safetensors.torch import load_file | |
| from littlekedi import LittleKediModel, ModelConfig | |
| from littlekedi.tokenizer import BPETokenizer | |
| model = LittleKediModel(ModelConfig.from_dict(json.load(open("config.json")))).eval() | |
| model.load_state_dict(load_file("model.safetensors")) | |
| tok = BPETokenizer.from_file("tokenizer.json") | |
| ids = torch.tensor([[tok.eot_id] + tok.encode("Photosynthesis is")]) | |
| print(tok.decode(model.generate(ids, 60, temperature=0.7, top_p=0.9, repetition_penalty=1.15)[0].tolist())) | |
| ``` | |
| Or interactively: `python sample.py --ckpt <checkpoint>.pt`. Base models are released as PyTorch weights only; | |
| GGUF builds come with the instruct models. | |
| ## Files | |
| | File | Contents | | |
| |---|---| | |
| | `model.safetensors` | PyTorch weights (embedding tied with the output head), `littlekedi` parameter names | | |
| | `config.json` | `ModelConfig` for `littlekedi` | | |
| | `tokenizer.json` | Byte-level BPE tokenizer (Hugging Face `tokenizers` format) | | |
| | `little_kedi.jpg` | The LittleKedi logo | | |
| ## Acknowledgements | |
| - The architecture follows **DeepSeek-V3** (DeepSeek-AI, 2024): MLA, DeepSeekMoE and auxiliary-loss-free balancing. | |
| - **Muon** (Keller Jordan et al., 2024) with Moonlight's update scaling (Liu et al., 2025). | |
| - Pretraining data: **FineWeb-Edu** (ODC-BY 1.0). | |
| - Pretraining data: **Cosmopedia v2** (ODC-BY 1.0). | |
| - Pretraining data: **FineMath 4+** (ODC-BY 1.0). | |
| - Pretraining data: **Reddit comments** (no license stated on the dataset card; the comments are Reddit users' content). | |
| - Pretraining data: **github-code-clean** (Apache 2.0, with each file under its own open-source license). | |
| - Pretraining data: **SmolTalk** (Apache 2.0 for its new subsets, with the datasets it includes under their own licenses). | |
| - Pretraining data: **Wikipedia** (CC BY-SA 3.0 and GFDL). | |
| *Card generated 2026-10-30 by `prepare_release.py` from `medium-wide-sparse.pt` (step 311278).* | |