Applicare tecniche di prompt engineering

Introduzione ad Amazon Bedrock

Nikhil Rangarajan

Data Scientist

Few-shot learning

  • Cos'è il few-shot learning?
    • Tecnica per guidare il modello con pochi esempi nel prompt
    • Aiuta a inferire schemi e migliorare la qualità delle risposte
  • Vantaggi chiave:
    • Riduce l'ambiguità del prompt
    • Produce output più coerenti e accurati

Diagramma concettuale che rappresenta l'apprendimento per esempio.

Introduzione ad Amazon Bedrock

Few-shot learning con i modelli

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:"""
Introduzione ad Amazon Bedrock

Cos'è il formato strutturato dell'output?

  • Rende le risposte chiare e prevedibili
  • Ideale per automazione ed estrazione dati

DOC.png

Introduzione ad Amazon Bedrock

Controllare il formato della risposta

  • Richiedi strutture di output specifiche
  • Usa marcatori chiari per il parsing
  • Definisci vincoli di formato
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]"""
Introduzione ad Amazon Bedrock

Creare prompt efficaci

  • Combina esempi few-shot con system prompt
  • Usa formati strutturati con esempi
  • Sovrapponi tecniche per risultati migliori
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"""
Introduzione ad Amazon Bedrock

Passons à la pratique !

Introduzione ad Amazon Bedrock

Preparing Video For Download...