A curated awesome list of resources, tutorials, papers, tools and courses for fine-tuning large language models.
nerdai/llms-from-scratch-rs
Rust translation of the code from Sebastian Raschka's book 'Build an LLM from Scratch', built on the Candle ML crate.
- Stars
- 341
- Forks
- 43
- Open issues
- 11
- Last commit
- 4 days ago
What is it?
This project ports the PyTorch code from Sebastian Raschka's book "Build an LLM from Scratch" to Rust, using the Candle crate as the machine learning framework. It follows the book's seven chapters, from text data handling and attention mechanisms to implementing a GPT-style model, pretraining, classification fine-tuning and instruction fine-tuning.
Examples and exercises are run through a single `main` binary, for instance `cargo run example 05.07` or `cargo run exercise 5.5`, and a `--features cuda` flag enables CUDA devices. Imports are placed inside each example's `main()` so readers can see exactly which dependencies each one needs. The project can also be installed from crates.io, and it uses the same the-verdict.txt dataset as the book.
Key features
- 01Translates the book's PyTorch code into Rust using the Candle crate.
- 02Covers seven chapters from tokenization to instruction fine-tuning.
- 03Runs examples and exercises through a single cargo binary by ID.
- 04Supports optional CUDA acceleration via a feature flag.
- 05Can be installed directly from crates.io.
Use cases
- Learning how a GPT-style LLM is built step by step in Rust.
- Comparing a Rust implementation of transformer components with the PyTorch original.
- Working through the exercises of Raschka's book in a Rust environment.
Quick start
- 1
Clone the repository
git clone https://github.com/nerdai/llms-from-scratch-rs.git - 2
Download the dataset into the data folder
mkdir -p 'data/' && wget 'https://raw.githubusercontent.com/rabst/LLMs-from-scratch/main/ch02/01_main-chapter-code/the-verdict.txt' -O 'data/the-verdict.txt' - 3
Run an example from the project root
cargo run example 05.07
Things to know
- Requires a Rust toolchain with Cargo installed.
- Examples are educational translations of book code, not a production LLM library.
In collections
Topics
FAQ
- What is llms-from-scratch-rs?
- Rust translation of the code from Sebastian Raschka's book 'Build an LLM from Scratch', built on the Candle ML crate. This project ports the PyTorch code from Sebastian Raschka's book "Build an LLM from Scratch" to Rust, using the Candle crate as the machine learning framework. It follows the book's seven chapters, from text data handling and attention mechanisms to implementing a GPT-style model, pretraining, classification fine-tuning and instruction fine-tuning.
- Is llms-from-scratch-rs free to use? What license does it have?
- llms-from-scratch-rs is open source under the MIT license. Check the license terms before using it in commercial products.
- Is llms-from-scratch-rs still maintained?
- Actively maintained. The last commit to llms-from-scratch-rs was on Nov 2, 2026.
- What can I use llms-from-scratch-rs for?
- Learning how a GPT-style LLM is built step by step in Rust. Comparing a Rust implementation of transformer components with the PyTorch original. Working through the exercises of Raschka's book in a Rust environment.
- How do I install llms-from-scratch-rs?
- Clone the repository: git clone https://github.com/nerdai/llms-from-scratch-rs.git Download the dataset into the data folder: mkdir -p 'data/' && wget 'https://raw.githubusercontent.com/rabst/LLMs-from-scratch/main/ch02/01_main-chapter-code/the-verdict.txt' -O 'data/the-verdict.txt' Run an example from the project root: cargo run example 05.07
- Where can I get llms-from-scratch-rs?
- The source code and installation instructions are on GitHub: https://github.com/nerdai/llms-from-scratch-rs
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Companion code for the book Build a Large Language Model (From Scratch), implementing a GPT-like LLM in PyTorch step by step.
Python-based LLM inference and serving framework focused on a lightweight design, easy scaling and high throughput.
A 12-chapter, commented tutorial that walks you through building and training a small LLaMA-style GPT from scratch in Python and PyTorch.
A curated, Markdown-based ML knowledge base of 923 papers, lectures and articles, plus a small NumPy-only custom classifier and regressor called APRL.
A Python library for working with LLMs through objects and types, letting developers prompt models and get structured outputs.