candding

API

The public types of the candding crate, the feature flags, the compatibility guarantees and where the generated reference lives.

The crate exposes a small surface: one model type, one builder, the descriptor that describes a model, one error enum, and the device helpers. Everything else, tokenization, pooling, batching and the family implementations, is reachable but rarely needed, because the pipeline is the same for every model.

Public types

TypePurpose
TextEmbeddinga loaded model; embed, query_embed, passage_embed, their _dim variants, query_embed_with_instruction, token_count, and the descriptor, dim, max_length, device and dtype accessors
TextEmbeddingBuilderconstruction from a model id or a directory, with device, dtype, max_length, batch_size, revision and descriptor
ModelDescriptoreverything about a model beyond its weights: dimension, default length, pooling, normalization, templates, default instruction, Dense directories, Matryoshka flag, license, size, gating, phase and backend status
BackendSupportthe CPU, Metal and CUDA verification status of one model
Supportone status: verified, pending or untested
Familythe architecture a model belongs to, and the mapping from a model_type string
PoolingCLS, mean or last token
CanddingErrorevery failure the crate produces, from a missing file to an unsupported architecture
Result<T>the crate's result alias over CanddingError
Devicecandle's device, re-exported so callers need no direct candle dependency
DTypecandle's dtype, re-exported for the same reason
device::autoMetal, then CUDA, then CPU, depending on the compiled features
device::cputhe CPU device
device::metala Metal device by ordinal
device::cudaa CUDA device by ordinal
device::describethe short backend name used in logs and errors

Feature flags

FeatureDefaultWhat it does
hf-cliondownloads a missing model by shelling out to the hf CLI
metaloffthe Metal backend on Apple GPUs
cudaoffthe CUDA backend on NVIDIA GPUs
cudnnoffimplies cuda and adds the cuDNN kernels
accelerateoffApple's BLAS on CPU
mkloffIntel's BLAS on CPU
model-testsofftest-only, enables the suites that need downloaded weights

There is no per-model or per-family feature: every family compiles in unconditionally, and the flags above are the whole matrix.

Compatibility

PropertyValue
Edition2024
Minimum Rustthe rust-version field of the workspace Cargo.toml
candlethe candle 0.11 line as pinned in Cargo.toml, for both candle-core and candle-nn
LicenseApache-2.0 OR MIT

The crate depends on candle, tokenizers, serde and thiserror, and on nothing that needs a system runtime: there is no ONNX runtime, no Python and no candle-transformers. Adding a GPU is a candle feature, not a different code path, which is what the devices and dtypes page describes.

Reference documentation

Item-level documentation is generated from the source, so the crate itself is the reference:

cargo doc -p candding --no-deps --open

The hosted docs.rs page follows the first crates.io release; until then the git dependency in getting started and the locally generated documentation are the way to read the API.

On this page