rasbt/reasoning-from-scratch

Implement a reasoning LLM in PyTorch from scratch, step by step

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 30 minutes ago
Added to GitGenius on September 13th, 2026
Created on March 4th, 2025
Open Issues & Pull Requests: 2 (+0)
GitHub issues: Enabled
Number of forks: 818
Total Stargazers: 5,214 (+0)
Total Subscribers: 61 (+0)

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 2
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 153 days
Stale 30+ days: 2
Stale 90+ days: 0

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • question (18)
  • bug (9)
  • enhancement (6)
  • typo (5)
  • documentation (2)
  • bonus material (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Reasoning from Scratch is an educational codebase that teaches how to implement a reasoning large language model in PyTorch from the ground up.

The repository addresses the challenge of understanding how reasoning capabilities are added to language models, moving beyond theoretical descriptions to hands-on implementation. It starts with a pre-trained base LLM and progressively adds reasoning functionality through code, allowing learners to see exactly how techniques like chain-of-thought reasoning, test-time compute scaling, and reinforcement learning from human feedback work in practice. The approach mirrors methods used in production reasoning models such as DeepSeek R1 and GPT-5 Thinking, while remaining tractable for educational purposes.

This project suits developers and researchers who want to understand reasoning LLMs deeply rather than just use them as black boxes. It is designed for those willing to engage with step-by-step implementations in Jupyter notebooks and PyTorch code. The repository is particularly valuable for anyone building or fine-tuning their own reasoning models, or for educators teaching how modern reasoning systems function. It also includes code for loading weights from existing pretrained models, bridging theory and practical application.

The project is structured as the official code repository accompanying a published book, with a troubleshooting guide provided for users. The codebase is organized progressively through chapters, with Chapter 2 covering environment setup and Python package management to help users get started.