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

A: I think I rated you very high at the beginning. Now I feel sad to see your scientific research progress is so slow.

B: I think I rated you very high at the beginning. 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