Skip to content

How to retrieve the source documents actually used for an answer in a generative RAG pipeline? #8441

Discussion options

You must be logged in to vote

Hi @fhamborg, you need to specify that in the prompt, here is an example:

You are an expert in the subject matter.
You provide answers based on the following context.

Instructions:
- Answer the question truthfully using the information provided.
- If multiple documents contain relevant information, combine them to
form a comprehensive answer.
- Reference your sources clearly by number, for example, [1] for the
first source.
- Do not use information outside of the provided sources.
- If no relevant information is found, state that directly.

Documents:

{% for document in documents %}
    Document[{{ loop.index }}]:
    {{ document.content }}
{% endfor %}

Question: {{ question }}
Answer:

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by fhamborg
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants