model : support classifier_pooling for rerankers (#29627)

* model : support classifier_pooling for ModernBERT rerankers

Assisted-by: Claude Opus 5.5

* model : read classifier pooling type in load_hparams

Write classifier.pooling_type from _try_set_pooling_type whenever the
config has classifier_pooling, and read it in
llama_model_base::load_hparams. ModernBERT falls back to mean when it
is unspecified.

Assisted-by: Claude Opus 5.5

* conversion : only accept cls and mean for classifier_pooling

Assisted-by: Claude Opus 5.5

* model : rename classifier_pooling_type to pooling_type_cls

Assisted-by: Claude Opus 5.5
This commit is contained in:
bosh authored and GitHub committed 2026-09-29 22:33:05 +02:00
1 parent 7fee178464
commit 48de2a1bcb
9 files changed
+21 -2

No files matched your search

+5
View File
@@ -20,6 +20,11 @@ void llama_model_modern_bert::load_arch_hparams(llama_model_loader & ml) {
hparams.llm_ffn_op = llm_ffn_op_type_from_string(hidden_act, LLM_FFN_GEGLU);
}
// GGUFs without a classifier pooling type use mean (gte-reranker-modernbert-base)
if (hparams.pooling_type_cls == LLAMA_POOLING_TYPE_UNSPECIFIED) {
hparams.pooling_type_cls = LLAMA_POOLING_TYPE_MEAN;
}
switch (hparams.n_layer()) {
case 12:
type = LLM_TYPE_47M; break; // granite-embedding-small