kaisugi commited on
Commit
d676ee7
0 Parent(s):

initial commit

Browse files
Files changed (6) hide show
  1. .gitattributes +34 -0
  2. README.md +106 -0
  3. config.json +24 -0
  4. pytorch_model.bin +3 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +8 -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,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: ja
3
+ license: cc-by-nc-sa-4.0
4
+ tags:
5
+ - roberta
6
+ - medical
7
+ mask_token: "[MASK]"
8
+ widget:
9
+ - text: "この患者は[MASK]と診断された。"
10
+ ---
11
+
12
+ # alabnii/jmedroberta-base-sentencepiece-vocab50000
13
+
14
+ ## Model description
15
+
16
+ This is a Japanese RoBERTa base model pre-trained on academic articles in medical sciences collected by Japan Science and Technology Agency (JST).
17
+
18
+ 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).
19
+
20
+ ## Datasets used for pre-training
21
+
22
+ - abstracts (train: 1.6GB (10M sentences), validation: 0.2GB (1.3M sentences))
23
+ - abstracts & body texts (train: 0.2GB (1.4M sentences))
24
+
25
+ ## How to use
26
+
27
+ **Input text must be converted to full-width characters(全角)in advance.**
28
+
29
+ You can use this model for masked language modeling as follows:
30
+ ```python
31
+ from transformers import AutoModelForMaskedLM, AutoTokenizer
32
+
33
+ model = AutoModelForMaskedLM.from_pretrained("alabnii/jmedroberta-base-sentencepiece-vocab50000")
34
+ model.eval()
35
+ tokenizer = AutoTokenizer.from_pretrained("alabnii/jmedroberta-base-sentencepiece-vocab50000")
36
+
37
+ texts = ['この患者は[MASK]と診断された。']
38
+ inputs = tokenizer.batch_encode_plus(texts, return_tensors='pt')
39
+ outputs = model(**inputs)
40
+ tokenizer.convert_ids_to_tokens(outputs.logits[0][1:-1].argmax(axis=-1))
41
+ # ['▁この', '患者は', 'SLE', '▁', 'と診断された', '。']
42
+ ```
43
+
44
+ Alternatively, you can employ [Fill-mask pipeline](https://huggingface.co/tasks/fill-mask).
45
+
46
+ ```python
47
+ from transformers import pipeline
48
+ fill = pipeline("fill-mask", model="alabnii/jmedroberta-base-sentencepiece-vocab50000", top_k=10)
49
+ fill("この患者は[MASK]と診断された。")
50
+ #[{'score': 0.021247705444693565,
51
+ # 'token': 3592,
52
+ # 'token_str': 'SLE',
53
+ # 'sequence': 'この患者はSLE と診断された。'},
54
+ # {'score': 0.012531018815934658,
55
+ # 'token': 16813,
56
+ # 'token_str': 'MSA',
57
+ # 'sequence': 'この患者はMSA と診断された。'},
58
+ # {'score': 0.01097362581640482,
59
+ # 'token': 41130,
60
+ # 'token_str': 'MELAS',
61
+ # 'sequence': 'この患者はMELAS と診断された。'},
62
+ # ...
63
+ ```
64
+
65
+ You can fine-tune this model on downstream tasks.
66
+
67
+ **See also sample Colab notebooks:** https://colab.research.google.com/drive/1D-FNO01XX82pL3So5GWfi2gVo338aAMo?usp=sharing
68
+
69
+ ## Tokenization
70
+
71
+ Each sentence is tokenized into tokens by [SentencePiece (Unigram)](https://huggingface.co/course/chapter6/7).
72
+
73
+ ## Vocabulary
74
+
75
+ The vocabulary consists of 50000 tokens induced by [SentencePiece (Unigram)](https://huggingface.co/course/chapter6/7).
76
+
77
+ ## Training procedure
78
+
79
+ The following hyperparameters were used during pre-training:
80
+
81
+ - learning_rate: 0.0001
82
+ - train_batch_size: 32
83
+ - eval_batch_size: 32
84
+ - seed: 42
85
+ - distributed_type: multi-GPU
86
+ - num_devices: 8
87
+ - total_train_batch_size: 256
88
+ - total_eval_batch_size: 256
89
+ - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
90
+ - lr_scheduler_type: linear
91
+ - lr_scheduler_warmup_steps: 20000
92
+ - training_steps: 2000000
93
+ - mixed_precision_training: Native AMP
94
+
95
+ ## Note: Why do we call our model RoBERTa, not BERT?
96
+
97
+ 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:
98
+
99
+ - We kept training only with max sequence length (= 512) tokens.
100
+ - We removed the next sentence prediction (NSP) training objective.
101
+ - We introduced dynamic masking (changing the masking pattern in each training iteration).
102
+
103
+ ## Acknowledgements
104
+
105
+ 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.
106
+ 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:1646472dd5bddf75f26576df6170b7a2407bc69730e0ca0c203913faa937fd2c
3
+ size 498061650
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "unk_token": "[UNK]",
3
+ "mask_token": "[MASK]",
4
+ "cls_token": "[CLS]",
5
+ "pad_token": "[PAD]",
6
+ "sep_token": "[SEP]",
7
+ "tokenizer_class": "T5Tokenizer"
8
+ }