|
--- |
|
language: ko |
|
license: apache-2.0 |
|
tags: |
|
- korean |
|
--- |
|
|
|
# KcBERT: Korean comments BERT |
|
|
|
** Updates on 2021.04.07 ** |
|
|
|
- KcELECTRA๊ฐ ๋ฆด๋ฆฌ์ฆ ๋์์ต๋๋ค!๐ค |
|
- KcELECTRA๋ ๋ณด๋ค ๋ ๋ง์ ๋ฐ์ดํฐ์
, ๊ทธ๋ฆฌ๊ณ ๋ ํฐ General vocab์ ํตํด KcBERT ๋๋น **๋ชจ๋ ํ์คํฌ์์ ๋ ๋์ ์ฑ๋ฅ**์ ๋ณด์
๋๋ค. |
|
- ์๋ ๊นํ ๋งํฌ์์ ์ง์ ์ฌ์ฉํด๋ณด์ธ์! |
|
- https://github.com/Beomi/KcELECTRA |
|
|
|
** Updates on 2021.03.14 ** |
|
|
|
- KcBERT Paper ์ธ์ฉ ํ๊ธฐ๋ฅผ ์ถ๊ฐํ์์ต๋๋ค.(bibtex) |
|
- KcBERT-finetune Performance score๋ฅผ ๋ณธ๋ฌธ์ ์ถ๊ฐํ์์ต๋๋ค. |
|
|
|
** Updates on 2020.12.04 ** |
|
|
|
Huggingface Transformers๊ฐ v4.0.0์ผ๋ก ์
๋ฐ์ดํธ๋จ์ ๋ฐ๋ผ Tutorial์ ์ฝ๋๊ฐ ์ผ๋ถ ๋ณ๊ฒฝ๋์์ต๋๋ค. |
|
|
|
์
๋ฐ์ดํธ๋ KcBERT-Large NSMC Finetuning Colab: <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> |
|
|
|
** Updates on 2020.09.11 ** |
|
|
|
KcBERT๋ฅผ Google Colab์์ TPU๋ฅผ ํตํด ํ์ตํ ์ ์๋ ํํ ๋ฆฌ์ผ์ ์ ๊ณตํฉ๋๋ค! ์๋ ๋ฒํผ์ ๋๋ฌ๋ณด์ธ์. |
|
|
|
Colab์์ TPU๋ก KcBERT Pretrain ํด๋ณด๊ธฐ: <a href="https://colab.research.google.com/drive/1lYBYtaXqt9S733OXdXvrvC09ysKFN30W"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> |
|
|
|
ํ
์คํธ ๋ถ๋๋ง ์ ์ฒด 12G ํ
์คํธ ์ค ์ผ๋ถ(144MB)๋ก ์ค์ฌ ํ์ต์ ์งํํฉ๋๋ค. |
|
|
|
ํ๊ตญ์ด ๋ฐ์ดํฐ์
/์ฝํผ์ค๋ฅผ ์ข๋ ์ฝ๊ฒ ์ฌ์ฉํ ์ ์๋ [Korpora](https://github.com/ko-nlp/Korpora) ํจํค์ง๋ฅผ ์ฌ์ฉํฉ๋๋ค. |
|
|
|
** Updates on 2020.09.08 ** |
|
|
|
Github Release๋ฅผ ํตํด ํ์ต ๋ฐ์ดํฐ๋ฅผ ์
๋ก๋ํ์์ต๋๋ค. |
|
|
|
๋ค๋ง ํ ํ์ผ๋น 2GB ์ด๋ด์ ์ ์ฝ์ผ๋ก ์ธํด ๋ถํ ์์ถ๋์ด์์ต๋๋ค. |
|
|
|
์๋ ๋งํฌ๋ฅผ ํตํด ๋ฐ์์ฃผ์ธ์. (๊ฐ์
์์ด ๋ฐ์ ์ ์์ด์. ๋ถํ ์์ถ) |
|
|
|
๋ง์ฝ ํ ํ์ผ๋ก ๋ฐ๊ณ ์ถ์ผ์๊ฑฐ๋/Kaggle์์ ๋ฐ์ดํฐ๋ฅผ ์ดํด๋ณด๊ณ ์ถ์ผ์๋ค๋ฉด ์๋์ ์บ๊ธ ๋ฐ์ดํฐ์
์ ์ด์ฉํด์ฃผ์ธ์. |
|
|
|
- Github๋ฆด๋ฆฌ์ฆ: https://github.com/Beomi/KcBERT/releases/tag/TrainData_v1 |
|
|
|
** Updates on 2020.08.22 ** |
|
|
|
Pretrain Dataset ๊ณต๊ฐ |
|
|
|
- ์บ๊ธ: https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments (ํ ํ์ผ๋ก ๋ฐ์ ์ ์์ด์. ๋จ์ผํ์ผ) |
|
|
|
Kaggle์ ํ์ต์ ์ํด ์ ์ ํ(์๋ `clean`์ฒ๋ฆฌ๋ฅผ ๊ฑฐ์น) Dataset์ ๊ณต๊ฐํ์์ต๋๋ค! |
|
|
|
์ง์ ๋ค์ด๋ฐ์ผ์
์ ๋ค์ํ Task์ ํ์ต์ ์งํํด๋ณด์ธ์ :) |
|
|
|
--- |
|
|
|
๊ณต๊ฐ๋ ํ๊ตญ์ด BERT๋ ๋๋ถ๋ถ ํ๊ตญ์ด ์ํค, ๋ด์ค ๊ธฐ์ฌ, ์ฑ
๋ฑ ์ ์ ์ ๋ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ์ตํ ๋ชจ๋ธ์
๋๋ค. ํํธ, ์ค์ ๋ก NSMC์ ๊ฐ์ ๋๊ธํ ๋ฐ์ดํฐ์
์ ์ ์ ๋์ง ์์๊ณ ๊ตฌ์ด์ฒด ํน์ง์ ์ ์กฐ์ด๊ฐ ๋ง์ผ๋ฉฐ, ์คํ์ ๋ฑ ๊ณต์์ ์ธ ๊ธ์ฐ๊ธฐ์์ ๋ํ๋์ง ์๋ ํํ๋ค์ด ๋น๋ฒํ๊ฒ ๋ฑ์ฅํฉ๋๋ค. |
|
|
|
KcBERT๋ ์์ ๊ฐ์ ํน์ฑ์ ๋ฐ์ดํฐ์
์ ์ ์ฉํ๊ธฐ ์ํด, ๋ค์ด๋ฒ ๋ด์ค์์ ๋๊ธ๊ณผ ๋๋๊ธ์ ์์งํด, ํ ํฌ๋์ด์ ์ BERT๋ชจ๋ธ์ ์ฒ์๋ถํฐ ํ์ตํ Pretrained BERT ๋ชจ๋ธ์
๋๋ค. |
|
|
|
KcBERT๋ Huggingface์ Transformers ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ๊ฐํธํ ๋ถ๋ฌ์ ์ฌ์ฉํ ์ ์์ต๋๋ค. (๋ณ๋์ ํ์ผ ๋ค์ด๋ก๋๊ฐ ํ์ํ์ง ์์ต๋๋ค.) |
|
|
|
## KcBERT Performance |
|
|
|
- Finetune ์ฝ๋๋ https://github.com/Beomi/KcBERT-finetune ์์ ์ฐพ์๋ณด์ค ์ ์์ต๋๋ค. |
|
|
|
| | Size<br/>(์ฉ๋) | **NSMC**<br/>(acc) | **Naver NER**<br/>(F1) | **PAWS**<br/>(acc) | **KorNLI**<br/>(acc) | **KorSTS**<br/>(spearman) | **Question Pair**<br/>(acc) | **KorQuaD (Dev)**<br/>(EM/F1) | |
|
| :-------------------- | :---: | :----------------: | :--------------------: | :----------------: | :------------------: | :-----------------------: | :-------------------------: | :---------------------------: | |
|
| KcBERT-Base | 417M | 89.62 | 84.34 | 66.95 | 74.85 | 75.57 | 93.93 | 60.25 / 84.39 | |
|
| KcBERT-Large | 1.2G | **90.68** | 85.53 | 70.15 | 76.99 | 77.49 | 94.06 | 62.16 / 86.64 | |
|
| KoBERT | 351M | 89.63 | 86.11 | 80.65 | 79.00 | 79.64 | 93.93 | 52.81 / 80.27 | |
|
| XLM-Roberta-Base | 1.03G | 89.49 | 86.26 | 82.95 | 79.92 | 79.09 | 93.53 | 64.70 / 88.94 | |
|
| HanBERT | 614M | 90.16 | **87.31** | 82.40 | **80.89** | 83.33 | 94.19 | 78.74 / 92.02 | |
|
| KoELECTRA-Base | 423M | **90.21** | 86.87 | 81.90 | 80.85 | 83.21 | 94.20 | 61.10 / 89.59 | |
|
| KoELECTRA-Base-v2 | 423M | 89.70 | 87.02 | **83.90** | 80.61 | **84.30** | **94.72** | **84.34 / 92.58** | |
|
| DistilKoBERT | 108M | 88.41 | 84.13 | 62.55 | 70.55 | 73.21 | 92.48 | 54.12 / 77.80 | |
|
|
|
|
|
\*HanBERT์ Size๋ Bert Model๊ณผ Tokenizer DB๋ฅผ ํฉ์น ๊ฒ์
๋๋ค. |
|
|
|
\***config์ ์ธํ
์ ๊ทธ๋๋ก ํ์ฌ ๋๋ฆฐ ๊ฒฐ๊ณผ์ด๋ฉฐ, hyperparameter tuning์ ์ถ๊ฐ์ ์ผ๋ก ํ ์ ๋ ์ข์ ์ฑ๋ฅ์ด ๋์ฌ ์ ์์ต๋๋ค.** |
|
|
|
## How to use |
|
|
|
### Requirements |
|
|
|
- `pytorch <= 1.8.0` |
|
- `transformers ~= 3.0.1` |
|
- `transformers ~= 4.0.0` ๋ ํธํ๋ฉ๋๋ค. |
|
- `emoji ~= 0.6.0` |
|
- `soynlp ~= 0.0.493` |
|
|
|
```python |
|
from transformers import AutoTokenizer, AutoModelWithLMHead |
|
|
|
# Base Model (108M) |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("beomi/kcbert-base") |
|
|
|
model = AutoModelWithLMHead.from_pretrained("beomi/kcbert-base") |
|
|
|
# Large Model (334M) |
|
|
|
tokenizer = AutoTokenizer.from_pretrained("beomi/kcbert-large") |
|
|
|
model = AutoModelWithLMHead.from_pretrained("beomi/kcbert-large") |
|
``` |
|
|
|
### Pretrain & Finetune Colab ๋งํฌ ๋ชจ์ |
|
|
|
#### Pretrain Data |
|
|
|
- [๋ฐ์ดํฐ์
๋ค์ด๋ก๋(Kaggle, ๋จ์ผํ์ผ, ๋ก๊ทธ์ธ ํ์)](https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments) |
|
- [๋ฐ์ดํฐ์
๋ค์ด๋ก๋(Github, ์์ถ ์ฌ๋ฌํ์ผ, ๋ก๊ทธ์ธ ๋ถํ์)](https://github.com/Beomi/KcBERT/releases/tag/TrainData_v1) |
|
|
|
#### Pretrain Code |
|
|
|
Colab์์ TPU๋ก KcBERT Pretrain ํด๋ณด๊ธฐ: <a href="https://colab.research.google.com/drive/1lYBYtaXqt9S733OXdXvrvC09ysKFN30W"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> |
|
|
|
#### Finetune Samples |
|
|
|
**KcBERT-Base** NSMC Finetuning with PyTorch-Lightning (Colab) <a href="https://colab.research.google.com/drive/1fn4sVJ82BrrInjq6y5655CYPP-1UKCLb?usp=sharing"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> |
|
|
|
**KcBERT-Large** NSMC Finetuning with PyTorch-Lightning (Colab) <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> |
|
|
|
> ์ ๋ ์ฝ๋๋ Pretrain ๋ชจ๋ธ(base, large)์ batch size๋ง ๋ค๋ฅผ ๋ฟ, ๋๋จธ์ง ์ฝ๋๋ ์์ ํ ๋์ผํฉ๋๋ค. |
|
|
|
## Train Data & Preprocessing |
|
|
|
### Raw Data |
|
|
|
ํ์ต ๋ฐ์ดํฐ๋ 2019.01.01 ~ 2020.06.15 ์ฌ์ด์ ์์ฑ๋ **๋๊ธ ๋ง์ ๋ด์ค** ๊ธฐ์ฌ๋ค์ **๋๊ธ๊ณผ ๋๋๊ธ**์ ๋ชจ๋ ์์งํ ๋ฐ์ดํฐ์
๋๋ค. |
|
|
|
๋ฐ์ดํฐ ์ฌ์ด์ฆ๋ ํ
์คํธ๋ง ์ถ์ถ์ **์ฝ 15.4GB์ด๋ฉฐ, 1์ต1์ฒ๋ง๊ฐ ์ด์์ ๋ฌธ์ฅ**์ผ๋ก ์ด๋ค์ ธ ์์ต๋๋ค. |
|
|
|
### Preprocessing |
|
|
|
PLM ํ์ต์ ์ํด์ ์ ์ฒ๋ฆฌ๋ฅผ ์งํํ ๊ณผ์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. |
|
|
|
1. ํ๊ธ ๋ฐ ์์ด, ํน์๋ฌธ์, ๊ทธ๋ฆฌ๊ณ ์ด๋ชจ์ง(๐ฅณ)๊น์ง! |
|
|
|
์ ๊ทํํ์์ ํตํด ํ๊ธ, ์์ด, ํน์๋ฌธ์๋ฅผ ํฌํจํด Emoji๊น์ง ํ์ต ๋์์ ํฌํจํ์ต๋๋ค. |
|
|
|
ํํธ, ํ๊ธ ๋ฒ์๋ฅผ `ใฑ-ใ
๊ฐ-ํฃ` ์ผ๋ก ์ง์ ํด `ใฑ-ํฃ` ๋ด์ ํ์๋ฅผ ์ ์ธํ์ต๋๋ค. |
|
|
|
2. ๋๊ธ ๋ด ์ค๋ณต ๋ฌธ์์ด ์ถ์ฝ |
|
|
|
`ใ
ใ
ใ
ใ
ใ
`์ ๊ฐ์ด ์ค๋ณต๋ ๊ธ์๋ฅผ `ใ
ใ
`์ ๊ฐ์ ๊ฒ์ผ๋ก ํฉ์ณค์ต๋๋ค. |
|
|
|
3. Cased Model |
|
|
|
KcBERT๋ ์๋ฌธ์ ๋ํด์๋ ๋์๋ฌธ์๋ฅผ ์ ์งํ๋ Cased model์
๋๋ค. |
|
|
|
4. ๊ธ์ ๋จ์ 10๊ธ์ ์ดํ ์ ๊ฑฐ |
|
|
|
10๊ธ์ ๋ฏธ๋ง์ ํ
์คํธ๋ ๋จ์ผ ๋จ์ด๋ก ์ด๋ค์ง ๊ฒฝ์ฐ๊ฐ ๋ง์ ํด๋น ๋ถ๋ถ์ ์ ์ธํ์ต๋๋ค. |
|
|
|
5. ์ค๋ณต ์ ๊ฑฐ |
|
|
|
์ค๋ณต์ ์ผ๋ก ์ฐ์ธ ๋๊ธ์ ์ ๊ฑฐํ๊ธฐ ์ํด ์ค๋ณต ๋๊ธ์ ํ๋๋ก ํฉ์ณค์ต๋๋ค. |
|
|
|
์ด๋ฅผ ํตํด ๋ง๋ ์ต์ข
ํ์ต ๋ฐ์ดํฐ๋ **12.5GB, 8.9์ฒ๋ง๊ฐ ๋ฌธ์ฅ**์
๋๋ค. |
|
|
|
์๋ ๋ช
๋ น์ด๋ก pip๋ก ์ค์นํ ๋ค, ์๋ cleanํจ์๋ก ํด๋ฆฌ๋์ ํ๋ฉด Downstream task์์ ๋ณด๋ค ์ฑ๋ฅ์ด ์ข์์ง๋๋ค. (`[UNK]` ๊ฐ์) |
|
|
|
```bash |
|
pip install soynlp emoji |
|
``` |
|
|
|
์๋ `clean` ํจ์๋ฅผ Text data์ ์ฌ์ฉํด์ฃผ์ธ์. |
|
|
|
```python |
|
import re |
|
import emoji |
|
from soynlp.normalizer import repeat_normalize |
|
|
|
emojis = list({y for x in emoji.UNICODE_EMOJI.values() for y in x.keys()}) |
|
emojis = ''.join(emojis) |
|
pattern = re.compile(f'[^ .,?!/@$%~๏ผ
ยทโผ()\x00-\x7Fใฑ-ใ
ฃ๊ฐ-ํฃ{emojis}]+') |
|
url_pattern = re.compile( |
|
r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)') |
|
|
|
def clean(x): |
|
x = pattern.sub(' ', x) |
|
x = url_pattern.sub('', x) |
|
x = x.strip() |
|
x = repeat_normalize(x, num_repeats=2) |
|
return x |
|
``` |
|
|
|
### Cleaned Data (Released on Kaggle) |
|
|
|
์๋ณธ ๋ฐ์ดํฐ๋ฅผ ์ `clean`ํจ์๋ก ์ ์ ํ 12GB๋ถ๋์ txt ํ์ผ์ ์๋ Kaggle Dataset์์ ๋ค์ด๋ฐ์ผ์ค ์ ์์ต๋๋ค :) |
|
|
|
https://www.kaggle.com/junbumlee/kcbert-pretraining-corpus-korean-news-comments |
|
|
|
|
|
## Tokenizer Train |
|
|
|
Tokenizer๋ Huggingface์ [Tokenizers](https://github.com/huggingface/tokenizers) ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ํ์ต์ ์งํํ์ต๋๋ค. |
|
|
|
๊ทธ ์ค `BertWordPieceTokenizer` ๋ฅผ ์ด์ฉํด ํ์ต์ ์งํํ๊ณ , Vocab Size๋ `30000`์ผ๋ก ์งํํ์ต๋๋ค. |
|
|
|
Tokenizer๋ฅผ ํ์ตํ๋ ๊ฒ์๋ `1/10`๋ก ์ํ๋งํ ๋ฐ์ดํฐ๋ก ํ์ต์ ์งํํ๊ณ , ๋ณด๋ค ๊ณจ๊ณ ๋ฃจ ์ํ๋งํ๊ธฐ ์ํด ์ผ์๋ณ๋ก stratify๋ฅผ ์ง์ ํ ๋ค ํ์ต์ ์งํํ์ต๋๋ค. |
|
|
|
## BERT Model Pretrain |
|
|
|
- KcBERT Base config |
|
|
|
```json |
|
{ |
|
"max_position_embeddings": 300, |
|
"hidden_dropout_prob": 0.1, |
|
"hidden_act": "gelu", |
|
"initializer_range": 0.02, |
|
"num_hidden_layers": 12, |
|
"type_vocab_size": 2, |
|
"vocab_size": 30000, |
|
"hidden_size": 768, |
|
"attention_probs_dropout_prob": 0.1, |
|
"directionality": "bidi", |
|
"num_attention_heads": 12, |
|
"intermediate_size": 3072, |
|
"architectures": [ |
|
"BertForMaskedLM" |
|
], |
|
"model_type": "bert" |
|
} |
|
``` |
|
|
|
- KcBERT Large config |
|
|
|
```json |
|
{ |
|
"type_vocab_size": 2, |
|
"initializer_range": 0.02, |
|
"max_position_embeddings": 300, |
|
"vocab_size": 30000, |
|
"hidden_size": 1024, |
|
"hidden_dropout_prob": 0.1, |
|
"model_type": "bert", |
|
"directionality": "bidi", |
|
"pad_token_id": 0, |
|
"layer_norm_eps": 1e-12, |
|
"hidden_act": "gelu", |
|
"num_hidden_layers": 24, |
|
"num_attention_heads": 16, |
|
"attention_probs_dropout_prob": 0.1, |
|
"intermediate_size": 4096, |
|
"architectures": [ |
|
"BertForMaskedLM" |
|
] |
|
} |
|
``` |
|
|
|
BERT Model Config๋ Base, Large ๊ธฐ๋ณธ ์ธํ
๊ฐ์ ๊ทธ๋๋ก ์ฌ์ฉํ์ต๋๋ค. (MLM 15% ๋ฑ) |
|
|
|
TPU `v3-8` ์ ์ด์ฉํด ๊ฐ๊ฐ 3์ผ, N์ผ(Large๋ ํ์ต ์งํ ์ค)์ ์งํํ๊ณ , ํ์ฌ Huggingface์ ๊ณต๊ฐ๋ ๋ชจ๋ธ์ 1m(100๋ง) step์ ํ์ตํ ckpt๊ฐ ์
๋ก๋ ๋์ด์์ต๋๋ค. |
|
|
|
๋ชจ๋ธ ํ์ต Loss๋ Step์ ๋ฐ๋ผ ์ด๊ธฐ 200k์ ๊ฐ์ฅ ๋น ๋ฅด๊ฒ Loss๊ฐ ์ค์ด๋ค๋ค 400k์ดํ๋ก๋ ์กฐ๊ธ์ฉ ๊ฐ์ํ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. |
|
|
|
- Base Model Loss |
|
|
|
![KcBERT-Base Pretraining Loss](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200719183852243.38b124.png) |
|
|
|
- Large Model Loss |
|
|
|
![KcBERT-Large Pretraining Loss](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200806160746694.d56fa1.png) |
|
|
|
ํ์ต์ GCP์ TPU v3-8์ ์ด์ฉํด ํ์ต์ ์งํํ๊ณ , ํ์ต ์๊ฐ์ Base Model ๊ธฐ์ค 2.5์ผ์ ๋ ์งํํ์ต๋๋ค. Large Model์ ์ฝ 5์ผ์ ๋ ์งํํ ๋ค ๊ฐ์ฅ ๋ฎ์ loss๋ฅผ ๊ฐ์ง ์ฒดํฌํฌ์ธํธ๋ก ์ ํ์ต๋๋ค. |
|
|
|
## Example |
|
|
|
### HuggingFace MASK LM |
|
|
|
[HuggingFace kcbert-base ๋ชจ๋ธ](https://huggingface.co/beomi/kcbert-base?text=์ค๋์+๋ ์จ๊ฐ+[MASK]) ์์ ์๋์ ๊ฐ์ด ํ
์คํธ ํด ๋ณผ ์ ์์ต๋๋ค. |
|
|
|
![์ค๋์ ๋ ์จ๊ฐ "์ข๋ค์", KcBERT-Base](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200719205919389.5670d6.png) |
|
|
|
๋ฌผ๋ก [kcbert-large ๋ชจ๋ธ](https://huggingface.co/beomi/kcbert-large?text=์ค๋์+๋ ์จ๊ฐ+[MASK]) ์์๋ ํ
์คํธ ํ ์ ์์ต๋๋ค. |
|
|
|
![image-20200806160624340](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200806160624340.58f9be.png) |
|
|
|
|
|
|
|
### NSMC Binary Classification |
|
|
|
[๋ค์ด๋ฒ ์ํํ ์ฝํผ์ค](https://github.com/e9t/nsmc) ๋ฐ์ดํฐ์
์ ๋์์ผ๋ก Fine Tuning์ ์งํํด ์ฑ๋ฅ์ ๊ฐ๋จํ ํ
์คํธํด๋ณด์์ต๋๋ค. |
|
|
|
Base Model์ Fine Tuneํ๋ ์ฝ๋๋ <a href="https://colab.research.google.com/drive/1fn4sVJ82BrrInjq6y5655CYPP-1UKCLb?usp=sharing"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> ์์ ์ง์ ์คํํด๋ณด์ค ์ ์์ต๋๋ค. |
|
|
|
Large Model์ Fine Tuneํ๋ ์ฝ๋๋ <a href="https://colab.research.google.com/drive/1dFC0FL-521m7CL_PSd8RLKq67jgTJVhL?usp=sharing"> |
|
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/> |
|
</a> ์์ ์ง์ ์คํํด๋ณผ ์ ์์ต๋๋ค. |
|
|
|
- GPU๋ P100 x1๋ ๊ธฐ์ค 1epoch์ 2-3์๊ฐ, TPU๋ 1epoch์ 1์๊ฐ ๋ด๋ก ์์๋ฉ๋๋ค. |
|
- GPU RTX Titan x4๋ ๊ธฐ์ค 30๋ถ/epoch ์์๋ฉ๋๋ค. |
|
- ์์ ์ฝ๋๋ [pytorch-lightning](https://github.com/PyTorchLightning/pytorch-lightning)์ผ๋ก ๊ฐ๋ฐํ์ต๋๋ค. |
|
|
|
#### ์คํ๊ฒฐ๊ณผ |
|
|
|
- KcBERT-Base Model ์คํ๊ฒฐ๊ณผ: Val acc `.8905` |
|
|
|
![KcBERT Base finetune on NSMC](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200719201102895.ddbdfc.png) |
|
|
|
- KcBERT-Large Model ์คํ ๊ฒฐ๊ณผ: Val acc `.9089` |
|
|
|
![image-20200806190242834](https://raw.githubusercontent.com/Beomi/KcBERT/master/img/image-20200806190242834.56d6ee.png) |
|
|
|
> ๋ ๋ค์ํ Downstream Task์ ๋ํด ํ
์คํธ๋ฅผ ์งํํ๊ณ ๊ณต๊ฐํ ์์ ์
๋๋ค. |
|
|
|
## ์ธ์ฉํ๊ธฐ/Citation |
|
|
|
KcBERT๋ฅผ ์ธ์ฉํ์ค ๋๋ ์๋ ์์์ ํตํด ์ธ์ฉํด์ฃผ์ธ์. |
|
|
|
``` |
|
@inproceedings{lee2020kcbert, |
|
title={KcBERT: Korean Comments BERT}, |
|
author={Lee, Junbum}, |
|
booktitle={Proceedings of the 32nd Annual Conference on Human and Cognitive Language Technology}, |
|
pages={437--440}, |
|
year={2020} |
|
} |
|
``` |
|
|
|
- ๋
ผ๋ฌธ์ง ๋ค์ด๋ก๋ ๋งํฌ: http://hclt.kr/dwn/?v=bG5iOmNvbmZlcmVuY2U7aWR4OjMy (*ํน์ http://hclt.kr/symp/?lnb=conference ) |
|
|
|
## Acknowledgement |
|
|
|
KcBERT Model์ ํ์ตํ๋ GCP/TPU ํ๊ฒฝ์ [TFRC](https://www.tensorflow.org/tfrc?hl=ko) ํ๋ก๊ทธ๋จ์ ์ง์์ ๋ฐ์์ต๋๋ค. |
|
|
|
๋ชจ๋ธ ํ์ต ๊ณผ์ ์์ ๋ง์ ์กฐ์ธ์ ์ฃผ์ [Monologg](https://github.com/monologg/) ๋ ๊ฐ์ฌํฉ๋๋ค :) |
|
|
|
## Reference |
|
|
|
### Github Repos |
|
|
|
- [BERT by Google](https://github.com/google-research/bert) |
|
- [KoBERT by SKT](https://github.com/SKTBrain/KoBERT) |
|
- [KoELECTRA by Monologg](https://github.com/monologg/KoELECTRA/) |
|
|
|
- [Transformers by Huggingface](https://github.com/huggingface/transformers) |
|
- [Tokenizers by Hugginface](https://github.com/huggingface/tokenizers) |
|
|
|
### Papers |
|
|
|
- [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding](https://arxiv.org/abs/1810.04805) |
|
|
|
### Blogs |
|
|
|
- [Monologg๋์ KoELECTRA ํ์ต๊ธฐ](https://monologg.kr/categories/NLP/ELECTRA/) |
|
- [Colab์์ TPU๋ก BERT ์ฒ์๋ถํฐ ํ์ต์ํค๊ธฐ - Tensorflow/Google ver.](https://beomi.github.io/2020/02/26/Train-BERT-from-scratch-on-colab-TPU-Tensorflow-ver/) |
|
|
|
|