| 1 | # MRCR Long-Context Accuracy Evaluation |
| 2 | |
| 3 | Smoke test for long-context behavior using OpenAI's public [`openai/mrcr`](https://huggingface.co/datasets/openai/mrcr) dataset. The model sees a long chat with several near-duplicate "needles" and must reproduce a specific earlier assistant turn verbatim, prepended with a random anti-guessing string. |
| 4 | |
| 5 | **Scoring:** if the response doesn't start with `random_string_to_prepend`, score is 0; otherwise the prefix is stripped and the mean `SequenceMatcher.ratio()` against the reference answer is reported. |
| 6 | |
| 7 | ## Usage |
| 8 | |
| 9 | ```bash |
| 10 | # Pytest (spawns the server) |
| 11 | pytest -s -v tests/evals/mrcr/test_mrcr_correctness.py \ |
| 12 | --config-list-file=configs/models-small.txt |
| 13 | |
| 14 | # Standalone (server already running; model and context auto-discovered) |
| 15 | vllm serve Qwen/Qwen3-0.6B --reasoning-parser qwen3 --port 8000 |
| 16 | python tests/evals/mrcr/mrcr_eval.py --port 8000 |
| 17 | ``` |
| 18 | |
| 19 | ## Configuration |
| 20 | |
| 21 | ```yaml |
| 22 | model_name: "Qwen/Qwen3-0.6B" |
| 23 | # Per-needle thresholds catch bucket-specific regressions (sliding window, |
| 24 | # chunked prefill, prefix cache) that an aggregate can hide. A scalar |
| 25 | # (e.g. `match_ratio_threshold: 0.20`) is also accepted and checked against |
| 26 | # the mean match ratio. |
| 27 | match_ratio_threshold: |
| 28 | 2: 0.30 |
| 29 | 4: 0.15 |
| 30 | 8: 0.10 |
| 31 | num_samples: 30 |
| 32 | needles: [2, 4, 8] |
| 33 | # max_prompt_tokens: 32768 # Optional; defaults to server max_model_len - max_tokens - 256 |
| 34 | max_tokens: 2048 |
| 35 | concurrency: 8 |
| 36 | server_args: "--max-model-len 32768 --reasoning-parser qwen3" |
| 37 | ``` |
| 38 | |
| 39 | ## Notes |
| 40 | |
| 41 | - Samples stream from three parquet shards (`{N}needle/{N}needle_0.parquet`); only the first few row groups are fetched, not the full 1.4 GB repo. |
| 42 | - `max_prompt_tokens` defaults to `max_model_len - max_tokens - 256`, i.e. fills whatever context the server advertises. Set `--max-model-len` on the server to control the smoke-test context length; override `--max-prompt-tokens` on the client to cap below that. |
| 43 | - Sample length is pre-filtered by `n_chars × 4 ≤ max_prompt_tokens`, then verified via the server's `/tokenize` endpoint under the actual chat template. |
| 44 | - Reasoning models: start the server with `--reasoning-parser <name>` (e.g. `qwen3`, `deepseek_r1`) so `<think>` goes to `message.reasoning_content` and doesn't contaminate the scored answer. |