์ผ๊ด ์์ธก์ ์ฌ์ฉํ๋ฉด ์ง์ฐ ์๊ฐ์ ๋ฏผ๊ฐํ์ง ์์ ์ฌ๋ฌ ๊ฐ์ ํ๋กฌํํธ๋ฅผ Anthropic Claude ๋ชจ๋ธ์ ์ ์กํ ์ ์์ต๋๋ค. ์์ฒญ๋ง๋ค ํ๋์ ์ ๋ ฅ ํ๋กฌํํธ๋ฅผ ์ ์กํ๋ ์จ๋ผ์ธ ์์ธก๊ณผ ๋ฌ๋ฆฌ ๋จ์ผ ์์ฒญ์ผ๋ก ๋ค์์ ์ ๋ ฅ ํ๋กฌํํธ๋ฅผ ์ผ๊ด ์ฒ๋ฆฌํ ์ ์์ต๋๋ค.
์ง์๋๋ Anthropic Claude ๋ชจ๋ธ
Vertex AI๋ ๋ค์ Anthropic Claude ๋ชจ๋ธ์ ์ผ๊ด ์์ธก์ ์ง์ํฉ๋๋ค.
- Claude Opus 4.1
- Claude Opus 4
- Claude Sonnet 4
- Claude 3.7 Sonnet
- Claude 3.5 Sonnet v2
- Claude 3.5 Haiku
ํ ๋น๋
๊ธฐ๋ณธ์ ์ผ๋ก ๋จ์ผ ํ๋ก์ ํธ์์ ๋ง๋ค ์ ์๋ ๋์ ์ผ๊ด ์์ฒญ ์๋ 4๊ฐ์ ๋๋ค.
์ ๋ ฅ ์ค๋น
์์ํ๊ธฐ ์ ์ BigQuery ํ ์ด๋ธ ๋๋ Cloud Storage์ JSONL ํ์ผ๋ก ์ ๋ ฅ ๋ฐ์ดํฐ ์ธํธ๋ฅผ ์ค๋นํฉ๋๋ค. ๋ ์์ค์ ์ ๋ ฅ์ ๋ค์ ์์์ ๊ฐ์ด Anthropic Claude API ์คํค๋ง JSON ํ์์ ๋ฐ๋ผ์ผ ํฉ๋๋ค.
{
"custom_id": "request-1",
"request": {
"messages": [{"role": "user", "content": "Hello!"}],
"anthropic_version": "vertex-2023-10-16",
"max_tokens": 50
}
}
BigQuery
BigQuery ์ ๋ ฅ ํ ์ด๋ธ์ ๋ค์ ์คํค๋ง๋ฅผ ์ค์ํด์ผ ํฉ๋๋ค.
์ด ์ด๋ฆ | ์ค๋ช |
---|---|
custom_id | ์ ๋ ฅ์ ์ถ๋ ฅ๊ณผ ์ผ์น์ํค๋ ๊ฐ ์์ฒญ์ ID์ ๋๋ค. |
์์ฒญ | ์์ฒญ ๋ณธ๋ฌธ(์ ๋ ฅ ํ๋กฌํํธ์ด๋ฉฐ Anthropic Claude API ์คํค๋ง๋ฅผ ๋ฐ๋ผ์ผ ํจ) |
- ์ ๋ ฅ ํ ์ด๋ธ์๋ ์ผ๊ด ์์ ์์ ๋ฌด์๋๋ ๋ค๋ฅธ ์ด์ด ์์ ์ ์์ต๋๋ค.
- ์ผ๊ด ์์ธก ์์
์ ์ผ๊ด ์์ธก ์ถ๋ ฅ์
response(JSON)
๋ฐstatus
์ด๋ผ๋ ๋ ๊ฐ์ง ์ด ์ด๋ฆ์ ์์ฝํฉ๋๋ค. ์ ๋ ฅ ํ ์ด๋ธ์์ ์ด๋ฌํ ์ด์ ์ฌ์ฉํ์ง ๋ง์ธ์.
Cloud Storage
Cloud Storage์ ๊ฒฝ์ฐ ์ ๋ ฅ ํ์ผ์ Cloud Storage ๋ฒํท์ ์๋ JSONL ํ์ผ์ด์ด์ผ ํฉ๋๋ค.
๋ฐฐ์น ์์ธก ์์ฒญ
BigQuery ๋๋ Cloud Storage์ ์ ๋ ฅ์ ์ฌ์ฉํ์ฌ Claude ๋ชจ๋ธ์์ ์ผ๊ด ์์ธก์ ์คํํฉ๋๋ค. BigQuery ํ ์ด๋ธ ๋๋ Cloud Storage ๋ฒํท์ JSONL ํ์ผ ์ค ํ๋์ ์์ธก์ ์ถ๋ ฅํ๋๋ก ๋ ๋ฆฝ์ ์ผ๋ก ์ ํํ ์ ์์ต๋๋ค.
BigQuery
BigQuery ์ ๋ ฅ ํ ์ด๋ธ, ๋ชจ๋ธ, ์ถ๋ ฅ ์์น๋ฅผ ์ง์ ํฉ๋๋ค. ์ผ๊ด ์์ธก ์์ ๊ณผ ํ ์ด๋ธ์ด ๋์ผํ ๋ฆฌ์ ์ ์์ด์ผ ํฉ๋๋ค.
Python
Vertex AI SDK for Python์ ์ค์นํ๊ฑฐ๋ ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ์ Vertex AI SDK for Python ์ค์น๋ฅผ ์ฐธ์กฐํ์ธ์. ์์ธํ ๋ด์ฉ์ Python API ์ฐธ๊ณ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
REST
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- LOCATION: ์ ํํ Anthropic Claude ๋ชจ๋ธ์ ์ง์ํ๋ ๋ฆฌ์ (Claude ๋ฆฌ์ ์ฐธ๊ณ )
- PROJECT_ID: ํ๋ก์ ํธ ID
- MODEL: ๋ชจ๋ธ์ ์ด๋ฆ
- INPUT_URI: ์ผ๊ด ์์ธก ์
๋ ฅ์ด ์๋ BigQuery ํ
์ด๋ธ(์:
bq://myproject.mydataset.input_table
) - OUTPUT_FORMAT: BigQuery ํ
์ด๋ธ์ ์ถ๋ ฅํ๋ ค๋ฉด
bigquery
๋ฅผ ์ง์ ํฉ๋๋ค. Cloud Storage ๋ฒํท์ ์ถ๋ ฅํ๋ ค๋ฉดjsonl
์ ์ง์ ํฉ๋๋ค. - DESTINATION: BigQuery์ ๊ฒฝ์ฐ
bigqueryDestination
์ ์ง์ . Cloud Storage์ ๊ฒฝ์ฐgcsDestination
์ ์ง์ ํฉ๋๋ค. - OUTPUT_URI_FIELD_NAME: BigQuery์ ๊ฒฝ์ฐ
outputUri
์ ์ง์ ํฉ๋๋ค. Cloud Storage์ ๊ฒฝ์ฐoutputUriPrefix
์ ์ง์ ํฉ๋๋ค. - OUTPUT_URI: BigQuery์ ๊ฒฝ์ฐ ํ
์ด๋ธ ์์น(์:
bq://myproject.mydataset.output_result
)๋ฅผ ์ง์ ํฉ๋๋ค. Cloud Storage์ ๊ฒฝ์ฐ ๋ฒํท ๋ฐ ํด๋ ์์น(์:gs://mybucket/path/to/outputfile
)๋ฅผ ์ง์ ํฉ๋๋ค.
HTTP ๋ฉ์๋ ๋ฐ URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs
JSON ์์ฒญ ๋ณธ๋ฌธ:
'{ "displayName": "JOB_NAME", "model": "publishers/anthropic/models/MODEL", "inputConfig": { "instancesFormat":"bigquery", "bigquerySource":{ "inputUri" : "INPUT_URI" } }, "outputConfig": { "predictionsFormat":"OUTPUT_FORMAT", "DESTINATION":{ "OUTPUT_URI_FIELD_NAME": "OUTPUT_URI" } } }'
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
curl
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs"
PowerShell
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs" | Select-Object -Expand Content
๋ค์๊ณผ ๋น์ทํ JSON ์๋ต์ด ์์ ๋ฉ๋๋ค.
Cloud Storage
JSONL ํ์ผ์ Cloud Storage ์์น, ๋ชจ๋ธ, ์ถ๋ ฅ ์์น๋ฅผ ์ง์ ํฉ๋๋ค.
Python
Vertex AI SDK for Python์ ์ค์นํ๊ฑฐ๋ ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ์ Vertex AI SDK for Python ์ค์น๋ฅผ ์ฐธ์กฐํ์ธ์. ์์ธํ ๋ด์ฉ์ Python API ์ฐธ๊ณ ๋ฌธ์๋ฅผ ์ฐธ์กฐํ์ธ์.
REST
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- LOCATION: ์ ํํ Anthropic Claude ๋ชจ๋ธ์ ์ง์ํ๋ ๋ฆฌ์ (Claude ๋ฆฌ์ ์ฐธ๊ณ )
- PROJECT_ID: .
- MODEL: ๋ชจ๋ธ์ ์ด๋ฆ
- INPUT_URIS: JSONL ์ผ๊ด ์์ธก ์
๋ ฅ์ Cloud Storage ์์น(์:
gs://bucketname/path/to/jsonl
)๋ฅผ ์ผํ๋ก ๊ตฌ๋ถํ ๋ชฉ๋ก์ ๋๋ค. - OUTPUT_FORMAT: BigQuery ํ
์ด๋ธ์ ์ถ๋ ฅํ๋ ค๋ฉด
bigquery
๋ฅผ ์ง์ ํฉ๋๋ค. Cloud Storage ๋ฒํท์ ์ถ๋ ฅํ๋ ค๋ฉดjsonl
์ ์ง์ ํฉ๋๋ค. - DESTINATION: BigQuery์ ๊ฒฝ์ฐ
bigqueryDestination
์ ์ง์ . Cloud Storage์ ๊ฒฝ์ฐgcsDestination
์ ์ง์ ํฉ๋๋ค. - OUTPUT_URI_FIELD_NAME: BigQuery์ ๊ฒฝ์ฐ
outputUri
์ ์ง์ ํฉ๋๋ค. Cloud Storage์ ๊ฒฝ์ฐoutputUriPrefix
์ ์ง์ ํฉ๋๋ค. - OUTPUT_URI: BigQuery์ ๊ฒฝ์ฐ ํ
์ด๋ธ ์์น(์:
bq://myproject.mydataset.output_result
)๋ฅผ ์ง์ ํฉ๋๋ค. Cloud Storage์ ๊ฒฝ์ฐ ๋ฒํท ๋ฐ ํด๋ ์์น(์:gs://mybucket/path/to/outputfile
)๋ฅผ ์ง์ ํฉ๋๋ค.
HTTP ๋ฉ์๋ ๋ฐ URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs
JSON ์์ฒญ ๋ณธ๋ฌธ:
'{ "displayName": "JOB_NAME", "model": "publishers/anthropic/models/MODEL", "inputConfig": { "instancesFormat":"jsonl", "gcsSource":{ "uris" : "INPUT_URIS" } }, "outputConfig": { "predictionsFormat":"OUTPUT_FORMAT", "DESTINATION":{ "OUTPUT_URI_FIELD_NAME": "OUTPUT_URI" } } }'
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
curl
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs"
PowerShell
์์ฒญ ๋ณธ๋ฌธ์ request.json
ํ์ผ์ ์ ์ฅํ๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs" | Select-Object -Expand Content
๋ค์๊ณผ ๋น์ทํ JSON ์๋ต์ด ์์ ๋ฉ๋๋ค.
์ผ๊ด ์์ธก ์์ ์ ์ํ ๊ฐ์ ธ์ค๊ธฐ
์ผ๊ด ์์ธก ์์ ์ ์ํ๋ฅผ ๊ฐ์ ธ์ ์์ ์ด ์๋ฃ๋์๋์ง ํ์ธํฉ๋๋ค.
REST
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- PROJECT_ID: .
- LOCATION: ์ผ๊ด ์์ ์ด ์๋ ๋ฆฌ์ ์ ๋๋ค.
- JOB_ID: ์์ ์ ๋ง๋ค ๋ ๋ฐํ๋ ์ผ๊ด ์์ ID์ ๋๋ค.
HTTP ๋ฉ์๋ ๋ฐ URL:
GET https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs/JOB_ID
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ์ ํํฉ๋๋ค.
curl
๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs/JOB_ID"
PowerShell
๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/batchPredictionJobs/JOB_ID" | Select-Object -Expand Content
๋ค์๊ณผ ๋น์ทํ JSON ์๋ต์ด ์์ ๋ฉ๋๋ค.
์ผ๊ด ์์ธก ์ถ๋ ฅ ๊ฐ์ ธ์ค๊ธฐ
์ผ๊ด ์์ธก ์์
์ด ์๋ฃ๋๋ฉด ์ง์ ํ ์์น์์ ์ถ๋ ฅ์ ๊ฐ์ ธ์ต๋๋ค. BigQuery์ ๊ฒฝ์ฐ ์ถ๋ ฅ์ ๋์ BigQuery ํ
์ด๋ธ์ response(JSON)
์ด์ ์์ต๋๋ค. Cloud Storage์ ๊ฒฝ์ฐ ์ถ๋ ฅ์ด ์ถ๋ ฅ Cloud Storage ์์น์ JSONL ํ์ผ๋ก ์ ์ฅ๋ฉ๋๋ค.
๋ชจ๋ ํ์ด ์๋ฃ๋ ํ ๋๋ 24์๊ฐ์ด ์ง๋ ํ(๋ ์ค ๋จผ์ ๋๋ฌํ๋ ์์ ) ์ ์ฒด ์ผ๊ด ์์ธก ๊ฒฐ๊ณผ์ ์ก์ธ์คํ ์ ์์ต๋๋ค.