{"abstract":"Unequal vector norms distort cosine ranking.","category":"Vector retrieval ranking","checks":6,"contract":"Rows are [id,dot,query_norm_squared,vector_norm_squared], with positive norms and valid dot products. Rank by signed cosine dot/sqrt(query_norm_squared*vector_norm_squared), then ID.","contract_signature":"rows","evaluation_group":"vector-retrieval-cosine-from-dot-and-norms","failed_approach":"Dividing by the norm product instead of its square root over-penalizes large vectors.","family":"w3-vector-retrieval-ranking-cosine-from-dot-and-norms","id":"FA-99491","implementations":{"attempt":{"sha256":"53d3d307f0d305c88d83ce94d8d57c0b781ee1314d4c92130a51fd7fc96962fe","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(rows):\n    return [r[0] for r in sorted(rows,key=lambda r:(-(r[1]/(r[2]*r[3])),r[0]))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('large norm lowers cosine',solve([['a',3.5,4,4],['b',4,4,16]]),['a','b'])\ncheck('small cosine despite dot',solve([['a',8,1,64],['b',3,1,16]]),['a','b'])\ncheck('negative cosine',solve([['a',-2,1,16],['b',-1,1,1]]),['a','b'])\ncheck('equivalent cosine lexical',solve([['z',2,1,4],['a',1,1,1]]),['a','z'])\ncheck('scaled vectors',solve([['a',N,N,N],['b',2*N,4*N,4*N]]),['a','b'])\ncheck('three norm scales',solve([['c',1,1,16],['a',3,1,9],['b',2,1,4]]),['a','b','c'])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"a7035dd2328828f0aa930dc058cea4b5a4e4b34e96020ef79863696024924dbf","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(rows):\n    return [r[0] for r in sorted(rows,key=lambda r:(-r[1],r[0]))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('large norm lowers cosine',solve([['a',3.5,4,4],['b',4,4,16]]),['a','b'])\ncheck('small cosine despite dot',solve([['a',8,1,64],['b',3,1,16]]),['a','b'])\ncheck('negative cosine',solve([['a',-2,1,16],['b',-1,1,1]]),['a','b'])\ncheck('equivalent cosine lexical',solve([['z',2,1,4],['a',1,1,1]]),['a','z'])\ncheck('scaled vectors',solve([['a',N,N,N],['b',2*N,4*N,4*N]]),['a','b'])\ncheck('three norm scales',solve([['c',1,1,16],['a',3,1,9],['b',2,1,4]]),['a','b','c'])\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w3-vector-retrieval-ranking-cosine-from-dot-and-norms","generated_at":"2026-09-30T16:48:24.913743+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"An offline vector retrieval toy model isolates one ranking contract from embedding generation, storage, and serving.","root_cause":"Raw dot products are ranked without accounting for candidate and query magnitudes.","sha256":"9b6b3e352054855d5bc21ee0d24eaca4d6ccbb779192c40f39b05c68bfca48f8","title":"Vector retrieval: Unequal vector norms distort cosine ranking · case 01","variant":1,"variant_policy":"The fixture code references N, supplied as 1 through 5. Fixed boundary checks may repeat. These records share one mechanism and must remain together in evaluation splits.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":28.309,"exit_code":1,"observations":[{"actual":["a","b"],"check":"large norm lowers cosine","expected":["a","b"],"passed":true},{"actual":["b","a"],"check":"small cosine despite dot","expected":["a","b"],"passed":false},{"actual":["a","b"],"check":"negative cosine","expected":["a","b"],"passed":true},{"actual":["a","z"],"check":"equivalent cosine lexical","expected":["a","z"],"passed":true},{"actual":["a","b"],"check":"scaled vectors","expected":["a","b"],"passed":true},{"actual":["b","a","c"],"check":"three norm scales","expected":["a","b","c"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"large norm lowers cosine\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"small cosine despite dot\", \"actual\": [\"b\", \"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"negative cosine\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"equivalent cosine lexical\", \"actual\": [\"a\", \"z\"], \"expected\": [\"a\", \"z\"], \"passed\": true}, {\"check\": \"scaled vectors\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"three norm scales\", \"actual\": [\"b\", \"a\", \"c\"], \"expected\": [\"a\", \"b\", \"c\"], \"passed\": false}], \"passed\": false}\n"},"broken":{"elapsed_ms":27.41,"exit_code":1,"observations":[{"actual":["b","a"],"check":"large norm lowers cosine","expected":["a","b"],"passed":false},{"actual":["a","b"],"check":"small cosine despite dot","expected":["a","b"],"passed":true},{"actual":["b","a"],"check":"negative cosine","expected":["a","b"],"passed":false},{"actual":["z","a"],"check":"equivalent cosine lexical","expected":["a","z"],"passed":false},{"actual":["b","a"],"check":"scaled vectors","expected":["a","b"],"passed":false},{"actual":["a","b","c"],"check":"three norm scales","expected":["a","b","c"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"large norm lowers cosine\", \"actual\": [\"b\", \"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"small cosine despite dot\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"negative cosine\", \"actual\": [\"b\", \"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"equivalent cosine lexical\", \"actual\": [\"z\", \"a\"], \"expected\": [\"a\", \"z\"], \"passed\": false}, {\"check\": \"scaled vectors\", \"actual\": [\"b\", \"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"three norm scales\", \"actual\": [\"a\", \"b\", \"c\"], \"expected\": [\"a\", \"b\", \"c\"], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}