Coder Social home page Coder Social logo

wyu-du / reinforce-paraphrase-generation Goto Github PK

View Code? Open in Web Editor NEW
81.0 5.0 12.0 45.14 MB

This repository contains the data and code for the paper "An Empirical Comparison on Imitation Learning and Reinforcement Learning for Paraphrase Generation" (EMNLP2019).

License: MIT License

Python 100.00%
reinforcement-learning imitation-learning paraphrase-generation

reinforce-paraphrase-generation's Introduction

A Unified Reinforcement Learning Framework for Pointer Generator Model

This repository contains the data and code for the paper "An Empirical Comparison on Imitation Learning and Reinforcement Learning for Paraphrase Generation".

Useage

Training

  1. Model Setting: modify the path where the model will be saved.
vim config.py
log_root = os.path.join(root_dir, "Reinforce-Paraphrase-Generation/log_twitter")
  1. Pre-train: train the standard pointer-generator model with supervised learning from scratch.
python train.py
  1. Fine-tune: modify the training mode and the path where the fine-tuned model will be saved.
vim config.py
log_root = os.path.join(root_dir, "Reinforce-Paraphrase-Generation/log_rl")
mode = "RL"

Fine tune the pointer-generator model with REINFORCE algorithm.

python train.py -m ../log_twitter/best_model/model_best_XXXXX

Decoding & Evaluation

  1. Decoding: first, specify the model path.
vim config.py
log_root = os.path.join(root_dir, "Reinforce-Paraphrase-Generation/log_twitter")

Second, apply beam search to generate sentences on test set:

python decode.py ../log_twitter/best_model/model_best_XXXXX
  1. Evaluation:
    • The average BLEU score will show up automatically in the terminal after finishing decoding.

    • If you want to get the ROUGE scores, you should first intall pyrouge, here is the guidance. Then, you can uncomment the code snippet specified in utils.py and decode.py. Finally, run decode.py to get the ROUGE scores.

reinforce-paraphrase-generation's People

Contributors

wyu-du avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

reinforce-paraphrase-generation's Issues

Is it okay to use teacher forcing in evaluation?

Hi Wu!

I'm studying conditional text generation using your code. Thanks for publishing such a great code.

while reading eval.py, I wondered whether it is allowed to use teacher forcing in evaluation mode, since evaluation process, I think, was supposed to be the same as the model's decoding process. (including beam search)

On the other hand, I suspect it is okay because we use teacher forcing in the training mode. That is, we aim to evaluate its performance in the same environment as the training mode.

Which one do you think is the convention? Thanks in advance!

Dependencies for the code.

Hi,
Could you specify what dependencies could be used for the code? or where I can find them? e.g. The version number. Thanks very much.

Xiao

GPU利用率低

首先,感谢作者大大的杰出贡献。

但是运行代码的过程中,GPU占用率总是在10%+到30%之间跳动,即使将batch size设置为128也不管用。请问这可能是什么的原因?谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.