पाठ 9 / 25

Grounded Answers From Retrieved Context

Pass context to the LLM node and keep it honest.

Context in, citations out

A typical RAG workflow: start (query) to knowledge retrieval (chunks) to LLM node (instructions, context, question) to end. Instruct the model to answer only from the context, to say when the answer is not there, and to cite sources. Enable citation or source display where available so users can check answers. Combine with the threshold so off-topic questions receive "I don't know" rather than an answer built on an unrelated chunk. Dify's node names, menus and options change between versions; check the current Dify documentation.

A grounded answer prompt

Put context and question in clearly marked sections.

System:
You answer customer questions using ONLY the context below.
If the context does not contain the answer, reply: "I could not find this in our help articles."
Quote the article title you used.

Context:
{{#knowledge_retrieval.result#}}

Question:
{{#start.query#}}

Test unanswerable questions

Include questions your documents cannot answer in testing; a good RAG app admits it rather than inventing.

त्वरित जाँच: What should a grounded RAG app do when the context lacks the answer?

  • Return the whole knowledge base
  • Invent a plausible answer
  • Say it could not find the answer
  • Crash
Answer

Say it could not find the answer — Honest refusals build trust.