From 1a68ec93781c9014ac0a1e174887ae703c6deaf8 Mon Sep 17 00:00:00 2001 From: Rares Vernica Date: Sat, 16 May 2026 23:39:04 -0700 Subject: [PATCH] server : honor --embd-normalize CLI arg (#23125) 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 | 2 +- tools/server/server-context.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/arg.cpp b/common/arg.cpp index 84b3c8f96..d7a935fc1 100644 --- a/common/arg.cpp +++ b/common/arg.cpp @@ -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)", diff --git a/tools/server/server-context.cpp b/tools/server/server-context.cpp index 4d162f81d..1ce7f0958 100644 --- a/tools/server/server-context.cpp +++ b/tools/server/server-context.cpp @@ -4527,7 +4527,7 @@ std::unique_ptr 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) {