File size: 1,128 Bytes
33e1eec
4450b33
5590f51
4450b33
5590f51
9184a5c
cfd6f1f
 
4450b33
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
English-Simile-Generation is a seq2seq paraphrase model which can transform sentence A to sentence B containing figurative or simile expression.

A: Now I feel sad to see your scientific research progress is so slow.

B: Now I feel sad to see your scientific research progress is as slow as snail.

**To our knowledge, our model have better performance,diversity and practicability compared to EMNLP21 paper (Generating similes effortlessly like a Pro:
A Style Transfer Approach for Simile Generation). **

      from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
      tokenizer = AutoTokenizer.from_pretrained("figurative-nlp/English-Simile-Generation")
      model = AutoModelForSeq2SeqLM.from_pretrained("figurative-nlp/Ehinese-Simile-Generation")
      
      
      input_ids = tokenizer(
          "Adrenaline shot through him powerful", 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 : Adrenaline shot through him like an electric current