번역 LLM (TLLM) 모델
Google의 최신 최첨단 번역 모델인 TLLM은 사용 가능한 최고 품질의 번역을 제공하는 대규모 언어 모델 (LLM)입니다. 다른 번역 모델과 비교했을 때 어려운 워크로드에서 MetricX 및 COMET 점수가 훨씬 더 높습니다. 맞춤설정은 물론 더 가벼운 적응형 번역도 지원합니다.
모델 ID는 general/translation-llm입니다.
TLLM 모델에 액세스하려면 Cloud Translation - Basic API 또는 Cloud Translation - Advanced API가 사용 설정된 Google Cloud 프로젝트와 인증된 호출을 수행할 사용자 인증 정보가 있어야 합니다. Python 또는 다른 프로그래밍 언어를 사용하여 모델에 액세스하려면 클라이언트 라이브러리를 설치합니다 (Cloud Translation - Advanced API 기능에는 v3이 필요함).
여기에 제시된 예시에서 PROJECT_ID는 프로젝트 ID를 나타내고
REGION_NAME는 번역 작업을 실행하려는 Google Cloud 리전
의 기술 리전 이름 (예: us-central1)을 나타냅니다.
필요한 경우 ISO-639 코드를 사용하여 출발어
와 도착어를 식별합니다.
텍스트 번역 REST 예시
REST API를 사용하여 TLLM 모델에서
TranslateText
를 호출할 수 있습니다. 요청 필드를 request.json과 같은 JSON 파일에 넣을 수 있습니다.
{
"contents": ["This is text that I would like to have translated.",
"It can include up to 1024 strings."],
"mimeType": "text/plain",
"sourceLanguageCode": "en"
"targetLanguageCode": "it",
"model": "projects/PROJECT_ID/locations/REGION_NAME/models/general/translation-llm"
}
그런 다음 curl 명령어를 사용하여 요청을 제출할 수 있습니다.
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "x-goog-user-project: PROJECT_ID" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_ID:translateText"
응답은 다음과 같은 JSON 문서입니다.
{
"translations": [
{
"translatedText": "Este es el texto que me gustaría traducir.",
"model": "projects/PROJECT_ID/locations/REGION_NAME/models/general/translation-llm"
},
{
"translatedText": "Puede incluir hasta 1024 cadenas.",
"model": "projects/PROJECT_ID/locations/REGION_NAME/models/general/translation-llm"
}
]
}
텍스트 번역 REST 예시 (Basic/V2)
Cloud Translation - Basic (V2) REST API를 사용하여 표준 Translation LLM 모델을 호출할 수 있습니다. 인증에는 API 키를 사용해야 합니다.
curl -X POST \
-H "Content-Type: application/json; charset=utf-8" \
-d '{
"q": ["The old lighthouse stood on the edge of the cliff."],
"target": "es",
"model": "projects/PROJECT_ID/locations/REGION_NAME/models/general/translation-llm"
}' \
"https://translation.googleapis.com/language/translate/v2?key=YOUR_API_KEY"
텍스트 번역 Python 예시
다음은 TLLM 모델로 TranslateText를 호출하는 샘플 Python 코드입니다.
from google.cloud import translate_v3
def translate():
response = translate_v3.TranslationServiceClient().translate_text(
contents=["Life is short.",
"Art is long."],
target_language_code='fr',
source_language_code='en',
parent=f"projects/PROJECT_ID/locations/REGION_NAME",
model=f"projects/PROJECT_ID/locations/REGION_NAME/models/general/translation-llm"
)
print(response)
return response
translate()
응답은 JSON 객체 형식을 취합니다.
translations {
translated_text: "La vie est courte."
model: "projects/261347268520/locations/us-central1/models/general/translation-llm"
}
translations {
translated_text: "L'art est long."
model: "projects/261347268520/locations/us-central1/models/general/translation-llm"
}
translations {
translated_text: "La vie est courte."
model: "projects/261347268520/locations/us-central1/models/general/translation-llm"
}
translations {
translated_text: "L'art est long."
model: "projects/261347268520/locations/us-central1/models/general/translation-llm"