llama-crab
Safe, ergonomic and complete Rust bindings for llama.cpp.
This is the main crate of the llama-crab workspace. Most applications
should depend on this crate; use llama-crab-sys only
when you need direct access to raw llama.cpp symbols.
Quickstart
[]
= "0.1"
use ;
Loading a model from Hugging Face
Pass a Hugging Face repository id (e.g. TheBloke/Llama-2-7B-Chat-GGUF) directly to
LlamaParams::new; the library will download the GGUF to the official HF cache and load it.
For repos with multiple .gguf files, specify the filename via with_hf_filename:
use ;
let mut llama = load?;
# Ok::
The model is cached at ~/.cache/huggingface/hub (or $HF_HOME/hub if set). Set
HF_TOKEN for gated repos. Requires the hf-hub cargo feature:
[]
= { = "0.1", = ["hf-hub"] }
Features
- Text completion, chat completion, infill, embeddings and reranking.
- Sampling chains, grammar-constrained decoding, JSON-Schema to GBNF.
- Tool-call parsing for ChatML, Mistral, Llama 3, Functionary and plain JSON.
- Multimodal support (vision and audio) through
mtmd. - Hardware backends for CPU, Metal, CUDA, Vulkan, ROCm, OpenCL and KleidiAI.
- Mobile presets and packaging profiles for Android and iOS.
For the full feature table, backend flags and mobile build details, see the user guide.
Resources
- API reference (0.1.7) —
rustdocfor the current release. - API reference (latest) —
rustdocfor the latest version. - User guide
- Examples repository
- Workspace README
License
Licensed under the MIT License.