Views
No views yet
pinanolm_core) powers every current and future variant
(20M, 50M, 100M, 250M, Instruct, Code, Math, Security, Embed, Vision). It keeps
the clean, from-scratch PyTorch architecture of the family and scales capacity
(hidden 512, 16 layers, 16 heads, SwiGLU, 2048-token context) for meaningfully
better generation quality than PiNanoLM-50M while remaining practical on edge
devices after quantization.scaled_dot_product_attention (auto), manual fallback| Component | PiNanoLM-50M (V2) | PiNanoLM-100M (V3) |
|---|---|---|
| Parameters | 49,972,608 | 102,777,344 |
| Hidden size | 384 | 512 |
| Layers | 12 | 16 |
| Attention heads | 12 (head_dim 32) | 16 (head_dim 32) |
| FFN intermediate | 2192 | 2816 |
| FFN activation | SwiGLU | SwiGLU |
| Context length | 1024 | 2048 |
| KV cache | (added) | yes |
| Positional encoding | RoPE (theta=10000) | RoPE (theta=10000) |
| Normalization | RMSNorm (eps 1e-5) | RMSNorm (eps 1e-5) |
| Attention | flash (SDPA) + fallback | flash (SDPA) + fallback |
| Weight tying | Yes | Yes |
| Vocabulary | 32,768 (BPE) | 32,768 (BPE, same tokenizer) |
pinanolm_core/variants.py):| Variant | Params (est.) |
|---|---|
| pinanolm-20m | 19,798,272 |
| pinanolm-50m | 49,972,608 |
| pinanolm-100m | 102,777,344 |
| pinanolm-250m | 219,839,232 |
1pinanolm-100m/
2 pinanolm_core/ # SHARED engine: config, model, generation, data, utils, variants
3 pinanolm_100m/ # 100M preset (Pinanolm100mConfig / Pinanolm100mForCausalLM)
4 pinanolm_50m/ # 50M preset (backwards-compatible over shared engine)
5 pinanolm_20m/ # 20M preset - V1 backwards-compatibility over shared engine
6 models/ # re-export of the shared model engine + all presets
7 tokenizer/ # tokenizer loader (shared family BPE)
8 dataprep/ # dataset mixtures + quality report (thin re-export)
9 preprocessing/ # text cleaning / tokenization helpers
10 configuration/ # config + variant registry re-export
11 utilities/ # logging, collate, checkpoint I/O
12 training/ # train.py (AMP, grad accum, ckpt, rotation, early-stop, DDP)
13 inference/ # generate.py CLI + programmatic Generator
14 export/ # export_all.py (TorchScript, ONNX, INT8, GGUF)
15 benchmark/ # benchmark.py (tok/s, latency, RAM, CPU, load time)
16 benchmarking/ # re-export of the benchmark routine
17 quantization/ # re-export of edge quantization exports
18 evaluation/ # evaluate.py (val loss, perplexity, throughput, samples)
19 scripts/ # train_tokenizer.py, preprocess.py, upload_hf.py
20 tests/ # unit tests (27)
21 examples/ # run_pipeline.py
22 config.json generation_config.json
23 tokenizer.json tokenizer_config.json special_tokens_map.json
24 requirements.txt LICENSE README.md MODEL_CARD.md
25 docs/ (TRAINING, INFERENCE, BENCHMARK, EDGE, FINETUNING, CONTRIBUTING)1git clone https://huggingface.co/ismailtasdelen/pinanolm-100m
2cd pinanolm-100m
3pip install -r requirements.txt1import json, torch
2from pinanolm_100m import Pinanolm100mConfig, Pinanolm100mForCausalLM
3from tokenizers import Tokenizer
4from safetensors.torch import load_model
5
6cfg = Pinanolm100mConfig.from_dict(json.load(open("config.json")))
7model = Pinanolm100mForCausalLM(cfg).eval()
8load_model(model, "checkpoints/model.safetensors")
9tok = Tokenizer.from_file("tokenizer.json")
10
11ids = torch.tensor([tok.encode("The history of computing is").ids])
12out = model.generate(ids, max_new_tokens=64, temperature=0.9, top_k=40,
13 top_p=0.9, typical_p=0.95, repetition_penalty=1.1)
14print(tok.decode(out[0].tolist()))checkpoints/checkpoint_latest.pt.1# 1. (tokenizer is reused from the family; retrain only if explicitly needed)
2# 2. preprocess corpus -> token shards (shared pipeline, with quality report)
3python scripts/preprocess.py --corpus-dir data/corpus \
4 --tokenizer tokenizer.json --seq-len 2048 --out data/tokenized --quality-report
5# 3. train
6python training/train.py --config config.json --data data/tokenized \
7 --out checkpoints --epochs 2 --batch-size 8 --grad-accum 8 \
8 --precision bf16 --grad-checkpointing --report-qualitypinanolm_core.data module also
supports configurable mixtures of Hugging Face streaming sources -
FineWeb-Edu, TinyStories, Wikipedia, public-domain books - via
scripts/preprocess.py --mix "local:0.5,fineweb-edu:0.5". For production
pretraining, swap in FineWeb-Edu.1python inference/generate.py --prompt "Explain HTTP." --max-new-tokens 128
2python inference/generate.py --prompt "Once upon a time" --stream \
3 --temperature 0.8 --top-k 40 --top-p 0.9 --typical-p 0.95 \
4 --repetition-penalty 1.1 --presence-penalty 0.2temperature, top_k, top_p, typical_p (locally-typical
sampling), repetition_penalty, presence_penalty, frequency_penalty,
max_new_tokens, batched prompts (--prompts-file) and token streaming
(--stream). Generation uses a KV cache for efficient autoregressive decode.1python evaluation/evaluate.py --config config.json \
2 --safetensors checkpoints/model.safetensors --out evaluation_report.json1python export/export_all.py --config config.json \
2 --safetensors checkpoints/model.safetensors --out export \
3 --formats torchscript onnx int8 gguf --llama-cpp ~/llama.cppexport/model_torchscript.ptexport/model.onnxexport/model_int8.ptexport/pinanolm-100m-f16.gguf (direct) + q8_0 / q4_k_m
(via llama.cpp). PiNanoLM's RoPE+RMSNorm+SwiGLU+tied layout maps onto the
llama architecture for convert_hf_to_gguf.py.1python benchmark/benchmark.py --config config.json \
2 --safetensors checkpoints/model.safetensors
3python benchmark/benchmark.py --compare --variant pinanolm-50m --variant pinanolm-100mbenchmark_result.json). Run on x86, RPi 4 and RPi 5 to compare across
devices.python -m unittest discover -s testspinanolm_20m re-exposes the original Pinanolm20mConfig / Pinanolm20mForCausalLM
API on top of the shared engine (GELU FFN, ctx 512), so existing V1 code and the
shared tokenizer keep working unchanged. pinanolm_50m is the V2 preset.pinanolm_core/variants.py: PiNanoLM-250M, PiNanoLM-Instruct, PiNanoLM-Code,
PiNanoLM-Math, PiNanoLM-Security, PiNanoLM-Embed, PiNanoLM-Vision. The shared
engine handles architecture, training, inference, export and benchmarking for
all of them.1@misc{pinanolm100m2026,
2 title = {PiNanoLM-100M: A Lightweight Transformer Foundation Model for Edge Devices},
3 author = {Ismail Tasdelen and contributors},
4 year = {2026},
5 url = {https://huggingface.co/ismailtasdelen/pinanolm-100m}
6}