Erstellen Sie eine JSONL-Datei mit dem Namenabc.jsonl
, die mindestens die Mindestanzahl an Datensätzen enthält (sieheKontingente für Amazon Bedrock). Sie können den folgenden Inhalt als erste Zeile und Eingabe verwenden:
{
"recordId": "CALL0000001",
"modelInput": {
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the following call transcript: ..."
}
]
}
]
}
}
Erstellen Sie einen S3-Bucket mit dem Namen amzn-s3-demo-bucket-input
und laden Sie die Datei in ihn hoch. Erstellen Sie dann einen S3-Bucketamzn-s3-demo-bucket-output
, in den Sie Ihre Ausgabedateien schreiben sollen. Führen Sie den folgenden Codeausschnitt aus, um einen Job einzureichen und das jobArn
aus der Antwort abzurufen:
import boto3
bedrock = boto3.client(service_name="bedrock")
inputDataConfig=({
"s3InputDataConfig": {
"s3Uri": "s3://amzn-s3-demo-bucket-input/abc.jsonl"
}
})
outputDataConfig=({
"s3OutputDataConfig": {
"s3Uri": "s3://amzn-s3-demo-bucket-output/"
}
})
response=bedrock.create_model_invocation_job(
roleArn="arn:aws:iam::123456789012:role/MyBatchInferenceRole",
modelId="anthropic.claude-3-haiku-20240307-v1:0",
jobName="my-batch-job",
inputDataConfig=inputDataConfig,
outputDataConfig=outputDataConfig
)
jobArn = response.get('jobArn')
Gibt den Namen status
des Auftrags zurück.
bedrock.get_model_invocation_job(jobIdentifier=jobArn)['status']
Listet Batch-Inferenzjobs auf, die. Failed
bedrock.list_model_invocation_jobs(
maxResults=10,
statusEquals="Failed",
sortOrder="Descending"
)
Beenden Sie den Auftrag, den Sie gestartet haben.
bedrock.stop_model_invocation_job(jobIdentifier=jobArn)