project-nomad/admin/app/controllers
jakeaturner a915cdcfc9 feat(AI): add opt-in relevance check for off-topic retrieval
The post-rerank relevance floor rejects noise but passes coherent
off-topic questions, and it gets worse as the library grows. Adding
Gutenberg prose, the Python tutorial and MDN pages to the eval corpus
took the off-topic leak rate from 22% to 67% at the 0.62 floor.

Score cutoff does not fix it. The weakest correct top hit scores 0.666
while "write me a haiku about autumn leaves" pulls Walden at 0.705.
A cosine floor and a top-vs-median contrast test both cost recall
faster than they cut leaks.

- Add rag.relevanceCheck (default off). After the floor, the tasks
  model, or the chat model when none is set, gives one grammar-constrained
  on_topic verdict for the whole retrieved set. Off topic means no
  context and no citations. Any failure keeps the chunks unjudged.
- Add a Settings > Models toggle recommending an 8B+ tasks model.
  On llama3:8b the check cuts off-topic leaks from 67% to 6% for about
  5 points of core recall@5 and ~0.6s per turn. On 3B models it rejects
  most valid questions, which is why it is opt-in.
- Add 6 distractor documents and an off_topic suite (18 unanswerable
  questions, 7 distractor controls) to the eval corpus.
- Report per-tag leak rates and leaked cases with top scores in
  eval:retrieval. Add --judge-model to measure the check and --dump to
  export pre-floor candidate pools for offline gate simulation.
- Pin the check off in eval:generation so a local setting cannot move
  scores.
- Record the distractor sweep on RAG_MIN_FINAL_SCORE. The 0.62 default
  stays: 0.65 halves leaks at no measured recall cost but leaves only
  0.016 of margin.

The corpus fingerprint changes to b4ebe5dce8699f5d. Retrieval reports
from before this commit are not comparable, and a new baseline is
committed.

Refs #1341
2026-09-29 15:54:41 -07:00
..
benchmark_controller.ts fix(benchmark): surface a clear reason when leaderboard submission fails (#1138) 2026-08-04 03:38:38 +00:00
chats_controller.ts fix(security): SSRF validation for map downloads and error sanitization (CWE-918, CWE-209) (#552) 2026-04-21 14:26:28 -07:00
collection_updates_controller.ts fix(security): path traversal and SSRF protections from pre-launch audit 2026-03-11 14:08:09 -07:00
conditions_controller.ts Add offline FDA drug reference (labels, interaction view, conditions, remedies) (#1040) 2026-08-04 03:38:33 +00:00
creator_packs_controller.ts feat(creator-packs): gated per-creator video packs, offline via Kiwix (#1106) 2026-08-04 03:38:27 +00:00
docs_controller.ts fix(Docs): fix doc rendering 2025-07-11 15:31:07 -07:00
downloads_controller.ts fix(downloads): add retry button and resource download link for failed downloads (#1059) 2026-08-04 03:37:31 +00:00
drug_reference_controller.ts Add offline FDA drug reference (labels, interaction view, conditions, remedies) (#1040) 2026-08-04 03:38:33 +00:00
easy_setup_controller.ts feat(AI): enable remote AI chat host 2026-04-03 14:26:50 -07:00
home_controller.ts Add offline FDA drug reference (labels, interaction view, conditions, remedies) (#1040) 2026-08-04 03:38:33 +00:00
maps_controller.ts fix(maps): cap marker notes at 500 characters server-side 2026-09-29 15:54:41 -07:00
nomad_md_controller.ts feat(AI): nomad.md for custom instructions (#1127) 2026-08-04 03:38:33 +00:00
ollama_controller.ts fix(chat): stop capping answers at 1024 tokens and surface truncation 2026-09-29 15:54:41 -07:00
openapi_controller.ts fix(UI): add API reference to Settings sidebar 2026-08-04 03:38:40 +00:00
rag_controller.ts feat(kb): per-file active toggle + collection grouping/bulk toggle (#1286) 2026-09-29 15:54:41 -07:00
settings_controller.ts feat(AI): add opt-in relevance check for off-topic retrieval 2026-09-29 15:54:41 -07:00
supply_depot_controller.ts feat: supply depot 2026-06-23 04:46:45 +00:00
system_controller.ts chore(dashboard): label the link tile field URL, drop the scheme hint 2026-09-29 15:54:41 -07:00
zim_controller.ts feat(zim): let users browse the Kiwix library in any language 2026-09-29 15:54:41 -07:00