モデルの精度を向上させる方法

  •  
 
ズィスト2023年3月14日 - 14:18 に投稿

タグ

はじめに

テキスト補間で複雑なタスクを実行したたときに間違った答えが出力されることはありませんか?
今回は間違った答えを減らす方法について記載されている資料を要約したいと思います。 こちらで紹介する方法は一般論であり、タスクによっては使えない場合があるので予めご了承ください。

複雑なタスクで成功させる方法の例

複雑すぎるタスクを与えると誤った推論を作成する可能性がある。 物事を推論する時間とスペースがあればモデルは確実に答える可能性がある。
例えば以下の内容をtext-davinci-002に尋ねると間違った答えが返される。

Q: A juggler has 16 balls. Half of the balls are golf balls and half of the golf balls are blue. How many blue golf balls are there? A: There are 8 blue golf balls.

以下のようにpromptに"Let's think step by step"を追加することでモデルは確実に問題を解決することが判明した。

Q: A juggler has 16 balls. Half of the balls are golf balls and half of the golf balls are blue. How many blue golf balls are there? Let's think step by step. A: There are 16 balls in total. Half of the balls are golf balls. That means that there are 8 golf balls. Half of the golf balls are blue. That means that there are 4 blue golf balls.

このLet's think step by stepによりGPT-3の解決率が向上した。

複雑なタスクの信頼性を向上させる方法

複雑な言語タスクで大規模な言語モデルの信頼性を向上させる方法として一般的に以下がある。次章以降で詳細を解説する。

  • より明確に指示を与える
  • 複雑なタスクを簡単なサブタスクに分割する
  • モデルがタスクに集中できるような指示を構成する
  • 回答する前にモデルに説明を促す
  • 考えられる多くの答えの正当性を尋ねてから、統合する
  • 多くの出力を生成し、モデルを使用して最適なものを選択します
  • カスタムモデルを微調整してパフォーマンスを最大化

複雑なタスクを簡単なサブタスクに分割する

モデルに考える時間と余裕を与える方法のひとつに、タスクをよりシンプルに分割する方法がある。
以下の選択肢式の推論の問題を例に説明する。

Use the following clues to answer the following multiple-choice question. Clues: 1. Miss Scarlett was the only person in the lounge. 2. The person with the pipe was in the kitchen. 3. Colonel Mustard was the only person in the observatory. 4. Professor Plum was not in the library nor the billiard room. 5. The person with the candlestick was in the observatory. Question: Was Colonel Mustard in the observatory with the candlestick? (a) Yes; Colonel Mustard was in the observatory with the candlestick (b) No; Colonel Mustard was not in the observatory with the candlestick (c) Unknown; there is not enough information to determine whether Colonel Mustard was in the observatory with the candlestick Solution:

分割していない状態では回答は以下になる

(c) Unknown; there is not enough information to determine whether Colonel Mustard was in the observatory with the candlestick

手がかり3,5はマスタード大佐が天文台にいた唯一の人物であり天文台にいる人物がローソク台を持っていたことを立証しているが、モデルはこれらを組み合わせて正しい答えを導き出すことができなかった。
直接答えを求める代わりに以下のように3つのタスクに分割する

  • 手がかりを1つずつ見ていき、その手がかりが関連する可能性があるかどうかを検討する
  • 関連する手がかりを組み合わせて問題の答えを推論します。
  • 最終的な答えを書く
Use the following clues to answer the following multiple-choice question, using the following procedure: (1) First, go through the clues one by one and consider whether the clue is potentially relevant (2) Second, combine the relevant clues to reason out the answer to the question (3) Third, map the answer to one of the multiple choice answers: either (a), (b), or (c) Clues: 1. Miss Scarlett was the only person in the lounge. 2. The person with the pipe was in the kitchen. 3. Colonel Mustard was the only person in the observatory. 4. Professor Plum was not in the library nor the billiard room. 5. The person with the candlestick was in the observatory. Question: Was Colonel Mustard in the observatory with the candlestick? (a) Yes; Colonel Mustard was in the observatory with the candlestick (b) No; Colonel Mustard was not in the observatory with the candlestick (c) Unknown; there is not enough information to determine whether Colonel Mustard was in the observatory with the candlestick Solution: (1) First, go through the clues one by one and consider whether the clue is potentially relevant:

出力は以下のようになる

Clue 1: Miss Scarlett was the only person in the lounge. This clue is not relevant. Clue 2: The person with the pipe was in the kitchen. This clue is not relevant. Clue 3: Colonel Mustard was the only person in the observatory. This clue is relevant. Clue 4: Professor Plum was not in the library nor the billiard room. This clue is not relevant. Clue 5: The person with the candlestick was in the observatory. This clue is relevant. (2) Second, combine the relevant clues to reason out the answer to the question: Clue 3 and Clue 5 both say that the person with the candlestick was in the observatory. Colonel Mustard was the only person in the observatory, so Colonel Mustard was the person with the candlestick. (3) Third, write the final answer: (a) Yes

このようにモデルに考える時間と余裕を与えることで正しい答えを導くことができる。

モデルがタスクに集中できるような指示を構成する

例えば英語で次のフランス語の文章を元の言語で要約するタスクを与えた場合、英語で要約される可能性がある。最初に「オリジナルの言語を識別してください。」という内容を追加するだけでフランス語の文章で要約される。

回答する前にモデルに説明を促す

回答する前にモデルに説明を促す方法の例としていくつかある。今回は以下について解説する。

  • zero-shot
  • few-shot

zero-shot

