Downloads · 30 days
24
4% of all-time downloads
figurative-nlp/Chinese-Simile-Generation
Chinese-Simile-Generation is a machine learning model from figurative-nlp. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
chinese-simile-generative 是一个将句子A改写成带有修辞手法(主要为比喻,明喻)的句子B的seq2seq模型。
Downloads · 30 days
24
4% of all-time downloads
All-time downloads
602
Public
Repo size
1.9 GB
Likes
2
Public
Click a slice to open those files.
.bin465 MB · 100%
From the Hugging Face model README
chinese-simile-generative 是一个将句子A改写成带有修辞手法(主要为比喻,明喻)的句子B的seq2seq模型。
A: 想当初对你的定级是很高的,现在我很伤心,看到你的科研进度这么慢。
B: 想当初对你的定级是很高的,现在我很伤心,看到你的科研进度像蜗牛一样慢。
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("figurative-nlp/chinese-simile-generation")
model = AutoModelForSeq2SeqLM.from_pretrained("figurative-nlp/chinese-simile-generation")
input_ids = tokenizer(
"我走得很慢,慢极了", return_tensors="pt"
).input_ids
outputs = model.generate(input_ids,num_beams = 5,max_length = 64)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(result)
#result : 我走的很慢,像蜗牛一样。