KE-T5: Korean-English T5 KE-T5 是使用韩语和英语语料库预先训练的 Text-to-Text Transfer Transformer 模型。词汇量为 64,000 个子词令牌,…
KE-T5: Korean-English T5 KE-T5 是使用韩语和英语语料库预先训练的 Text-to-Text Transfer Transformer 模型。词汇量为 64,000 个子词令牌,…
KE-T5는 Text-to-Text Transfer Transformer 모델을 한국어와 영어 코퍼스를 이용하여 사전학습한 모델입니다.
Vocabulary는 64,000개의 sub-word token으로 이루어져 있으며, Google의 sentencepiece를 이용하여 만들었습니다. Sentencepiece 모델은 한국어와 영어가 약 7:3의 비율로 섞인 30GB의 코퍼스를 99.95% 커버하도록 학습되었습니다.
사전학습에 사용된 비정형 코퍼스에 대한 구성과 정보는 Datasets을 참고하시기 바랍니다.
기존 KE-T5보다 많은 양의 토큰을 입력으로 받고 출력으로 생성 가능한 Long KE-T5가 공개되었습니다. Long KE-T5는 입력 기준 4096 토큰, 출력 기준 1024 토큰으로 학습되었습니다. 또한 Long KE-T5를 활용한 간단한 생성 모델(Downstream Tasks) 몇 개가 공개 되었으며 지속적으로 추가 모델들이 공개될 예정입니다.
Pytorch와 Huggingface transformers를 사용하시는 분들이 Downstream task들을 비교적 쉽게 학습시킬 수 있는 KE-T5 Downstreams가 공개되었습니다. NER, Summarization, Sequence Classification등 여러 task를 학습시킬 수 있습니다.
KE-T5를 이용하여 Downstream task를 학습하기 위해서는 먼저 pre-trained model을 다운 받아야 합니다. pre-trained models에서 다운 받으실 수 있습니다
이 섹션에서는 Google Cloud Platform에서 TPU를 이용하여 학습하는 방법만 설명합니다. GPU에서 사용하실 경우 T5 github에서 설명하듯이 gin-config의 utils.run.mesh_devices와 utils.run.mesh_shape parameter를 오버라이드 해주시면 됩니다.
TFRC를 이용하시면 TPU를 한달간 무료로 사용하실 수 있습니다.
먼저 되도록 TPU Zone과 동일한 곳에 버킷과 VM instance를 생성합니다. VM instance와 TPU의 area는 버킷보다 세분화 되어 있습니다. 생성한 VM instance에 접속한 후 아래와 같이 repository를 clone하고 필요한 python package들을 설치합니다.
git clone https://github.com/AIRC-KETI/ke-t5.git
cd ke-t5
pip3 install -r requirements.txtdatasets 폴더에 있는 script로 데이터셋을 생성하고 Bucket에 복사합니다. 아래의 스크립트에서는 생성된 데이터셋을 버킷의 root에 복사한다고 가정했습니다. 데이터셋 생성방법은 여기를 확인하시기 바랍니다.
또한 다운받은 pre-trained 모델도 버킷에 저장하고 해당 디렉토리를 PRETRAINED_MODEL_DIR 변수에 assign합니다.
학습하고자 하는 task를 TASK 변수에 assign합니다.
아래 스크립트와 같이 TPU를 생성하고 모델을 학습합니다.
…Pre-trained 모델의 체크포인트뿐만 아니라 일부 Downstream tasks의 saved model도 공개했습니다.
Tensorflow saved 모델은 tensorflow와 tensorflow_text가 설치되어 있으면 바로 사용하실 수 있습니다.
아래 예는 python에서 saved model을 사용하는 방법이며, ke_t5_nikl_summary_mixture_equal task를 다운받았다고 가정하고 있습니다.
ke_t5_nikl_summary_mixture_equal task는 ke_t5_nikl_summarization_summary와 ke_t5_nikl_summarization_topic의 mixture tasks이며, 각각 summarize_topic과 summarize_summary로 입력 텍스트가 시작합니다.
ke_t5_nikl_summarization_summary은 사람이 요약한 데이터를 이용하여 학습하며, ke_t5_nikl_summarization_topic은 topic sentences를 생성하도록 학습됩니다.
…데이터셋은 한국어의 경우 센터에서 확보하고 있는 비정형 코퍼스 중 Manual Cleaning을 여러번 진행한 데이터셋과 NIKL 데이터셋(국립 국어원 모두의 말뭉치)의 비정형 코퍼스 일부를 사용하였습니다. 영어의 경우 RealNews 데이터셋을 사용하였습니다. 데이터셋 구성은 아래와 같습니다.
keDataset size: 92.02GiB
Corpus type: ko (Newspaper, Written, Web text, Messenger, Spoken) en (Newspaper)
Split
'train': total 39,344,633 examples (ko: 25,544,795, en: 13,799,838)
'validation': total 39,283 examples (ko: 25,420, en: 13,863)
ke.newslikeDataset size: 81.74 GiB
Corpus type: ko (Newspaper) en (Newspaper)
Split
'train': total 36,534,568 examples (ko: 22,735,237, en: 13,799,838)
'validation': total 36,452 examples (ko: 22,619, en: 13,863)
koDataset size: 57.77 GiB
Corpus type: ko (Newspaper, Written, Web text, Messenger, Spoken)
Split
'train': total 25,545,302 examples
'validation': total 25,450 examples
ko.newslikeDataset size: 47.49 GiB
Corpus type: ko (Newspaper)
Split
'train': total 22,735,237 examples
'validation': total 22,619 examples
HuggingFace 모델 허브에 모델이 추가되어 사용이 가능합니다.
Huggingface TFT5ForConditionalGeneration, T5ForConditionalGeneration를 사용하실 경우 아래 코드와 같이 사용하시면 됩니다.
from transformers import T5Tokenizer, T5ForConditionalGeneration
model_name = 'KETI-AIR/ke-t5-base'
tokenizer = T5Tokenizer.from_pretrained(model_name)
model = T5ForConditionalGeneration.from_pretrained(model_name) Dataset
Size
steps
Download URL(Tensorflow)
Huggingface Transformers
ke
small
5.5M
Download
KETI-AIR/ke-t5-small
base
2.2M
Download
KETI-AIR/ke-t5-base
large
1.7M
Download
KETI-AIR/ke-t5-large
ke.newslike
small
5.4M
Download
KETI-AIR/ke-t5-small-newslike
base
2.2M
Download
KETI-AIR/ke-t5-base-newslike
large
1.7M
Download
KETI-AIR/ke-t5-large-newslike
ko
small
5.3M
Download
KETI-AIR/ke-t5-small-ko
base
2.3M
Download
KETI-AIR/ke-t5-base-ko
large
1M
Download
KETI-AIR/ke-t5-large-ko Dataset
Size
steps
ke_t5_nikl_summary_mixture_equal
ke_t5_ko_en_qa_equal
ke_t5_ko_translation_proportional
ke
small
1M
Download
Download
Download
base
600K
Download
Download
Download
large
600K
Download
Download
Download
ke.newslike
small
1M
Download
Download
Download
base
600K
Download
Download
Download
large
600K
Download
Download
Download
ko
small
1M
Download
Download
Download
base
600K
Download
Download
Download KE-T5에서 지원하는 모든 task들의 목록입니다.
| Task Name | Input Format | Output Format | Task Type | Language |
|---|---|---|---|---|
| ke_t5_kor_copora_nsmc | nsmc sentence:{sentence} |
negative or positive |
Classification | ko |
| ke_t5_kor_copora_qpair | qpair question1: {question1} question2: {question2} |
duplicated or not_duplicate |
Classification | ko |
| ke_t5_kor_copora_kornli | kornli premise: {premise} hypothesis: {hypothesis} |
entailment or neutral or contradiction |
Classification | ko |
| ke_t5_kor_copora_korsts | korsts sentence1: {sentence1} sentence2: {sentence2} |
{score} e.g. 1.4 |
Predict similarity score | ko |
| ke_t5_kor_copora_khsd | khsd sentence: {sentence} |
hate or offensive or none |
Classification | ko |
| ke_t5_nikl_cola | niklcola sentence: {sentence} |
unacceptable or acceptable |
Classification | ko |
| ke_t5_korquad_allanswers | question: {question} context: {article} |
{answer} |
Extractive QA | ko |
| ke_t5_nikl_summarization | summarize: {text} |
{summary} |
Summarization | ko |
| ke_t5_nikl_summarization_summary | summarize_summary: {text} |
{summary} |
Summarization | ko |
| ke_t5_nikl_summarization_topic | summarize_topic: {text} |
{summary} |
Select topic sentences | ko |
| klue_tc_gen | klue_tc title: {text} |
{topic} |
Select topic | ko |
| klue_nli_gen | klue_nli premise: {premise} hypothesis: {hypothesis} |
entailment or neutral or contradiction |
Classification | ko |
| klue_sts_gen | klue_sts sentence1: {sentence1} sentence2: {sentence2} |
{score} e.g. 1.4 |
Predict similarity score | ko |
| klue_re_gen | klue_re text: ~~~*{subject}*~~~#{object}#~~ |
{relation} |
Select relation | ko |
| klue_mrc_gen | klue_mrc question: {question} context: {article} |
{answer} |
Extractive QA | ko |
ke_t5_glue_cola_v002
inputs
cola sentence: That picture of Susan offended her.targets
"unacceptable", "acceptable"ke_t5_glue_sst2_v002
inputs
sst2 sentence: a valueless kiddie paean to pro basketball underwritten by the nba.targets
"negative", "positive"ke_t5_glue_mrpc_v002
inputs
mrpc sentence1: The show's closure affected third-quarter earnings per share by a penny. sentence2: The company said this impacted earnings by a penny a share.targets
"not_equivalent", "equivalent"ke_t5_glue_qqp_v002
inputs
qqp question1: Who is going to be a better president - Hillary Clinton or Donald Trump? question2: In what aspects is Hillary Clinton better than Trump?targets
"not_duplicate", "duplicate"ke_t5_glue_stsb_v002
inputs
stsb sentence1: For what it's worth, dirt on the lens might not be as detrimental as you would think. sentence2: Regular dish washing fluid is great for removing grease, as it not only dissolves it but also binds it.targets
0.4ke_t5_glue_mnli_v002
inputs
mnli hypothesis: The other villages and settlements are not as developed. premise: Other villages are much less developed, and therein lies the essence of many delights.targets
"entailment", "neutral", "contradiction"ke_t5_glue_mnli_mismatched_v002
inputs
mnli hypothesis: SEND has renovated dozens of homes to sell at affordable prices. premise: In the past eight years SEND has renovated over 70 homes for affordable resale to families, created more than 100 high quality apartments, assisted 20 businesses to expand or improve their facilities, created three new parks, and taught more than 200 youth work ethics and skills.targets
"entailment", "neutral", "contradiction"ke_t5_glue_mnli_matched_v002
inputs
mnli hypothesis: The other villages and settlements are not as developed. premise: Other villages are much less developed, and therein lies the essence of many delights.targets
"entailment", "neutral", "contradiction"ke_t5_glue_qnli_v002
inputs
qnli question: When were the finalists announced? sentence: The South Florida/Miami area has previously hosted the event 10 times (tied for most with New Orleans), with the most recent one being Super Bowl XLIV in 2010.targets
"entailment", "not_entailment"ke_t5_glue_rte_v002
inputs
…targets
"entailment", "not_entailment"ke_t5_glue_ax_v002
inputs
mnli hypothesis: {hypothesis} premise: {premise}targets
"entailment", "neutral", "contradiction"ke_t5_glue_wnli_v002_simple_eval
pre-processor description (t5)
A typical example from WNLI might look like:
{
'sentence1': 'The fish ate the worm. It was tasty.',
'sentence2': 'The worm was tasty.',
'label': 1,
}
This will be transformed to:
{
'inputs': 'wsc: The fish ate the worm. *I暂无开放 Issues,或尚未同步最近议题。