MulaiMulai sekarang secara gratis

Implement few-shot learning for geometry

You're working with a technology company that's developing an educational platform for primary school science and maths training. They need their AI model to follow specific educational formats, and have asked you to use geometric shapes as a demonstration.

The boto3 and json libraries have been pre-imported.

Latihan ini adalah bagian dari kursus

Introduction to Amazon Bedrock

Lihat Kursus

Petunjuk latihan

  • Complete the prompt by completing the definitions of the two shapes described, including the "Shape" and "Description" labels.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Add two more shape descriptions
messages = [
    {"role": "user", "content": """Here are descriptions of geometric shapes:
Shape - Triangle. Description: 3 sides, angles sum to 180°. Seen in roofs.
Shape - ____. Description: 4 equal sides, 90° angles. Found in tiles.
____ - ____. ____: Round, no corners. Seen in wheels.
Now describe this shape: Hexagon"""}  
]

request_body = json.dumps({"anthropic_version": "bedrock-2023-05-31","max_tokens": 100, "messages": messages})
response = bedrock.invoke_model(modelId='anthropic.claude-3-5-sonnet-20240620-v1:0', body=request_body)
response_body = json.loads(response['body'].read().decode())

print(response_body['content'][0]['text'])
Edit dan Jalankan Kode