Minimalist ML framework for Rust
open sourceMIT OR Apache-2.0self-hostablefree
candle is Hugging Face's machine learning framework for Rust, with a PyTorch-like tensor API, a CPU backend (optionally with MKL or Apple's Accelerate), CUDA with multi-GPU support through NCCL, Metal, and WebAssembly for running models in the browser. Its goals are serverless inference with small binaries and removing Python from production; it can also train. candle-transformers implements many models (LLaMA, Mistral, Phi, Gemma, Qwen, Whisper, Stable Diffusion, BERT, JinaBERT, nomic-bert, ModernBERT and more), loads safetensors, npz, GGML/GGUF and PyTorch files, and supports llama.cpp's quantized types. The crates are candle-core, candle-nn and candle-transformers (the crate named candle is an unrelated placeholder); its BERT example embeds sentences with all-MiniLM-L6-v2 by default, and fastembed-rs uses it for its Qwen3 and BERT backends.
Problems it solves
- run a Hugging Face model in Rust without Python or libtorch
- ship a small binary that does model inference for a serverless function
- compute sentence embeddings in a Rust program with a BERT model from the Hub
- run a quantized GGUF language model from my own Rust code
- run Whisper speech recognition inside a Rust app
- run an ML model in the browser compiled to WebAssembly from Rust
- use the GPU on Apple silicon or NVIDIA from a Rust inference program
- port a PyTorch model to Rust with a familiar tensor API
- train a small neural network in pure Rust
- the GIL and Python overhead are slowing down my model serving
- load safetensors weights directly in Rust
- run an ONNX model in Rust without linking a C++ runtime
Features
- PyTorch-like tensor API with autograd and training
- CPU backend with optional MKL (x86) and Accelerate (macOS)
- CUDA backend with cuDNN, multi-GPU via NCCL, and JIT CUDA kernels in Rust (cuTile)
- Metal backend for Apple silicon
- WebAssembly support for in-browser models
- candle-transformers: LLMs, Whisper, Stable Diffusion, BERT-family encoders, vision models and more
- loads safetensors, npz, GGML/GGUF and PyTorch files
- quantization with llama.cpp's quantized types
- flash-attention v2 layer (candle-flash-attn)
- ONNX model evaluation (candle-onnx)
View 1 more
- sentence-embedding examples: BERT, JinaBERT, nomic-bert, ModernBERT, gte-Qwen, Stella, XLM-RoBERTa
Capabilities
| Has official SDKs | plan not known |
|---|
Alternatives
The same job
These do what candle does.
- model2vec-rs Fast State-of-the-Art Static Embeddings in Rust
- fastembed-rs Rust library for generating vector embeddings, reranking locally
- ort Fast ML inference & training for ONNX models in Rust
- Burn A Rust tensor library and deep learning framework for training and inference on any hardware.
- ONNX Runtime Cross-platform, high performance ML inferencing and training accelerator
