junnyu commited on
Commit
7ef73ba
1 Parent(s): 7efc1de

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -18
README.md CHANGED
@@ -4,14 +4,11 @@ tags:
4
  - glycebert
5
  inference: False
6
  ---
7
-
8
- # GlyceBert_pytorch
9
- ## https://github.com/JunnYu/GlyceBert_pytorch
10
-
11
- 本项目主要自定义了tokenization_glycebert_fast.py文件中的GlyceBertTokenizerFast代码。从而可以从huggingface.co调用。
12
  ```python
13
  pretrained_tokenizer_name = "junnyu/ChineseBERT-base"
14
- tokenizer = GlyceBertTokenizerFast.from_pretrained(pretrained_tokenizer_name)
15
  ```
16
 
17
  # Paper
@@ -20,32 +17,29 @@ tokenizer = GlyceBertTokenizerFast.from_pretrained(pretrained_tokenizer_name)
20
 
21
  # Install
22
  ```bash
23
- pip install glycebert
24
  or
25
- pip install git+https://github.com/JunnYu/GlyceBert_pytorch.git
26
  ```
27
 
28
  # Usage
29
  ```python
30
  import torch
31
- from transformers import BertConfig as GlyceBertConfig
 
32
 
33
- from glycebert import GlyceBertForMaskedLM, GlyceBertTokenizerFast
34
-
35
- # 使用我这个里面的tokenizer config和model config
36
  pretrained_tokenizer_name = "junnyu/ChineseBERT-base"
37
  pretrained_model_name = "ShannonAI/ChineseBERT-base"
38
 
39
- tokenizer = GlyceBertTokenizerFast.from_pretrained(pretrained_tokenizer_name)
40
- config = GlyceBertConfig.from_pretrained(pretrained_tokenizer_name)
41
- chinese_bert = GlyceBertForMaskedLM.from_pretrained(
42
- pretrained_model_name, config=config
43
- )
44
 
45
  text = "北京是[MASK]国的首都。"
46
  inputs = tokenizer(text, return_tensors="pt")
47
  print(inputs)
48
  maskpos = 4
 
49
  with torch.no_grad():
50
  o = chinese_bert(**inputs)
51
  value, index = o.logits.softmax(-1)[0, maskpos].topk(10)
@@ -63,4 +57,4 @@ print(outputs)
63
  ```
64
 
65
  # Reference
66
- https://github.com/ShannonAI/ChineseBert
 
4
  - glycebert
5
  inference: False
6
  ---
7
+ # ChineseBert_pytorch
8
+ 本项目主要自定义了tokenization_chinesebert_fast.py文件中的ChineseBertTokenizerFast代码。从而可以从huggingface.co调用。
 
 
 
9
  ```python
10
  pretrained_tokenizer_name = "junnyu/ChineseBERT-base"
11
+ tokenizer = ChineseBertTokenizerFast.from_pretrained(pretrained_tokenizer_name)
12
  ```
13
 
14
  # Paper
 
17
 
18
  # Install
19
  ```bash
20
+ pip install chinesebert
21
  or
22
+ pip install git+https://github.com/JunnYu/ChineseBert_pytorch.git
23
  ```
24
 
25
  # Usage
26
  ```python
27
  import torch
28
+ from transformers import BertConfig as ChineseBertConfig
29
+ from chinesebert import ChineseBertForMaskedLM, ChineseBertTokenizerFast
30
 
 
 
 
31
  pretrained_tokenizer_name = "junnyu/ChineseBERT-base"
32
  pretrained_model_name = "ShannonAI/ChineseBERT-base"
33
 
34
+ tokenizer = ChineseBertTokenizerFast.from_pretrained(pretrained_tokenizer_name)
35
+ config = ChineseBertConfig.from_pretrained(pretrained_tokenizer_name)
36
+ chinese_bert = ChineseBertForMaskedLM.from_pretrained(pretrained_model_name, config=config)
 
 
37
 
38
  text = "北京是[MASK]国的首都。"
39
  inputs = tokenizer(text, return_tensors="pt")
40
  print(inputs)
41
  maskpos = 4
42
+
43
  with torch.no_grad():
44
  o = chinese_bert(**inputs)
45
  value, index = o.logits.softmax(-1)[0, maskpos].topk(10)
 
57
  ```
58
 
59
  # Reference
60
+ https://github.com/ShannonAI/ChineseBert