Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
InferenceConfiguration Struct
LLM inference configuration.
| Stability | Experimental |
|---|---|
| Source | bedrock/agents/prompt-override.ts |
Example
const agent = new bedrock.Agent(this, 'Agent', {
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction: 'You are a helpful assistant.',
promptOverrideConfiguration: bedrock.PromptOverrideConfiguration.fromSteps([
{
stepType: bedrock.AgentStepType.PRE_PROCESSING,
stepEnabled: true,
customPromptTemplate: 'Your custom prompt template here',
inferenceConfig: {
temperature: 0.0,
topP: 1,
topK: 250,
maximumLength: 1,
stopSequences: ["\n\nHuman:"],
},
}
])
});
agent = bedrock.Agent(self, "Agent",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
instruction="You are a helpful assistant.",
prompt_override_configuration=bedrock.PromptOverrideConfiguration.from_steps([
step_type=bedrock.AgentStepType.PRE_PROCESSING,
step_enabled=True,
custom_prompt_template="Your custom prompt template here",
inference_config=bedrock.InferenceConfiguration(
temperature=0,
top_p=1,
top_k=250,
maximum_length=1,
stop_sequences=["\n\nHuman:"]
)
])
)
Agent agent = Agent.Builder.create(this, "Agent")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.instruction("You are a helpful assistant.")
.promptOverrideConfiguration(PromptOverrideConfiguration.fromSteps(List.of(PromptStepConfigBase.builder()
.stepType(AgentStepType.PRE_PROCESSING)
.stepEnabled(true)
.customPromptTemplate("Your custom prompt template here")
.inferenceConfig(InferenceConfiguration.builder()
.temperature(0)
.topP(1)
.topK(250)
.maximumLength(1)
.stopSequences(List.of("\n\nHuman:"))
.build())
.build())))
.build();
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var agent = new Agent(this, "Agent", new AgentProps {
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
Instruction = "You are a helpful assistant.",
PromptOverrideConfiguration = PromptOverrideConfiguration.FromSteps(new [] { new PromptStepConfigBase {
StepType = AgentStepType.PRE_PROCESSING,
StepEnabled = true,
CustomPromptTemplate = "Your custom prompt template here",
InferenceConfig = new InferenceConfiguration {
Temperature = 0,
TopP = 1,
TopK = 250,
MaximumLength = 1,
StopSequences = new [] { @"
Human:" }
}
} })
});
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
agent := bedrock.NewAgent(this, jsii.String("Agent"), &AgentProps{
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
Instruction: jsii.String("You are a helpful assistant."),
PromptOverrideConfiguration: bedrock.PromptOverrideConfiguration_FromSteps([]PromptStepConfigBase{
&PromptStepConfigBase{
StepType: bedrock.AgentStepType_PRE_PROCESSING,
StepEnabled: jsii.Boolean(true),
CustomPromptTemplate: jsii.String("Your custom prompt template here"),
InferenceConfig: &InferenceConfiguration{
Temperature: jsii.Number(0),
TopP: jsii.Number(1),
TopK: jsii.Number(250),
MaximumLength: jsii.Number(1),
StopSequences: []*string{
jsii.String("\n\nHuman:"),
},
},
},
}),
})
Properties
maximumLengthnumbermaximum_lengthint | floatmaximumLengthNumberMaximumLengthdoubleMaximumLength*float64 required #Integer
min 0 max 4096
stopSequencesstring[]stop_sequencestyping.List[str]stopSequencesList<String>StopSequencesstring[]StopSequences*[]*string required #A stop sequence is a sequence of characters that causes the model to stop generating the response.
length 0-4
temperaturenumbertemperatureint | floattemperatureNumberTemperaturedoubleTemperature*float64 required #A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options.
Floating point
min 0 max 1
notes
The value that you set for topK is the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topK to 50, the model selects the next token from among the top 50 most likely choices.
Integer
min 0 max 500
notes
The value that you set for Top P determines the number of most-likely candidates from which the model chooses the next token in the sequence. For example, if you set topP to 80, the model only selects the next token from the top 80% of the probability distribution of next tokens.
Floating point
min 0 max 1