ken11
commited on
Commit
•
8012371
1
Parent(s):
bdafbb9
init
Browse files- README.md +66 -0
- added_tokens.json +1 -0
- config.json +28 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- spiece.model +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +1 -0
README.md
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- fill-mask
|
4 |
+
- japanese
|
5 |
+
- albert
|
6 |
+
|
7 |
+
language:
|
8 |
+
- ja
|
9 |
+
|
10 |
+
license: mit
|
11 |
+
|
12 |
+
widget:
|
13 |
+
- text: "2022年の[MASK]概要"
|
14 |
+
|
15 |
+
---
|
16 |
+
## albert-base-japanese-v1
|
17 |
+
日本語事前学習済みALBERTモデルです
|
18 |
+
|
19 |
+
## How to use
|
20 |
+
### ファインチューニング
|
21 |
+
このモデルはPreTrainedモデルです
|
22 |
+
基本的には各種タスク用にファインチューニングして使用されることを想定しています
|
23 |
+
|
24 |
+
### Fill-Mask
|
25 |
+
このモデルではTokenizerにSentencepieceを利用しています
|
26 |
+
そのままでは`[MASK]`トークンのあとに[余計なトークンが混入する問題](https://ken11.jp/blog/sentencepiece-tokenizer-bug)があるので、利用する際には以下のようにする必要があります
|
27 |
+
```py
|
28 |
+
from transformers import (
|
29 |
+
AlbertForMaskedLM, AlbertTokenizerFast
|
30 |
+
)
|
31 |
+
import torch
|
32 |
+
|
33 |
+
|
34 |
+
tokenizer = AlbertTokenizerFast.from_pretrained("ken11/albert-base-japanese-v1")
|
35 |
+
model = AlbertForMaskedLM.from_pretrained("ken11/albert-base-japanese-v1")
|
36 |
+
|
37 |
+
text = "大学で[MASK]の研究をしています"
|
38 |
+
tokenized_text = tokenizer.tokenize(text)
|
39 |
+
del tokenized_text[tokenized_text.index(tokenizer.mask_token) + 1]
|
40 |
+
|
41 |
+
input_ids = [tokenizer.cls_token_id]
|
42 |
+
input_ids.extend(tokenizer.convert_tokens_to_ids(tokenized_text))
|
43 |
+
input_ids.append(tokenizer.sep_token_id)
|
44 |
+
|
45 |
+
inputs = {"input_ids": [input_ids], "token_type_ids": [[0]*len(input_ids)], "attention_mask": [[1]*len(input_ids)]}
|
46 |
+
batch = {k: torch.tensor(v, dtype=torch.int64) for k, v in inputs.items()}
|
47 |
+
output = model(**batch)[0]
|
48 |
+
_, result = output[0, input_ids.index(tokenizer.mask_token_id)].topk(5)
|
49 |
+
|
50 |
+
print(tokenizer.convert_ids_to_tokens(result.tolist()))
|
51 |
+
# ['英語', '心理学', '数学', '医学', '日本語']
|
52 |
+
```
|
53 |
+
|
54 |
+
## Training Data
|
55 |
+
学習には
|
56 |
+
- [日本語Wikipediaの全文](https://ja.wikipedia.org/wiki/Wikipedia:%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89)
|
57 |
+
- [livedoorニュースコーパス](https://www.rondhuit.com/download.html#ldcc)
|
58 |
+
|
59 |
+
を利用しています
|
60 |
+
|
61 |
+
## Tokenizer
|
62 |
+
トークナイザーは[Sentencepiece](https://github.com/google/sentencepiece)を利用しています
|
63 |
+
こちらも学習データは同様です
|
64 |
+
|
65 |
+
## Licenese
|
66 |
+
[The MIT license](https://opensource.org/licenses/MIT)
|
added_tokens.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"<pad>": 32000}
|
config.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"AlbertForMaskedLM"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"bos_token_id": 2,
|
7 |
+
"classifier_dropout_prob": 0.1,
|
8 |
+
"embedding_size": 128,
|
9 |
+
"eos_token_id": 3,
|
10 |
+
"hidden_act": "gelu",
|
11 |
+
"hidden_dropout_prob": 0,
|
12 |
+
"hidden_size": 768,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"inner_group_num": 1,
|
15 |
+
"intermediate_size": 3072,
|
16 |
+
"layer_norm_eps": 1e-12,
|
17 |
+
"max_position_embeddings": 512,
|
18 |
+
"model_type": "albert",
|
19 |
+
"num_attention_heads": 12,
|
20 |
+
"num_hidden_groups": 1,
|
21 |
+
"num_hidden_layers": 12,
|
22 |
+
"pad_token_id": 0,
|
23 |
+
"position_embedding_type": "absolute",
|
24 |
+
"torch_dtype": "float32",
|
25 |
+
"transformers_version": "4.12.5",
|
26 |
+
"type_vocab_size": 2,
|
27 |
+
"vocab_size": 32001
|
28 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:359a2eb4bf8438c7ee79f71d9ae5cb999e8f7c43e271165090b39fec0a43a86b
|
3 |
+
size 45934350
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"bos_token": "[CLS]", "eos_token": "[SEP]", "unk_token": "<unk>", "sep_token": "[SEP]", "pad_token": "<pad>", "cls_token": "[CLS]", "mask_token": {"content": "[MASK]", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true}}
|
spiece.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a92e9d6477b60da3a89422630e3b2bcf94335e2b5b2d199d308976405c965227
|
3 |
+
size 800120
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": false, "remove_space": true, "keep_accents": true, "bos_token": "[CLS]", "eos_token": "[SEP]", "unk_token": "<unk>", "sep_token": "[SEP]", "pad_token": "<pad>", "cls_token": "[CLS]", "mask_token": {"content": "[MASK]", "single_word": false, "lstrip": true, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "tokenize_chinese_chars": false, "sp_model_kwargs": {}, "tokenizer_class": "AlbertTokenizer"}
|