llm: grounded generation endpoint — /query with citations #571

Closed
opened 2026-07-16 19:26:08 +00:00 by kert · 2 comments
Owner

RAG chain: retrieve → generate with the local instruct model, answers grounded in retrieved context only.

Scope

  • /query: question + filters → streamed answer with inline citations (bib item keys)
  • refuses/abstains when retrieval returns nothing relevant
  • context-window budgeting for the chosen model

Acceptance

  • answers on the pilot docket cite real items; no-context questions get an abstention, not a hallucination

Spec: docs/superpowers/specs/2026-07-16-llm-module-design.md

RAG chain: retrieve → generate with the local instruct model, answers grounded in retrieved context only. **Scope** - [ ] `/query`: question + filters → streamed answer with inline citations (bib item keys) - [ ] refuses/abstains when retrieval returns nothing relevant - [ ] context-window budgeting for the chosen model **Acceptance** - answers on the pilot docket cite real items; no-context questions get an abstention, not a hallucination Spec: [`docs/superpowers/specs/2026-07-16-llm-module-design.md`](https://git.fhirworx.io/homelab/stack/src/branch/main/docs/superpowers/specs/2026-07-16-llm-module-design.md)
kert added this to the P34: LLM Query — RAG API, CLI, notebook client milestone 2026-07-16 19:26:08 +00:00
kert added the apillm labels 2026-07-16 19:26:08 +00:00
Author
Owner

Status audit (2026-08-13, repo-verified): PARTIAL. POST /chat (api.py:74) functionally supersedes /query: streamed grounded generation with citations + abstention (rag.py:20-26,64-94). Missing vs body: metadata filters, context-window budgeting; citations are comment ids rather than bib item keys.

**Status audit (2026-08-13, repo-verified):** PARTIAL. POST /chat (api.py:74) functionally supersedes /query: streamed grounded generation with citations + abstention (rag.py:20-26,64-94). Missing vs body: metadata filters, context-window budgeting; citations are comment ids rather than bib item keys.
Author
Owner

Grounded generation with citations is live at llm.fhirworx.io (2026-09-03). Retrieval now spans comments + rules (rebuilt from fr_anchors paragraphs) + new corpus (all non-comment bib items incl. Zotero-only storage PDFs), recency-blended (llm/rerank.py, optional since). Every source carries a deep link (llm/links.py): FR #p-N:~:text=… paragraph highlight, comment page / attachment PDF #page=N, corpus item URL. Spec: docs/superpowers/specs/2026-09-03-llm-corpus-recency-links-gpu-design.md.

Grounded generation with citations is live at llm.fhirworx.io (2026-09-03). Retrieval now spans `comments` + `rules` (rebuilt from fr_anchors paragraphs) + new `corpus` (all non-comment bib items incl. Zotero-only storage PDFs), recency-blended (`llm/rerank.py`, optional `since`). Every source carries a deep link (`llm/links.py`): FR `#p-N:~:text=…` paragraph highlight, comment page / attachment PDF `#page=N`, corpus item URL. Spec: docs/superpowers/specs/2026-09-03-llm-corpus-recency-links-gpu-design.md.
kert closed this issue 2026-09-03 14:58:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#571