# karpathy/nanogpt

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/karpathy-nanogpt).**

59,730 stars · 10,298 forks · Python · MIT

## Links

- GitHub: https://github.com/karpathy/nanoGPT
- awesome-repositories: https://awesome-repositories.com/repository/karpathy-nanogpt.md

## Description

nanoGPT is a lightweight engine for training and fine-tuning transformer-based language models from scratch. It provides a minimalist codebase designed for educational exploration and rapid experimentation with neural network architectures, utilizing self-attention and feed-forward layers to process sequences and predict subsequent elements.

The project distinguishes itself through a focus on high-speed data ingestion and hardware-accelerated performance. It includes a dedicated pipeline for transforming raw text into memory-mapped binary files, which enables efficient streaming during training. To maximize throughput, the system supports distributed data parallelism across multiple graphics processing units and employs just-in-time kernel compilation to optimize mathematical operations for specific hardware.

Beyond core training capabilities, the repository provides a command-line interface for generative text inference, allowing users to sample sequences from trained models using configurable parameters. It also includes integrated benchmarking tools to measure iteration speeds and identify hardware bottlenecks, ensuring efficient model development across various configurations.

## Tags

### Artificial Intelligence & ML

- [Transformer](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/architectures/transformer.md) — Utilizes stacked self-attention and feed-forward layers to process sequences and capture long-range dependencies.
- [Generative Text Inference](https://awesome-repositories.com/f/artificial-intelligence-ml/generative-ai-resources/generative-ai/generative-text-inference.md) — Produces text outputs from trained models using configurable sampling parameters and prompt inputs.
- [Transformer Training Engines](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/frameworks/training-systems/model-training-engines/transformer-training-engines.md) — Optimizes computational throughput for training and fine-tuning transformer-based language models from scratch.
- [Text Generation Runtimes](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/engines-runtimes-servers/text-generation-runtimes.md) — Exposes a command-line interface for sampling text sequences with adjustable generation settings.
- [Tensor Libraries](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-optimization-and-inference/hardware-and-acceleration/tensor-computing-libraries/tensor-libraries.md) — Executes high-dimensional array operations and mathematical functions essential for training deep neural networks.
- [Large Language Model Training Frameworks](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/training-frameworks/large-language-model-training-frameworks.md) — Scales model training across single or multi-GPU environments using a minimalist, research-focused codebase.
- [Model Training Pipelines](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-training-and-tuning/training-frameworks/model-training-pipelines.md) — Coordinates end-to-end workflows for training and fine-tuning models across various hardware accelerators. ([source](https://github.com/karpathy/nanoGPT#readme))
- [Neural Network Research Tools](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/architectures/neural-network-components/neural-network-research-tools.md) — Serves as a minimalist, educational implementation of transformer architectures for rapid prototyping and research.
- [Data Preparation Tools](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/data-ingestion-preparation/data-preparation-tools.md) — Transforms raw text datasets into structured binary formats suitable for machine learning ingestion. ([source](https://github.com/karpathy/nanoGPT#readme))
- [Dataset Preprocessing Utilities](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/data-ingestion-preparation/dataset-preprocessing-utilities.md) — Converts raw text corpora into optimized binary formats to accelerate data ingestion during training.
- [Model Optimization](https://awesome-repositories.com/f/artificial-intelligence-ml/model-optimization.md) — Refines training throughput and model efficiency through a minimalist, experimental architecture codebase.
- [Tokenizers](https://awesome-repositories.com/f/artificial-intelligence-ml/natural-language-processing/tokenizers.md) — Decomposes raw text into numerical units using character-level tokenization for model ingestion.
- [Data-Parallel Training](https://awesome-repositories.com/f/artificial-intelligence-ml/distributed-training-frameworks/data-parallel-training.md) — Distributes training workloads across multiple hardware units by synchronizing gradients to accelerate convergence.
- [Inference Generators](https://awesome-repositories.com/f/artificial-intelligence-ml/machine-learning/infrastructure/model-inference-serving/model-integration-pipelines/model-inference/inference-generators.md) — Generates text outputs from trained models using configurable sampling parameters like temperature and token limits. ([source](https://github.com/karpathy/nanoGPT#readme))

### Data & Databases

- [Data Processing Pipelines](https://awesome-repositories.com/f/data-databases/data-processing-pipelines.md) — Orchestrates the conversion of raw text corpora into efficient binary formats for high-throughput training pipelines.
- [Binary Data Formats](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-processing/data-serialization-parsing/binary-data-formats.md) — Stores data in memory-mapped binary structures to facilitate rapid sequential access during training.

### Part of an Awesome List

- [Educational Resources](https://awesome-repositories.com/f/awesome-lists/ai/educational-resources.md) — Active development rewrite of the original GPT implementation.
- [Large Language Models](https://awesome-repositories.com/f/awesome-lists/ai/large-language-models.md) — Minimalist repository for training and fine-tuning GPT models.
- [General NLP](https://awesome-repositories.com/f/awesome-lists/more/general-nlp.md) — Listed in the “General NLP” section of the The Incredible Pytorch awesome list.

### Programming Languages & Runtimes

- [JIT Kernel Compilers](https://awesome-repositories.com/f/programming-languages-runtimes/compiler-interpreter-internals/compiler-infrastructure/jit-kernel-compilers.md) — Compiles mathematical kernels at runtime to maximize hardware acceleration during training.
