One-shot prompting: basterà?
Come hai visto, c'è margine di miglioramento nel prompt iniziale. Prova ad aggiungere un esempio, Love these! = 5, e a includere = dopo ogni recensione per vedere se ottieni un formato più coerente e numeri più accurati.
Questo esercizio fa parte del corso
Lavorare con DeepSeek in Python
Istruzioni dell'esercizio
- Aggiungi l'esempio
Love these! = 5all'inizio del prompt e aggiungi=dopo ogni recensione nel prompt per indicare come dovrebbe essere formattato il risultato.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")
# Add the example to the prompt
prompt = """Classify sentiment as 1-5 (negative to positive). Return no explanations:
1. ____
2. Unbelievably good! ____
3. Shoes fell apart on the second use. ____
4. The shoes look nice, but they aren't very comfortable. ____
5. Can't wait to show them off! ____"""
response = client.chat.completions.create(model="deepseek-ai/DeepSeek-V3", messages=[{"role": "user", "content": prompt}], max_tokens=150)
print(response.choices[0].message.content)