번역 기능을 추가 하고자 facebook/nllb-200-distilled-600M 모델 사용
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("facebook/nllb-200-distilled-600M")
model = AutoModelForSeq2SeqLM.from_pretrained("facebook/nllb-200-distilled-600M")
공식 문서를 참고하여 직접 모델을 로드하여 사용하려고 했으나
번역 언어가 인식이 안되고 다른 언어로 번역하는 문제가 생김
translator = pipeline(
'translation',
model='facebook/nllb-200-distilled-600M',
device=0,
src_lang='eng_Latn', # input language
tgt_lang='kor_Hang', # output language
max_length=512
)
파이프 라인을 만들어 해결
- 기존의 result값이 문자열이었으나
{"translation_text":"~~~~"} 와 같이 key-value의 형태로 반환 따로 추출해 문자열로 반환
'개발일지 > BrewWing' 카테고리의 다른 글
| TroubleShooting: Traceback Error (0) | 2025.02.04 |
|---|---|
| TroubleShooting: 번역 텍스트 줄바꿈 없어짐 문제 (0) | 2025.02.04 |
| TroubleShooting: Llama 답변 구조 문제 (0) | 2025.01.29 |
| TroubleShooting: 답변 줄 정리 (0) | 2025.01.29 |
| 데이터 전처리 (0) | 2025.01.04 |