Expand description
BERT GGUF → BertEncoder.
Tensor names and requiredness follow llama.cpp
llama_model_bert::load_arch_tensors (src/models/bert.cpp), and
hparam keys follow its load_arch_hparams plus the shared
LLM_KV_* set.
§bert.cpp upstream is five architectures; this is one of them
nomic-bert, nomic-bert-moe, jina-bert-v2, jina-bert-v3 and
neo-bert all build their graph from the same file, each switching
on model.arch for RoPE, a gated FFN, expert layers or a second
attention norm. crate::bert_encoder implements only the plain
bert shape, so every one of those differences is checked for here
and refused by name: a checkpoint that carries ffn_gate or
attn_q_norm is not silently run without it.
The last line of defence is
crate::loader::assert_every_tensor_consumed, which the load ends
with: for bge-small-en-v1.5-q8_0.gguf this graph reads all 197
tensors, so any weight a variant adds and this module has no home
for stops the load instead of being ignored.
Constants§
- BERT_
ARCH - The architecture string this loader implements.
Functions§
- check_
arch - The whole architecture policy of this loader, in one place so it can
be tested without a GGUF:
bertand nothing else. - load_
bert_ encoder - Same, from an already-open file — so a caller that also needs the
tokenizer out of it (
crate::embedding_model) mmaps it once. - load_
bert_ encoder_ from_ path - Loads a
bertGGUF into a runnable encoder. - read_
bert_ hparams - Reads and checks
bert.*hparams. Fails closed on anything the graph incrate::bert_encoderdoes not implement.