Riassunto ed espansione del testo

Prompt Engineering con l'API di OpenAI

Fouad Trad

Machine Learning Engineer

Riassunto del testo

  • Condensa il testo in un formato più breve
  • Snellisce i processi aziendali
    • Finanza -> riassume report lunghi
    • Marketing -> trasforma feedback dei clienti in insight azionabili
  • Gli LLM possono riassumere testi con prompt efficaci

Immagine che mostra come il riassunto trasforma una pila di libri in un documento con un sommario.

Prompt Engineering con l'API di OpenAI

Prompt inefficace

  • Specifica solo il testo da riassumere
text = "I recently purchased your XYZ Smart Watch and wanted to provide some feedback
based on my experience with the product. I must say that I'm impressed with the sleek design 
and build quality of the watch. It feels comfortable on the wrist and looks great with any 
outfit. The touchscreen is responsive and easy to navigate through the various features."

prompt = f"""Summarize the text delimited by triple backticks: ```{text}```""" print(get_response(prompt))
L'autore ha acquistato lo Smart Watch XYZ ed è colpito dal design elegante, dalla qualità 
costruttiva e dalla comodità al polso. Trova il touchscreen reattivo e intuitivo 
per navigare tra le funzioni dell'orologio.
Prompt Engineering con l'API di OpenAI

Migliorare il prompt

  • Limiti dell'output
  • Struttura dell'output
  • Focus del riassunto

Immagine che mostra una persona che sale di un gradino come segno di miglioramento.

Prompt Engineering con l'API di OpenAI

Prompt efficace: limiti dell'output

  • Specifica numero di frasi, parole, caratteri
text = "I recently purchased your XYZ Smart Watch and wanted to provide some feedback
based on my experience with the product. I must say that I'm impressed with the sleek design 
and build quality of the watch. It feels comfortable on the wrist and looks great with any 
outfit. The touchscreen is responsive and easy to navigate through the various features."

prompt = f"""Summarize the text delimited by triple backticks in one sentence: ```{text}```""" print(get_response(prompt))
Il cliente è colpito dal design elegante, dalla qualità costruttiva, dalla comodità e 
dalla reattività del touchscreen dello Smart Watch XYZ.
Prompt Engineering con l'API di OpenAI

Prompt efficace: struttura dell'output

  • Specifica la struttura dell'output
text = "I recently purchased your XYZ Smart Watch and wanted to provide some feedback
based on my experience with the product. I must say that I'm impressed with the sleek design 
and build quality of the watch. It feels comfortable on the wrist and looks great with any 
outfit. The touchscreen is responsive and easy to navigate through the various features."

prompt = f"""Summarize the text delimited by triple backticks, in at most three bullet points. ```{text}```""" print(get_response(prompt))
- Lo Smart Watch XYZ ha un design elegante e un'ottima qualità costruttiva.
- È comodo al polso e sta bene con qualsiasi outfit.
- Il touchscreen è reattivo e facile da usare per navigare tra le funzioni.
Prompt Engineering con l'API di OpenAI

Prompt efficace: focus del riassunto

  • Chiedi al modello di concentrarsi su parti specifiche del testo
text = "I recently purchased your XYZ Smart Watch and wanted to provide some feedback
based on my experience with the product. I must say that I'm impressed with the sleek design 
and build quality of the watch. It feels comfortable on the wrist and looks great with any 
outfit. The touchscreen is responsive and easy to navigate through the various features."

prompt = f"""Summarize the review delimited by triple backticks, in three sentences, focusing on the key features and user experience: ```{text}```""" print(get_response(prompt))
Prompt Engineering con l'API di OpenAI

Prompt efficace: focus del riassunto

Il cliente ha acquistato lo Smart Watch XYZ ed è rimasto colpito dal design 
elegante e dalla qualità costruttiva.
Lo trova comodo da indossare e adatto a qualsiasi outfit.
Il touchscreen è reattivo e intuitivo, facilitando la navigazione 
tra le funzioni dell'orologio.
Prompt Engineering con l'API di OpenAI

Espansione del testo

  • Genera testo da idee o bullet point
  • Aumenta efficienza e produttività
  • Gli LLM possono espandere testo con prompt ben progettati

Immagine che spiega che l'espansione del testo consiste nel generare un testo completo da poche idee o requisiti.

Prompt Engineering con l'API di OpenAI

Prompt per l'espansione del testo

  • Chiedi al modello di espandere il testo delimitato
  • Metti in evidenza gli aspetti su cui concentrarsi
  • Fornisci requisiti di output (tono, lunghezza, struttura, audience)

Icona di una matita che scrive su un quaderno.

Prompt Engineering con l'API di OpenAI

Espandere la descrizione di un servizio

service_description = """Service: Social XYZ
- Social Media Strategy Development
- Content Creation and Posting 
- Audience Engagement and Community Building
- Increased Brand Visibility
- Enhanced Customer Engagement
- Data-Driven Marketing Decisions"""
prompt = f"""Expand the description for the Social XYZ service delimited by triple 
backticks to provide an overview of its features and benefits, without bypassing 
the limit of two sentences. Use a professional tone.
```{service_description}```"""
print(get_response(prompt))
Prompt Engineering con l'API di OpenAI

Espandere la descrizione di un servizio

Social XYZ è un servizio completo di social media che offre sviluppo strategico, 
creazione e pubblicazione di contenuti per aiutare le aziende a coinvolgere il 
proprio pubblico e costruire una community online solida.

Con focus su maggiore visibilità del brand e migliore engagement dei clienti, 
Social XYZ consente decisioni di marketing data-driven per risultati ottimali.
Prompt Engineering con l'API di OpenAI

Vamos praticar!

Prompt Engineering con l'API di OpenAI

Preparing Video For Download...