This model can convert the literal expression to figurative/metaphorical expression. Below is the usage of our model:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
tokenizer = AutoTokenizer.from_pretrained("figurative-nlp/t5-figurative-generation")
model = AutoModelForSeq2SeqLM.from_pretrained("figurative-nlp/t5-figurative-generation")
input_ids = tokenizer(
"research is <m> very difficult </m> for me.", return_tensors="pt"
).input_ids # Batch size 1
outputs = model.generate(input_ids,beam_search = 5)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
#result : research is a tough nut to crack for me.
For example (the <m> and </m> is the mark that inform the model which literal expression we want to convert it as figurative expression):
Input: as of a cloud that softly <m> covers </m> the sun.
Output: as of a cloud that softly drapes over the sun.
Input: that car coming around the corner <m> surprised me. </m>
Output: that car coming around the corner knocked my socks off.
Note: the figurative language here includes metaphor, idiom and simile. We don't guarantee that the results generated results are satisfactory to you. We are trying to improve the effect of the model.