Machine Learning with Rust, Second Edition: Implement data pipelines, classical models, deep learning and NLP using burn, candle, linfa and smartcore
This machine learning book is a new edition out now for Rust developers to build practical machine learning systems without getting bogged down in the complexities of Rust 1.85. We put together a single workspace over eleven chapters, building it from a Polars-based data pipeline through classical models, deep neural networks, and natural language processing, right up to a deployed REST API.
We teach you to make use of linfa and smartcore crates for regression, classification, ensemble methods, and support vector machines. We build and train neural networks using the Burn framework, work with convolutional architectures on image data, and load pre-trained transformer models through Candle. We also use a lightweight NLP pipeline with TF-IDF and Gaussian Naive Bayes from first principles. At all times, Rust's ownership model and type system work together to make sure things are correct, rather than getting in the way.
This particular book is a perfect knowledge source for developers who already know Rust at a beginner’s level and want to use that knowledge for machine learning tasks. You don't need to have worked with any ML frameworks before.
Key Learnings
- Structure a multi-crate Rust workspace for end-to-end machine learning.
- Build type-safe data pipelines using Polars and Apache Arrow.
- Train, evaluate, and improve classical models with linfa and smartcore.
- Implement backpropagation and mini-batch gradient descent.
- Train multilayer perceptrons and convolutional networks using Burn.
- Load and fine-tune pre-trained BERT models using Candle.
- Apply LoRA weight adaptation to transformer layers.
- Construct production TF-IDF and Naive Bayes NLP pipeline.
- Serve trained models using axum and tokio.
- Implement live model hot-reloading and request batching without server downtime.
Table of Content
- Why Rust for Machine Learning?
- Data Engineering with Polars and Arrow
- Regression and Classification
- Decision Trees, Random Forests, and Gradient Boosting
- SVMs, Naive Bayes, and k-NN
- Neural Networks from First Principles
- Deep Learning with Burn
- Computer Vision Pipelines with Burn
- Transformer Inference and Fine-Tuning with Candle
- Natural Language Processing in Rust
- Model Serving and REST APIs