dalgarak commited on
Commit
5f4fa37
·
verified ·
1 Parent(s): 51adcf4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +221 -3
README.md CHANGED
@@ -1,3 +1,221 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ language:
4
+ - ko
5
+ - en
6
+ - ja
7
+ - zh
8
+ pipeline_tag: fill-mask
9
+ ---
10
+ # Model Card for faster-GBST-KEByT5-base (584M #params)
11
+
12
+ <!-- Provide a quick summary of what the model is/does. -->
13
+ KEByT5: Korean-Enhanced/Enriched Byte-level Text-to-Text Transfer Transformer(T5)의 GBST 버전으로,
14
+ CharFormer(Tay et al., 2021)를 기반으로 합니다.
15
+
16
+ 한국어를 위해 토큰 후보 구간을 1∼9 바이트 단위로 청킹하여 후보군을 생성하고, GBST로 나온 소프트 임베딩 시퀀스를 1/6로 다운샘플링하여, 서브워드 기반 모델(한국어 평균 2.3∼2.7 토큰, 3만 단어)을 넘어서는 속도/성능 목표를 갖는 토큰-프리 언어모델을 지향합니다.
17
+
18
+ ## Prerequirements / and Model Loading HOW-TO
19
+
20
+ 본 모델의 구동을 위해서는 GBSWT5 모듈이 필요합니다. 모델에 포함되어 있는 코드를 from_pretrained() 메서드 호출 인자로 trust_remote_code=True를 추가해, 별도 모듈 없이 사용 가능합니다.
21
+
22
+ https://github.com/etri-crossmodal/gbswt5
23
+
24
+ 아래와 같이 pip를 통해 모듈을 설치 가능합니다. 모델 사용 방법은 github를 참조해주십시오.
25
+ ```
26
+ pip install git+https://github.com/etri-crossmodal/gbswt5.git
27
+ ```
28
+
29
+ 또는, 최신 버전의 Transformers와 함께, 별도의 코드 없이 아래의 방법으로 모델 사용이 가능합니다:
30
+ ```python
31
+ from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
32
+
33
+ tokenizer = AutoTokenizer.from_pretrained("etri-lirs/faster-gbst-kebyt5-base")
34
+ # 아래와 같이 trust_remote_code=True를 붙임으로, 자동으로 관련 코드를 다운로드 받고 쓸 수 있습니다
35
+ model = AutoModelForSeq2SeqLM.from_pretrained("etri-lirs/faster-gbst-kebyt5-base", trust_remote_code=True)
36
+ ```
37
+
38
+ 또한, 다운스트림 태스크 학습 시, 아래의 python 코드와 같이, GBST layer를 frozen 하여 학습하는 것을 권장합니다.
39
+ ```
40
+ gbst_frozen_target = ['encoder.embed_tokens.embeds.weight',
41
+ 'encoder.embed_tokens.positional_convol.2.convol.weight',
42
+ 'encoder.embed_tokens.positional_convol.2.convol.bias',
43
+ 'encoder.embed_tokens.positional_convol.2.proj.weight',
44
+ 'encoder.embed_tokens.positional_convol.2.proj.bias',
45
+ 'encoder.embed_tokens.cand_scoring.0.weight',
46
+ 'encoder.embed_tokens.cand_scoring.0.bias',
47
+ # embedding weight는 frozen 하지 않는 쪽이 일반적으로 더 나은 성능을 보임.
48
+ #'shared.weight',
49
+ ]
50
+ print("** GBST Model found, freeze GBSWT layer for training downstream.")
51
+ for name, param in self.model.named_parameters():
52
+ if name in gbst_frozen_target:
53
+ print(f"** freeze {name} layer.")
54
+ param.requires_grad = False
55
+ else:
56
+ param.requires_grad = True
57
+ ```
58
+
59
+
60
+ 참고로, 모델에 포함된 원격 코드에는 다음의 오픈소스 소프트웨어가 포함되어 있습니다:
61
+ * 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)
62
+ * 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.
63
+
64
+ ## KEByT5: Korean-Enhanced/Enriched Byte-level Text-to-Text Transfer Transformer(T5)
65
+
66
+ 크로스모달 및 다국어 친화적인 한국어 중심의 토큰-프리 언어 이해 생성 모델
67
+ (EN=Cross-modal, Multilingual Friendly, Token-free Encoder-Decoder Pretrained Language Model for Korean)
68
+
69
+ * 본 사전학습 언어모델은 시각, 청각과 같은 텍스트 이외의 모달리티와 교차언어 지식 교환에 용이한 토큰-프리 사전학습 언어모델을 목표로 합니다.
70
+ * 별도의 tokenizer가 필요없지만, 편의를 위해 AutoTokenizer.from_pretrained()를 사용하여 다른 토크나이저 기반 인코더-디코더 모델과 동일하게 처리할 수 있습니다. 토크나이저를 생략하고 싶은 경우, UTF-8 입력을 바이트 단위로 쪼개어, 각 바이트에 +3을 하여 Token ID를 생성합니다. (즉, ASCII value 0 == Token ID 3, ASCII value 255 == Token ID 258)
71
+ * 현재 Preview 스테이지에 있는 모델이며, 활용에는 fine-tuning이 필요합니다.
72
+ * 그래디언트 기반 서브워드 토큰화 [(Gradient-based Subword Tokenization; CharFormer; Tay et al., 2021;)](https://arxiv.org/abs/2106.12672)를 적용한 본 모델은, KLUE-MRC에서 같은 규모의 KEByT5-base 모델 대비 학습에서 2.7배, 추론에서 1.46배 이상의 학습 속도가 개선되었습니다. 일부 학습/추론 성능에 비교 가능한 차이가 있을 수 있습니다. 상세한 내용은 하위 평가 지표를 참고하십시오.
73
+
74
+ ## Acknowledgements
75
+ * 본 사전학습 언어모델은 2022년도 정부(과학기술정보통신부)의 재원으로 정보통신기획평가원의 지원을 받아 수행된 연구임 (No. RS-2022-00187238, 효율적 사전학습이 가능한 한국어 대형 언어모델 사전학습 기술 개발)
76
+ (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))
77
+
78
+ # Model Details
79
+
80
+ 본 사전학습 언어모델은 다음과 같은 규모를 가집니다:
81
+ * kebyt5-small : 330M [link](https://huggingface.co/etri-lirs/kebyt5-small-preview)
82
+ * kebyt5-base : 580M [link](https://huggingface.co/etri-lirs/kebyt5-base-preview)
83
+ * kebyt5-large : 1.23B [link](https://huggingface.co/etri-lirs/kebyt5-large-preview)
84
+ * GBST-kebyt5-base : 584M [link](https://huggingface.co/etri-lirs/gbst-kebyt5-base-preview)
85
+ * faster-GBST-kebyt5-base : 584M (this model)
86
+ * GBST-kebyt5-large : 1.23B [link](https://huggingface.co/etri-lirs/gbst-kebyt5-large-preview)
87
+
88
+ 이들 모델은 [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)와 구현 상 두 모델은 별도의 수정없이 바로 교환하여 사용할 수 있습니다.
89
+ huggingface transformers에서의 사용법 역시, T5ForConditionalGeneration을 동일하게 사용할 수 있습니다.
90
+
91
+ ## Model Description
92
+
93
+ <!-- Provide a longer summary of what this model is. -->
94
+
95
+ - **Developed by:** Language Intelligence Research Section, Electronics and Telecommunications Research Institute(ETRI)
96
+ - **Model type:** Encoder-Decoder Transformer, specifically, ByT5.
97
+ - **Language(s) (NLP):** Korean, English(partially for translation task), Chinese(partially for translation task), Japanese(partially for translation task).
98
+ - **License:** Apache 2.0 License
99
+ - **Finetuned from model:** kebyt5-small/-base/-xl model weights were initialized by google/byt5-* for Warm-start pretraining.
100
+
101
+ ## Model Sources
102
+
103
+ - **Repository:** 다운스트림 태스크 학습을 위해, https://github.com/etri-crossmodal/llm-downstream-s2s
104
+ - **Paper:** 신종훈 외, "한국어 중심의 토큰-프리 언어 이해-생성 모델 사전학습 연구", 제35회 한글 및 한국어 정보처리 학술대회 논문집, pp.711-715. 2023.
105
+ (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.)
106
+
107
+ # Uses
108
+
109
+ 해당 사전학습 언어모델은 연구 및 교육 목적의 활용으로 그 사용 목적이 제한됩니다.
110
+
111
+ ## Direct Use
112
+
113
+ 현재 공개되는 모델은 T5 모델 학습에 사용된 Corrupted span denoising 만으로 학습되어 있어, 실제 응용 태스크에 적용하기 위해서는 fine-tuning 과정이 필요합니다.
114
+
115
+ Sentinel Token(token id 258, 257, 256, ...)을 사용하여 Masked Token Prediction을 수행할 수 있으나, 예측된 내용에는 부적절한 내용이 있을 수 있습니다.
116
+
117
+ ## Downstream Use [optional]
118
+
119
+ Token-free 모델의 특성 상, 복잡하거나 Noisy한 입력에 강건하며, 짧은 시퀀스 길이의 생성에 적합합니다. (예: 언어 이해, 대화 응답 생성)
120
+
121
+ # Bias, Risks, Limitations, and Recommendations
122
+
123
+ Masked Token Prediction을 통해 획득될 수 있는 정보에는 다른 생성형 언어모델과 같은 위험을 가지고 있을 수 있습니다. 학습에 사용된 데이터는 욕설, 음란, 정치적 내용 및 기타 거친 언어들에 대한 별도의 처리가 이루어지지 않았습니다. 따라서, 사회적으로 용인되지 않은 토큰이나 텍스트를 생성할 수 있으며, 주변 문맥에 따라서 공격적인 입력에 어떠한 결과를 생성할 수 있을지 쉽게 예상할 수 없습니다.
124
+
125
+ 한편, 본 언어모델은 주로 한국어 텍스트로 학습되었으며, 이들의 특성을 전이할 수 있는 다운스트림 태스크, 그 중에서도 분류, 요약, 짧은 문장 생성에 적합할 수 있습니다. 입출력 수준에서 미등록어(Out-of-Vocabulary)가 존재할 수 없으나, 사전학습되지 않은 텍스트 시퀀스에 대해서는 추가의 도메인 적응 학습 및 다운스트림 태스크의 미세조정이 필요합니다.
126
+
127
+ [More Information Needed]
128
+
129
+ ## How to Get Started with the Model
130
+ Transformers 4.27.0 이상의 버전에서, 다음의 파이썬 코드를 사용하여 모델과 tokenizer를 사용할 수 있습니다. 상기에 언급된 바와 같이, transformer 모듈 로드 전 gbswt5 모듈을 import 해야 합니다:
131
+
132
+ ```
133
+ import gbswt5
134
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
135
+
136
+ tokenizer = AutoTokenizer.from_pretrained("etri-lirs/faster-gbst-kebyt5-base")
137
+ model = AutoModelForSeq2SeqLM.from_pretrained("etri-lirs/faster-gbst-kebyt5-base")
138
+ ```
139
+
140
+ # Training Details
141
+
142
+ ## Training Data
143
+ 본 사전학습에는 아래의 공개 데이터가 사용되었습니다:
144
+
145
+ * 국립국어원, 모두의 말뭉치. 신문 v2.0
146
+ * 국립국어원, 모두의 말뭉치. 구어 말뭉치 v1.2
147
+ * 국립국어원, 모두의 말뭉치. 문어 말뭉치 v1.0
148
+ * 국립국어원, 모두의 말뭉치. 신문 2020 v1.0
149
+ * 국립국어원, 모두의 말뭉치. 신문 2021 v1.0
150
+ * 한국어 위키피디어 덤프, [v2020.09.20](https://github.com/lovit/kowikitext)
151
+ * [나무위키 덤프](https://github.com/lovit/namuwikitext)
152
+ * 한국정보화진흥원, AIHub. 전문분야 말뭉치, 법률/특허 지식베이스, 논문/도서/대화/대본 요약, 한영/한일/한중 번역 말뭉치, 콜센터/주문/뉴스기사/시각정보 질의응답, 방송/회의/상담 음성인식 데이터.
153
+ * 한국정보화진흥원, AIHub. 대규모 웹데이터 기반 한국어 말뭉치 데이터
154
+ * 한국정보화진흥원, AIHub. 온라인 구어체 말뭉치 데이터.
155
+ * [KcBERT 말뭉치, v2022.3Q](https://github.com/Beomi/KcBERT)
156
+
157
+ 또한, 소량의 자체 구축된 데이터 및 합성 데이터 일부를 사용, 전체 약 ~220GB 가량의 데이터로 학습되었습니다.
158
+
159
+ # Evaluation
160
+
161
+ ## Testing Data, Factors & Metrics & Results
162
+
163
+ 한국어 언어 이해 태스크에 사용되는 [KLUE dataset, v1.1](https://klue-benchmark.com/)의 dev set을 사용하여 평가되었습니다.
164
+ 생성은 모두 seq2seq을 이용한 출력 레이블 직접 생성 방법을 사용했습니다.
165
+
166
+ 모든 모델의 학습 조건은 유효배치 크기 16, 학습 epoch 4로 고정, 파라미터 크기에 따라 고정된 학습률, Cosine-Annealing LR Scheduler (min lr=1e-7, restarts=4, gamma=0.7)을 사용하여 학습 되었습니다. 상세 테스트 환경은 신종훈 외, 2023에 기록된 것과 같습니다.
167
+ 상기 학술논문 이후에 출시된 본 모델(GBST-KEByT5-Large)의 다운스트림 태스크 학습 조건은 태스크 별로 가변적인 학습률(LR 6.2e-5~4.6e-5) 사이의 값을 사용하여 학습하였고, 나머지 조건은 동일하게 설정하였습니다.
168
+
169
+ 하기 미세조정 실험을 위해 사용된 학습기를 함께 공개하였습니다. 해당 학습기는 다른 huggingface encoder-decoder 모델(BART 등)의 학습도 함께 사용할 수 있습니다. https://github.com/etri-crossmodal/llm-downstream-s2s
170
+
171
+ | models | KLUE-TC(YNAT) (F1) | KLUE-NER (Entity, Char F1) | KLUE-DP (UAS, LAS) | KLUE-MRC (EM, ROUGE-W) |
172
+ |-------------|---------------|--------------|-------------------|------------------|
173
+ | google/byt5-large (1.23B) | 78.52 | 48.81, 63.95 | 44.26, 7.805 | _NOT TESTED_ |
174
+ | KEByT5-Base (580M) | 84.99 | 86.75, 91.05 | 88.70, 85.90 | 62.28, 68.38 |
175
+ | GBST-KEByT5-Base (584M) | 85.29 | 87.35, 92.09 | 88.33, 85.00 | 59.69, 66.44 |
176
+ | **faster-GBST-KEByT5-base (584M)** | - | - | - | 64.08, 70.75 (LR 8e-5)) |
177
+ | KEByT5-Large (1.23B) | 85.68 | 88.09, 92.40 | 87.18, 85.52 | 70.07, 75.81 |
178
+ | 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) |
179
+ | faster-GBST-KEByT5-Large (1.23B) | 85.48(LR 3e-5) | 87.35, 92.06(LR 3e-5) | 86.12, 83.34 (not final) | 69.21, 74.86 (LR 6.2e-5)) |
180
+
181
+ 대화 상태 추적(DST; Dialogue State Tracking) 태스크인 KLUE-WOS-v1.1 결과는 다음과 같습니다. 평가는 모두 seq2seq을 이용한 다이얼로그 상태 직접 생성을 사용했습니다:
182
+ | models | WOS (JGA, %) | WOS (F1, %) |
183
+ | ------- | ---------- | ----------- |
184
+ | klue/klue-roberta-large | 50.22 | 92.23 |
185
+ | KEByT5-Base (580M) | 77.15 | 96.92 |
186
+ | GBST-KEByt5-base (584M) | 75.94 | 96.73 |
187
+ | KEByT5-Large (1.23B) | 78.54 | 97.28 |
188
+ | GBST-KEByT5-Large (1.23B) | -(not tested yet) | - |
189
+
190
+ 관계 추출(RE; Relation Extraction) 태스크인 KLUE-RE-v1.1 결과는 다음과 같습니다. no_relation을 제외한 29개의 관계 클래스에 대한 Micro F1 결과입니다:
191
+ | models | KLUE-RE (F1, %) |
192
+ | ------- | ---------- |
193
+ | klue/klue-roberta-base | 65.90 |
194
+ | KEByT5-Base (580M) | 65.48 |
195
+ | KEByT5-Large (1.23B) | 68.95 |
196
+ | GBST-KEByT5-Large (1.23B) | -(not tested yet) |
197
+
198
+ GBST 적용을 통한 효율화 개선은 다음과 같이 평가되었습니다. 평가 환경은 A100 PCIE 80GB가 사용되었으며, 정밀도는 bfloat16에서 측정되었습니다.
199
+ 학습 및 평가에는 KLUE-MRC 데이터셋이 사용되었습니다. 이들 데이터셋의 길이는 최대 6800 bytes의 문맥이 들어갑니다.
200
+
201
+ | model | training sample/sec. | inference sample/sec. |
202
+ | ----- | -------------------- | --------------------- |
203
+ | KEByT5-base (580M) | 1.30 | 3.95 |
204
+ | GBST-KEByT5-base (584M) | 3.56 | 5.77 |
205
+ | GBST-KEByT5-Large (1.23B) | 2.02 | not tested |
206
+
207
+ ## Compute Infrastructure
208
+
209
+ * Trained on nVidia A100 80GB * 8EA
210
+
211
+ # Citations
212
+
213
+ * 신종훈 외, "한국어 중심의 토큰-프리 언어 이해-생성 모델 사전학습 연구", 제35회 한글 및 한국어 정보처리 학술대회 논문집, pp.711-715. 2023.
214
+ * 허정 외, "생성형 언어모델을 이용한 관계 추출", 제35회 한글 및 한국어 정보처리 학술대회 논문집. pp.708-710. 2023.
215
+ * 이기영 외, "한국어 토큰-프리 사전학습 언어모델 KeByT5를 이용한 한국어 생성 기반 대화 상태 추적", 제35회 한글 및 한국어 정보처리 학술대회 논문집. pp.644-647. 2023.
216
+
217
+ # Model Card Authors/Contacts
218
+
219
+ Jong-hun Shin(ETRI), e-mail=jhshin82 _AT_ etri _DOT_ re _DOT_ kr.
220
+
221
+