LLM inference, evaluation and retrieval
how-many-questions
How many questions does an eval need before it can see that a new version of a model, a 4-bit copy for example, answers worse than the old one?
Answer
It depends on two numbers: the loss to be found and the share of questions the two versions answer differently. In sql-under-compression, q4_k_m answered 85 of 1,034 Spider questions differently from f16 and lost 3.2 points: 59 questions lost, 26 gained. Taking those counts as the truth, a run needs 668 questions to see the loss with a chance of 80 %. My first run there had 200 questions and could not see it. Its chance was 26.9 %, so that was the likely outcome, not bad luck.
How it was measured
- Both versions answer the same questions, so only the questions they answer differently tell them apart. Lost went from right to wrong, gained from wrong to right. The exact two-sided sign test asks how likely a split at least this uneven would be if each differing question were a fair coin toss. It is the test release-gate and sql-under-compression use.
- For a plan, the number of differing questions in a run is binomial, and each differing question is lost with chance (differ rate + loss) divided by twice the differ rate. The power is the chance that the test lands below the level, 0.05 by default, with more lost than gained questions. The code sums it over every number of differing questions and leaves out only terms that add up to less than 1e-18. The fewest lost questions that reach the level are counted with exact integers.
- The normal approximation gives 626 questions for the same plan, the exact sum 668, 7 % more. With few differing questions, as in a plan for a small eval, the approximation is too hopeful.
- With the counts from sql-under-compression, the power goes from 11 % at 100 questions to 94 % at all 1,034. It is the same table as in my article on that run, and a test pins every row.
- Typed with one decimal, as 8.2 % and 3.2 points, the same run gives 663 questions, and 27.1 % at 200. That is why --from takes the counts of a finished run, questions lost, gained and asked, so nothing is rounded.
- At 8.2 % of questions differing, the smallest loss seen with a chance of 80 % is 5.8 points at 200 questions and 2.6 points at 1,034.
- The tests check the power against a sum over every possible outcome for runs of up to 47 questions, within 1e-12, the counts against a direct scan with the sign test, and the thresholds and p-values against the ones sql-under-compression publishes. Every example in the README is a test. 132 tests pass in CI.
Proof
Every file is pinned to the commit the numbers come from, so the links cannot drift. The DOI leads to the Zenodo archive of every release.
Reproduce it
python -m howmany --from 59 26 1034 --questions 200
python -m howmany --differ 8.2 --loss 3.2 --questions 200
python -m howmany --differ 8.2 --questions 1034
pip install -r requirements-dev.txt
pytestRun from a clone, with nothing to install: the tool uses only Python's standard library. The first command prints the plan above, the third the smallest loss a full run sees. The test tools are needed only for the checks. CI runs ruff, mypy in strict mode, vulture and the tests.
Limits
- The two inputs are assumptions. Using the loss a run has just measured to explain that same run's p-value is circular. A plan should use the smallest loss that would matter, for example the largest one a release may lose.
- The differ rate of a pilot run is itself uncertain. A higher differ rate needs more questions for the same loss, so the safe choice is the upper end of the pilot's interval.
- Questions are taken as independent. Spider's questions share 20 databases, and questions on the same database tend to fail together. Then the real noise is larger than the sign test assumes, and a plan from this tool is too small.
- Only a loss counts. The test is two-sided, as in release-gate, but the power counts only the runs that show more lost than gained questions.
- From 80 % of questions differing, the power can drop a little with one more question, and a smaller run may reach the target too: with 95 % differing and a loss of 73 points, the tool reports 15 questions, while 13 already reach 80 %. Below 80 % no such case was found.
- Runs go up to 100,000 questions, and a plan that needs more says so. The slowest plan measured took 14 s.