I have a list of documents in my RAG pipeline.
In the response, I also need to provide citations like [1] [2] in between content. sample given below !
This will help reduce hallucinations and avoid out of context, since each line or para or code or table response crafted has a proper citation.
I need help with prompt to achieve this.
The citation should be provided in the response and its actual document name in end, as given in image
@supershaneski , Thanks for your reply.
But
I’m working on text data in my documents.
So, if user ask: How to create a google account
The response should contain verified citations for each step from documents.
else should reply- i dont know.
I tried to fine-tune prompt to include citations:
OpenAI src: Prompt engineering - OpenAI API
But OpenAI prompt gives me a list of citations in the end of response. While
I need them verified sentence by sentence.
Thanks
Are you looking for something like this?: Wikipedia RAG example (source code - baml, ts)
If you want it to give you them sentence-by-sentence, then you need to instruct it to give them to you like that, e.g. answer in (sentence, citation) pairs.
Thanks @sam-boundary ,
it is exactly what I’m looking for
Does it work for Code blocs, table , steps based questions ?
Yep - BAML allows you to define arbitrary input and output types, so it’s really just a matter of whatever you can think of! You can take a look at the getting started guide here
1 Like