News

ニュース

GPT を ファインチューニング(fine tuning) してみた

OpenAIのテキスト生成モデルは、膨大な量のテキストで事前にトレーニングされています。モデルを効果的に使うために、GPTはプロンプトに指示や、時にはいくつかの例を含める。タスクを実行する方法を示すためにデモンストレーションを使用することは、しばしば “数ショット学習 “と呼ばれます。

ファインチューニングは、プロンプトに収まるよりも多くの例でトレーニングすることで、数発学習を改善する。いったんモデルが微調整されれば、プロンプトにそれほど多くの例を提供する必要はなくなる。これによりコストを削減し、より低レイテンシーのリクエストを可能にします。

ファインチューニングは、APIを通じて利用可能なモデルから、以下を提供することでより多くのものを引き出します:

  • プロンプトよりも高品質な結果
  • プロンプトに収まるより多くの例でトレーニング可能
  • プロンプトの短縮によるトークンの節約
  • 待ち時間の少ないリクエスト

ハイレベルなファインチューニングには、以下のステップが含まれます:

  1. トレーニングデータの準備とアップロード
  2. 新しいファインチューニング・モデルをトレーニングする
  3. 結果を評価し、必要に応じてステップ1に戻る。
  4. 微調整したモデルを使用する

一般的な使用例

OpenAIのテキスト生成モデルを微調整することで、特定の用途により適したものにすることができるが、それには時間と労力を慎重に投資する必要がある。

OpenAI

一般的な使用例:

  • スタイル、トーン、フォーマットの設定
  • アウトプットの信頼性向上
  • 複雑なプロンプトに従わない場合の修正
  • 多くのエッジケースを特定の方法で処理する
  • プロンプトで表現するのが難しい新しいスキルやタスクの実行
  • コストと待ち時間の削減

モデル+データ形式

現在、以下のモデルでファインチューニングが可能です:

  • gpt-3.5-turbo-1106 (おすすめ)
  • gpt-3.5-turbo-0613
  • babbage-002
  • davinci-002
  • gpt-4-0613 (実験的)

GPT-4のファインチューニングは、実験的なアクセスプログラムとなっています。対象となるユーザーは、ファインチューニングの新規ジョブを作成する際に、ファインチューニングUIからアクセスをリクエストすることができます。

OpenAI

データ形式

  • gpt-3.5-turbo
  • babbage と devinci:

モデルを微調整するには、少なくとも10個の例を提供する必要があります。通常、gpt-3.5-turboで50から100のトレーニング例でファインチューニングを行うことで、明確な改善が見られますが、適切な数は正確なユースケースによって大きく異なります。

OpenAI

手数料

cost = 1kトークンあたりの基本コスト * 入力ファイルのトークン数  *  学習エポック数
  • チェックフォーマット+見積もり: Code

トークン制限

トークンの上限は、選択するモデルによって異なる。

gpt-3.5-turbo-1106では、コンテキストの最大長は16,385なので、各トレーニング例も16,385トークンに制限されます。gpt-3.5-turbo-0613では、各トレーニング例は4,096トークンに制限されます。

デフォルトの長さより長い例は、訓練例の最後からトークンを削除する最大コンテキスト長に切り詰められます。

トレーニング例全体がコンテキストに収まっていることを確認するには、メッセージ内容のトークン数の合計が制限を下回っていることを確認してください。

トークンのカウント: Notebook

#例:

この例では、GPT-3.5-turbo-0613 モデルのファインチューニングを、顧客メッセー ジをトップレベルとサブレベルの両方のカテゴリーに分類するようモデルに指示するようデ ザインされたデータセットを使って実行します。この微調整の主な目的は、モデルが顧客メッセージを正確に分類できるようにすることです。モデルの分類の出力形式はJSONになります。

データ

TrainValidateTest
731910
  • トレーニングデータ:
  • 検証データ
  • テストデータ
Support QueryTop CategorySub Category
Are there any fees for using online banking?Fees and ChargesUnderstanding Fees
What types of home loans do you offer for first-time buyers?Loans and MortgagesLoan Application
How do I file a complaint about a recent issue?Customer ServiceComplaint Handling
Can I cancel a pending transfer?Payments and TransfersWire Transfers
How do I open a new savings account?Account ManagementAccount Opening
The ATM didn’t dispense cash but my account was charged.Transaction Services
Failed Transactions
What are the steps to activate my new card?Card ServicesCard Activation/Deactivation
How do I download and install the bank’s mobile app?
Online and Mobile Banking
Technical Support
What are the bank’s security measures against fraud?Fraud and SecuritySecurity Measures
How do I open a fixed deposit account?Savings and InvestmentsAccount Types

