~/book
LLMs, Rust &
Functional Programming
A ground-up guide to building intelligent systems with Rust — no Python, no magic, no hand-waving. Just types, tensors, and transformers.
Status: Work in Progress
Writing in public. Early chapters released as blog posts. Subscribe to follow along.
About This Book
Most ML literature assumes Python. Most systems literature ignores ML. This book lives at the intersection: building real language model infrastructure using Rust's type system, ownership model, and performance characteristics.
The approach is bottom-up. We start with the functional programming patterns that make Rust code composable and correct — monads, algebraic types, parser combinators — and build toward a fully functional inference engine.
By the end, you'll have implemented attention from scratch, built a KV cache, written a sampler, and assembled a production-ready inference server — all in safe (mostly) Rust.
No prior ML experience required. Familiarity with Rust fundamentals is assumed. A curiosity about how language models actually work is essential.
What You'll Learn
Table of Contents
Part I — Foundations
- 01Why Rust for AI SystemsUpcoming
- 02Types as Contracts: Rust's Ownership ModelUpcoming
- 03Functional Patterns in Rust: From Iterators to MonadsUpcoming
- 04Algebraic Data Types and Pattern MatchingUpcoming
Part II — Language Models from the Ground Up
- 01Tokenization: Bytes, Characters, and BPEUpcoming
- 02Attention Is All You Need — Implemented in RustUpcoming
- 03The Transformer Architecture End-to-EndUpcoming
- 04KV Cache, Positional Encodings, and EfficiencyUpcoming
Part III — Inference & Production
- 01Memory-Mapped Models and Zero-Copy LoadingUpcoming
- 02SIMD and Hardware-Accelerated InferenceUpcoming
- 03Sampling Strategies: Greedy, Top-k, Top-p, and BeamUpcoming
- 04Building a Production Inference Server in RustUpcoming
Part IV — Agents and Composition
- 01RAG Pipelines with Functional CompositionUpcoming
- 02Tool Use and Structured OutputsUpcoming
- 03Multi-Agent Coordination without a Central OrchestratorUpcoming
- 04Evaluating LLM Systems RigorouslyUpcoming
Stay in the loop
Get notified when chapters drop
Early chapters will be released as blog posts. Subscribe to the newsletter to get them first.
Subscribe