準備資料以微調理解模型
以下是準備資料以微調理解模型的指導方針和要求:
-
用於微調的資料大小下限取決於任務 (即複雜或簡單),但我們建議您至少為希望模型學習的每個任務提供 100 個範例。
-
我們建議您在訓練和推論期間以零樣本設定使用最佳化提示詞,以獲得最佳結果。
-
訓練和驗證資料集必須是 JSONL 檔案,其中每一行都是對應於記錄的 JSON 物件。這些檔案名稱只能包含英數字元、底線、連字號、斜線和句點。
-
影像和影片限制條件
-
資料集不能包含不同的媒體模態。也就是說,資料集要麽是帶影像的文字,要麽是帶影片的文字。
-
一個範例 (訊息中的單一記錄) 可以有多個影像
-
一個範例 (訊息中的單一記錄) 只能有 1 個影片
-
-
schemaVersion可以是任何字串值 -
(選用)
system回合可以是客戶提供的自訂系統提示詞。 -
支援的角色為
user和assistant。 -
第一個回合
messages應一律以"role": "user"開頭。最後一個回合是機器人的回應,以「角色」:「助理」表示。 -
Amazon Bedrock 必須可存取
image.source.s3Location.uri和video.source.s3Location.uri。 -
您的 Amazon Bedrock 服務角色必須能夠存取 Amazon S3 中的影像檔案。如需授與存取權的詳細資訊,請參閱建立用於模型自訂的服務角色
-
影像或影片必須與資料集位於相同的 Amazon S3 儲存貯體中。例如,如果您的資料集位於
s3://amzn-s3-demo-bucket/train/train.jsonl中,則您的影像或影片必須位於s3://amzn-s3-demo-bucket中 -
術語
User:、Bot:、Assistant:、System:、<image>、<video>和[EOS]是預留關鍵字。如果使用者提示詞或系統提示詞以任何這些關鍵字開頭,或在其提示詞中的任何位置具有這些關鍵字,則訓練任務會因為資料問題而失敗。如果您需要將這些關鍵字用於您的使用案例,您必須將其替換為具有類似意義的其他關鍵字,以便您的訓練可以繼續進行。
資料集格式範例
下列範例資料集格式提供供您遵循的指南。
下列範例針對純文字進行自訂微調。
// train.jsonl { "schemaVersion": "bedrock-conversation-2024", "system": [ { "text": "You are a digital assistant with a friendly personality" } ], "messages": [ { "role": "user", "content": [ { "text": "What is the capital of Mars?" } ] }, { "role": "assistant", "content": [ { "text": "Mars does not have a capital. Perhaps it will one day." } ] } ] }
下列範例針對文字和單一影像進行自訂微調。
// train.jsonl{ "schemaVersion": "bedrock-conversation-2024", "system": [{ "text": "You are a smart assistant that answers questions respectfully" }], "messages": [{ "role": "user", "content": [{ "text": "What does the text in this image say?" }, { "image": { "format": "png", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-image.png", "bucketOwner": "your-aws-account-id" } } } } ] }, { "role": "assistant", "content": [{ "text": "The text in the attached image says 'LOL'." }] } ] }
下列範例針對文字和影片進行自訂微調。
{ "schemaVersion": "bedrock-conversation-2024", "system": [{ "text": "You are a helpful assistant designed to answer questions crisply and to the point" }], "messages": [{ "role": "user", "content": [{ "text": "How many white items are visible in this video?" }, { "video": { "format": "mp4", "source": { "s3Location": { "uri": "s3://your-bucket/your-path/your-video.mp4", "bucketOwner": "your-aws-account-id" } } } } ] }, { "role": "assistant", "content": [{ "text": "There are at least eight visible items that are white" }] } ] }
資料集限制條件
Amazon Nova 對理解模型的模型自訂套用下列限制。
模型 |
範例下限 |
範例上限 |
上下文長度 |
|---|---|---|---|
Amazon Nova Micro |
8 |
20k |
32k |
Amazon Nova Lite |
8 |
20k |
32k |
Amazon Nova Pro |
8 |
20k |
32k |
影像上限 |
10/樣本 |
影像檔案大小上限 |
10 MB |
影片上限 |
1/樣本 |
影片長度/持續時間上限 |
90 秒 |
影片檔案大小上限 |
50 MB |
支援的媒體格式
-
影像 -
png,jpeg,gif,webp -
影片 -
mov,mkv,mp4,webm