Repository navigation
model : support classifier_activation for rerankers - #29692
Conversation
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
Assisted-by: Claude Opus 5.5
|
I removed And yes, checked the numbers, it should have been
It doesn't show end to end because the encoder FFN is on the tanh gelu too and that error is bigger. ModernBERT GGUFs without the key score slightly differently now (up to 0.0006 in these tests) and match a GGUF with the key set to gelu. With the erf head in both runs, switching the encoder to |
…er-activation Assisted-by: Codex
…er-activation Assisted-by: Codex
* model : support classifier_activation for rerankers Assisted-by: Claude Opus 5.5 * model : map classifier gelu to gelu_erf and accept tanh Assisted-by: Claude Opus 5.5 * model : default act_cls to tanh, ModernBERT falls back to gelu_erf Assisted-by: Claude Opus 5.5
Overview
Rank head applies GELU for ModernBERT and tanh for other architectures.
ModernBertForSequenceClassificationreadsclassifier_activationfromconfig.json, andibm-granite/granite-embedding-reranker-english-r2sets it to"silu", so its scores are still off after #29627.This PR:
{arch}.classifier.activationkey (gguf-py andllama-arch)_try_set_pooling_typewhen the config hasclassifier_activation(gelu,siluandtanhare accepted)llama_model_base::load_hparamsand mapsgeluto the exact (erf) GELU like transformers. A key in the GGUF always takes precedence. Without the key the head uses tanh, and ModernBERT uses the exact GELU (the transformers default)Additional information
Scores for 6 query/passage pairs (f16,
llama-server --reranking, CPU) compared with transformers in fp32:classifier_activationAlibaba-NLP/gte-reranker-modernbert-baseibm-granite/granite-embedding-reranker-english-r2ModernBERT reranker GGUFs converted before this PR have no key and now get the exact GELU instead of the tanh approximation. In my tests their scores moved by up to 0.0006 and match a GGUF with the key set to
gelu. A GGUF of a model that uses another activation (granite,silu) has to be reconverted to pick it up. Other architectures still use tanh. GGUFs converted with this branch still load on master (which ignores the new key).Checks: CPU build with
LLAMA_FATAL_WARNINGS=ON(no warnings),ctest -L 'main|python', flake8, editorconfig-checker, the gguf-py tests,test-llama-archsand the server rerank/embedding tests.Requirements