Skip to main content

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/*

Metadata

Release files for picogpt 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picogpt 0.1.1
File Size Uploaded
picogpt-0.1.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for picogpt 0.1.1
File Interpreter ABI Platform
picogpt-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / picogpt-0.1.1.tar.gz

Download URL picogpt-0.1.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4ea9475f40e95447ca38423eff2013c588797cf3ec8de9c98e3b59f5562a1cad
BLAKE2b-256 checksum
How to use checksums
9948f7dc00de4115db73ccd6e4f0780787b5759447a51584f408d764fa423487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / picogpt-0.1.1-py3-none-any.whl

Download URL picogpt-0.1.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e51aabaf1d147c38303b04956d44e8939cf261241d6c65780495d1dcd51eadc3
BLAKE2b-256 checksum
How to use checksums
15d4d45ca1b456a430209acb09442127bc39aec846a93eb3e08d5ad8f5c38f3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page