Huiyuan Lai commited on
Commit
2f6cbbd
·
1 Parent(s): 0d1a3a2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +7 -9
README.md CHANGED
@@ -5,7 +5,7 @@ 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.
@@ -20,16 +20,14 @@ cd mFLAG
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
 
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](laihuiyuan/mFLAG) paper by [Huiyuan Lai](https://laihuiyuan.github.io/) and [Malvina Nissim](https://scholar.google.nl/citations?user=hnTpEOAAAAAJ&hl=en).
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.
 
20
  ```python
21
  from model import MultiFigurativeGeneration
22
  from tokenization_mflag import MFlagTokenizerFast
23
+ tokenizer = MFlagTokenizerFast.from_pretrained('laihuiyuan/mFLAG')
24
+ model = MultiFigurativeGeneration.from_pretrained('laihuiyuan/mFLAG')
 
25
 
26
  # hyperbole to sarcasm
27
+ inp_ids = tokenizer.encode("<hyperbole> I am not happy that he urged me to finish all the hardest tasks in the world", return_tensors="pt")
28
+ fig_ids = tokenizer.encode("<sarcasm>", add_special_tokens=False, return_tensors="pt")
29
+ outs = model.generate(input_ids=inp_ids[:, 1:], fig_ids=fig_ids, forced_bos_token_id=fig_ids.item(), num_beams=5, max_length=60,)
30
+ text = tokenizer.decode(outs[0, 2:].tolist(), skip_special_tokens=True, clean_up_tokenization_spaces=False)
 
31
  ```
32
 
33
  # Citation Info