非構造化応答を導く

Llama 3 を使いこなす

Imtihan Ahmed

Machine Learning Engineer

モデル出力の制御

  • ✅ パラメータ
  • ✅ 役割

モデルの調整方法

Llama 3 を使いこなす

モデル出力の制御

  • ✅ パラメータ
  • ✅ 役割

モデルの調整方法 - プロンプトの洗練

Llama 3 を使いこなす

モデル出力の制御

  • ✅ パラメータ
  • ✅ 役割

モデルの調整方法 - ゼロショット/フューショット

Llama 3 を使いこなす

モデル出力の制御

  • ✅ パラメータ
  • ✅ 役割

モデルの調整方法 - ストップワード

Llama 3 を使いこなす

プロンプトの洗練

  • 例:要約
text_choice1 = "Summarize key trends in the aviation industry from the last year, 
                focusing on fuel efficiency innovations."

text_choice2 = "Tell me about the aviation industry."
output = llm(text_choice1) # 具体的なプロンプトの方が効果的 print(output['choices'][0]['text'])
The aviation industry has made significant strides in fuel efficiency innovations 
over the last year, driven by the need to reduce greenhouse gas emissions and 
operating costs. Sustainable Aviation Fuels (SAFs) have emerged as a key trend...
Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素

Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素 - 精度

Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素 - あいまいさ

Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素 - キーワード

Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素 - 行動語

Llama 3 を使いこなす

効果的なプロンプトの要素

効果的なプロンプトの要素 - 例

Llama 3 を使いこなす

ゼロショット・プロンプト

  • ゼロショット・プロンプティング:単一の指示
text = "Summarize recent mergers in the airline industry."

output = llm(text) print(output['choices'][0]['text'])
Recent mergers in the airline industry include Alaska Air Group's acquisition of 
Hawaiian Airlines in 2024, with both airlines continuing to operate as separate 
brands. In 2022, Delta Air Lines purchased 20% of LATAM Airlines Group...
Llama 3 を使いこなす

ゼロショットの洗練

  • タスク、期待する出力、追加の文脈を区別する必要があります
  • ラベル付きのゼロショット・プロンプティング
text = """
       INSTRUCTION: Write concisely and in 2-3 sentences that cover only key points.
       QUESTION: Summarize recent mergers in the airline industry.
       ANSWER:
       """
Llama 3 を使いこなす

フューショット・プロンプト

  • フューショット・プロンプティング:複数の例を使用

プロンプト

Llama 3 を使いこなす

フューショット・プロンプト

  • フューショット・プロンプティング:複数の例を使用

「航空機モデル」を強調したプロンプト

Llama 3 を使いこなす

フューショット・プロンプト

  • フューショット・プロンプティング:複数の例を使用

「乗客数」を強調したプロンプト

Llama 3 を使いこなす

フューショット・プロンプト

  • フューショット・プロンプティング:複数の例を使用

「燃料消費」を強調したプロンプト

Llama 3 を使いこなす

フューショット・プロンプト

$$

output = llm(f"Continue the entries: {text}") 

print(output['choices'][0]['text'])
Aircraft Model: Airbus A350-900
Passenger Capacity: 350
Fuel Consumption: 2.39 liters per seat per 100 km
Llama 3 を使いこなす

ストップワードの使用

  • 簡潔な洞察が必要
  • stop ワードで所定の地点で応答を終了
  • 例:質問応答アプリ
text = "Which airlines operate direct flights from London to Singapore?"


output = llm(text, stop=["Q:"]) # 応答を "Q:" で停止
print(output['choices'][0]['text'])
You can fly direct from London to Singapore with Singapore Airlines and 
British Airways.
Llama 3 を使いこなす

Vamos praticar!

Llama 3 を使いこなす

Preparing Video For Download...