|
--- |
|
license: other |
|
language: |
|
- ko |
|
- en |
|
- ja |
|
- zh |
|
pipeline_tag: fill-mask |
|
--- |
|
# Model Card for GBST-KEByT5-large (1.23B #params) |
|
|
|
<!-- Provide a quick summary of what the model is/does. --> |
|
KEByT5: Korean-Enhanced/Enriched Byte-level Text-to-Text Transfer Transformer(T5)의 GBST 버전으로, |
|
CharFormer(Tay et al., 2021)를 기반으로 합니다. |
|
|
|
한국어를 위해 토큰 후보 구간을 (1, 2, 3, 6, 9) 바이트 단위로 청킹하여 후보군을 생성하고, GBST로 나온 소프트 임베딩 시퀀스를 1/3로 다운샘플링하여 학습 및 추론 효율성을 개선합니다. |
|
|
|
## Prerequirements / and Model Loading HOW-TO |
|
|
|
본 모델의 구동을 위해서는 GBSWT5 모듈이 필요합니다. |
|
|
|
https://github.com/etri-crossmodal/gbswt5 |
|
|
|
아래와 같이 pip를 통해 모듈을 설치 가능합니다. 모델 사용 방법은 github를 참조해주십시오. |
|
``` |
|
pip install git+https://github.com/etri-crossmodal/gbswt5.git |
|
``` |
|
|
|
또는, 최신 버전의 Transformers와 함께, 별도의 코드 없이 아래의 방법으로 모델 사용이 가능합니다: |
|
```python |
|
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("etri-lirs/gbst-kebyt5-large-preview") |
|
# 아래와 같이 trust_remote_code=True를 붙임으로, 자동으로 관련 코드를 다운로드 받고 쓸 수 있습니다 |
|
model = AutoModelForSeq2SeqLM.from_pretrained("etri-lirs/gbst-kebyt5-large-preview", trust_remote_code=True) |
|
``` |
|
|
|
또한, 다운스트림 태스크 학습 시, 아래의 python 코드와 같이, GBST layer를 frozen 하여 학습하는 것을 권장합니다. |
|
``` |
|
gbst_frozen_target = ['encoder.embed_tokens.embeds.weight', |
|
'encoder.embed_tokens.positional_convol.2.convol.weight', |
|
'encoder.embed_tokens.positional_convol.2.convol.bias', |
|
'encoder.embed_tokens.positional_convol.2.proj.weight', |
|
'encoder.embed_tokens.positional_convol.2.proj.bias', |
|
'encoder.embed_tokens.cand_scoring.0.weight', |
|
'encoder.embed_tokens.cand_scoring.0.bias', |
|
# embedding weight는 frozen 하지 않는 쪽이 일반적으로 더 나은 성능을 보임. |
|
#'shared.weight', |
|
] |
|
print("** GBST Model found, freeze GBSWT layer for training downstream.") |
|
for name, param in self.model.named_parameters(): |
|
if name in gbst_frozen_target: |
|
print(f"** freeze {name} layer.") |
|
param.requires_grad = False |
|
else: |
|
param.requires_grad = True |
|
``` |
|
|
|
|
|
참고로, 모델에 포함된 원격 코드에는 다음의 오픈소스 소프트웨어가 포함되어 있습니다: |
|
* This software includes lucidrains/charformer-pytorch GitHub project for GBST implementation, which distributed under MIT License. Copyright (c) 2021 Phil Wang. all rights reserved. (Original Code URL: https://github.com/lucidrains/charformer-pytorch) |
|
* This software includes HuggingFace transformers's T5 implementation for GBST-enabled T5 model, which distributed under Apache 2.0 License. Copyright 2018- The Huggingface team. All rights reserved. |
|
|
|
## KEByT5: Korean-Enhanced/Enriched Byte-level Text-to-Text Transfer Transformer(T5) |
|
|
|
크로스모달 및 다국어 친화적인 한국어 중심의 토큰-프리 언어 이해 생성 모델 |
|
(EN=Cross-modal, Multilingual Friendly, Token-free Encoder-Decoder Pretrained Language Model for Korean) |
|
|
|
* 본 사전학습 언어모델은 시각, 청각과 같은 텍스트 이외의 모달리티와 교차언어 지식 교환에 용이한 토큰-프리 사전학습 언어모델을 목표로 합니다. |
|
* 별도의 tokenizer가 필요없지만, 편의를 위해 AutoTokenizer.from_pretrained()를 사용하여 다른 토크나이저 기반 인코더-디코더 모델과 동일하게 처리할 수 있습니다. 토크나이저를 생략하고 싶은 경우, UTF-8 입력을 바이트 단위로 쪼개어, 각 바이트에 +3을 하여 Token ID를 생성합니다. (즉, ASCII value 0 == Token ID 3, ASCII value 255 == Token ID 258) |
|
* 현재 Preview 스테이지에 있는 모델이며, 활용에는 fine-tuning이 필요합니다. |
|
* 그래디언트 기반 서브워드 토큰화 [(Gradient-based Subword Tokenization; CharFormer; Tay et al., 2021;)](https://arxiv.org/abs/2106.12672)를 적용한 본 모델은, KLUE-MRC에서 같은 규모의 KEByT5-base 모델 대비 학습에서 2.7배, 추론에서 1.46배 이상의 학습 속도가 개선되었습니다. 일부 학습/추론 성능에 비교 가능한 차이가 있을 수 있습니다. 상세한 내용은 하위 평가 지표를 참고하십시오. |
|
|
|
## Acknowledgements |
|
* 본 사전학습 언어모델은 2022년도 정부(과학기술정보통신부)의 재원으로 정보통신기획평가원의 지원을 받아 수행된 연구임 (No. RS-2022-00187238, 효율적 사전학습이 가능한 한국어 대형 언어모델 사전학습 기술 개발) |
|
(EN=This pretrained language model was supported by the Institute of Information & communication Technology Planning & Evaluation(IITP) grant funded by the Korea government(MSIT) (No. RS-2022-00187238, Development of Large Korean Language Model Technology for Efficient Pre-training)) |
|
|
|
# Model Details |
|
|
|
본 사전학습 언어모델은 다음과 같은 규모를 가집니다: |
|
* kebyt5-small : 330M [link](https://huggingface.co/etri-lirs/kebyt5-small-preview) |
|
* kebyt5-base : 580M [link](https://huggingface.co/etri-lirs/kebyt5-base-preview) |
|
* kebyt5-large : 1.23B [link](https://huggingface.co/etri-lirs/kebyt5-large-preview) |
|
* GBST-kebyt5-base : 584M [link](https://huggingface.co/etri-lirs/gbst-kebyt5-base-preview) |
|
* GBST-kebyt5-large : 1.23B (this model) |
|
|
|
이들 모델은 [google/byt5-small](https://huggingface.co/google/byt5-small), [google/byt5-base](https://huggingface.co/google/byt5-base), [google/byt5-large](https://huggingface.co/google/byt5-large) 모델과 동일한 신경망 구조와 크기를 가지며, 토크나이저(ByT5Tokenizer)와 구현 상 두 모델은 별도의 수정없이 바로 교환하여 사용할 수 있습니다. |
|
huggingface transformers에서의 사용법 역시, T5ForConditionalGeneration을 동일하게 사용할 수 있습니다. |
|
|
|
## Model Description |
|
|
|
<!-- Provide a longer summary of what this model is. --> |
|
|
|
- **Developed by:** Language Intelligence Research Section, Electronics and Telecommunications Research Institute(ETRI) |
|
- **Model type:** Encoder-Decoder Transformer, specifically, ByT5. |
|
- **Language(s) (NLP):** Korean, English(partially for translation task), Chinese(partially for translation task), Japanese(partially for translation task). |
|
- **License:** Apache 2.0 License |
|
- **Finetuned from model:** kebyt5-small/-base/-xl model weights were initialized by google/byt5-* for Warm-start pretraining. |
|
|
|
## Model Sources |
|
|
|
- **Repository:** 다운스트림 태스크 학습을 위해, https://github.com/etri-crossmodal/llm-downstream-s2s |
|
- **Paper:** 신종훈 외, "한국어 중심의 토큰-프리 언어 이해-생성 모델 사전학습 연구", 제35회 한글 및 한국어 정보처리 학술대회 논문집, pp.711-715. 2023. |
|
(EN=Shin et al., "Towards Korean-Centric Token-free Pretrained Language Model", in Procs. of the 35th Annual Conference on Human and Cognitive Language Technology. pp. 711-715. 2023.) |
|
|
|
# Uses |
|
|
|
해당 사전학습 언어모델은 연구 및 교육 목적의 활용으로 그 사용 목적이 제한됩니다. |
|
|
|
## Direct Use |
|
|
|
현재 공개되는 모델은 T5 모델 학습에 사용된 Corrupted span denoising 만으로 학습되어 있어, 실제 응용 태스크에 적용하기 위해서는 fine-tuning 과정이 필요합니다. |
|
|
|
Sentinel Token(token id 258, 257, 256, ...)을 사용하여 Masked Token Prediction을 수행할 수 있으나, 예측된 내용에는 부적절한 내용이 있을 수 있습니다. |
|
|
|
## Downstream Use [optional] |
|
|
|
Token-free 모델의 특성 상, 복잡하거나 Noisy한 입력에 강건하며, 짧은 시퀀스 길이의 생성에 적합합니다. (예: 언어 이해, 대화 응답 생성) |
|
|
|
사전학습은 1024 bytes 길이의 데이터를 학습했기 때문에, 이를 초과하는 긴 시퀀스를 다루는 문제에 적합하지 않을 수 있습니다. |
|
|
|
더 긴 시퀀스를 다뤄야 하는 문제에서는, [GBST 기반의 토큰-프리 언어모델](https://huggingface.co/etri-lirs/gbst-kebyt5-base-preview)을 사용하는 것을 권장합니다. |
|
|
|
# Bias, Risks, Limitations, and Recommendations |
|
|
|
Masked Token Prediction을 통해 획득될 수 있는 정보에는 다른 생성형 언어모델과 같은 위험을 가지고 있을 수 있습니다. 학습에 사용된 데이터는 욕설, 음란, 정치적 내용 및 기타 거친 언어들에 대한 별도의 처리가 이루어지지 않았습니다. 따라서, 사회적으로 용인되지 않은 토큰이나 텍스트를 생성할 수 있으며, 주변 문맥에 따라서 공격적인 입력에 어떠한 결과를 생성할 수 있을지 쉽게 예상할 수 없습니다. |
|
|
|
한편, 본 언어모델은 주로 한국어 텍스트로 학습되었으며, 이들의 특성을 전이할 수 있는 다운스트림 태스크, 그 중에서도 분류, 요약, 짧은 문장 생성에 적합할 수 있습니다. 입출력 수준에서 미등록어(Out-of-Vocabulary)가 존재할 수 없으나, 사전학습되지 않은 텍스트 시퀀스에 대해서는 추가의 도메인 적응 학습 및 다운스트림 태스크의 미세조정이 필요합니다. |
|
|
|
[More Information Needed] |
|
|
|
## How to Get Started with the Model |
|
Transformers 4.27.0 이상의 버전에서, 다음의 파이썬 코드를 사용하여 모델과 tokenizer를 사용할 수 있습니다. 상기에 언급된 바와 같이, transformer 모듈 로드 전 gbswt5 모듈을 import 해야 합니다: |
|
|
|
``` |
|
import gbswt5 |
|
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("etri-lirs/gbst-kebyt5-base-preview") |
|
model = AutoModelForSeq2SeqLM.from_pretrained("etri-lirs/gbst-kebyt5-base-preview") |
|
``` |
|
|
|
# Training Details |
|
|
|
## Training Data |
|
본 사전학습에는 아래의 공개 데이터가 사용되었습니다: |
|
|
|
* 국립국어원, 모두의 말뭉치. 신문 v2.0 |
|
* 국립국어원, 모두의 말뭉치. 구어 말뭉치 v1.2 |
|
* 국립국어원, 모두의 말뭉치. 문어 말뭉치 v1.0 |
|
* 국립국어원, 모두의 말뭉치. 신문 2020 v1.0 |
|
* 국립국어원, 모두의 말뭉치. 신문 2021 v1.0 |
|
* 한국어 위키피디어 덤프, [v2020.09.20](https://github.com/lovit/kowikitext) |
|
* [나무위키 덤프](https://github.com/lovit/namuwikitext) |
|
* 한국정보화진흥원, AIHub. 전문분야 말뭉치, 법률/특허 지식베이스, 논문/도서/대화/대본 요약, 한영/한일/한중 번역 말뭉치, 콜센터/주문/뉴스기사/시각정보 질의응답, 방송/회의/상담 음성인식 데이터. |
|
* 한국정보화진흥원, AIHub. 대규모 웹데이터 기반 한국어 말뭉치 데이터 |
|
* 한국정보화진흥원, AIHub. 온라인 구어체 말뭉치 데이터. |
|
* [KcBERT 말뭉치, v2022.3Q](https://github.com/Beomi/KcBERT) |
|
|
|
또한, 소량의 자체 구축된 데이터 및 합성 데이터 일부를 사용, 전체 약 ~220GB 가량의 데이터로 학습되었습니다. |
|
|
|
# Evaluation |
|
|
|
## Testing Data, Factors & Metrics & Results |
|
|
|
한국어 언어 이해 태스크에 사용되는 [KLUE dataset, v1.1](https://klue-benchmark.com/)의 dev set을 사용하여 평가되었습니다. |
|
생성은 모두 seq2seq을 이용한 출력 레이블 직접 생성 방법을 사용했습니다. |
|
|
|
모든 모델의 학습 조건은 유효배치 크기 16, 학습 epoch 4로 고정, 파라미터 크기에 따라 고정된 학습률, Cosine-Annealing LR Scheduler (min lr=1e-7, restarts=4, gamma=0.7)을 사용하여 학습 되었습니다. 상세 테스트 환경은 신종훈 외, 2023에 기록된 것과 같습니다. |
|
상기 학술논문 이후에 출시된 본 모델(GBST-KEByT5-Large)의 다운스트림 태스크 학습 조건은 태스크 별로 가변적인 학습률(LR 6.2e-5~4.6e-5) 사이의 값을 사용하여 학습하였고, 나머지 조건은 동일하게 설정하였습니다. |
|
|
|
하기 미세조정 실험을 위해 사용된 학습기를 함께 공개하였습니다. 해당 학습기는 다른 huggingface encoder-decoder 모델(BART 등)의 학습도 함께 사용할 수 있습니다. https://github.com/etri-crossmodal/llm-downstream-s2s |
|
|
|
| models | KLUE-TC(YNAT) (F1) | KLUE-NER (Entity, Char F1) | KLUE-DP (UAS, LAS) | KLUE-MRC (EM, ROUGE-W) | |
|
|-------------|---------------|--------------|-------------------|------------------| |
|
| google/byt5-large (1.23B) | 78.52 | 48.81, 63.95 | 44.26, 7.805 | _NOT TESTED_ | |
|
| KEByT5-Base (580M) | 84.99 | 86.75, 91.05 | 88.70, 85.90 | 62.28, 68.38 | |
|
| GBST-KEByT5-Base (584M) | 85.29 | 87.35, 92.09 | 88.33, 85.00 | 59.69, 66.44 | |
|
| KEByT5-Large (1.23B) | 85.68 | 88.09, 92.40 | 87.18, 85.52 | 70.07, 75.81 | |
|
| GBST-KEByT5-Large (1.23B) | 85.72(LR 4e-5) | 87.22, 91.54(LR 4.6e-5) | -, - | 68.6, 74.33 (LR 6.2e-5) | |
|
|
|
대화 상태 추적(DST; Dialogue State Tracking) 태스크인 KLUE-WOS-v1.1 결과는 다음과 같습니다. 평가는 모두 seq2seq을 이용한 다이얼로그 상태 직접 생성을 사용했습니다: |
|
| models | WOS (JGA, %) | WOS (F1, %) | |
|
| ------- | ---------- | ----------- | |
|
| klue/klue-roberta-large | 50.22 | 92.23 | |
|
| KEByT5-Base (580M) | 77.15 | 96.92 | |
|
| GBST-KEByt5-base (584M) | 75.94 | 96.73 | |
|
| KEByT5-Large (1.23B) | 78.54 | 97.28 | |
|
| GBST-KEByT5-Large (1.23B) | -(not tested yet) | - | |
|
|
|
관계 추출(RE; Relation Extraction) 태스크인 KLUE-RE-v1.1 결과는 다음과 같습니다. no_relation을 제외한 29개의 관계 클래스에 대한 Micro F1 결과입니다: |
|
| models | KLUE-RE (F1, %) | |
|
| ------- | ---------- | |
|
| klue/klue-roberta-base | 65.90 | |
|
| KEByT5-Base (580M) | 65.48 | |
|
| KEByT5-Large (1.23B) | 68.95 | |
|
| GBST-KEByT5-Large (1.23B) | -(not tested yet) | |
|
|
|
GBST 적용을 통한 효율화 개선은 다음과 같이 평가되었습니다. 평가 환경은 A100 PCIE 80GB가 사용되었으며, 정밀도는 bfloat16에서 측정되었습니다. |
|
학습 및 평가에는 KLUE-MRC 데이터셋이 사용되었습니다. 이들 데이터셋의 길이는 최대 6800 bytes의 문맥이 들어갑니다. |
|
|
|
| model | training sample/sec. | inference sample/sec. | |
|
| ----- | -------------------- | --------------------- | |
|
| KEByT5-base (580M) | 1.30 | 3.95 | |
|
| GBST-KEByT5-base (584M) | 3.56 | 5.77 | |
|
| GBST-KEByT5-Large (1.23B) | 2.02 | not tested | |
|
|
|
## Compute Infrastructure |
|
|
|
* Trained on nVidia A100 80GB * 8EA |
|
|
|
# Citations |
|
|
|
* 신종훈 외, "한국어 중심의 토큰-프리 언어 이해-생성 모델 사전학습 연구", 제35회 한글 및 한국어 정보처리 학술대회 논문집, pp.711-715. 2023. |
|
* 허정 외, "생성형 언어모델을 이용한 관계 추출", 제35회 한글 및 한국어 정보처리 학술대회 논문집. pp.708-710. 2023. |
|
* 이기영 외, "한국어 토큰-프리 사전학습 언어모델 KeByT5를 이용한 한국어 생성 기반 대화 상태 추적", 제35회 한글 및 한국어 정보처리 학술대회 논문집. pp.644-647. 2023. |
|
|
|
# Model Card Authors/Contacts |
|
|
|
Jong-hun Shin(ETRI), e-mail=jhshin82 _AT_ etri _DOT_ re _DOT_ kr. |
|
|
|
|
|
|