Skip to content

How to show document fragments/snippets in Q&A RAG app? #116

Answered by Saksham65
niutech asked this question in Q&A
Discussion options

You must be logged in to vote

Hey there!

You can replicate NotebookLM’s “hover to see references” feature by following these steps:

Instruct the LLM to include citations:

Modify your prompt_template in BaseRAGQuestionAnswerer to tell the LLM to insert citation markers ([1], [2], etc.) in the response:

prompt_template=(
    "Given the following documents:\n{context}\n\n"
    "Answer the question in detail, and include citations in the format [number] "
    "that map to the corresponding document snippets.\n\n"
    "Question: {query}"
)

Set return_context_docs=True:

When calling the RAG endpoint, ensure that the response includes both the generated answer and the retrieved document snippets:

response = pathway_client.p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by niutech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants