Skip to content

New pattern - lambda-bedrock-prompt-optimization-cdk#3119

Open
NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-bedrock-prompt-optimization-cdk
Open

New pattern - lambda-bedrock-prompt-optimization-cdk#3119
NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-lambda-bedrock-prompt-optimization-cdk

Conversation

@NithinChandranR-AWS
Copy link
Copy Markdown
Contributor

Description

First pattern for Amazon Bedrock Advanced Prompt Optimization (launched May 2026).

What it does

  • Lambda function triggers Bedrock Advanced Prompt Optimization jobs
  • Uploads evaluation samples to S3, creates optimization job, polls for completion
  • Returns optimized prompt with quality score comparison

Testing

Deployed and tested on live AWS account:

  • ✅ Original prompt score: 0.578 → Optimized: 0.900 (+55%)
  • ✅ Output tokens reduced 81% (156 → 29)
  • ✅ Jobs complete in ~10 minutes

Key findings documented

  • Lambda runtime boto3 doesn't include AdvPO API — needs bundled requirements.txt
  • IAM requires inference-profile/* resource (not just job resource)
  • Input JSONL needs version field: bedrock-2026-05-14

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Deploy a Lambda function that triggers Bedrock Advanced Prompt
Optimization jobs. Optimizes prompts across models with quality
scoring and comparison. Deployed and tested - 55% quality improvement.

Requires boto3>=1.42.0 (bundled via requirements.txt).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants