文字摘要與展開

使用 OpenAI API 的提示工程

Fouad Trad

Machine Learning Engineer

文字摘要

  • 將長文濃縮成短摘要
  • 精簡商務流程
    • 金融 -> 摘要冗長報告
    • 行銷 -> 將顧客回饋轉成可行洞見
  • 使用適當提示,LLM 可進行摘要

說明摘要如何把一堆書變成一份摘要文件的圖片。

使用 OpenAI API 的提示工程

無效的提示

  • 只指定要摘要的文字
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.
使用 OpenAI API 的提示工程

優化提示

  • 輸出長度限制
  • 輸出結構
  • 摘要焦點

顯示一個人從較低台階跨到較高台階,象徵提升的圖片。

使用 OpenAI API 的提示工程

有效提示:輸出限制

  • 指定句數、字數、字元數
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.
使用 OpenAI API 的提示工程

有效提示:輸出結構

  • 指定輸出結構
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.
使用 OpenAI API 的提示工程

有效提示:摘要焦點

  • 要求模型聚焦於文字的特定部分
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))
使用 OpenAI API 的提示工程

有效提示:摘要焦點

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.
使用 OpenAI API 的提示工程

文字展開

  • 從想法或條列擴寫成文本
  • 提升效率與生產力
  • 使用設計良好的提示,LLM 可展開文字

說明文字展開是根據少量想法或需求生成完整文字的圖片。

使用 OpenAI API 的提示工程

文字展開提示

  • 要求模型展開定界文字
  • 強調需聚焦的面向
  • 提供輸出需求(語氣、長度、結構、受眾)

顯示鉛筆在筆記本上書寫的圖示。

使用 OpenAI API 的提示工程

擴寫服務說明

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))
使用 OpenAI API 的提示工程

擴寫服務說明

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.
使用 OpenAI API 的提示工程

一起來練習吧!

使用 OpenAI API 的提示工程

Preparing Video For Download...