File size: 710 Bytes
ddd0d47 169f2b5 900b70e 169f2b5 900b70e 169f2b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
---
license: apache-2.0
language:
- en
- ko
tags:
- transliteration
- multilingual
---
```
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
def transliteration(word: str):
model_checkpoint = "eunsour/en-ko-transliterator"
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, src_lang="en", tgt_lang="ko")
encoded_en = tokenizer(word, truncation=True, max_length=48, return_tensors="pt")
generated_tokens = model.generate(**encoded_en)
result = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
return result
transliteration("transformer")
# ['트랜스포머']
``` |