これは答えの前にLet's think step by stepをつける方法である。この方法は特に多段階の算数問題、記号推理問題、戦略問題、その他の推論で効果があるが、単純な計算問題や常識問題等には効果がない。
また、Let's think step by stepは一般的な方法でありユースケースに合わせて別の単語を使用することで効果が高くなる可能性がある。使用方法は以下のようになる。

First, think step by step about why X might be true. Second, think step by step about why Y might be true. Third, think step by step about whether X or Y makes more sense.

実際の例は以下のようになる。

Using the IRS guidance below, answer the following questions using this format: (1) For each criterion, determine whether it is met by the vehicle purchase - {Criterion} Let's think step by step. {explanation} {yes or no, or if the question does not apply then N/A}. (2) After considering each criterion in turn, phrase the final answer as "Because of {reasons}, the answer is likely {yes or no}." IRS guidance: """ You may be eligible for a federal tax credit under Section 30D if you purchased a car or truck that meets the following criteria: - Does the vehicle have at least four wheels? - Does the vehicle weigh less than 14,000 pounds? - Does the vehicle draw energy from a battery with at least 4 kilowatt hours that may be recharged from an external source? - Was the vehicle purchased in a year before 2022? - If so, has the manufacturer sold less than 200,000 qualifying vehicles? (Tesla and GM have sold more than 200,000 qualifying vehicles.) - Was the vehicle purchased in a year after 2022? - If so, is the vehicle present in the following list of North American-assembled vehicles? (The only electric vehicles assembled in North America are the Audi Q5, BMW 330e, BMW X5, Chevrolet Bolt EUV, Chevrolet Bolt EV, Chrysler Pacifica PHEV, Ford Escape PHEV, Ford F Series, Ford Mustang MACH E, Ford Transit Van, GMC Hummer Pickup, GMC Hummer SUV, Jeep Grand Cherokee PHEV, Jeep Wrangler PHEV, Lincoln Aviator PHEV, Lincoln Corsair Plug-in, Lucid Air, Nissan Leaf, Rivian EDV, Rivian R1S, Rivian R1T, Tesla Model 3, Tesla Model S, Tesla Model X, Tesla Model Y, Volvo S60, BMW 330e, Bolt EV, Cadillac Lyriq, Mercedes EQS SUV, and Nissan Leaf.) """ Question: Can I claim a federal tax credit for my Toyota Prius Prime bought in 2021? Solution: (1) For each criterion, determine whether it is met by the vehicle purchase - Does the vehicle have at least four wheels? Let's think step by step.

レスポンスは以下のようになる。

The Toyota Prius Prime has four wheels, so the answer is yes. - Does the vehicle weigh less than 14,000 pounds? Let's think step by step. The Toyota Prius Prime weighs less than 14,000 pounds, so the answer is yes. - Does the vehicle draw energy from a battery with at least 4 kilowatt hours that may be recharged from an external source? Let's think step by step. The Toyota Prius Prime has a battery with at least 4 kilowatt hours that may be recharged from an external source, so the answer is yes. - Was the vehicle purchased in a year before 2022? Let's think step by step. The Toyota Prius Prime was purchased in 2021, which is before 2022, so the answer is yes. - Was the vehicle purchased in a year after 2022? N/A - If so, is the vehicle present in the following list of North American-assembled vehicles? N/A (2) After considering each criterion in turn, phrase the final answer as "Because of {reasons}, the answer is likely {yes or no}." Because the Toyota Prius Prime meets all of the criteria for a federal tax credit, the answer is likely yes.

few-shot

few-shotの例を説明する。例えば以下のような問題が合ったとする。

Q: Roger has 5 tenis balls. He buys 2 more cans of tennis balls. Each can has 3 tenis balls. How many tennis balls does he have now? A: The answer is 11. Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more,how many apples do they have?

この場合、答えを導き出すことができず以下のようになる

A: The answere is 27

問題を以下のように修正することで答えを導き出すことができる。

Q: Roger has 5 tenis balls. He buys 2 more cans of tennis balls. Each can has 3 tenis balls. How many tennis balls does he have now? A: Rother started with 5 balls. 2 cans of 3tennis balls each is 6 tennis balls. 5 + 6 =11. The answer is 11. Q: The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more,how many apples do they have?

この場合答えは以下のようになる。

A: The cafeteria had 23 apples originally.They used 20 to make lunch. So they had 23 - 20 = 3. They bought 6 more apples, so they have 3 + 6 = 9. The answer is 9.

few-shotは数学の問題だけでなく、スポーツの理解、文字の連結に関する問題でも思考の連鎖がパフォーマンスが向上した。ほとんどの場合、8個以下の例題で十分な効果を確認することができた。
zero-shotと比較してFew-shotの利点は最終的な答えにたどり着くまでにモデルに実行させたい推論の形式、長さ、スタイルをより簡単に指定できることである。これはモデルが最初に適切な方法で推論していない場合に特に役に立つ。

まとめ

今回はテキスト補間で精度を向上させる方法をいくつか紹介した。 原文には他にも精度を上げる様々な方法を紹介しているが、説明が複雑になるため今回は簡単なものを紹介した。気になる方は原文を読んでみてください。 また、将来的にはより優れたモデルや技術が発表されて今回紹介した方法が使えるとは限らないが、原理については共通であるためモデルを扱う上で重要な技術となるだろう。

コメントを追加

プレーンテキスト

  • HTMLタグは利用できません。
  • 行と段落は自動的に折り返されます。
  • ウェブページのアドレスとメールアドレスは自動的にリンクに変換されます。
CAPTCHA
この質問はあなたが人間の訪問者であるかどうかをテストし、自動化されたスパム送信を防ぐためのものです。