]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama-context: only warn on pooling_type when user specified (#16674)
authortakuya kodama <redacted>
Mon, 20 Oct 2025 07:44:21 +0000 (15:44 +0800)
committerGitHub <redacted>
Mon, 20 Oct 2025 07:44:21 +0000 (10:44 +0300)
The unexpeced pooling_type warning was incorrectly shown when users did not
specify the --pooling-type parameter. In this case, the parameter
defaults to `LLAMA_POOLING_TYPE_UNSPECIFIED (-1)`, and the code
automatically applies the model's default pooling type.

Example of spurious warning:
```
$ llama-embedding -hf ggml-org/bge-m3-Q8_0-GGUF -p "hello"
...
llama_init_from_model: model default pooling_type is [2], but [-1] was specified
...
```

This fix ensures the warning only appears when users explicitly specify
a pooling type that differs from the model's default (e.g., using
--pooling-type mean on a model that expects CLS pooling).

src/llama-context.cpp

index e7526e7d0a55791630066cad4ce0df075a9c8e64..bd348bcad370a8ca5c53e3a6c576d278b6b1dba1 100644 (file)
@@ -2346,7 +2346,8 @@ llama_context * llama_init_from_model(
         return nullptr;
     }
 
-    if (params.pooling_type != model->hparams.pooling_type) {
+    if (params.pooling_type != LLAMA_POOLING_TYPE_UNSPECIFIED &&
+        params.pooling_type != model->hparams.pooling_type) {
         //user-specified pooling-type is different from the model default
         LLAMA_LOG_WARN("%s: model default pooling_type is [%d], but [%d] was specified\n", __func__,
                        model->hparams.pooling_type, params.pooling_type);