Part of #2: Add RAG (Retrieval Augmented Generation) with citations
Scope
Implement citation tracking that maps generated answer segments back to their source chunks, providing transparent attribution and verifiability.
Details
- Parse LLM output to extract inline citation references
- Map citations back to original source documents with metadata (filename, chunk index, similarity score)
- Produce a structured citations list alongside the answer
- Support citation formats: inline
[Source: X] and appended bibliography
- Track citation coverage: what percentage of the answer is grounded in retrieved sources
Output Structure
class RAGResult:
answer: str # Generated answer text
citations: List[Citation] # Source attributions
retrieval_scores: List[float] # Per-chunk relevance scores
coverage: float # % of answer grounded in sources
class Citation:
source: str # e.g., "consensus-guide.md"
chunk_index: int # Which chunk in the source
similarity: float # Retrieval similarity score
text_span: str # The cited portion of the answer
Acceptance Criteria
Part of #2: Add RAG (Retrieval Augmented Generation) with citations
Scope
Implement citation tracking that maps generated answer segments back to their source chunks, providing transparent attribution and verifiability.
Details
[Source: X]and appended bibliographyOutput Structure
Acceptance Criteria