Skip to content

Prompt Management for KnowledgeBases

0

Hi, I am unable to find support for Prompt Management prompts when using RetrieveAndGenerate for KnowledgeBase.

Here is what I have from the official documentation, we cannot provide the promptArn. "generationConfiguration": { "promptTemplate": { "textPromptTemplate": "string" } } Is my assumption correct and what are the alternatives then?

2 Answers
1
Accepted Answer

Hi,

If you look at official documentation and for the time being (Prompt management is brand new), only Converse & InvokeModel when you infer directly with Bedrock models can work with Prompt Management:

Amazon Bedrock Runtime APIs Converse and InvokeModel support executing a 
prompt using a Prompt identifier. You can simply provide the prompt identifier 
as a parameter to Converse and InvokeModel API calls. 
We will retrieve the necessary prompt information including the Foundation Model, 
model configuration, system instructions, user/assistant messages, and tool configuration 
to execute the prompt and return the model response.

from https://aws.amazon.com/bedrock/prompt-management/

Best,

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

1

Your assumption is correct. The RetrieveAndGenerate API for Knowledge Bases in Amazon Bedrock does not support using prompts from Prompt Management directly.

When using RetrieveAndGenerate with a Knowledge Base, you cannot provide a promptArn or use prompts created in Prompt Management. The prompt is under service control in this API.

As an alternative, you have a couple of options:

  1. Use the textPromptTemplate field in the generationConfiguration as you've shown. This allows you to provide a custom prompt template as a string, but it doesn't use saved prompts from Prompt Management.

  2. If you want more control over the prompt, you can use a two-step process: a. First, use the Retrieve API to get the relevant information from your Knowledge Base. b. Then, use this retrieved information to construct your own prompt, which you can then use with a model inference call.

This approach gives you more flexibility in crafting your prompt, including the ability to use prompts you've created in Prompt Management. However, it requires more work on your part to manage the retrieval and prompt construction process.

Remember that while this method requires more manual handling, it offers greater control over the prompt used in your application.
Sources
Can we send system prompt in Retrieve and generate | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

  • what is the recommended ways to store the generation prompt then, of course not in the code :)

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.