Resumen y ampliación de textos

Ingeniería de prompts con la API de OpenAI

Fouad Trad

Machine Learning Engineer

Resumen de texto

  • Condensa el texto en un formato más breve
  • Agiliza los procesos empresariales
    • Finanzas -> resume informes extensos
    • Marketing -> transforma los comentarios de los clientes en conclusiones prácticas
  • Los LLM pueden resumir textos con prompts eficaces

Imagen que muestra cómo la generación de resúmenes transforma una pila de libros en un documento con un resumen.

Ingeniería de prompts con la API de OpenAI

Prompt ineficaz

  • Solo especifica el texto que hay que resumir
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.
Ingeniería de prompts con la API de OpenAI

Mejora del prompt

  • Límites de salida
  • Estructura de salida
  • Enfoque de resumen

Imagen de una persona subiendo un escalón, como señal de mejora.

Ingeniería de prompts con la API de OpenAI

Prompt eficaz: límites de salida

  • Especifica el número de oraciones, palabras y caracteres
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.
Ingeniería de prompts con la API de OpenAI

prompt eficaz: estructura de salida

  • Especifica la estructura de salida
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.
Ingeniería de prompts con la API de OpenAI

Prompt eficaz: enfoque en la síntesis

  • Pide al modelo que se centre en partes específicas del texto
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))
Ingeniería de prompts con la API de OpenAI

Prompt eficaz: centrado en resumir

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.
Ingeniería de prompts con la API de OpenAI

Expansión de texto

  • Genera texto a partir de ideas o puntos clave
  • Mejora la eficiencia y la productividad
  • Los LLM pueden ampliar el texto con prompts bien elaborados

Imagen que explica que la expansión de texto consiste en generar un texto completo a partir de unas pocas ideas o requisitos.

Ingeniería de prompts con la API de OpenAI

Prompts de expansión de texto

  • Pide al modelo que amplíe el texto delimitado
  • Destaca los aspectos en los que debes centrarte
  • Indica los requisitos de salida (tono, longitud, estructura y público)

Icono de un lápiz escribiendo en un cuaderno.

Ingeniería de prompts con la API de OpenAI

Ampliación de la descripción del servicio

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))
Ingeniería de prompts con la API de OpenAI

Ampliación de la descripción del servicio

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.
Ingeniería de prompts con la API de OpenAI

¡Practiquemos!

Ingeniería de prompts con la API de OpenAI

Preparing Video For Download...