テキストの要約と拡張

OpenAI API で学ぶプロンプトエンジニアリング

Fouad Trad

Machine Learning Engineer

テキスト要約

  • テキストを短い形式に圧縮する
  • ビジネスプロセスを効率化する
    • 財務 → 長大なレポートを要約する
    • マーケティング → 顧客フィードバックを実用的なインサイトに変換する
  • LLMは効果的なプロンプトでテキストを要約できる

要約によって大量の本が1枚の要約文書に変換される様子を示す画像。

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...