llms-from-scratch-rs  by nerdai

Rust LLM implementation from scratch

Created 11 months ago
251 stars

Top 99.8% on SourcePulse

GitHubView on GitHub
Project Summary

<2-3 sentences summarising what the project addresses and solves, the target audience, and the benefit.> This project provides a comprehensive Rust translation of the code from Sebastian Raschka's "Build an LLM from Scratch" book. It targets engineers and researchers seeking to understand and implement Large Language Models (LLMs) using Rust and the minimalist Candle ML framework, offering a practical, step-by-step approach to LLM development.

How It Works

The project meticulously translates the PyTorch codebase from Raschka's acclaimed book into Rust. It leverages the Candle crate, a minimalist machine learning framework, to implement core LLM components. This includes working with text data, coding attention mechanisms, building a GPT model, and performing pretraining and fine-tuning tasks. The Rust implementation aims to offer a performant and memory-efficient alternative for LLM experimentation, following the book's pedagogical structure.

Quick Start & Requirements

Installation can be done by cloning the repository (git clone) and using Cargo, or by installing directly via cargo install llms-from-scratch-rs. A prerequisite is having Rust and Cargo installed. Data required for examples and exercises can be downloaded using wget into a data/ subdirectory. Examples and exercises are run via cargo run example <id> or cargo run exercise <id>. CUDA acceleration is available by compiling with the --features cuda flag.

Highlighted Details

  • Offers a direct Rust implementation of concepts from a leading LLM educational resource.
  • Utilizes the Candle ML framework, providing a minimalist and potentially performant Rust-native ML development environment.
  • Includes a wide array of runnable examples and exercises covering the full LLM lifecycle, from tokenization to instruction fine-tuning.
  • Supports GPU acceleration via CUDA through a Cargo feature flag.

Maintenance & Community

No specific details regarding maintainers, community channels (e.g., Discord, Slack), or project roadmaps are provided in the README.

Licensing & Compatibility

The license type is not explicitly stated in the provided README content.

Limitations & Caveats

The project employs a non-standard import style within its examples and exercises, placing relevant imports directly under the main() function for educational clarity, which deviates from typical Rust project conventions.

Health Check
Last Commit

6 days ago

Responsiveness

1 day

Pull Requests (30d)
16
Issues (30d)
0
Star History
12 stars in the last 30 days

Explore Similar Projects

Starred by Théophile Gervet Théophile Gervet(Cofounder of Genesis AI), Jason Knight Jason Knight(Director AI Compilers at NVIDIA; Cofounder of OctoML), and
7 more.

lingua by facebookresearch

0.0%
5k
LLM research codebase for training and inference
Created 1 year ago
Updated 2 months ago
Starred by Yineng Zhang Yineng Zhang(Inference Lead at SGLang; Research Scientist at Together AI), Lewis Tunstall Lewis Tunstall(Research Engineer at Hugging Face), and
15 more.

torchtune by meta-pytorch

0.2%
6k
PyTorch library for LLM post-training and experimentation
Created 2 years ago
Updated 1 day ago
Feedback? Help us improve.