Vector retrieval comparison workshop / 6 MIN READ
Reconcile the metric behind a vector-search ranking
The same supplied vectors can support different nearest-result orders.
AI-assisted research and analysis for the SNS Creative Fieldbook
Sources checked 2026-11-07
A retrieval result is partly defined by its comparison rule. Before an editor explains a changed search order as improved understanding, verify what mathematical comparison the implementation actually made and what the intended model expects.
What you will leave with: A known-answer ranking contract with a separate semantic-relevance review.
Use this when
- A vector-search implementation changes its comparison setting.
- An index migration produces a different candidate order from the same supplied vectors.
Not an embedding-model selection guide, proof of semantic quality or permission to change a live search index.
Establish the comparison contract
Scikit-learn defines cosine similarity as the dot product divided by both vector lengths. Its Euclidean-distance reference defines distance from the squared lengths and dot product. Higher cosine similarity and lower Euclidean distance use opposite score directions.
Ask the model and index owners to identify the intended comparison, vector preparation and returned score meaning. A label such as similarity may hide a transformed value or a reversed ordering convention. Preserve the actual configuration rather than assuming that two products with similar controls interpret those controls identically.
Use supplied synthetic vectors to check the implementation before bringing real content into the example. Keep the input array, query and candidate identities together. A result list cannot be diagnosed if the vectors changed at the same time as the index configuration. Separate a revised representation from a revised rule for comparing that representation.
Compare three rules on the same candidates
Use q = (1,0), A = (1,1), B = (10,1). Cosines are 1/√2 ≈ 0.707107 and 10/√101 ≈ 0.995037: B ranks first. Euclidean distances are 1 and √82 ≈ 9.055385: A ranks first. Raw dot products are 1 and 10.
Now replace A by (100,100). Its cosine is unchanged, but its dot product becomes 100 and outranks B’s 10. This controlled scaling changes the raw-dot ranking without changing A’s direction.
Retain all three named outputs instead of highlighting whichever one agrees with an expected answer. The actual local execution uses scikit-learn 1.8.0 and NumPy 2.3.5, with independent scalar formulas checking the results. These are arithmetic comparisons between invented vectors, not embeddings of actual products or evidence that one retrieved document answers a real query better.
Ask a reviewer to reconstruct the reversal from the inputs. They should explain which quantity changed, not merely observe that candidate A moved. That distinction gives the technical owner a useful regression question while avoiding an unsupported claim that a new order reflects greater intelligence or a better understanding of the customer.
Treat normalization as an explicit model decision
With both candidates normalized to unit length, Euclidean distances from q become approximately 0.765367 and 0.099627, again favoring B. For unit vectors, squared distance equals 2 − 2 times cosine similarity. Reject a zero vector before this normalization; its length cannot be used as a divisor.
Do not normalize a production representation merely to make the toy rankings agree. Have the model owner explain what preprocessing the intended representation requires and what information a change would retain or discard. Record where that preparation happens so an index import and a query path do not quietly apply different contracts.
Preserve the deliberate failure input beside the successful example. A pipeline that produces a numeric value for every supplied row may still be accepting an input that has no justified interpretation under the chosen contract. Ask the implementation owner to define the appropriate rejection or fallback behavior rather than letting a convenient library convention become an unreviewed product policy.
Keep implementation precision separate from semantic judgment. The fixture checks a small, well-conditioned set of values; it does not establish approximate-index recall, stability for every numerical range or the suitability of the underlying representation. Those questions need their own evidence rather than being implied by a passing local calculation.
Connect mathematical acceptance to relevance review
Prepare a compact handoff containing the unchanged vectors, named metric, score direction, preparation steps and observed candidate order. Record which values were calculated locally and which, if any, were observed in a receiving index. No production search service was queried for this lesson, so the synthetic result remains a target for a later authorized comparison.
Once the technical contract is verified, evaluate real relevance with an appropriate query-and-result review. A mathematically faithful order can still return content that is unhelpful, outdated or outside the requested scope. Preserve the distinction between correctly executing a chosen comparison and choosing a representation that serves the audience.
If the intended ranking contract changes, keep that decision explicit in the release record and review the consequences before deployment. Do not quietly relabel a changed score as the old one or promise improved search quality from this fixture alone. The deliverable is a reproducible explanation and a bounded next review, not authorization to replace the live index.
Make the reasoning concrete.
A fictional catalog team sees candidate order change after an index configuration review. An editor proposes announcing better semantic search before the team establishes which comparison changed.
Interpret the new order immediately
Opening: Treat the ranking difference as evidence of improved understanding.
Hypothesis: The release gets a simple positive story.
Risk: The claim may describe a configuration difference rather than better relevance.
Verify the ranking contract first
Opening: Reproduce the controlled comparison and separate it from the later content review.
Hypothesis: The team can explain the change accurately.
Risk: Semantic quality still requires independent evaluation.
The team requests the contract comparison before making a quality claim. It does not change the index or publish an announcement.
Take the questions into your next brief.
Use these prompts in your own notes. Nothing is submitted from this page.
Identity
Are the query and candidate vectors unchanged across the comparison?
Metric
What exact quantity and score direction does the implementation use?
Preparation
Where is any vector normalization applied and why?
Failure
What input must be rejected before the stipulated calculation?
Relevance
Which real content judgments remain outside the numerical fixture?
Watch for the wrong conclusion.
- Changing vectors and ranking configuration while attributing the outcome to only one.
- Treating a convenient numeric fallback as an approved input contract.
- Calling a mathematical ranking check a semantic-quality evaluation.
Your next action
Reconstruct the two candidate orders and the controlled scaling case, then state what evidence is still needed about real search relevance.
Sources & scope
Original synthetic vectors and search-review procedure. Local numerical library calls and independent scalar checks only. No actual embedding model, customer query, production index or semantic-quality study was used.
- Scikit-learn: cosine_similarity →Primary scientific software documentation · Supports: Supports normalized-dot comparison and its unit-length interpretation.
- Scikit-learn: euclidean_distances →Primary scientific software documentation · Supports: Supports Euclidean-distance calculation.