picoGPT logo

picoGPT

jaymody/picoGPT

An unnecessarily tiny implementation of GPT-2 in NumPy

GraphCanon updated 3d · GitHub synced 3d

3.5k stars456 forksLast push 3y Python MIT

Decision brief

`picoGPT` is a minimal and extremely compact GPT-2 model, written in NumPy for the sake of readability despite significant inefficiencies.

Good fit when

  • - Use `picoGPT` when you need an example to understand GPT-2's functioning at its most pared-down level.
  • - Opt for this tool if your goal is educational or as a base to elaborate on for academic demonstration without focusing on performance.

Avoid when

  • - Avoid `picoGPT` in scenarios requiring efficient batch processing or advanced generation techniques like top-p sampling, as it lacks these features.
  • - Do not use `picoGPT` if speed and scalability are critical for your project, given its megaSlow execution.
Requirements:
Min 2 GB RAM; PicoGPT may struggle with larger datasets due to its inefficiencies, despite being minimal.

Observed Jul 12, 2026 · Source: enrich:decision_facts

Verify the decision

Maintenance and security

Full trust report
Maintenance
Dormant (1211d since push)
As of 3d
Provenance
Not a fork · Personal account
As of 3d
Security (OSV)
32 low (32 low)
As of 1mo

Public GitHub metadata and optional OSV scans. Signals, not a guarantee. Trust methodology.

Install

pip install picoGPT
PyPI

How it fits your stack(2)

Typed graph edges - alternatives, integrations, successors, and dependencies. Ranked by relationship type, not raw GitHub stars.

Relationship graph

Optional deeper exploration of typed edges and category neighbours.

Similar tools

Same-category neighbours not already linked as typed edges.

Evidence and technical details

Sourced facts, taxonomy, compatibility claims, README excerpt, and machine-readable endpoints.

Overview

PicoGPT is a minimal and readable GPT-2 model implementation using NumPy. The forward pass code is extremely concise (40 lines), but lacks efficiency features like batch processing or advanced sampling techniques.

Capability facts

Languages
python

Source: github.language · Aug 18, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

Python runtimePython

Source: README excerpt (regex_v1, Aug 18, 2026)

pt2.py` contains the actual GPT model and generation code which we can run as a python script.
Source link

Tags

README

PicoGPT

Accompanying blog post: GPT in 60 Lines of Numpy


You've seen openai/gpt-2.

You've seen karpathy/minGPT.

You've even seen karpathy/nanoGPT!

But have you seen picoGPT??!?

picoGPT is an unnecessarily tiny and minimal implementation of GPT-2 in plain NumPy. The entire forward pass code is 40 lines of code.

picoGPT features:

  • Fast? ❌ Nah, picoGPT is megaSLOW 🐌
  • Training code? ❌ Error, 4️⃣0️⃣4️⃣ not found
  • Batch inference? ❌ picoGPT is civilized, single file line, one at a time only
  • top-p sampling? ❌ top-k? ❌ temperature? ❌ categorical sampling?! ❌ greedy? ✅
  • Readable? gpt2.pygpt2_pico.py
  • Smol??? ✅✅✅✅✅✅ YESS!!! TEENIE TINY in fact 🤏

A quick breakdown of each of the files:

  • encoder.py contains the code for OpenAI's BPE Tokenizer, taken straight from their gpt-2 repo.
  • utils.py contains the code to download and load the GPT-2 model weights, tokenizer, and hyper-parameters.
  • gpt2.py contains the actual GPT model and generation code which we can run as a python script.
  • gpt2_pico.py is the same as gpt2.py, but in even fewer lines of code. Why? Because why not 😎👍.

Dependencies

pip install -r requirements.txt

Tested on Python 3.9.10.

Usage

python gpt2.py "Alan Turing theorized that computers would one day become"

Which generates

 the most powerful machines on the planet.

The computer is a machine that can perform complex calculations, and it can perform these calculations in a way that is very similar to the human brain.

You can also control the number of tokens to generate, the model size (one of ["124M", "355M", "774M", "1558M"]), and the directory to save the models:

python gpt2.py \
    "Alan Turing theorized that computers would one day become" \
    --n_tokens_to_generate 40 \
    --model_size "124M" \
    --models_dir "models"

For agents

This page has a .md twin and JSON over the API.

Was this helpful?

Anonymous feedback helps us improve pages and translations.