Download pretrained model weights and configuration files from the HuggingFace Hub. Supports single-file and sharded SafeTensors checkpoints, caching, authentication, and offline mode.
let config =
Kaun_hf.load_config ~model_id:"bert-base-uncased" ()
in
let weights =
Kaun_hf.load_weights ~model_id:"bert-base-uncased" ()
in
(* weights : (string * Kaun.Ptree.tensor) list *)
load_weights ~model_id () is the list of (name, tensor) pairs from model_id's SafeTensors checkpoint.
Handles sharded checkpoints transparently: when model.safetensors.index.json is present, all referenced shards are downloaded and merged. Falls back to model.safetensors when no index exists.
Tensor names are the raw keys from the SafeTensors file (e.g. "bert.encoder.layer.0.attention.self.query.weight"). Model code is responsible for mapping these to its own parameter structure.