awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
karpathy avatar

karpathy/build-nanogpt

0
View on GitHub↗
4,746 stars·750 forks·Python·33 views

Build Nanogpt

This is an educational implementation that builds a generative pre-trained transformer (GPT) language model from scratch using PyTorch. The project is structured as a step-by-step tutorial, walking through the construction of a decoder-only transformer architecture and its training loop with clean git commits and an accompanying video lecture for a hands-on learning experience.

What sets this implementation apart is its focus on practical reproduction: it provides a workflow to train a 124-million-parameter model from scratch in about one hour on cloud GPU hardware, costing under ten dollars. The tutorial covers both the architecture construction and the full training pipeline, making it suitable for those who want to understand the inner workings of a GPT-scale model without relying on pre-built frameworks.

The technical implementation covers the core components of a decoder-only transformer, including causal masked self-attention where each token attends only to preceding tokens, cross-entropy loss minimization for next-token prediction, weight-decay regularization to prevent overfitting, and GPU-accelerated training through PyTorch for large-scale computation. While the project is small in scale, it mirrors the architectural patterns used in larger language models.

Features

  • Decoder Architectures - Implements the core decoder-only transformer architecture that processes token sequences for autoregressive generation.
  • From-Scratch Decoder Implementations - Focuses on implementing the decoder-only transformer from scratch with causal self-attention and weight-decay.
  • GPU-Accelerated Training - Executes forward and backward passes on CUDA-capable GPUs to accelerate large-scale model training.
  • Language Model Training - Provides a complete implementation for training a GPT-2-scale language model from scratch with cloud GPU optimization.
  • 124M-Parameter Reproduction Guides - Provides a guide for training a 124-million-parameter language model on cloud GPUs for under ten dollars.
  • Triangular Mask Implementations - Implements the triangular attention mask that enforces unidirectional token access in the self-attention mechanism.
  • Cross-Entropy Loss Functions - Uses cross-entropy loss as the objective function for next-token prediction during language model training.
  • Cloud GPU Reproduction Pipelines - Ships a workflow that reproduces a 124M-parameter model on cloud GPU hardware in about one hour for under ten dollars.
  • Transformer Language Models - Implements a decoder-only transformer language model that processes token sequences and predicts the next token.
  • From-Scratch Training - Demonstrates the complete workflow of training a generative pre-trained transformer from scratch on text data.
  • From-Scratch Implementations - Builds a generative pre-trained transformer entirely from scratch, covering both architecture construction and training loop.
  • Deep Learning Prototyping Kits - Provides a hands-on environment for prototyping transformer components like causal self-attention and loss functions.
  • PyTorch Tensor Operations - Leverages PyTorch for all tensor operations and automatic differentiation throughout the model implementation.
  • Transformer Tutorials - Provides a step-by-step walkthrough for implementing a transformer language model using PyTorch.
  • Transformer Architecture Walkthroughs - Provides a structured tutorial with clean git commits and video lecture for building a transformer language model.
  • Courses and Tutorials - Lecture on building GPT models from scratch.
  • Learning Resources - Lecture series on building GPT models.

Star history

Star history chart for karpathy/build-nanogptStar history chart for karpathy/build-nanogpt

How this analysis was created: This summary and feature list are AI-generated from collected project material and can contain mistakes. Stars, license and language are imported from GitHub. Inclusion does not mean that we have tested or audited this project. Check the source documentation for any feature you depend on. Learn more on our About page.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Projects sharing features with Build Nanogpt

These projects share indexed features with Build Nanogpt. Shared tags can include platform or build tooling; verify the primary use case before treating a result as a replacement.
  • datawhalechina/so-large-lmdatawhalechina avatar

    datawhalechina/so-large-lm

    7,400View on GitHub↗

    This project is a comprehensive educational curriculum and structured learning path covering the full lifecycle of large language models. It provides a guided progression through the theory, architecture, training, and deployment of these models. The curriculum includes specialized guides on transformer architecture, model training tutorials, and frameworks for designing autonomous agents. It also provides dedicated resources for studying model safety and ethics. The material covers a wide range of technical capabilities, including distributed training strategies, parameter-efficient fine-tu

    View on GitHub↗7,400
  • openai/gpt-2openai avatar

    openai/gpt-2

    24,967View on GitHub↗

    This project is a transformer-based language model and autoregressive text generator designed to predict the next token in a sequence to produce human-like prose and synthetic text. It functions as a large language model that utilizes a transformer architecture to learn linguistic patterns from large datasets for unsupervised multitask learning. The repository provides a distribution of pre-trained weights, enabling natural language processing tasks without requiring additional training. This allows the model to perform zero-shot task generalization by applying learned patterns to new tasks.

    Python
    View on GitHub↗24,967
  • morizeyao/gpt2-chineseMorizeyao avatar

    Morizeyao/GPT2-Chinese

    7,596View on GitHub↗

    GPT2-Chinese is a Chinese language model implementation based on the GPT-2 architecture. It provides a causal language model trainer and a natural language generation tool designed for training and generating human-like Chinese text sequences. The system integrates a BERT tokenizer to process Chinese corpora into manageable units for machine learning. It enables the development of predictive text models that can generate specific patterns, such as news or poetry, through prompt-based text completion. The project covers a full workflow including text tokenization, model training using a trans

    Python
    View on GitHub↗7,596
  • cs231n/cs231n.github.iocs231n avatar

    cs231n/cs231n.github.io

    10,923View on GitHub↗

    This project is a static educational website and comprehensive curriculum focused on computer vision and deep learning. It serves as a public repository of instructional materials, lecture notes, and technical guides specifically detailing convolutional neural networks and visual recognition. The site is developed using static-site generation to host course documentation and student project directories. It provides structured academic resources that guide learners through image classification, generative modeling, and the implementation of various neural network architectures. The curriculum

    Jupyter Notebook
    View on GitHub↗10,923
Compare all 30 related projects→

Frequently asked questions

What does karpathy/build-nanogpt do?

This is an educational implementation that builds a generative pre-trained transformer (GPT) language model from scratch using PyTorch. The project is structured as a step-by-step tutorial, walking through the construction of a decoder-only transformer architecture and its training loop with clean git commits and an accompanying video lecture for a hands-on learning experience.

What are the main features of karpathy/build-nanogpt?

The main features of karpathy/build-nanogpt are: Decoder Architectures, From-Scratch Decoder Implementations, GPU-Accelerated Training, Language Model Training, 124M-Parameter Reproduction Guides, Triangular Mask Implementations, Cross-Entropy Loss Functions, Cloud GPU Reproduction Pipelines.

Which projects share features with karpathy/build-nanogpt?

Projects with overlapping indexed features include: datawhalechina/so-large-lm — This project is a comprehensive educational curriculum and structured learning path covering the full lifecycle of… openai/gpt-2 — This project is a transformer-based language model and autoregressive text generator designed to predict the next… morizeyao/gpt2-chinese — GPT2-Chinese is a Chinese language model implementation based on the GPT-2 architecture. It provides a causal language… datawhalechina/tiny-universe — Tiny Universe is an educational monorepo that delivers multiple independent implementations of core AI subsystems as… cs231n/cs231n.github.io — This project is a static educational website and comprehensive curriculum focused on computer vision and deep… facebookresearch/fairseq — Fairseq is a PyTorch toolkit for sequence-to-sequence modeling, specializing in neural machine translation, automatic…