Get startedGet started for free

Parameters for product descriptions

RoboChef Labs is preparing product-page text for its new ChefBot Pro Cooking Robot. Using the provided generate_description() function, you experiment with different combinations of temperature, top_p, and max_tokens to try different solutions.

The boto3 and json libraries, and generate_description() function, have been pre-imported.

This exercise is part of the course

Introduction to Amazon Bedrock

View Course

Exercise instructions

  • Set parameters for three configurations, using different values of the parameters for a conservative, balanced, and creative output.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

bedrock = boto3.client('bedrock-runtime', region_name='us-east-1')
product = "ChefBot Pro – AI Cooking Robot"

# Configuration 1: Conservative/Consistent
result1 = generate_description(bedrock, product, temperature=____, top_p=0.85, max_tokens=50)
# Configuration 2: Balanced
result2 = generate_description(bedrock, product, temperature=0.5, top_p=0.92, max_tokens=____)
# Configuration 3: Creative
result3 = generate_description(bedrock, product, temperature=0.8, top_p=____, max_tokens=200)

print("Conservative Result:", result1)
print("Balanced Result:", result2)
print("Creative Result:", result3)
Edit and Run Code