# karpathy/minGPT

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

Repository: https://github.com/karpathy/minGPT
Canonical: https://ross.abutalabs.com/products/mingpt
Language: Python
License: MIT
License Family: permissive
Last push: 2024-08-15T04:09:40+00:00

## Health v2 (maintenance only)
Score: 32/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 0, release rhythm 35, longevity 100
- inputs: {"age_days": 2207, "days_push": 748, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: no_releases
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 24840, forks 3321 (observed 2026-08-28T04:11:37.664993+00:00)

## What it is
A minimal, clean PyTorch re-implementation of OpenAI's GPT covering both training and inference in roughly 300 lines of code. It is designed primarily for education and interpretability, and is now semi-archived in favor of the author's nanoGPT rewrite.

## Use cases
- learn how the GPT transformer model works internally
- train a small GPT model from scratch in PyTorch
- implement a character-level language model on a text file
- load a pretrained GPT-2 and generate text from a prompt
- study a readable reference implementation of a transformer
- train GPT on toy tasks like integer addition

## When to choose
- you want a small, readable codebase to understand GPT architecture
- you need a hackable starting point for transformer experiments
- you are teaching or learning about language model training

## When to avoid
- you need state-of-the-art performance or recent features - use nanoGPT instead
- you want to fine-tune large production-grade models
- you need active maintenance and community support

## Facets
- artifact type: library
- maturity: maintenance
- function: llm-training, deep-learning, machine-learning
- domain: large-language-models, deep-learning, education, machine-learning
- platform: python
- tags: gpt, transformer, pytorch, educational, language-model, minimal-implementation, gpu

## Member repositories
- karpathy/minGPT (main) score 32

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:11:37.664993+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T16:56:09.188707+00:00, confidence not recorded.
  - readme: https://github.com/karpathy/minGPT (fetched 2026-08-28T04:11:37.664993+00:00, sha ad81f8f2df88)
- Data as of 2026-08-30T08:39:29.467469+00:00.
