Delta Ledger

An AI analyst that has to show its work.

Two 10-Ks, hundreds of pages each. It finds what changed, says why it matters, and never shows a quote it can't prove.

The architecture

Heavy work runs offline. Visitors never trigger a model bill.

Eight decisions

Prove quotes with code

No quote ships unless it's in the filing.

Every quote is checked as a substring of the filing, with whitespace, curly quotes and dashes folded. Only quotes that pass reach the second, skeptical model. 169 of 236 findings are proven; the rest are shown as unproven, never hidden.

src/quotes.py

Diff first, then pay for tokens

The model reads the edit, not the 10-K.

Sections are paired across years by meaning, then a line diff keeps only what changed plus two lines of context. Results are cached by a hash of their inputs, so an unchanged rerun costs nothing.

diffing.py

Measure accuracy on real filings

94% precision, 94% recall.

A golden set of 6 real 10-K pairs, 24 hand-labelled section judgments, against free baselines that flag every section or flag by diff size.

EVAL_REPORT.md

Price every model call

A ledger of tokens and exact dollars.

Every chat and embedding call goes through one OpenRouter client and lands in llm_calls with tokens, cost, provider and errors. It caught a run where half the calls were silently rate-limited.

llm/client.py

Overlap chunks by exactly 500

Proving a quote is one SQL call.

Passages are 2,400 characters and overlap by exactly 500, so any quote up to 500 characters sits inside one passage. A property test checks 300 random substrings.

chunking.py

Search by meaning and keyword

Two rankings, fused.

pgvector cosine distance and Postgres full-text rank, merged with reciprocal rank fusion in one statement. Ignoring company-wide words (the company's own name) took keyword hits from 21% to 46%.

search.py

Return passages, not answers

The asker's model writes the answer.

search_filings returns sources; verify_quote proves them for free. The server's only model call is one query embedding, capped at 2,000 a day, falling back to keyword search.

mcp_server.py

Three free services, not five on AWS

Supabase, Render, Vercel.

It started on Lambda, API Gateway, S3 and CloudFront with an export step. One database is now the source of truth, and responses were checked byte for byte before the switch.

render.yaml

The numbers

Retrieval eval on 24 questions
Search modeRight passage in top 5Questions in the filing's wordsReworded questionsMRR
Meaning only (vector)46%50%42%0.23
Keyword only46%67%25%0.24
Hybrid (both, fused)50%58%42%0.31
Who pays for what
ActionCostPaid by
Visiting this site, sample answers, checking a quote$0nobody
An MCP search (one query embedding)≈ $0.0000002the owner, capped at 2,000 a day
The answer written from the passagestheir modelthe asker
Embedding all 3,374 passages, once≈ $0.05the owner

Try the quote checker