Skip to content

Evidence and citations ​

Citations in Scholar Lens are built by code from the index, never written by the model. This page explains how evidence is chosen, how the model cites it, how claims are checked, and how the confidence label is computed. The code is in app/agent/evidence.py.

Evidence ids ​

The pack node gives each chosen passage an id: S1, S2 and so on. The model sees the passages in an evidence block, each under its id and a short source label (for example "Multiple view Geometry, p. 265 · 9.2.2"). The prompt tells it to cite every factual sentence with ids in square brackets, such as [S3] or [S2, S5].

The model never sees a citation format it could imitate wrongly. It writes only ids.

Choosing the evidence ​

pack_with_decisions merges course passages, web passages, notes and code results, removes duplicates, and sorts them by score. It keeps passages until one of three limits:

  • the style's passage limit: 8 for Summary, 16 for Comprehensive and Academic,
  • the evidence token budget (EVIDENCE_TOKEN_BUDGET, 12,000 tokens by default),
  • the relevance floor (EVIDENCE_MIN_SCORE, 0.1), when a reranker scored the passages.

Each left-out passage gets its reason ("Too weak", "Past limit", "Over budget") in the evidence.packed event, which the Sources tab shows.

A passage carries its neighbouring chunks as context, so the model reads a derivation whole. The citation still points to the chunk itself.

Turning ids into citations ​

cite() runs in finalize:

  1. It finds every [S…] marker in the answer, skipping maths and code spans. It also accepts a few spellings small models produce, such as [source 3].
  2. It groups passages into references by source_key: the same book page, or the same web work by DOI, title or address. Two passages of one page become one reference. One paper found at two addresses becomes one reference. A note or a code result is always its own reference.
  3. It numbers the references in order of first use and rewrites the markers as [1], [2].
  4. It builds the reference list from chunk metadata: document title, page, section path, web title, address and access date.

An id the model made up, with no passage behind it, is dropped.

Checking claims ​

The verify node asks the model for the answer's main claims (up to 12 for Summary, 25 otherwise). For each claim the model gives the ids it cites, a short quote from those passages, and whether it thinks the passages support it.

check_claims then decides each verdict in code:

VerdictMeaning
verifiedThe quote was found in one of the cited passages
unquotedThe model says it is supported, but its quote is not in any cited passage
unsupportedThe model itself says the passages don't support it
uncitedThe claim cites no existing passage

The quote check (quote_in) is fuzzy on purpose, because the same formula is written many ways:

  • It lowercases and drops everything but letters and digits, after mapping \top, ᵀ, \times, ×, superscript and subscript digits and a few LaTeX commands to plain forms. So K'^T F K matches K ′ T FK, and K⁻¹ matches K^{-1}.
  • A long quote matches when at least 80 % of it appears as one run of text. A quote with "..." is checked part by part.
  • A quoted equation also matches when its sides appear in order, close together. Books write chains like F = A = B, and a quote of F = B is one link of it.
  • A claim citing a code result is verified when every number it states is in the cell's output, allowing for rounding.

The same function checks the judge's quotes in the evals, so a fix to it helps both.

Uncited sentences ​

statements() splits an answer into prose sentences and bullets, skipping headings, table rows, the Gaps section and short fragments. uncited_sentences() returns those with no citation. revise gets up to 15 of them per round and must add a citation or replace the sentence with "(not established by the sources)". finalize reports how many remain.

Confidence ​

confidence() turns the checks into a label with reasons:

LabelRule
LowNo evidence; or no checkable claims; or under 60 % of claims verified; or under half the queries covered; or, with a reranker, the best passage under 0.3
HighWith a reranker: at least 90 % of claims verified, every query covered, and the best passage at least 0.7
MediumEverything else

Without a reranker an answer can't be High, because fused scores say nothing about absolute relevance. Failed equation checks cap the label at Medium. The reasons list the numbers behind the label, and the count of uncited sentences.

The mind map ​

mind_map() builds a Markmap outline from the answer's own headings and bullets, without the model. Its root is the plan's topic.