Skip to main content

Module weights

Module weights 

Source
Expand description

HuggingFace safetensors weight loading and key resolution.

Functions§

detect_weight_prefix
Detect the common prefix for transformer weight keys.
load_hf_weights
Load and merge safetensors shards from disk.
resolve_bias
Resolve an optional bias tensor by logical suffix (e.g. layers.0.self_attn.q_proj). Returns None when the model has no bias for that layer (e.g. Llama/Mistral).
resolve_lm_head
Resolve lm_head — may live outside the model prefix.
resolve_weight
Resolve a weight tensor by logical suffix (e.g. layers.0.self_attn.q_proj).
tie_word_embeddings_from_config