Résumé et expansion de texte

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Fouad Trad

Machine Learning Engineer

Résumé de texte

  • Condense le texte en format court
  • Rationalise les processus d'affaires
    • Finance -> résume des rapports longs
    • Marketing -> transforme les commentaires clients en pistes concrètes
  • Les LLM peuvent résumer avec des invites efficaces

Image montrant comment le résumé transforme une pile de livres en un document contenant un sommaire.

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invite inefficace

  • Indique seulement le texte à résumer
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))
The author purchased the XYZ Smart Watch and is impressed with its sleek design, build 
quality, and comfortable fit on the wrist. They find the touchscreen responsive and 
user-friendly for navigating the watch's features.
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Améliorer l'invite

  • Limites de sortie
  • Structure de sortie
  • Focalisation du résumé

Image montrant une personne qui passe d'une marche à une plus haute, signe d'amélioration.

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invite efficace : limites de sortie

  • Précisez le nombre de phrases, mots, caractères
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))
The customer is impressed with the sleek design, build quality, comfort, and responsiveness 
of the XYZ Smart Watch's touch screen.
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invite efficace : structure de sortie

  • Précisez la structure de sortie
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))
- The XYZ Smart Watch has a sleek and impressive design with  excellent build quality.
- It feels comfortable on the wrist and complements any outfit.
- The touch screen is responsive and user-friendly for easy navigation through the features.
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invite efficace : focalisation du résumé

  • Demandez au modèle de cibler certaines parties du texte
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))
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invite efficace : focalisation du résumé

The customer purchased the XYZ Smart Watch and was impressed with its sleek design 
and build quality. 
They found it comfortable to wear and versatile enough to match any outfit. 
The touch screen was responsive and user-friendly, making it easy to navigate 
through the watch's features.
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Expansion de texte

  • Génère du texte à partir d'idées ou de puces
  • Améliore l'efficacité et la productivité
  • Les LLM peuvent étoffer un texte avec de bonnes invites

Image expliquant que l'expansion de texte consiste à générer un texte complet à partir de quelques idées ou exigences.

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Invites pour l'expansion de texte

  • Demandez au modèle d'étoffer le texte délimité
  • Soulignez les aspects clés à traiter
  • Donnez les exigences de sortie (ton, longueur, structure, public)

Icône d'un crayon écrivant dans un cahier.

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Développer la description d'un service

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))
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Développer la description d'un service

Social XYZ is a comprehensive social media service that offers strategic 
development, content creation, and posting to help businesses effectively engage 
with their target audience and build a strong online community. 

With a focus on increasing brand visibility and enhancing customer engagement, 
Social XYZ enables businesses to make data-driven marketing decisions for optimal 
results.
Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Passons à la pratique !

Conception de invites (Prompt Engineering) avec l'API d'OpenAI

Preparing Video For Download...