first commit
Browse files- README.md +90 -0
- config.json +37 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +9 -0
- spm.model +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +16 -0
README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: ja
|
| 3 |
+
license: cc-by-sa-4.0
|
| 4 |
+
library_name: transformers
|
| 5 |
+
tags:
|
| 6 |
+
- deberta
|
| 7 |
+
- deberta-v2
|
| 8 |
+
- fill-mask
|
| 9 |
+
datasets:
|
| 10 |
+
- wikipedia
|
| 11 |
+
- cc100
|
| 12 |
+
- oscar
|
| 13 |
+
metrics:
|
| 14 |
+
- accuracy
|
| 15 |
+
mask_token: "[MASK]"
|
| 16 |
+
widget:
|
| 17 |
+
- text: "京都大学で自然言語処理を[MASK]する。"
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Model Card for Japanese DeBERTa V2 base
|
| 21 |
+
|
| 22 |
+
## Model description
|
| 23 |
+
|
| 24 |
+
This is a Japanese DeBERTa V2 base model pre-trained on Japanese Wikipedia, the Japanese portion of CC-100, and the Japanese portion of OSCAR.
|
| 25 |
+
|
| 26 |
+
## How to use
|
| 27 |
+
|
| 28 |
+
You can use this model for masked language modeling as follows:
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from transformers import AutoTokenizer, AutoModelForMaskedLM
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained('ku-nlp/deberta-v2-base-japanese')
|
| 33 |
+
model = AutoModelForMaskedLM.from_pretrained('ku-nlp/deberta-v2-base-japanese')
|
| 34 |
+
|
| 35 |
+
sentence = '京都大学で自然言語処理を[MASK]する。'
|
| 36 |
+
encoding = tokenizer(sentence, return_tensors='pt')
|
| 37 |
+
...
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
You can also fine-tune this model on downstream tasks.
|
| 41 |
+
|
| 42 |
+
## Tokenization
|
| 43 |
+
|
| 44 |
+
The input text should be segmented into words by [Juman++](https://github.com/ku-nlp/jumanpp) in advance. [Juman++ 2.0.0-rc3](https://github.com/ku-nlp/jumanpp/releases/tag/v2.0.0-rc3) was used for pre-training. Each word is tokenized into subwords by [sentencepiece](https://github.com/google/sentencepiece).
|
| 45 |
+
|
| 46 |
+
## Training Data
|
| 47 |
+
|
| 48 |
+
We used the following corpora for pre-training:
|
| 49 |
+
|
| 50 |
+
- Japanese Wikipedia (as of 20221020, 3.2GB, 27M sentences, 1.3M documents)
|
| 51 |
+
- Japanese portion of CC-100 (85GB, 619M sentences, 66M documents)
|
| 52 |
+
- Japanese portion of OSCAR (54GB, 326M sentences, 25M documents)
|
| 53 |
+
|
| 54 |
+
Note that we filtered out documents annotated with "header", "footer", or "noisy" tags in OSCAR.
|
| 55 |
+
Also note that Japanese Wikipedia was duplicated 10 times to make the total size of the corpus comparable to that of CC-100 and OSCAR. As a result, the total size of the training data is 171GB.
|
| 56 |
+
|
| 57 |
+
## Training procedure
|
| 58 |
+
|
| 59 |
+
We first segmented texts in the corpora into words using [Juman++](https://github.com/ku-nlp/jumanpp).
|
| 60 |
+
Then, we built a sentencepiece model with 32000 tokens including words ([JumanDIC](https://github.com/ku-nlp/JumanDIC)) and subwords induced by the unigram language model of [sentencepiece](https://github.com/google/sentencepiece).
|
| 61 |
+
|
| 62 |
+
We tokenized the segmented corpora into subwords using the sentencepiece model and trained the Japanese DeBERTa model using [transformers](https://github.com/huggingface/transformers) library.
|
| 63 |
+
The training took three weeks using 8 NVIDIA A100-SXM4-40GB GPUs.
|
| 64 |
+
|
| 65 |
+
The following hyperparameters were used during pre-training:
|
| 66 |
+
|
| 67 |
+
- learning_rate: 2e-4
|
| 68 |
+
- per_device_train_batch_size: 44
|
| 69 |
+
- distributed_type: multi-GPU
|
| 70 |
+
- num_devices: 8
|
| 71 |
+
- gradient_accumulation_steps: 6
|
| 72 |
+
- total_train_batch_size: 2,112
|
| 73 |
+
- max_seq_length: 512
|
| 74 |
+
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-06
|
| 75 |
+
- lr_scheduler_type: linear schedule with warmup
|
| 76 |
+
- training_steps: 500,000
|
| 77 |
+
- warmup_steps: 10,000
|
| 78 |
+
|
| 79 |
+
The accuracy of the trained model on the masked language modeling task was 0.779.
|
| 80 |
+
The evaluation set consists of 5,000 randomly sampled documents from each of the training corpora.
|
| 81 |
+
|
| 82 |
+
## Fine-tuning on NLU tasks
|
| 83 |
+
|
| 84 |
+
<!-- https://github.com/yahoojapan/JGLUE -->
|
| 85 |
+
Coming soon.
|
| 86 |
+
|
| 87 |
+
## Acknowledgments
|
| 88 |
+
|
| 89 |
+
This work was supported by Joint Usage/Research Center for Interdisciplinary Large-scale Information Infrastructures (JHPCN) through General Collaboration Project no. jh221004, "Developing a Platform for Constructing and Sharing of Large-Scale Japanese Language Models".
|
| 90 |
+
For training models, we used the mdx: a platform for the data-driven future.
|
config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"DebertaV2ForMaskedLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_head_size": 64,
|
| 6 |
+
"attention_probs_dropout_prob": 0.1,
|
| 7 |
+
"conv_act": "gelu",
|
| 8 |
+
"conv_kernel_size": 3,
|
| 9 |
+
"hidden_act": "gelu",
|
| 10 |
+
"hidden_dropout_prob": 0.1,
|
| 11 |
+
"hidden_size": 768,
|
| 12 |
+
"initializer_range": 0.02,
|
| 13 |
+
"intermediate_size": 3072,
|
| 14 |
+
"layer_norm_eps": 1e-07,
|
| 15 |
+
"max_position_embeddings": 512,
|
| 16 |
+
"max_relative_positions": -1,
|
| 17 |
+
"model_type": "deberta-v2",
|
| 18 |
+
"norm_rel_ebd": "layer_norm",
|
| 19 |
+
"num_attention_heads": 12,
|
| 20 |
+
"num_hidden_layers": 12,
|
| 21 |
+
"pad_token_id": 0,
|
| 22 |
+
"pooler_dropout": 0,
|
| 23 |
+
"pooler_hidden_act": "gelu",
|
| 24 |
+
"pooler_hidden_size": 768,
|
| 25 |
+
"pos_att_type": [
|
| 26 |
+
"p2c",
|
| 27 |
+
"c2p"
|
| 28 |
+
],
|
| 29 |
+
"position_biased_input": false,
|
| 30 |
+
"position_buckets": 256,
|
| 31 |
+
"relative_attention": true,
|
| 32 |
+
"share_att_key": true,
|
| 33 |
+
"torch_dtype": "float32",
|
| 34 |
+
"transformers_version": "4.23.1",
|
| 35 |
+
"type_vocab_size": 0,
|
| 36 |
+
"vocab_size": 32000
|
| 37 |
+
}
|
pytorch_model.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:57fb86bf188376f5d1230e5835270f9e7bb00e5db5aaedfb9445df7b571ba9c3
|
| 3 |
+
size 548197213
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "[CLS]",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"eos_token": "[SEP]",
|
| 5 |
+
"mask_token": "[MASK]",
|
| 6 |
+
"pad_token": "[PAD]",
|
| 7 |
+
"sep_token": "[SEP]",
|
| 8 |
+
"unk_token": "[UNK]"
|
| 9 |
+
}
|
spm.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6c111c16e2e52366dcac46b886e40650bb843fe2938a65f5970271fc5697a127
|
| 3 |
+
size 805061
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": "[CLS]",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": false,
|
| 5 |
+
"eos_token": "[SEP]",
|
| 6 |
+
"keep_accents": true,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"name_or_path": "data/deberta_v2_tokenizer",
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"sp_model_kwargs": {},
|
| 12 |
+
"special_tokens_map_file": null,
|
| 13 |
+
"split_by_punct": false,
|
| 14 |
+
"tokenizer_class": "DebertaV2Tokenizer",
|
| 15 |
+
"unk_token": "[UNK]"
|
| 16 |
+
}
|