update
Browse files
README.md
CHANGED
@@ -32,7 +32,7 @@ for i, id in enumerate(tokenizer.encode(text)):
|
|
32 |
pt_outputs_sentence += "".join(
|
33 |
tokenizer.convert_ids_to_tokens([id], skip_special_tokens=True))
|
34 |
print(pt_outputs_sentence)
|
35 |
-
# pytorch 今天[
|
36 |
```
|
37 |
|
38 |
## tensorflow2.0使用
|
@@ -40,8 +40,8 @@ print(pt_outputs_sentence)
|
|
40 |
import tensorflow as tf
|
41 |
from transformers import RoFormerTokenizer, TFRoFormerForMaskedLM
|
42 |
text = "今天[MASK]很好,我[MASK]去公园玩。"
|
43 |
-
tokenizer = RoFormerTokenizer.from_pretrained("junnyu/
|
44 |
-
tf_model = TFRoFormerForMaskedLM.from_pretrained("junnyu/
|
45 |
tf_inputs = tokenizer(text, return_tensors="tf")
|
46 |
tf_outputs = tf_model(**tf_inputs, training=False).logits[0]
|
47 |
tf_outputs_sentence = "tf2.0: "
|
@@ -54,7 +54,7 @@ for i, id in enumerate(tokenizer.encode(text)):
|
|
54 |
tf_outputs_sentence += "".join(
|
55 |
tokenizer.convert_ids_to_tokens([id], skip_special_tokens=True))
|
56 |
print(tf_outputs_sentence)
|
57 |
-
# tf2.0 今天[
|
58 |
```
|
59 |
|
60 |
## 引用
|
|
|
32 |
pt_outputs_sentence += "".join(
|
33 |
tokenizer.convert_ids_to_tokens([id], skip_special_tokens=True))
|
34 |
print(pt_outputs_sentence)
|
35 |
+
# pytorch: 今天[天||气||都||风||人]很好,我[想||要||就||也||还]去公园玩。
|
36 |
```
|
37 |
|
38 |
## tensorflow2.0使用
|
|
|
40 |
import tensorflow as tf
|
41 |
from transformers import RoFormerTokenizer, TFRoFormerForMaskedLM
|
42 |
text = "今天[MASK]很好,我[MASK]去公园玩。"
|
43 |
+
tokenizer = RoFormerTokenizer.from_pretrained("junnyu/roformer_chinese_char_base")
|
44 |
+
tf_model = TFRoFormerForMaskedLM.from_pretrained("junnyu/roformer_chinese_char_base")
|
45 |
tf_inputs = tokenizer(text, return_tensors="tf")
|
46 |
tf_outputs = tf_model(**tf_inputs, training=False).logits[0]
|
47 |
tf_outputs_sentence = "tf2.0: "
|
|
|
54 |
tf_outputs_sentence += "".join(
|
55 |
tokenizer.convert_ids_to_tokens([id], skip_special_tokens=True))
|
56 |
print(tf_outputs_sentence)
|
57 |
+
# tf2.0 今天[天||气||都||风||人]很好,我[想||要||就||也||还]去公园玩。
|
58 |
```
|
59 |
|
60 |
## 引用
|