準備資料集 - Amazon Bedrock

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

準備資料集

在開始模型自訂工作之前,您需要以最低限度的方式準備訓練資料集。是否支援驗證資料集,以及訓練和驗證資料集的格式取決於下列因素。

  • 自訂工作的類型 (微調或繼續預先訓練)。

  • 數據的輸入和輸出方式。

微調和持續訓練前資料格式的模型支援

下表詳細說明各個模型所支援的微調和持續訓練前資料格式:

模型名稱 微調:T ext-to-text 微調:T ext-to-image 和我 mage-to-embeddings 繼續預訓:T ext-to-text 微調:單回合訊息 微調:多回合訊息
Amazon Titan Text G1 - Express
Amazon Titan Text G1 - Lite
Amazon 泰坦文本總理
Amazon Titan Image Generator G1 V1
Amazon Titan Multimodal Embeddings G1 G1
Anthropic Claude 3 Haiku
Cohere Command
Cohere Command Light
Meta Llama 2 13B
Meta Llama 2 70B

若要查看適用於自訂不同模型之訓練和驗證資料集的預設配額,請參閱模型自訂配額

為您的自訂模型準備訓練和驗證資料集

選取與您的使用案例相關的索引標籤

Fine-tuning: Text-to-text

若要微調 text-to-text 模型,請建立含有多JSON行的JSONL檔案,以準備訓練和選擇性驗證資料集。每JSON行都是同時包含promptcompletion欄位的範例。每個記號使用 6 個字元作為記號數量的近似值。格式如下所示。

{"prompt": "<prompt1>", "completion": "<expected generated text>"} {"prompt": "<prompt2>", "completion": "<expected generated text>"} {"prompt": "<prompt3>", "completion": "<expected generated text>"}

以下是問答任務的範例項目:

{"prompt": "what is AWS", "completion": "it's Amazon Web Services"}
Fine-tuning: Text-to-image & Image-to-embeddings

若要微調 text-to-image 或 image-to-embedding 模型,請建立含有多JSON行的JSONL檔案,以準備訓練資料集。不支援驗證資料集。每一JSON行都是一個樣本image-ref,其中包含一URI個圖像的 Amazon S3,caption以及一個可能是提示圖像。

影像必須為JPEG或PNG格式。

{"image-ref": "s3://bucket/path/to/image001.png", "caption": "<prompt text>"} {"image-ref": "s3://bucket/path/to/image002.png", "caption": "<prompt text>"} {"image-ref": "s3://bucket/path/to/image003.png", "caption": "<prompt text>"}

以下是範例項目:

{"image-ref": "s3://amzn-s3-demo-bucket/my-pets/cat.png", "caption": "an orange cat with white spots"}

若要允許 Amazon 基岩存取映像檔,請在主控台中存取訓練和驗證檔案,以及在 S3 中寫入輸出檔案的權限為您設定的 Amazon 基岩模型自訂服務角色新增類似的IAM政策。您在訓練資料集中提供的 Amazon S3 路徑必須位於您在政策中指定的資料夾中。

Continued Pre-training: Text-to-text

若要在 text-to-text 模型上執行「繼續預先訓練」,請透過建立具有多JSON行的JSONL檔案來準備訓練和選用的驗證資料集。因為繼續預先訓練涉及未標記的資料,因此每JSON行都是僅包含欄位的範例。input每個記號使用 6 個字元作為記號數量的近似值。格式如下所示。

{"input": "<input text>"} {"input": "<input text>"} {"input": "<input text>"}

以下是可能位於訓練資料中的範例項目。

{"input": "AWS stands for Amazon Web Services"}
Fine-tuning: Single-turn messaging

若要使用單回合傳訊格式微調 text-to-text 模型,請建立含有多JSON行的JSON檔案,以準備訓練和選擇性驗證資料集。兩個資料檔案的JSONL格式都必須是。每行都以 json 格式指定一個完整的數據樣本; 並且每個數據樣本必須格式化為 1 行(刪除每個樣本中的所有 '\ n')。具有多個數據樣本的一行或將數據樣本拆分為多行將不起作用。

欄位

  • system(選擇性):包含系統訊息的字串,可設定交談的內容。

  • messages:消息對象的數組,每個對象包含:

    • roleuserassistant

    • content:訊息的文字內容

規則

  • messages陣列必須包含 2 則訊息

  • 第一條消息必須有role一個用戶

  • 最後一條消息必須有role一個助理

{"system": "<system message>","messages":[{"role": "user", "content": "<user query>"},{"role": "assistant", "content": "<expected generated text>"}]}

範例

{"system": "You are an helpful assistant.","messages":[{"role": "user", "content": "what is AWS"},{"role": "assistant", "content": "it's Amazon Web Services."}]}
Fine-tuning: Multi-turn messaging

若要使用多回合傳訊格式微調 text-to-text 模型,請建立含有多JSON行的JSONL檔案,以準備訓練和選擇性驗證資料集。兩個資料檔案的JSONL格式都必須是。每行都以 json 格式指定一個完整的數據樣本; 並且每個數據樣本必須格式化為 1 行(刪除每個樣本中的所有 '\ n')。具有多個數據樣本的一行或將數據樣本拆分為多行將不起作用。

欄位

  • system(選擇性):包含系統訊息的字串,可設定交談的內容。

  • messages:消息對象的數組,每個對象包含:

    • roleuserassistant

    • content:訊息的文字內容

規則

  • messages陣列必須包含 2 則訊息

  • 第一條消息必須有role一個用戶

  • 最後一條消息必須有role一個助理

  • 訊息必須在userassistant角色之間交替。

{"system": "<system message>","messages":[{"role": "user", "content": "<user query 1>"},{"role": "assistant", "content": "<expected generated text 1>"}, {"role": "user", "content": "<user query 2>"},{"role": "assistant", "content": "<expected generated text 2>"}]}

範例

{"system": "system message","messages":[{"role": "user", "content": "Hello there."},{"role": "assistant", "content": "Hi, how can I help you?"},{"role": "user", "content": "what are LLMs?"},{"role": "assistant", "content": "LLM means large language model."},]}