Skip to content

RetrieveAndGenerate API response is giving empty list for retrievedReferences even when output is being generated and mapped to source docs.

1

Using retrieve_and_generate API to query knowledge base on AWS Bedrock. The response body consist of output answer along with the source mapping but the cited retrievedReferences is an empty list. And the citations['generatedResponsePart']['textResponsePart']['text'] is showing 'Sorry, I am unable to assist you with this request.'

{ "citations": [ { "generatedResponsePart": { "textResponsePart": { "span": { "end": 50, "start": 0 }, "text": "Sorry, I am unable to assist you with this request." } }, "retrievedReferences": [] } ] }

I need to get the cited responses.

I am using boto3 1.34.85 Same issue is with the latest boto3 version as well. I have tried this with different claude models and all have same issue.

Any idea whats causing the issue?

2 Answers
0

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

AWS
EXPERT
answered 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.

0

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.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.