A tiny GPT with tiktoken BPE and RoPE (auto-extend), CUDA/MPS/CPU aware.
Project description
picogpt
A tiny GPT with tiktoken BPE and RoPE (auto-extend), with a simple class API.
- Minimal, readable GPT-style Transformer for next-token prediction.
- Tokenization with a production-grade BPE (tiktoken
cl100k_base). - Device selection: prefers CUDA (with mixed precision), else MPS, else CPU.
- A single-stream language-modeling dataset with random (x, y) slices.
- Short training run and autoregressive sampling from a prompt.
Dependencies: numpy, torch, tiktoken
Install
pip install picogpt
pip install build
python -m build
pip install dist/picogpt-*.whl
from picogpt import PicoGPT
picoGPT = PicoGPT() # defaults: tiny model, CUDA/MPS/CPU auto-detect
# Train on your text file
picoGPT.train_with_file("corpus.txt")
# Save / load
picoGPT.save_model("out/pico.pt")
picoGPT.load_model("out/pico.pt")
# Inspect
picoGPT.info()
# Inference
answer = picoGPT.ask("RL aligns the model")
print(answer)
# defaults
PicoGPT(
block_size=64, n_embd=96, n_head=3, n_layer=2, dropout=0.1, rope_base=10000.0,
batch_size=48, train_steps=600, learning_rate=3e-3, seed=0,
tokenizer_name="cl100k_base", max_new_tokens=200, temperature=0.9, top_k=50,
device="auto", amp=True
)
---
## Publish to PyPI (quick guide)
```bash
# from the project root (where pyproject.toml lives)
python -m pip install --upgrade build twine
python -m build
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
picogpt-0.1.1.tar.gz
(8.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file picogpt-0.1.1.tar.gz.
File metadata
- Download URL: picogpt-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea9475f40e95447ca38423eff2013c588797cf3ec8de9c98e3b59f5562a1cad
|
|
| MD5 |
5ac3f52fed1ca1827b73c9f9a1496ffa
|
|
| BLAKE2b-256 |
9948f7dc00de4115db73ccd6e4f0780787b5759447a51584f408d764fa423487
|
File details
Details for the file picogpt-0.1.1-py3-none-any.whl.
File metadata
- Download URL: picogpt-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e51aabaf1d147c38303b04956d44e8939cf261241d6c65780495d1dcd51eadc3
|
|
| MD5 |
1217090080c6382e765fc52a70b24215
|
|
| BLAKE2b-256 |
15d4d45ca1b456a430209acb09442127bc39aec846a93eb3e08d5ad8f5c38f3d
|