Skip to content

Tests and evals ​

Scholar Lens has two kinds of checks. Tests check that the code works, with fake models, in a few minutes. Evals check that answers are correct, with the real models, over hours. This page explains how to run both and how to read an eval report.

Run the tests ​

The backend tests start a throwaway Postgres with pgvector through testcontainers, so Docker must be running. They use a hash embedder and a scripted chat model, so no model server is needed.

From the backend folder, with the Python environment active:

bash
python -m pytest

The suite has about 270 tests and takes a few minutes. Before each commit, also run the linters:

bash
ruff check app evals tests
bash
mypy app

The sandbox has its own tests, from the sandbox folder:

bash
python -m pytest

The fork-bomb tests there run only inside a container (they are skipped unless /.dockerenv exists).

CAUTION

Never run the fork-bomb tests directly on a host. Outside gVisor they can take the whole machine down.

For the frontend and the extension, from their folders:

bash
npm run lint
bash
npm run build

The frontend also has npm run typecheck.

Continuous integration ​

GitHub Actions runs the same checks for pull requests into main, and when started by hand from Actions, CI, Run workflow. It does not run on every push, to save paid minutes on the private repository. Run the checks locally before you commit.

Run the evals ​

An eval runs a golden question set through the real answer graph and grades every answer. It needs the database with the set's documents indexed, and the model server. Web search is off during evals.

From the backend folder:

bash
python -m evals.run --set rcv-week6-essential --owner <username> --style all
  • --owner is the user whose Library holds the documents.
  • --style all runs the set once per style: Summary, Comprehensive and Academic. On the 35B model that takes about 3½ hours.
  • --ids q01,q05 or --limit 5 runs a few questions.
  • --retrieval-only measures retrieval alone (recall@k and MRR), with no model calls. It takes seconds.
  • --rejudge evals/reports/<report>.json grades the saved answers of an earlier report again, without re-running the graph. Use it after a change to the judge.

Run evals with nothing else on the model. LM Studio's context is shared between its slots, and a chat next to an eval can overflow it.

Reports go to backend/evals/reports/ as JSON and Markdown. They are not in git, because they quote the books. The Quality tab in Settings lists the reports found on the server.

The golden sets ​

Each set is a YAML file in backend/evals/sets/:

SetSourceQuestions
rcv-week6-essentialHartley and Zisserman, Multiple View Geometry, sections 9.1 to 9.632
siftA 10-page summary of Lowe (2004), SIFT32
transformer"Attention Is All You Need" and a course's week 6 slides32

A question has a kind:

  • in_scope: answerable from the sources. Correct when every listed fact is stated and there is no major error.
  • outside_scope: on the topic but outside the assigned sources. Correct when the answer declines or answers it fully.
  • trap: a false premise. Correct when the answer corrects it or declines.

Each question lists facts for the judge, must_include keyword groups, and the expected pages. About a quarter of the questions in the newer sets are held_out: true: they are for checking only, never for tuning prompts. A gap between held-out and other questions means the prompts were tuned to the visible ones.

How answers are graded ​

  • The rubric judge is the local model, with thinking on. It grades each fact as stated, partly stated, missing or contradicted, and lists wrong statements. It must quote the answer and the sources for each verdict, and code checks the quotes, so an invented error doesn't count.
  • The keyword score checks must_include against the normalised answer. It is kept to compare: the report gives the agreement between the two.
  • Citations follow the ALCE method. The answer is split into statements. The judge checks each one against the passages it cites, quoting the supporting words, which code verifies.
    • Citation precision: citations that support their statement, out of all citations.
    • Citation recall: statements fully supported by their citations, out of all statements. Uncited statements count as unsupported.
  • Page locality: how many citations point to the expected pages. It is reported but is not a gate.
  • Confident-wrong: answers graded not correct that were given with High confidence.

Every report lists a spot-check sample: each judge and keyword disagreement plus random questions up to 20 %, for a person to check by hand.

The release gate ​

A release must reach at least 90 % correct, at least 95 % citation precision and at most 2 % confident-wrong, on every set and in every style.