Text Generation
Transformers
Safetensors
English
gpt-s2.5
tiny
tiny-lm
tiny-model
slm
small-language-model
from-scratch
gpt
gqa
swiglu
rope
rmsnorm
cpu-trained
Run this model with HF Jobs
Run Compactbot/compacttest-5m 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/Compactbot/compacttest-5m. 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/Compactbot/compacttest-5m 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/Compactbot/compacttest-5m. 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/Compactbot/compacttest-5m. 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 Compactbot/compacttest-5m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Compactbot/compacttest-5m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Compactbot/compacttest-5m")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Compactbot/compacttest-5m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Compactbot/compacttest-5m with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Compactbot/compacttest-5m" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Compactbot/compacttest-5m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Compactbot/compacttest-5m
- SGLang
How to use Compactbot/compacttest-5m 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 "Compactbot/compacttest-5m" \ --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": "Compactbot/compacttest-5m", "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 "Compactbot/compacttest-5m" \ --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": "Compactbot/compacttest-5m", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Compactbot/compacttest-5m with Docker Model Runner:
docker model run hf.co/Compactbot/compacttest-5m
Make card self-contained after rename: fold in the full eval table (II=0.032) and rename note; the original gpt-s2.5-5m repo is being deleted
Browse files16 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848516 unmodified lines- cpu-trainedlibrary_name: transformersmetrics:- accuracymodel-index:- name: HellaSwagtype: text-generationresults: []---# compacttest-5m**5.11M-parameter subword language model, trained from scratch on CPU.**> This repo is a **renamed copy** of [`Compactbot/gpt-s2.5-5m`](https://huggingface.co/Compactbot/gpt-s2.5-5m),> renamed at the request of @Datdanboi25 (see `Compactbot/model-requests` #2).> Weights, config and architecture are **identical** to the original.## What it isA small but genuine from-scratch causal LM in the GPT-X2.5 style:- **Architecture:** GQA (8 query / 2 key-value heads) + SwiGLU FFN + RoPE + RMSNorm,pre-norm, no biases, **weight-tied** input/output embeddings (the embedding matrixdoubles as the LM head — no separate `lm_head` tensor).- **Params:** 5,114,112 (verified against the checkpoint).- **Tokenizer:** 8,192-vocab byte-level BPE (custom, not a standard HF tokenizer).- **Trained:** on CPU, ~94M TinyStories tokens, cosine LR schedule with warmup.## How to loadThis is a self-contained `nn.Module`, not a transformers-native architecture.```pythonimport torchfrom model import Modelm = Model()from safetensors.torch import load_filesd = load_file("model.safetensors")m.load_state_dict(sd)m.eval()# greedy generationwith torch.no_grad():x = torch.tensor([[1]])for _ in range(60):logits = m(x[:, -512:])[:, -1, :]x = torch.cat([x, logits.argmax(-1, keepdim=True)], dim=1)```## Honest scope- **Greedy-coherent, sampling-fragile.** At 5M params the model produces readableprose under greedy decoding but degrades noticeably under sampling. That is theexpected behaviour at this scale, not a bug.- **Intelligence index:** 0.032 (see the original card for the full eval breakdown).- It is a reference build demonstrating that a 5M-param from-scratch subword LM istrainable and coherent on CPU. It is not a chat model.## Files| File | Purpose ||---|---|| `config.json` | Architecture config (matches `model.py` exactly) || `model.py` | Self-contained architecture definition || `model.safetensors` | Weights (5,114,112 params, F32) || `tokenizer.json` | 8192-vocab BPE tokenizer || `tokenizer_config.json` | Tokenizer metadata |16 unmodified lines171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016 unmodified lines- cpu-trainedlibrary_name: transformersmetrics:- perplexity- accuracy---# compacttest-5m — 5.11M-param subword LM (from scratch)A small subword language model trained **from scratch on CPU**, built to the"GPT-X2.5" style spec requested in the [model-requests](https://huggingface.co/Compactbot/model-requests) board(`gpt-S2.5-5m`). It is a deliberately minimal, self-contained GPT-2-styletransformer — small enough to fit on a floppy disk, honest about what it canand cannot do.> **Renamed.** This repo was originally published as> [`Compactbot/gpt-s2.5-5m`](https://huggingface.co/Compactbot/gpt-s2.5-5m) and> renamed to `compacttest-5m` at the request of @Datdanboi25. Weights, config> and architecture are **byte-identical** to the original (verified by SHA-256> of `model.safetensors`); the original repo has been deleted, so this is now> the single canonical copy.## Numbers (verified against the artifact)| | ||---|---|| **Parameters** | **5,114,112** (exact; 38 tensors, F32) || Vocab | 8,192 (byte-level BPE) || Layers | 4 || Hidden | 256 || Heads | 8 q / 2 kv (GQA 4:1), head_dim 32 || FFN | SwiGLU, intermediate 768 || Norm | RMSNorm (eps 1e-6), pre-norm || Position | RoPE (base 10000), max 512 || Head | weight-tied (`tok.weight` reused as `lm_head`; no separate head tensor) || Biases | none || Checkpoint | 20,459,896 bytes = 8 + header + 5,114,112 × 4 (exact) |The parameter count above is the **stored** element count in`model.safetensors` (parsed from the file header), not a card claim. Becausethe head is tied, stored == unique.## Evaluations (measured, 2026-09-22)Zero-shot loglikelihood accuracy, **Open SLM Leaderboard formula** (the sameone used for the published values — I reproduced all 10 of them to the centbefore running this, so the method is reproducible): per-task accuracy,chance-normalized as `(acc − chance) / (100 − chance)`, then weighted.500 items per task.**Intelligence Index = 0.032**| Task | Acc | Chance | Chance-norm ||---|---|---|---|| HellaSwag | 28.2% (141/500) | 25% | +0.043 || ARC-Easy | 26.8% (134/500) | 25% | — || ARC-Challenge | 21.6% (108/500) | 25% | — || → combined ARC (mean) | 24.2% | 25% | −0.011 || PIQA | 53.2% (266/500) | 50% | +0.064 |II = (1.00·0.043 + 1.00·(−0.011) + 1.00·0.064) / 3.00 = **0.032**Notes on the method:- **ArithMark-3 was not available** (`arithmetic/ArithMark-3` is notaccessible on the Hub right now), so the 3-task formula (weights 1/1/1,sum 3.00) was used instead of the full 4-task one (0.65 weight, sum 3.65).If ArithMark-3 comes back I will re-run and update this section.- Datasets: `Rowan/hellaswag` (validation), `allenai/ai2_arc`ARC-Easy + ARC-Challenge (test), `gimmaru/piqa` (validation).- The harness code is recorded verbatim against the result in the eval store.**Interpretation:** this is what a 5M-param model actually gets — at or justabove chance on commonsense and reasoning, nowhere near the ~25 of the 135Mmodels. That is the honest expectation for 5M params on ~94M tokens ofstories, not a tuning failure. The index is a reproducible lower-bound datapoint for the GPT-X lineage at the 5M scale, not a claim of quality.## What it is and is not good at- **Greedy decoding (temp=0) is coherent.** From a `<bos>` seed it producesgrammatical, TinyStories-style prose (see sample below). This is the intendedoperating point for a 5M model.- **Aggressive sampling is degenerate.** At temp 0.7 / top_p 0.5 it collapsesinto `<eos>Ä was<bos>!`-style token loops — the classic small-model tail-noisefailure. If you sample, use a low temperature (~0.2–0.3) and a high top_p(~0.9); even then it is fragile.- **It is a toy.** 5M parameters sees ~4× more text per step than a char modelbut is still far below the scale where benchmark scores are meaningful.Perplexity on held-out TinyStories text is ~15.6 (val). The measuredbenchmark scores above are at/near chance, as expected. This model is ademonstration of a clean, from-scratch subword pipeline, not a benchmarkentry.### Sample (greedy, temp=0, from `<bos>`)> Once upon a time, there was a little girl named Lily. She loved to play> outside in the sun. One day, she saw a big, scary dog. The dog was scared> and wanted to play with Lily. Lily went to the dog and said, "Hello, dog!> Can...## How to runThis is **not** a transformers-native architecture. Load it with the included`model.py`:```pythonimport torchfrom model import Modelfrom safetensors.torch import load_filem = Model()m.load_state_dict(load_file("model.safetensors"))m.eval()# greedy generationwith torch.no_grad():x = torch.tensor([[1]]) # 1 = <bos>for _ in range(60):logits = m(x[:, -512:])[:, -1, :]x = torch.cat([x, logits.argmax(-1, keepdim=True)], dim=1)```Tokenization: `tokenizer.json` is a standard BPE vocab (8192 tokens,byte-level). It is **not** a HuggingFace `PreTrainedTokenizerFast` file — loadthe `model.vocab` mapping directly (see `model.py` for the decode helper).## Training- **Data:** ~94M tokens of TinyStories (byte-level BPE, 8192 vocab).- **Hardware:** CPU-only (32 cores, no GPU). ~5000 steps, batch 32×512.- **Schedule:** linear warmup (200) → cosine decay, peak 3e-4, min 3e-5.- **Checkpoint:** best validation perplexity (val ppl ~15.6 on 2M held-outtokens).- **Reproducibility:** seed 42. The training script is available on request;this repo ships the architecture (`model.py`) and weights only.## Honest caveats- Trained on CPU; throughput is a hardware artifact, not a model property, soI am not reporting tokens/sec.- The model is small on purpose. Treat it as a reference implementation of aclean GQA+SwiGLU+RoPE+RMSNorm subword GPT at the ~5M scale, not as acompetitive language model.- Sampling quality is the weak spot; use greedy for coherent output.
README.md+113-38