Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Introduction to Amazon Bedrock

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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'])
Code bewerken en uitvoeren