Prompt engineering-technieken toepassen

Introductie tot Amazon Bedrock

Nikhil Rangarajan

Data Scientist

Few-shot learning

  • Wat is few-shot learning?
    • Een techniek om het model te sturen met een paar voorbeelden in de prompt
    • Helpt patronen afleiden en verbetert de antwoordkwaliteit
  • Belangrijkste voordelen:
    • Vermindert ambiguïteit in de prompt
    • Levert consistenter en nauwkeuriger output

Een schematische weergave van leren aan de hand van voorbeelden.

Introductie tot Amazon Bedrock

Few-shot learning met modellen

prompt = """Here are examples of AWS service summaries:

Service: Amazon S3
Summary: Object storage service for storing and retrieving any amount of data.

Service: Amazon EC2
Summary: Virtual servers in the cloud for running applications.

Now, write a similar summary for:
Service: AWS Lambda\n\nSummary:"""
Introductie tot Amazon Bedrock

Wat is gestructureerde output?

  • Maakt modelantwoorden duidelijk en voorspelbaar
  • Ideaal voor automatisering en data-extractie

DOC.png

Introductie tot Amazon Bedrock

Het antwoordformaat sturen

  • Vraag een specifieke outputstructuur
  • Gebruik duidelijke markers voor parsing
  • Definieer formaatbeperkingen
prompt = """Analyze AWS Lambda and provide output in this format:
DESCRIPTION:[2-3 sentence description]
KEY FEATURES:
- [feature 1]
- [feature 2]
USE CASES:
1. [use case 1]
2. [use case 2]"""
Introductie tot Amazon Bedrock

Effectieve prompts maken

  • Combineer few-shotvoorbeelden met systeemprompts
  • Gebruik gestructureerde opmaak met voorbeelden
  • Stapel technieken voor betere resultaten
prompt = """You are an AWS technical writer. 
Here's an example of how to document APIs:
API: GetItem
Format: - Purpose: [one line], 
- Parameters: [list], 
- Returns: [description]
Now document the following API:
API: PutItem"""
Introductie tot Amazon Bedrock

Laten we oefenen!

Introductie tot Amazon Bedrock

Preparing Video For Download...