]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
server : honor --embd-normalize CLI arg (#23125)
authorRares Vernica <redacted>
Sun, 17 May 2026 06:39:04 +0000 (23:39 -0700)
committerGitHub <redacted>
Sun, 17 May 2026 06:39:04 +0000 (09:39 +0300)
The --embd-normalize flag was registered only for the embedding and debug
examples, so llama-server rejected it and the /embedding handler used a
hard-coded default of 2 (L2). Add LLAMA_EXAMPLE_SERVER to the flag's
example set and read params.embd_normalize as the handler's default. The
per-request "embd_normalize" body field continues to override.

common/arg.cpp
tools/server/server-context.cpp

index 84b3c8f962da0f6ac43f71ae0b91846a227b463a..d7a935fc17919c3094de5cb64102500de7a7c5ed 100644 (file)
@@ -2808,7 +2808,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
         [](common_params & params, int value) {
             params.embd_normalize = value;
         }
-    ).set_examples({LLAMA_EXAMPLE_EMBEDDING, LLAMA_EXAMPLE_DEBUG}));
+    ).set_examples({LLAMA_EXAMPLE_EMBEDDING, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_DEBUG}));
     add_opt(common_arg(
         {"--embd-output-format"}, "FORMAT",
         "empty = default, \"array\" = [[],[]...], \"json\" = openai style, \"json+\" = same \"json\" + cosine similarity matrix, \"raw\" = plain whitespace-delimited output (one embedding per line)",
index 4d162f81d9bb936d82ecc0d027ec339b6eb12dc2..1ce7f0958279ccaa67844b83d479d188a97b242c 100644 (file)
@@ -4527,7 +4527,7 @@ std::unique_ptr<server_res_generator> server_routes::handle_embeddings_impl(cons
         }
     }
 
-    int embd_normalize = 2; // default to Euclidean/L2 norm
+    int embd_normalize = params.embd_normalize;
     if (body.count("embd_normalize") != 0) {
         embd_normalize = body.at("embd_normalize");
         if (meta->pooling_type == LLAMA_POOLING_TYPE_NONE) {