Skip to content

Is it possible to create a RAG with citations? #8286

Answered by julian-risch
alybel asked this question in Questions
Discussion options

You must be logged in to vote

Hi @alybel yes that's possible! You're looking for the Haystack component called AnswerBuilder: https://docs.haystack.deepset.ai/docs/answerbuilder
It has an optional parameter reference_pattern. You could set that reference_pattern to \\[(?:(\\d+),?\\s*)+\\] and then instruct the LLM to include references in the answer. The AnswerBuilder will then extract references to documents from the answer generated by the LLM. Set the prompt of the LLM in your pipeline to something like the following so that it includes references in the generated answer:

...
Always use references in the form [NUMBER OF DOCUMENT] if you use information from a document, e.g. [3] for document [3].
Never name the docu…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@julian-risch
Comment options

@alybel
Comment options

Answer selected by alybel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants