reasoning-from-scratch
rasbt/reasoning-from-scratch
Implement a reasoning LLM in PyTorch from scratch, step by step
Implement a reasoning LLM in PyTorch from scratch, step by step
Categories
Tags
Similar tools
ollama
ollama/ollama
Get up and running with Kimi-K2.6, GLM-5.1, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
prompts.chat
f/prompts.chat
The world's largest open-source prompt library for AI
transformers
huggingface/transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models
open-webui
open-webui/open-webui
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
awesome-llm-apps
Shubhamsaboo/awesome-llm-apps
100+ AI Agent & RAG apps you can actually run — clone, customize, ship.
LLMs-from-scratch
rasbt/LLMs-from-scratch
Implement a ChatGPT-like LLM in PyTorch from scratch
Install
git clone https://github.com/rasbt/reasoning-from-scratchREADME
Build A Reasoning Model (From Scratch)
This repository contains the code for developing an LLM reasoning model and is the official code repository for the book Build a Reasoning Model (From Scratch).
(Printed in color.)
In Build a Reasoning Model (From Scratch), you will learn and understand how a reasoning large language model (LLM) works.
Reasoning is one of the most exciting and important recent advances in improving LLMs, but it’s also one of the easiest to misunderstand if you only hear the term reasoning and read about it in theory. This is why this book takes a hands-on approach. We will start with a pre-trained base LLM and then add reasoning capabilities ourselves, step by step in code, so you can see exactly how it works.
The methods described in this book walk you through the process of developing your own small-but-functional reasoning model for educational purposes. It mirrors the approaches used in creating large-scale reasoning models such as DeepSeek R1, GPT-5 Thinking, and others. In addition, this book includes code for loading the weights of existing, pretrained models.
- Link to the official source code repository
- Link to the book at Manning (the publisher's website)
- Link to the book page on Amazon.com (TBD)
- ISBN 9781633434677
To download a copy of this repository, click on the Download ZIP button or execute the following command in your terminal:
git clone --depth 1 https://github.com/rasbt/reasoning-from-scratch.git
Tip: Chapter 2 provides additional tips on installing Python, managing Python packages, and setting up your coding environment.
Table of Contents (In Progress)
- Troubleshooting Guide
| Chapter Title | Main Code |
|---|---|
| Ch 1: Understanding reasoning Models | No code |
| Ch 2: Generating Text with a Pre-trained LLM | - ch02_main.ipynb - ch02_exercise-solutions.ipynb |
| Ch 3: Evaluating Reasoning Models | - ch03_main.ipynb - ch03_exercise-solutions.ipynb |
| Ch 4: Improving Reasoning with Inference-Time Scaling | - ch04_main.ipynb - ch04_exercise-solutions.ipynb |
| Ch 5: Inference-Time Scaling via Self-Refinement | - ch05_main.ipynb - ch05_exercise-solutions.ipynb |
| Ch 6: Training Reasoning Models with Reinforcement Learning | - ch06_main.ipynb - ch06_exercise-solutions.ipynb |
| Ch 7: Improving GRPO for Reinforcement Learning | - ch07_main.ipynb - ch07_exercise-solutions.ipynb |
| Ch 8: Distilling Reasoning Models for Efficient Reasoning | - ch08_main.ipynb - [ch08_exercise-solutions.ipynb] |
