fix(memory): normalize gRPC query vector to fix near-zero cosine scores#3422
Merged
fix(memory): normalize gRPC query vector to fix near-zero cosine scores#3422
Conversation
…ro cosine scores Qdrant stores Cosine-distance vectors as unit vectors internally. The REST API normalizes the query vector server-side; the gRPC path does not. Sending an un-normalized vector via gRPC produces near-zero dot-product scores (~0.022) even when the collection dimension matches, making skill injection non-functional (issue #3391). Fix: L2-normalize the query vector in QdrantOps::search before passing it to SearchPointsBuilder. Zero-magnitude vectors are left unchanged to avoid division by zero. Add unit tests for l2_normalize covering: unit vector, arbitrary vector, zero vector (no-op), and already-unit idempotency.
This was referenced Apr 26, 2026
bug-ops
added a commit
that referenced
this pull request
Apr 26, 2026
…antOps The deprecated gRPC search_points path produced near-zero cosine scores (~0.011) for skill injection, causing all candidates to fall below the 0.20 threshold and zero skills to be injected per turn. Replace SearchPointsBuilder + client.search_points() with QueryPointsBuilder + client.query() as recommended by qdrant-client 1.17.0. The Query API returns correct scores (~0.53) for the same unit-normalized vectors. Also remove the l2_normalize workaround added in #3422 — it had no effect since Ollama embeddings are already unit-normalized (norm ≈ 1.0). Closes #3425
bug-ops
added a commit
that referenced
this pull request
Apr 26, 2026
…antOps (#3428) The deprecated gRPC search_points path produced near-zero cosine scores (~0.011) for skill injection, causing all candidates to fall below the 0.20 threshold and zero skills to be injected per turn. Replace SearchPointsBuilder + client.search_points() with QueryPointsBuilder + client.query() as recommended by qdrant-client 1.17.0. The Query API returns correct scores (~0.53) for the same unit-normalized vectors. Also remove the l2_normalize workaround added in #3422 — it had no effect since Ollama embeddings are already unit-normalized (norm ≈ 1.0). Closes #3425
Merged
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QdrantOps::searchbefore handing it toSearchPointsBuilderTest plan
l2_normalize(unit vector, arbitrary [3,4]→[0.6,0.8], zero vector, idempotency)cargo run --features full -- --config .local/config/testing.toml, verify skill candidates score 0.20–0.45 instead of ~0.022Closes #3391
Closes #3421