karpathy

    karpathy/minGPT

    A minimal PyTorch re-implementation of the OpenAI GPT (Generative Pretrained Transformer) training

    llm
    Python
    MIT
    25.0K stars
    3.3K forks
    269 GitHub watchers
    Updated Nov 14, 2026
    View on GitHub

    Build with Backblaze B2

    SDKs, agent skills, IDE extensions, and reference pipelines from Backblaze Labs. All open source.

    Explore Backblaze Labs

    Loading star history...

    Where it stands

    Rank, growth pace and release cadence relative to everything GStars tracks.

    The project lists 11 contributors on GitHub.

    Use Cases & Benefits

    • Implements a minimal, clean PyTorch version of the GPT transformer model for both training and inference.
    • Offers a compact, interpretable, and educational codebase around 300 lines, simplifying understanding and customization of GPT.
    • Use for learning and experimenting with transformer-based language models in a straightforward, minimal environment.
    • Use for training custom GPT models on specific datasets with easy-to-adapt PyTorch training boilerplate.
    • Use for prototyping character-level or token-level language modeling projects with minimal dependencies and complexity.

    Should you depend on it?

    License terms, project hygiene and risks, from GitHub metadata and GStars' snapshots.

    License

    MIT

    Permissive: commercial use, modification and redistribution are allowed with attribution.

    Community files

    • README: present

    Watch-outs

    • Warning: No commits in over a year (last push Aug 2024).
    • No GitHub releases; pin a commit or tag instead of a release.

    General guidance from repository metadata, not legal advice. How we score

    From the README

    A PyTorch re-implementation of GPT, both training and inference. minGPT tries to be small, clean, interpretable and educational, as most of the currently available GPT model implementations can a bit sprawling. GPT is not a complicated model and this implementation is appropriately about 300 lines of code (see mingpt/model.py). All that's going on is that a sequence of indices feeds into a Transformer, and a probability distribution over the next index in the sequence comes out. The majority of the complexity is just being clever with batching (both across examples and over sequence length) for efficiency.

    note (Jan 2023): though I may continue to accept and change some details, minGPT is in a semi-archived state. For more recent developments see my rewrite nanoGPT. Basically, minGPT became referenced across a wide variety of places (notebooks, blogs, courses, books, etc.) which made me less willing to make the bigger changes I wanted to make to move the code forward. I also wanted to change the direction a bit, from a sole focus on education to something that is still simple and hackable but has teeth (reproduces medium-sized industry benchmarks, accepts some tradeoffs to gain runtime efficiency, etc).

    Excerpt from the karpathy/minGPT README on GitHub (MIT license). © its authors.Read the full README on GitHub

    Daily snapshots

    Stars gained per day, and how forks and open issues moved, from GStars' daily snapshots

    Forks

    3.3K+12

    Open issues

    82-1

    Compared with peers in LLM

    Fastest-growing repositories GStars tracks in this cohort for the week of Nov 22, by 7-day star growth

    karpathy/minGPT compared with LLM repositories by stars, 7-day star growth, health score and last release
    RepositoryStars+7dHealthLast release
    firecrawl/firecrawl207.0K+5.5K51156 days ago
    DietrichGebert/ponytail196.9K+5.2K5924 days ago
    affaan-m/ECC309.0K+5.1K6252 days ago
    Tencent/LoopForge5.7K+4.2K652 days ago
    tashfeenahmed/freellmapi56.7K+3.8K45today
    karpathy/minGPT25.0K—12—
    Category median196.9K+5.1K59—

    Also by karpathy

    Other repositories from this maintainer that GStars tracks

    Discover Repositories

    Search across tracked repositories by name or description