Phân tích theo 4 nhóm nguyên nhân:
1. Context chưa đủ / không chứa câu trả lời (retrieval miss). Check: log doc đã retrieve, kiểm tra ground-truth passage có được truy xuất không. Fix: tăng top-K, thêm hybrid search/rerank, query rewriting, chunking lại (có thể câu trả lời bị cắt qua 2 chunk).
2. Context đúng nhưng LLM không theo. Nguyên nhân: prompt không ràng buộc rõ ("answer based on context"), context quá dài ("lost in the middle"), hoặc model yếu. Fix: system prompt rõ ràng kiểu "Chỉ trả lời dựa trên CONTEXT. Nếu không có thông tin, trả lời 'Tôi không biết'", dùng citation format [source:doc_id], sort chunks theo relevance giảm dần (đặt relevant ở đầu/cuối), giảm context size, dùng model mạnh hơn.
3. Context mâu thuẫn giữa các nguồn. Fix: thêm metadata (date, author, authority), yêu cầu model ưu tiên nguồn gần nhất hoặc uy tín nhất, hoặc trả lời "tài liệu A nói X, B nói Y".
4. Không có guardrail. Thêm faithfulness check — LLM thứ 2 (hoặc cùng model với prompt riêng) so output vs context, trả về score. Từ chối/regenerate nếu faithfulness thấp. Tool: RAGAS metrics (faithfulness, answer_relevance, context_precision/recall), TruLens, Ragas, Arize Phoenix.
Phương pháp đo: tập golden Q&A từ tài liệu thực; đo faithfulness và answer correctness qua LLM-as-judge + spot-check human. Thiết lập regression suite để phát hiện degrade khi thay prompt/model/chunking.
Root-cause by 4 buckets:
1. Context insufficient / missing answer (retrieval miss). Check: log retrieved docs; was the ground-truth passage retrieved? Fix: increase top-K, add hybrid search/reranker, query rewriting, re-chunk (maybe the answer spans two chunks).
2. Context correct but LLM ignores it. Causes: prompt doesn't constrain enough, context too long ("lost in the middle"), or weak model. Fix: strict system prompt like "Answer ONLY from CONTEXT. If info is missing, say 'I don't know'", citation format [source:doc_id], sort chunks by descending relevance (put relevant at start/end), shrink context, upgrade model.
3. Conflicting sources. Fix: add metadata (date, author, authority), have the model prefer the most recent/authoritative, or answer "doc A says X, doc B says Y".
4. No guardrail. Add faithfulness check — a second LLM (or same model with different prompt) compares output vs context, returns a score. Reject/regenerate on low faithfulness. Tools: RAGAS metrics (faithfulness, answer_relevance, context_precision/recall), TruLens, Arize Phoenix.
How to measure: maintain a golden Q&A set from real docs; evaluate faithfulness and answer correctness via LLM-as-judge + human spot checks. Set up a regression suite to catch regressions when changing prompt/model/chunking.