KoichiYasuoka
commited on
Commit
•
41bb348
1
Parent(s):
40d6e70
initial release
Browse files- README.md +32 -0
- config.json +44 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- "lzh"
|
4 |
+
tags:
|
5 |
+
- "classical chinese"
|
6 |
+
- "literary chinese"
|
7 |
+
- "ancient chinese"
|
8 |
+
- "token-classification"
|
9 |
+
license: "apache-2.0"
|
10 |
+
pipeline_tag: "token-classification"
|
11 |
+
widget:
|
12 |
+
- text: "子曰學而時習之不亦說乎有朋自遠方來不亦樂乎人不知而不慍不亦君子乎"
|
13 |
+
---
|
14 |
+
|
15 |
+
# roberta-classical-chinese-large-sentence-segmentation
|
16 |
+
|
17 |
+
## Model Description
|
18 |
+
|
19 |
+
This is a RoBERTa model pre-trained on Classical Chinese texts for sentence segmentation, derived from [roberta-classical-chinese-large-char](https://huggingface.co/KoichiYasuoka/roberta-classical-chinese-large-char). Every segmented sentence starts with token-class "B" and ends with token-class "E" (except for single-character sentence with token-class "S").
|
20 |
+
|
21 |
+
## How to Use
|
22 |
+
|
23 |
+
```py
|
24 |
+
import torch
|
25 |
+
from transformers import AutoTokenizer,AutoModelForTokenClassification
|
26 |
+
tokenizer=AutoTokenizer.from_pretrained("KoichiYasuoka/roberta-classical-chinese-large-sentence-segmentation")
|
27 |
+
model=AutoModelForTokenClassification.from_pretrained("KoichiYasuoka/roberta-classical-chinese-large-sentence-segmentation")
|
28 |
+
s="子曰學而時習之不亦說乎有朋自遠方來不亦樂乎人不知而不慍不亦君子乎"
|
29 |
+
p=[model.config.id2label[q] for q in torch.argmax(model(tokenizer.encode(s,return_tensors="pt"))[0],dim=2)[0].tolist()[1:-1]]
|
30 |
+
print("".join(c+"。" if q=="E" or q=="S" else c for c,q in zip(s,p)))
|
31 |
+
```
|
32 |
+
|
config.json
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "KoichiYasuoka/roberta-classical-chinese-large-char",
|
3 |
+
"architectures": [
|
4 |
+
"RobertaForTokenClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"bos_token_id": 0,
|
8 |
+
"eos_token_id": 2,
|
9 |
+
"finetuning_task": "ner",
|
10 |
+
"gradient_checkpointing": false,
|
11 |
+
"hidden_act": "gelu",
|
12 |
+
"hidden_dropout_prob": 0.1,
|
13 |
+
"hidden_size": 1024,
|
14 |
+
"id2label": {
|
15 |
+
"0": "B",
|
16 |
+
"1": "E",
|
17 |
+
"2": "E2",
|
18 |
+
"3": "E3",
|
19 |
+
"4": "M",
|
20 |
+
"5": "S"
|
21 |
+
},
|
22 |
+
"initializer_range": 0.02,
|
23 |
+
"intermediate_size": 4096,
|
24 |
+
"label2id": {
|
25 |
+
"B": 0,
|
26 |
+
"E": 1,
|
27 |
+
"E2": 2,
|
28 |
+
"E3": 3,
|
29 |
+
"M": 4,
|
30 |
+
"S": 5
|
31 |
+
},
|
32 |
+
"layer_norm_eps": 1e-05,
|
33 |
+
"max_position_embeddings": 514,
|
34 |
+
"model_type": "roberta",
|
35 |
+
"num_attention_heads": 16,
|
36 |
+
"num_hidden_layers": 24,
|
37 |
+
"pad_token_id": 1,
|
38 |
+
"position_embedding_type": "absolute",
|
39 |
+
"tokenizer_class": "BertTokenizer",
|
40 |
+
"transformers_version": "4.6.1",
|
41 |
+
"type_vocab_size": 1,
|
42 |
+
"use_cache": true,
|
43 |
+
"vocab_size": 26318
|
44 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c83591a8d2ac8ef72b1aaba2bbb60a01701f13da0a9c099d4c274c82fae030fb
|
3 |
+
size 1319346251
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": true, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": null, "name_or_path": "KoichiYasuoka/roberta-classical-chinese-large-char", "do_basic_tokenize": true, "never_split": null}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|