kaisugi commited on
Commit
976f5d4
0 Parent(s):

initial commit

Browse files
Files changed (6) hide show
  1. .gitattributes +34 -0
  2. README.md +114 -0
  3. config.json +24 -0
  4. pytorch_model.bin +3 -0
  5. tokenizer_config.json +10 -0
  6. vocab.txt +0 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: ja
3
+ license: cc-by-nc-sa-4.0
4
+ tags:
5
+ - roberta
6
+ - medical
7
+ inference: false
8
+ ---
9
+
10
+ # alabnii/jmedroberta-base-manbyo-wordpiece-vocab50000
11
+
12
+ ## Model description
13
+
14
+ This is a Japanese RoBERTa base model pre-trained on academic articles in medical sciences collected by Japan Science and Technology Agency (JST).
15
+
16
+ This model is released under the [Creative Commons 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/deed) (CC BY-NC-SA 4.0).
17
+
18
+ ## Datasets used for pre-training
19
+
20
+ - abstracts (train: 1.6GB (10M sentences), validation: 0.2GB (1.3M sentences))
21
+ - abstracts & body texts (train: 0.2GB (1.4M sentences))
22
+
23
+ ## How to use
24
+
25
+ **Before using the model, make sure that [Manbyo Dictionary](https://sociocom.naist.jp/manbyou-dic/) has been downloaded under `/usr/local/lib/mecab/dic/userdic`.**
26
+
27
+ ```bash
28
+ # download Manbyo-Dictionary
29
+
30
+ mkdir -p /usr/local/lib/mecab/dic/userdic
31
+ wget https://sociocom.jp/~data/2018-manbyo/data/MANBYO_201907_Dic-utf8.dic && mv MANBYO_201907_Dic-utf8.dic /usr/local/lib/mecab/dic/userdic
32
+ ```
33
+
34
+ **Input text must be converted to full-width characters(全角)in advance.**
35
+
36
+ You can use this model for masked language modeling as follows:
37
+ ```python
38
+ from transformers import AutoModelForMaskedLM, AutoTokenizer
39
+
40
+ model = AutoModelForMaskedLM.from_pretrained("alabnii/jmedroberta-base-manbyo-wordpiece-vocab50000")
41
+ model.eval()
42
+ tokenizer = AutoTokenizer.from_pretrained("alabnii/jmedroberta-base-manbyo-wordpiece-vocab50000")
43
+
44
+ texts = ['この患者は[MASK]と診断された。']
45
+ inputs = tokenizer.batch_encode_plus(texts, return_tensors='pt')
46
+ outputs = model(**inputs)
47
+ tokenizer.convert_ids_to_tokens(outputs.logits[0][1:-1].argmax(axis=-1))
48
+ # ['この', '患者', 'は', 'SLE', 'と', '診断', 'さ', 'れ', 'た', '。']
49
+ ```
50
+
51
+ Alternatively, you can employ [Fill-mask pipeline](https://huggingface.co/tasks/fill-mask).
52
+
53
+ ```python
54
+ from transformers import pipeline
55
+
56
+ fill = pipeline("fill-mask", model="alabnii/jmedroberta-base-manbyo-wordpiece-vocab50000", top_k=10)
57
+ fill("この患者は[MASK]と診断された。")
58
+ #[{'score': 0.035826072096824646,
59
+ # 'token': 10840,
60
+ # 'token_str': 'SLE',
61
+ # 'sequence': 'この 患者 は SLE と 診断 さ れ た 。'},
62
+ # {'score': 0.020926717668771744,
63
+ # 'token': 10777,
64
+ # 'token_str': '統合失調症',
65
+ # 'sequence': 'この 患者 は 統合失調症 と 診断 さ れ た 。'},
66
+ # {'score': 0.02092057280242443,
67
+ # 'token': 8338,
68
+ # 'token_str': '糖尿病',
69
+ # 'sequence': 'この 患者 は 糖尿病 と 診断 さ れ た 。'},
70
+ # ...
71
+ ```
72
+
73
+ You can fine-tune this model on downstream tasks.
74
+
75
+ **See also sample Colab notebooks:** https://colab.research.google.com/drive/1p2770dXs0lge1IkuSHYLO-G-KJ4gZtou?usp=sharing
76
+
77
+ ## Tokenization
78
+
79
+ Mecab (w/ IPAdic & [Manbyo Dictionary](https://sociocom.naist.jp/manbyou-dic/)) was used for pre-training. Each word is tokenized into tokens by [WordPiece](https://huggingface.co/course/chapter6/6).
80
+
81
+ ## Vocabulary
82
+
83
+ The vocabulary consists of 50000 tokens including words (IPAdic & [Manbyo Dictionary](https://sociocom.naist.jp/manbyou-dic/)) and subwords induced by [WordPiece](https://huggingface.co/course/chapter6/6).
84
+
85
+ ## Training procedure
86
+
87
+ The following hyperparameters were used during pre-training:
88
+
89
+ - learning_rate: 0.0001
90
+ - train_batch_size: 32
91
+ - eval_batch_size: 32
92
+ - seed: 42
93
+ - distributed_type: multi-GPU
94
+ - num_devices: 8
95
+ - total_train_batch_size: 256
96
+ - total_eval_batch_size: 256
97
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
98
+ - lr_scheduler_type: linear
99
+ - lr_scheduler_warmup_steps: 20000
100
+ - training_steps: 2000000
101
+ - mixed_precision_training: Native AMP
102
+
103
+ ## Note: Why do we call our model RoBERTa, not BERT?
104
+
105
+ As the config file suggests, our model is based on HuggingFace's `BertForMaskedLM` class. However, we consider our model as **RoBERTa** for the following reasons:
106
+
107
+ - We kept training only with max sequence length (= 512) tokens.
108
+ - We removed the next sentence prediction (NSP) training objective.
109
+ - We introduced dynamic masking (changing the masking pattern in each training iteration).
110
+
111
+ ## Acknowledgements
112
+
113
+ This work was supported by Japan Japan Science and Technology Agency (JST) AIP Trilateral AI Research (Grant Number: JPMJCR20G9), and Joint Usage/Research Center for Interdisciplinary Large-scale Information Infrastructures (JHPCN) (Project ID: jh221004), in Japan.
114
+ In this research work, we used the "[mdx: a platform for the data-driven future](https://mdx.jp/)".
config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "BertForMaskedLM"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "classifier_dropout": null,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "bert",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "torch_dtype": "float32",
20
+ "transformers_version": "4.16.1",
21
+ "type_vocab_size": 2,
22
+ "use_cache": true,
23
+ "vocab_size": 50000
24
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f46c45d39e0536ea37d6514f51035d2c05150465c61c5c88fd7348f282ee368c
3
+ size 498061650
tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "BertJapaneseTokenizer",
3
+ "word_tokenizer_type": "mecab",
4
+ "subword_tokenizer_type": "wordpiece",
5
+ "mecab_kwargs": {
6
+ "mecab_dic": "ipadic",
7
+ "mecab_option": "-u /usr/local/lib/mecab/dic/userdic/MANBYO_201907_Dic-utf8.dic",
8
+ "normalize_text": false
9
+ }
10
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff