eunsour commited on
Commit
900b70e
1 Parent(s): ddd0d47

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -5
README.md CHANGED
@@ -8,10 +8,20 @@ tags:
8
  - multilingual
9
  ---
10
  ```
11
- !pip install simpletransformers
12
- from simpletransformers.t5 import T5Model
13
 
14
- model = T5Model("mt5", "eunsour/en-ko-transliterator", use_cuda=False)
15
- print(model.predict(["transformer"]))
16
- print(model.predict(["attention"]))
 
 
 
 
 
 
 
 
 
 
 
17
  ```
 
8
  - multilingual
9
  ---
10
  ```
11
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
 
12
 
13
+ def transliteration(word: str):
14
+ model_checkpoint = "eunsour/en-ko-transliterator"
15
+
16
+ model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
17
+ tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, src_lang="en", tgt_lang="ko")
18
+
19
+ encoded_en = tokenizer(word, truncation=True, max_length=48, return_tensors="pt")
20
+ generated_tokens = model.generate(**encoded_en)
21
+ result = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
22
+
23
+ return result
24
+
25
+ transliteration("transformer")
26
+ # ['트랜스포머']
27
  ```