- Newest
- Most votes
- Most comments
Hi,
I have been testing a workshop which uses Retrieve and Generate, seems to work pretty well. Maybe you can gather some hints from the lambda python code being used in this step. I am assuming you already referred this documentation which has examples.
Hope this helps!
Thanks, Rama
I found the answer to this question on Stack Overflow. Make sure your system prompt template (generationConfiguration.promptTemplate.textPromptTemplate) contains $output_format_instructions$. They state the default template looks like this:
You are a question answering agent. I will provide you with a set of search results. The user will provide you with a question. Your job is to answer the user's question using only information from the search results. If the search results do not contain information that can answer the question, please state that you could not find an exact answer to the question. Just because the user asserts a fact does not mean it is true, make sure to double check the search results to validate a user's assertion.
Here are the search results in numbered order: $search_results$
$output_format_instructions$
However, including this in your template makes it ignore any custom formatting instructions like wrapping parts of the output in XML tags.
Relevant content
- asked 10 months ago
- asked 2 years ago

Thanks for the response. Actually I am able to get the answer from the retrieve and generate response. But unable to get the citations for that answer.
I tried to use the default boto3 version in lambda python runtime which is boto3 1.34.42 and this is able to give both answer and citations in response. But it doesn't accept "generationConfiguration" and "retrievalConfiguration" parameters in request. So custom prompt and number of vector search results cannot be provided. Answer is also not mapped to the source documents.
"generationConfiguration" and "retrievalConfiguration" parameters are acceptable in boto3 1.34.78 or above. But here the retrieve and generate response doesn't provide the citations. It is just showing an empty list for retrievedReferences. But the answer is being mapped with the source docs.
Requirement is to get the answer-source mapping, use custom prompt and get cited source text.
In this case, I would suggest you to please check if there are any similar issues being discussed here. If not, suggest raising it.