微調整と評価

  • プロセスの微調整
  • 結果(50トークンのリミット出力)
Support QueryTop CategorySub CategoryPrediction (Fine-tune)Prediction (Origin)
Are there any fees for using online banking?Fees and ChargesUnderstanding Fees{“Top Category”: “Fees and Charges”, “Sub Category”: “Understanding Fees”}The fees associated with online banking can vary depending on the bank or financial institution you are using. Some banks may offer online banking services for free, while others may charge fees for certain transactions or services. Common fees that may be associated with online banking include
What types of home loans do you offer for first-time buyers?Loans and MortgagesLoan Application“Top Category”: “Loans and Mortgages”, “Sub Category”: “Loan Application”}As an AI language model, I don’t offer home loans myself. However, I can provide you with information on common types of home loans that are often available for first-time buyers. These include:

1. Conventional Loans: These are traditional mortgage
How do I file a complaint about a recent issue?Customer ServiceComplaint Handling{“Top Category”: “Customer Service”, “Sub Category”: “Feedback and Suggestions”}To file a complaint about a recent issue, follow these steps:

1. Identify the appropriate organization or entity: Determine which organization or entity is responsible for addressing your complaint. This could be a company, government agency, educational institution, or any other relevant
Can I cancel a pending transfer?Payments and TransfersWire Transfers{“Top Category”: “Payments and Transfers”, “Sub Category”: “Wire Transfers”}It depends on the specific circumstances and the policies of the institution or service you are using for the transfer. Generally, if the transfer is still pending, there may be a chance to cancel it. You should contact the institution or service provider involved in the
How do I open a new savings account?Account ManagementAccount Opening{“Top Category”: “Savings and Investments”, “Sub Category”: “Account Types”}To open a new savings account, you can follow these steps:
1. Research and compare different banks or financial institutions: Look for banks or credit unions that offer savings accounts with favorable interest rates, low fees, and convenient access.
2. Choose the
The ATM didn’t dispense cash but my account was charged.Transaction Services
Failed Transactions
{“Top Category”: “Transaction Services”, “Sub Category”: “Failed Transactions”}I’m sorry to hear that. In such a situation, it is important to take the following steps:

1. Check your account balance: Confirm if the amount has been deducted from your account balance. You can do this by checking your account statement online
What are the steps to activate my new card?Card ServicesCard Activation/Deactivation{“Top Category”: “Card Services”, “Sub Category”: “Card Activation”}The steps to activate a new card may vary depending on the type of card and the issuing bank. However, here are some general steps that can help you activate your new card:

1. Read the instructions: Carefully review any instructions or information provided
How do I download and install the bank’s mobile app?
Online and Mobile Banking
Technical Support
{“Top Category”: “Online and Mobile Banking”, “Sub Category”: “Mobile Banking”}To download and install a bank’s mobile app, follow these general steps:

1. Open the app store on your mobile device. If you have an iPhone, open the App Store, and if you have an Android device, open the Google Play Store
What are the bank’s security measures against fraud?Fraud and SecuritySecurity Measures{“Top Category”: “Fraud and Security”, “Sub Category”: “Security Measures”}Banks employ various security measures to protect against fraud. Some common security measures include:

1. Multi-factor authentication: Banks often require customers to provide multiple forms of identification, such as passwords, PINs, security questions, or biometric data (f
How do I open a fixed deposit account?Savings and InvestmentsAccount Types{“Top Category”: “Savings and Investments”, “Sub Category”: “Account Types”}To open a fixed deposit account, you can follow these steps:

1. Research and choose a bank: Look for banks that offer fixed deposit accounts with competitive interest rates and favorable terms.

2. Visit the bank branch: Go to the nearest branch of

最後に

ファインチューニングされたモデルは、オリジナルモデルと比較して出力が顕著に改善されている。洗練された出力は著しく短く、明確に定義されたJSONフォーマットで表示され、微調整プロセスで使用された入力データに酷似している。特筆すべきは、顧客メッセージを特定のカテゴリーに分類するモデルの精度が大幅に向上したことである。

これらの結果は、顧客メッセージを分類するという我々の目標タスクに対処するための微調整の有効性を強調しています。この改良されたモデルにより、GPT APIを活用することが、より効率的で費用対効果の高いものになります。

現在、ファインチューニングされたモデルはAPIを通じてのみアクセス可能です。しかし、将来的には、この改良されたモデルをOpenCVを介してAssistantに統合することで、API利用以外の幅広い応用が可能になる可能性があります。