A RAG answer cites sources like [1] and [2]. Does each cited source actually support the sentence? A cheap first check is lexical overlap.
Implement check_citations(answer, sources, threshold=0.5):
., ! or ? followed by whitespace or the end, and keep non-empty sentences.[n] (1-based indices into sources).{"sentence": ..., "citations": [n, ...], "supported": bool}, where supported is True if the sentence has at least one citation and every cited source scores at least threshold. A citation number out of range counts as unsupported. A sentence with no content words is supported if it has a valid citation.