NanoTransformer
Stage-wise implementation of a tiny causal LM (context_len=3, ~2.1M params).
PyPI install
pip install nanotransformer
CLI entry points (you supply a config JSON):
nanotransformer-train --config /path/to/config.json
nanotransformer-eval --config /path/to/config.json --checkpoint /path/to/checkpoint.pt
nanotransformer-baseline --config /path/to/config.json --k 0.1
nanotransformer-latency --config /path/to/config.json --checkpoint /path/to/checkpoint.pt
Stage 1: Environment
python -m venv venv
source venv/bin/activate
python scripts/install_deps.py
Stage 2: Tokenizer and data
- Download a 50MB English corpus (optional helper):
python scripts/download_corpus.py --out data/corpus.txt --target-mb 50
- Or place your UTF-8 corpus at data/corpus.txt
- Train BPE tokenizer:
python scripts/train_tokenizer.py --corpus data/corpus.txt --vocab-size 10000 --out artifacts/tokenizer.json
- Build token ids and splits:
python scripts/prepare_data.py --corpus data/corpus.txt --tokenizer artifacts/tokenizer.json --out artifacts/data_ids.pt --splits-out artifacts/splits.pt
Stage 3: Train
python train.py --config configs/base.json
Stage 4: Evaluate
python eval.py --config configs/base.json --checkpoint checkpoints/best.pt
Stage 5: Trigram baseline (add-k smoothing)
python baseline_trigram.py --config configs/base.json --k 0.1
Stage 6: Latency
python measure_latency.py --config configs/base.json --checkpoint checkpoints/best.pt --iters 200 --warmup 10
Notes
- Adjust hyperparameters in configs/base.json
- Outputs: artifacts/ (tokenizer, data, metrics) and checkpoints/ (model)
Metadata
Release files for nanotransformer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nanotransformer-0.1.0.tar.gz | 7.6 kB | Without provenance | Details for nanotransformer-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nanotransformer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nanotransformer-0.1.0-py3-none-any.whl |
Total release size: 16.9 kB
Release files / nanotransformer-0.1.0.tar.gz
| Download URL | nanotransformer-0.1.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7aa02c234aed6332120bd8c151385768357950a8082c52b01c7d708b405d6a38
|
|
BLAKE2b-256 checksum How to use checksums |
227322102dfcddaa5b3fa8455923bf85f8e2dcc3bab98d72393efd9f861c4f50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / nanotransformer-0.1.0-py3-none-any.whl
| Download URL | nanotransformer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bdce5767181d952b69a938009080702de7ee8506f8f26c3696a82ab85a7a531f
|
|
BLAKE2b-256 checksum How to use checksums |
ad278ab255017306fce6b45af311f8d5e65e5bc3c7dcc75e51440905b37874c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Security for nanotransformer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.