From 42e7942ac94309ad749c0091b1275bb7d7b22aea Mon Sep 17 00:00:00 2001 From: hcl Date: Thu, 27 Aug 2026 18:56:07 +0800 Subject: [PATCH] fix(config): guard LlamaBidirectionalConfig against missing hf_config.pooling (#50536) Signed-off-by: Chenglun Hu --- vllm/model_executor/models/config.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vllm/model_executor/models/config.py b/vllm/model_executor/models/config.py index 12c9f5630e..fe7eca2757 100644 --- a/vllm/model_executor/models/config.py +++ b/vllm/model_executor/models/config.py @@ -549,9 +549,19 @@ class LlamaBidirectionalConfig(VerifyAndUpdateConfig): "last": "LAST", } - pooling_type = pooling_type_map.get(hf_config.pooling) + pooling = getattr(hf_config, "pooling", None) + if pooling is None: + raise ValueError( + "This bidirectional model requires a 'pooling' field in its HF " + "config (one of 'avg', 'cls', 'last'), but none was found. " + "Unlike the VL variants, no default is assumed here because " + "silently picking a pooling for an embedding model can produce " + "wrong embeddings." + ) + + pooling_type = pooling_type_map.get(pooling) if pooling_type is None: - raise ValueError(f"pool_type {hf_config.pooling!r} not supported") + raise ValueError(f"pool_type {pooling!r} not supported") assert model_config.pooler_config is not None model_config.pooler_config.seq_pooling_type = pooling_type