Document QA With Citations and LangChain
A citation receipt that separates exact source support from relevance to the question. Import query(directory, question, model). A model callback returns JSON {source:chunk_id,quote:exact_text}. --response accepts a recorded response and applies the same gate.
A citation receipt that separates exact source support from relevance to the question.
- Import query(directory, question, model). A model callback returns JSON {source:chunk_id,quote:exact_text}. --response accepts a recorded response and applies the same gate.
- Python 3.10+
- pathlib, strings, offsets, dictionaries and callback functions. Optional LangChain dependencies are pinned separately.
- Python Stdlib data structures, explicit algorithms and deterministic local tests.
Document QA With Citations and LangChain in 4 stages
A citation receipt that separates exact source support from relevance to the question.
Load local documents with stable provenance
The second overlapping chunk of abcdef starts at offset 3 when size=4 and overlap=1.
starter · ~2 hours · Python
loadlocaldocumentswithRank chunks with an inspectable keyword score
A socket query selects the socket chunk, while an unknown term abstains.
core · ~2 hours · Python
rankchunkswithanAccept only answers grounded in retrieved spans
A model response containing words absent from its cited chunk is rejected.
core · ~2 hours · Python
acceptonlyanswersgroundedUse a framework splitter without losing offsets
Framework chunks are converted to the same source-span contract used by the baseline.
stretch · ~2 hours · Python
useaframeworksplitter