本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
選項 2:使用調用日誌進行資料準備
當您建立強化微調任務時,可以讓 Amazon Bedrock 使用 S3 儲存貯體中的現有調用日誌做為訓練資料。對於 Amazon Bedrock,調用日誌是模型調用的詳細記錄。
若要使用調用日誌進行強化微調,請在 上設定模型調用日誌、使用其中一個模型調用操作,並確定您已將 Amazon S3 儲存貯體設定為日誌的目的地。如需設定調用日誌的詳細資訊,請參閱使用 CloudWatch Logs 和 Amazon S3 監控模型調用。
您必須先提供 Amazon Bedrock 許可,以從 S3 儲存貯體存取 S3 儲存貯體的日誌,才能啟動強化微調任務做為輸入。如需詳細資訊,請參閱調用日誌存取。
您可以選擇使用其中一個模型調用操作,將請求中繼資料新增至調用日誌中的提示-回應對,然後使用這個內容來篩選日誌。Amazon Bedrock 可以使用篩選的日誌來微調模型。
將請求中繼資料新增至叫用日誌中的提示和回應,以進行強化微調
透過調用日誌,您可以識別您希望 Amazon Bedrock 使用連接到調用日誌的請求中繼資料進行強化微調的訓練資料集提示。
以下是來自 InvokeModel呼叫的調用日誌範例requestMetadata:
{ "schemaType": "ModelInvocationLog", "schemaVersion": "1.0", "timestamp": "2024-09-11T17:16:18Z", "accountId": "XXXXX", "identity": { "arn": "arn:aws:sts::XXXXXXX:assumed-role/Admin/XXXXXX" }, "region": "us-east-1", "requestId": "7ee514f3-9eff-467c-af75-8fd564ce58e5", "operation": "InvokeModel", "modelId": "meta.llama3-1-405b-instruct-v1:0", "input": { "inputContentType": "application/json", "inputBodyJson": { "prompt": "story of two dogs", "max_tokens_to_sample": 300 }, "inputTokenCount": 13 }, "output": { "outputContentType": "application/json", "outputBodyJson": { "type": "completion", "completion": " Here is a story about two dogs:\n\nRex and Charlie were best friends who lived next door to each other. Every morning, their owners would let them out into the backyard to play. Rex was a golden retriever with long, shaggy fur. He loved to run and chase sticks. Charlie was a corgi with short legs and a big smile. He was happy just sniffing the grass and rolling around. \n\nThe two dogs spent every day playing together. Rex would grab a stick and bring it over to Charlie, wagging his tail excitedly. Charlie would take the other end of the stick in his mouth and they'd have a friendly game of tug-of-war. After tiring themselves out, they'd flop down in the warm sunshine for a nap. \n\nAt lunchtime, their owners would call them in for food. Rex would gobble up his kibble hungrily while Charlie ate his at a more leisurely pace. After lunch, it was right back outside for more playtime. The afternoon sunbeams would light up their fur as they chased each other around the yard. \n\nWhen it started getting late, their owners called them in for the night. Rex and Charlie would head inside, tired but happy after another fun day of play. After slurping up fresh water from their bowls, they'd curl up on their beds, Rex's fluffy golden tail tucked over his nose and little", "stop_reason": "max_tokens", "stop": null }, "outputTokenCount": 300 }, "requestMetadata": { "project": "CustomerService", "intent": "ComplaintResolution", "priority": "High" } }
當您啟動強化微調任務時,您可以將調用日誌指定為輸入資料來源。您可以使用 API AWS CLI或 SDK,透過 Amazon Bedrock 主控台啟動強化微調任務。
提供請求中繼資料的需求
請求中繼資料必須符合下列需求:
-
以 JSON
key:value格式提供。 -
金鑰和值對必須是最多 256 個字元的字串。
-
提供最多 16 個鍵/值對。
使用請求中繼資料篩選器
使用具有請求中繼資料的調用日誌後,您可以根據請求中繼資料套用篩選條件,選擇性地選擇要包含哪些提示來微調模型。例如,您可能只想包含具有 "project": "CustomerService"和 "priority": "High"請求中繼資料的 。
若要使用多個請求中繼資料篩選日誌,請使用單一布林運算子AND或 OR。您無法合併這些運算子。對於單一請求中繼資料篩選,請使用 Equals或 Not Equals運算子。