영한 번역 엉뚱하게 나오는데 내가 뭘 잘못한건가?

#6
by byoungkug - opened

소스

from transformers import MarianMTModel, MarianTokenizer
import torch

model_path = "/home/ppusari/python_venv/down"

tokenizer = MarianTokenizer.from_pretrained(model_path, src_lang="en", tgt_lang="ko")
model = MarianMTModel.from_pretrained(model_path)
device = torch.device("cpu")
model.to(device)

def translate_en_to_ko(sentences):
inputs = tokenizer(sentences, return_tensors="pt", padding=True, truncation=True).to(device)
outputs = model.generate(**inputs, max_length=512)
translated = [tokenizer.decode(t, skip_special_tokens=True) for t in outputs]
return translated

sentences = ["Hello, how are you?", "This is an offline translation test.", "I love programming and AI."]
results = translate_en_to_ko(sentences)
for src, tgt in zip(sentences, results):
print(f"EN: {src}")
print(f"KO: {tgt}")

결과

EN: Hello, how are you?
KO: , pleasing 신뢰할 수 있는 일반에 대 한

EN: This is an offline translation test.
KO: PI 인기 역사、Bubble.

EN: I love programming and AI.
KO: US 92호선 종착역.

문의사항

뭐가 문제 인가요?

이미 답을 찾으실 시간이긴 한데 답변드리자면, opus-mt-tc-big-en-ko 이 모델이 그냥 번역 점수가 많이 낮아요. nllb 600m이 언어 200개를 다루는 데도 영한번역 점수가 30점이 넘는데 얘는 13점입니다.

그냥 모델이 진짜 이상한걸 올려놨어요..;; 하;; 저도 낚임..

Sign up or log in to comment