Skip to main content

Module bert_gguf_loader

Module bert_gguf_loader 

Source
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: bert and 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 bert GGUF into a runnable encoder.
read_bert_hparams
Reads and checks bert.* hparams. Fails closed on anything the graph in crate::bert_encoder does not implement.