Personal software project · Backend, retrieval, evaluation
BERA – Book Edition Resolution Assistant
A personal software project: given an ISBN or a partial book description, BERA suggests one Open Library edition only when the evidence is unique and consistent. Otherwise it routes the case to human review and shows why.
The problem
One book exists as many editions: hardcover, paperback, translations, study guides. The input is often partial or damaged, such as an ISBN with a bad check digit or a few words from the cover.
BERA is decision support. It never creates listings, changes prices, calls external services or makes irreversible decisions. A person makes the final call.
Human-review workflow
- ReviewerEnter whatever is known
Any of ISBN, title, author, format, year, publisher, language, edition and free text, then Resolve.
- ISBN stageValidate and look up the ISBN
Normalization, checksum validation, ISBN-10/13 conversion and an exact lookup.
Always human reviewAn ISBN that maps to more than one record, or a guessed repair of a bad checksum.
- RetrievalFind candidate editions
SQLite FTS5 BM25 plus a trigram index that tolerates typos, fused with reciprocal rank fusion (k=60).
- Field checksCheck every field of every candidate
Each field is marked agree, disagree or unknown. Unknown fields never tell candidates apart.
- Decision policySuggest only a unique, consistent match
The suggestion must be the only consistent candidate across the whole catalog.
Suggested matchShown as a suggestion, not a confirmed match, with the ranked candidates and their field checks.
- Local model · optionalAdd an advisory view
When several candidates still fit, a local model may choose one and must cite fields. Both routes for changing a decision are closed, so it stays advisory.
- Decision policyOtherwise: needs human review
The screen shows reason codes such as multiple_consistent_candidates, the ranked candidates and their field checks.
- ReviewerConfirm or reject
The answer is stored as local feedback, kept separate from evaluation labels.
Architecture
I built the service in Python with FastAPI, the retrieval on SQLite FTS5 and the review UI in React and TypeScript, and implemented an evaluation harness that runs seven configurations on identical cases.
Backend · Python, FastAPI
- ISBN normalization and checksum validation
- Deterministic per-field checks
- Rule-based decision policy (conservative-rules-v2)
- Local SQLite traces
Retrieval · SQLite FTS5
- BM25 full-text index
- Trigram index for typos
- Reciprocal rank fusion
- Optional, evaluated: bge-small embeddings and a MiniLM reranker
Frontend · React, TypeScript
- Review screen with per-field check tables
- Advisory model panel
- Confirm/reject feedback
- Blind-first labeling UI
Local model route · optional
- Qwen3-4B-Instruct served by llama.cpp on 127.0.0.1
- Temperature 0, JSON-schema output
- Runs only when several candidates still fit
- Off by default
Safety and reliability
- Abstain unless unique. Unknown fields never distinguish candidates, and a suggestion must be unique across the whole catalog. The policy is a set of rules, not a calibrated confidence score.
- Cited fields are checked in code. Model output must fit a strict Pydantic schema, the choice must be an allowed id or ABSTAIN, and every cited value must exactly equal the candidate's stored field. Invalid output is rejected, never repaired. The model's free-text reasoning and confidence are not validated.
- A gate fixed in advance. The model may change a decision only on a route with at least 30 dev cases and a 95% Wilson lower confidence bound of at least 0.95. Dev evidence was 4/10 (lower bound 0.17), so both routes are closed and the model is advisory.
- Queries are never stored as text. Local SQLite traces keep per-stage timings and model status; the query itself is stored only as a salted HMAC.
- A hardened container. Docker runs as a non-root user with a read-only root filesystem and no-new-privileges; Compose binds to 127.0.0.1, and the model is off by default.
- Untrusted text stays data. Catalog data and queries are wrapped in per-request random delimiters, non-local model endpoints are refused, and 35 security tests cover forged ids, fabricated citations and prompt injection in catalog data or the query.
Evaluation and limitations
- Held-out · tag r20/40wrong suggestions observed
- 95% Wilson interval 0–8.8%. Read it with coverage: BERA suggested the right edition for 6 of 15 answerable queries.
- Held-out · tag r26/15answerable coverage
- Correct suggestions on the 15 queries where the labeler chose one edition (Wilson 19.8–64.3%). The other 9 went to review.
- Held-out · tag r225/25review cases routed to review
- Every query the labeler sent to human review, BERA also sent to review.
- Held-out · tag r2Identicaldecisions across all 7 configurations
- Lexical, embedding, reranker and routed local-model configurations made the same final decisions; the model showed no measured accuracy gain.
All held-out numbers come from the frozen tag bera-eval-freeze-2026-11-07-r2: 40 program-drafted, human-reviewed queries from Open Library records in 39 work families, one labeler, run once. They were not re-measured on v0.1.0 or later versions.
Limitations
- The sample is small and has one labeler, and the queries are program-drafted, not real traffic.
- The conservative policy limits coverage, not retrieval: the right edition was in the top five for 15 of 15 answerable queries.
- Confidence is not calibrated, and the model's routes stay closed.
- Not deployed or hosted, with no load or concurrency testing. It runs locally with Docker Compose.
Source, report and walkthrough
- GitHub repository Source code, README and quick start. (opens in a new tab)
- Evaluation report Method, held-out results and limitations. (opens in a new tab)
- Release v0.1.0 Published 2026-11-08. (opens in a new tab)
- Walkthrough video 2 min 24 s, WebM, 9 MB. Plays or downloads from GitHub. (opens in a new tab)
- Presentation page Walkthrough script and screenshots. (opens in a new tab)
There is no hosted demo. The demo and the walkthrough use only a 30-edition invented catalog.