{"abstract":"Top-k drops the final retained candidate.","category":"Token sampling filters","checks":6,"contract":"Return the k highest-scoring token IDs, ties by ascending ID; k<=0 returns empty and k beyond vocabulary returns all.","contract_signature":"scores, k","evaluation_group":"w3-tsf-top-k-zero-based-cutoff","failed_approach":"Clamping the erroneous k-1 still excludes one valid candidate.","family":"w3-token-sampling-filters-top-k-zero-based-cutoff","id":"FA-98341","implementations":{"attempt":{"sha256":"d33875b1ef102eb9318575b3988f312647795b8ad60577e049cd770b9627c5a9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(scores, k):\n    ranked=sorted(scores,key=lambda t:(-scores[t],t))\n    return ranked[:max(0,min(k-1,len(ranked)))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('top two',solve({'a':N+2,'b':N+1,'c':N},2),['a','b'])\ncheck('singleton',solve({'a':N},1),['a'])\ncheck('zero',solve({'a':N},0),[])\ncheck('oversized',solve({'b':N,'a':N},9),['a','b'])\ncheck('tie order',solve({'z':N,'a':N},1),['a'])\ncheck('empty',solve({},2),[])\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":"ead7a2b617ec620bd241b212de4085781dfe758cfe051c1d07f1eb960107de6c","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nN = 1\nobservations = []\ndef solve(scores, k):\n    ranked=sorted(scores,key=lambda t:(-scores[t],t))\n    return ranked[:max(0,k-1)]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('top two',solve({'a':N+2,'b':N+1,'c':N},2),['a','b'])\ncheck('singleton',solve({'a':N},1),['a'])\ncheck('zero',solve({'a':N},0),[])\ncheck('oversized',solve({'b':N,'a':N},9),['a','b'])\ncheck('tie order',solve({'z':N,'a':N},1),['a'])\ncheck('empty',solve({},2),[])\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":"These are toy finite-vocabulary contracts with supplied scores, histories, and draws; they do not claim production model quality or compatibility. 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-token-sampling-filters-top-k-zero-based-cutoff","generated_at":"2026-09-30T16:48:11.933319+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A finite, deterministic token-selection contract isolates one decoding operation from model inference and runtime behavior.","root_cause":"The cutoff subtracts one from a count that is already a slice length.","sha256":"588b2c7a5a3a62f28b6c6f8abfcf485450abe6157443443fb7b8be2bfdeef3dd","title":"Token sampling: Top-k drops the final retained candidate · 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":29.056,"exit_code":1,"observations":[{"actual":["a"],"check":"top two","expected":["a","b"],"passed":false},{"actual":[],"check":"singleton","expected":["a"],"passed":false},{"actual":[],"check":"zero","expected":[],"passed":true},{"actual":["a","b"],"check":"oversized","expected":["a","b"],"passed":true},{"actual":[],"check":"tie order","expected":["a"],"passed":false},{"actual":[],"check":"empty","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"top two\", \"actual\": [\"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"singleton\", \"actual\": [], \"expected\": [\"a\"], \"passed\": false}, {\"check\": \"zero\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"oversized\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"tie order\", \"actual\": [], \"expected\": [\"a\"], \"passed\": false}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":27.289,"exit_code":1,"observations":[{"actual":["a"],"check":"top two","expected":["a","b"],"passed":false},{"actual":[],"check":"singleton","expected":["a"],"passed":false},{"actual":[],"check":"zero","expected":[],"passed":true},{"actual":["a","b"],"check":"oversized","expected":["a","b"],"passed":true},{"actual":[],"check":"tie order","expected":["a"],"passed":false},{"actual":[],"check":"empty","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"top two\", \"actual\": [\"a\"], \"expected\": [\"a\", \"b\"], \"passed\": false}, {\"check\": \"singleton\", \"actual\": [], \"expected\": [\"a\"], \"passed\": false}, {\"check\": \"zero\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"oversized\", \"actual\": [\"a\", \"b\"], \"expected\": [\"a\", \"b\"], \"passed\": true}, {\"check\": \"tie order\", \"actual\": [], \"expected\": [\"a\"], \"passed\": false}, {\"check\": \"empty\", \"actual\": [], \"expected\": [], \"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."}}