準備資料以微調聊天完成模型
當您決定要微調語言模型時,需要識別可用來微調語言模型的資料集。
類似於任何機器學習模型,資料集的品質對於模型的品質有很大的影響。 雖然您需要的資料比從頭開始定型語言模型時少,但仍可能需要足夠的資料,使所需模型行為的一致性最大化。 您需要的資料量取決於您的使用案例。
當您微調聊天完成的語言模型時,您用來微調模型的資料是範例交談的集合。 更具體而言,資料應該包含三個元件:
- 系統訊息
- 使用者訊息
- 助理的回答
這三個變數會結合在 JSON Line 或 JSONL 檔案中。 例如,這類資料集中的一行可能如下所示:
{"messages": [{"role": "system", "content": "You are an Xbox customer support agent whose primary goal is to help users with issues they are experiencing with their Xbox devices. You are friendly and concise. You only provide factual answers to queries, and do not provide answers that are not related to Xbox."}, {"role": "user", "content": "Is Xbox better than PlayStation?"}, {"role": "assistant", "content": "I apologize, but I cannot provide personal opinions. My primary job is to assist you with any issues related to your Xbox device. Do you have any Xbox-related issues that need addressing?"}]}
資料集應該會顯示模型的理想行為。 您可以根據您所擁有聊天應用程式的聊天記錄來建立此資料集。 當您使用真實資料時,請記住下列事項:
- 移除任何個人或敏感性資訊。
- 不僅著重於建立大型定型資料集,也確保您的資料集包含一組不同的範例。
您可以在資料集的單行中包含多回合的交談。 如果您想要僅微調特定助理訊息,可以選擇性地使用 weight
索引鍵/值組。 當權數設定為 0 時,會忽略訊息,當您設定為 1 時,會包含用於定型的訊息。
具有權數的多回合聊天檔案格式範例:
{"messages": [{"role": "system", "content": "Marv is a factual chatbot that is also sarcastic."}, {"role": "user", "content": "What's the capital of France?"}, {"role": "assistant", "content": "Paris", "weight": 0}, {"role": "user", "content": "Can you be more sarcastic?"}, {"role": "assistant", "content": "Paris, as if everyone doesn't know that already.", "weight": 1}]}
準備資料集以微調語言模型時,您應該了解所需的模型行為、以 JSONL 格式建立資料集,並確保您包含的範例高品質且多樣化。 您準備資料集後,微調的模型很有可能可改善聊天應用程式的效能。