Huiyuan Lai
commited on
Commit
·
0d1a3a2
1
Parent(s):
24a3874
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
license: apache-2.0
|
5 |
+
---
|
6 |
+
|
7 |
+
# mFLAG
|
8 |
+
mFLAG is a sequence-to-sequence model for multi-figurative language generation. It was introduced in the paper [Multi-Figurative Language Generation]() paper by Huiyuan Lai and Malvina Nissim.
|
9 |
+
|
10 |
+
# Model description
|
11 |
+
mFLAG is a sequence-to-sequence model for multi-figurative language generation. It is trained by employing a scheme for multi-figurative language pre-training on top of BART, and a mechanism for injecting the target figurative information into the encoder; this enables the generation of text with the target figurative form from another figurative form without parallel figurative-figurative sentence pairs.
|
12 |
+
|
13 |
+
|
14 |
+
# How to use
|
15 |
+
```bash
|
16 |
+
git clone git@github.com:laihuiyuan/mFLAG.git
|
17 |
+
cd mFLAG
|
18 |
+
```
|
19 |
+
|
20 |
+
```python
|
21 |
+
from model import MultiFigurativeGeneration
|
22 |
+
from tokenization_mflag import MFlagTokenizerFast
|
23 |
+
|
24 |
+
tokenizer = MFlagTokenizerFast.from_pretrained('checkpoints/mFLAG')
|
25 |
+
model = MultiFigurativeGeneration.from_pretrained('checkpoints/mFLAG')
|
26 |
+
|
27 |
+
# hyperbole to sarcasm
|
28 |
+
inp_id = tokenizer.encode("<hyperbole> I am not happy that he urged me to finish all the hardest tasks in the world", return_tensors="pt")
|
29 |
+
fig_id = tokenizer.encode("<sarcasm>", add_special_tokens=False, return_tensors="pt")
|
30 |
+
|
31 |
+
outs = model.generate(input_ids=inp_id[:, 1:], fig_ids=fig_id, forced_bos_token_id=fig_id.item())
|
32 |
+
text = tokenizer.decode(outs[0].tolist(), skip_special_tokens=True, clean_up_tokenization_spaces=False)
|
33 |
+
```
|
34 |
+
|
35 |
+
# Citation Info
|
36 |
+
```BibTeX
|
37 |
+
@inproceedings{lai-etal-2022-multi,
|
38 |
+
title = "Multi-Figurative Language Generation",
|
39 |
+
author = "Lai, Huiyuan and Nissim, Malvina",
|
40 |
+
booktitle = "Proceedings of the 29th International Conference on Computational Linguistics",
|
41 |
+
month = October,
|
42 |
+
year = "2022",
|
43 |
+
address = "Gyeongju, Republic of korea",
|
44 |
+
}
|
45 |
+
```
|