figurative-nlp
commited on
Commit
·
8202a4e
1
Parent(s):
60e164e
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
chinese-simile-generative 是一个将句子A改写成带有修辞手法(主要为比喻,明喻)的句子B的seq2seq模型。
|
2 |
+
|
3 |
+
A: 我走得很慢,慢极了。
|
4 |
+
B: 我走的很慢,像蜗牛一样。
|
5 |
+
|
6 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained("figurative-nlp/chinese-simile-generation")
|
8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("figurative-nlp/chinese-simile-generation")
|
9 |
+
|
10 |
+
|
11 |
+
input_ids = tokenizer(
|
12 |
+
"我走得很慢,慢极了", return_tensors="pt"
|
13 |
+
).input_ids
|
14 |
+
outputs = model.generate(input_ids,num_beams = 5,max_length = 64)
|
15 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
+
print(result)
|
17 |
+
#result : 我走的很慢,像蜗牛一样。
|