FAILURE MAP
← Case archive

FA-99446 / Vector retrieval ranking / Open access

Vector retrieval: Cosine similarity is treated as a distance · case 01

Cosine similarity is treated as a distance.

Verified by executionVariant 1 · 6 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Similarity is sorted ascending as if it were a cost.

THE FAILURE

Similarity is sorted ascending as if it were a cost.

Unsuccessful approach: Reversing IDs resolves equal scores in the wrong lexical order even though the score direction is repaired.

Case contract

Rows are [id,similarity]; return highest similarity first, lexical ties.

Why this case matters

An offline vector retrieval toy model isolates one ranking contract from embedding generation, storage, and serving.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rows):
    return [x[0] for x in sorted(rows,key=lambda x:x[1])]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('strong match',solve([['weak',-0.2],['strong',0.8]]),['strong','weak'])
check('positive ordering',solve([['a',N/10],['b',N/10+0.1]]),['b','a'])
check('negative ordering',solve([['a',-0.9],['b',-0.1]]),['b','a'])
check('tie lexical',solve([['z',0.5],['a',0.5]]),['a','z'])
check('zero tie',solve([['z',0.0],['a',0.0]]),['a','z'])
check('input shuffled',solve([['c',0.1],['a',0.9],['b',0.4]]),['a','b','c'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
strong match['weak', 'strong']['strong', 'weak']Failed
positive ordering['a', 'b']['b', 'a']Failed
negative ordering['a', 'b']['b', 'a']Failed
tie lexical['z', 'a']['a', 'z']Failed
zero tie['z', 'a']['a', 'z']Failed
input shuffled['c', 'b', 'a']['a', 'b', 'c']Failed

SHA-256 / d41faa4bbed8c1aac29029a1779dbad276dff8dc1173d7eff0ee33b36f74e339

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rows):
    return [x[0] for x in sorted(rows,key=lambda x:(-x[1],tuple(-ord(c) for c in x[0])))]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('strong match',solve([['weak',-0.2],['strong',0.8]]),['strong','weak'])
check('positive ordering',solve([['a',N/10],['b',N/10+0.1]]),['b','a'])
check('negative ordering',solve([['a',-0.9],['b',-0.1]]),['b','a'])
check('tie lexical',solve([['z',0.5],['a',0.5]]),['a','z'])
check('zero tie',solve([['z',0.0],['a',0.0]]),['a','z'])
check('input shuffled',solve([['c',0.1],['a',0.9],['b',0.4]]),['a','b','c'])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
strong match['strong', 'weak']['strong', 'weak']Passed
positive ordering['b', 'a']['b', 'a']Passed
negative ordering['b', 'a']['b', 'a']Passed
tie lexical['z', 'a']['a', 'z']Failed
zero tie['z', 'a']['a', 'z']Failed
input shuffled['a', 'b', 'c']['a', 'b', 'c']Passed

SHA-256 / e7a7094c0c21d67fab9ad4aea4d1b19da6b6f33240a97cd9b6c1173e33300c11

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 6 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

Inputs are small exact toy vectors and scores. No production index, ANN recall, embedding quality, or latency claim is implied. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-30T16:48:24.474501+00:00.

Case digest / 9a2a91839cd45dcaa2305437e2eef4a217de469269ff14ebbaf6dffdee1ff5fd