ByT5-Korean - small
ByT5-Korean is a Korean specific extension of Google's ByT5.
A Korean syllable has three components (called Jamo): a beginning consonant, a middle vowel, and an optional final consonant; they are like individual characters of alphabet. While the ByT5's utf-8 encoding allows generic encoding for multiple languages, it is unnatural for Korean because it splits the bits representation of each Jamo in the middle.
ByT5-Korean extends ByT5's utf-8 encoding with special care for Korean syllables; each Jamo is represented with a extra token. ByT5-Korean was pre-trained on mC4 with 70% Korean and 30% English.
Encoding Scheme
id: token
0: <pad>
1: <eos>
2: <unk>
3~258: utf-8 encoding
259~277: beginning consonants(μ΄μ±), 19κ°(γ±γ²γ΄γ·γΈγΉγ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
)
278~298: middle vowel(μ€μ±), 21κ°(γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
‘γ
’γ
£)
299~326: final consonant(μ’
μ±), 무μ’
μ±+27κ°(γ±γ²γ³γ΄γ΅γΆγ·γΉγΊγ»γΌγ½γΎγΏγ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
γ
)
327~384: from <extra_id_0> to <extra_id_57>
Example Inference
import torch
from tokenizer import ByT5KoreanTokenizer # https://huggingface.co/everdoubling/byt5-Korean-small/blob/main/tokenizer.py
from transformers import T5ForConditionalGeneration
tokenizer_jamo = ByT5KoreanTokenizer()
model = T5ForConditionalGeneration.from_pretrained('everdoubling/byt5-Korean-small')
input_sentence = 'νκ΅μ΄ μν€λ°±κ³Ό(μμ΄: Korean Wikipedia)λ νκ΅μ΄λ‘ μ΄μλλ μν€λ°±κ³Όμ λ€μΈμ΄ν κ°μ΄λ° νλλ‘μ, 2002λ
10μ 11μΌμ <extra_id_0>. λν νμ¬ νκ΅μ΄ μν€λ°±κ³Όμλ λ겨주기, ν λ‘ , κ·Έλ¦Ό λ± νμ΄μ§λ‘ λΆλ¦¬λ λͺ¨λ λ¬Έμλ₯Ό ν¬ν¨νλ©΄ μ΄ 2,629,860κ°κ° <extra_id_1>λμ΄ μμΌλ©°, λ겨주기λ₯Ό ν¬ν¨ν μΌλ° λ¬Έμ μλ 1,278,560κ°,[1] κ·Έμ€ λ겨주기, λ§λ€λ₯Έ λ¬Έμλ₯Ό μ μΈν μΌλ° λ¬Έμ μλ 573,149κ°μ΄λ€.'
input_ids_jamo = tokenizer_jamo(input_sentence).input_ids
outputs_jamo = model_jamo.generate(torch.tensor([input_ids_jamo]))
print(tokenizer_jamo.decode(outputs_jamo[0]))
# <pad><extra_id_0>μ€λ¦½λμλ€<extra_id_1>ΔΔ
Additional information coming soon...
- Downloads last month
- 38
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.