GithubHelp home page GithubHelp logo

sysujayce / cgmh Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ningmiao/cgmh

0.0 0.0 0.0 1.26 MB

Codes for <CGMH: Constrained Sentence Generation by Metropolis-Hastings Sampling>

Python 100.00%

cgmh's Introduction

Constrained Sentence Generation via Metropolis-Hastings Sampling

Introduction

CGMH is a sampling based model for constrained sentence generation, which can be used in keyword-to-sentence generation, paraphrase, sentence correction and many other tasks.

Examples

  • Running example for parahrase: (All rejected proposal is omitted)
    what movie do you like most . ->
    which movie do you like most . (replace what with which) ->
    which movie do you like . (delete most) ->
    which movie do you like best . (insert best) ->
    which movie do you think best . (replace like with think) ->
    which movie do you think the best . (insert the) ->
    which movie do you think is the best . (insert is)

  • Running example for sentence correction: in the word oil price very high right now . ->
    in the word , oil price very high right now . (insert ,) ->
    in the word , oil prices very high right now . (replace price with prices) ->
    in the word , oil prices are very high right now . (insert are)

  • Extra Examples for sentence correction:
    origin: even if we are failed , we have to try to get a new things .->
    generated: even if we are failing , we have to try to get some new things .

    origin: in the word oil price very high right now .->
    generated: in the word , oil prices are very high right now .

    origin: the reason these problem occurs is also becayse of the exam .->
    generated: the reason these problems occur is also because of the exam .

Requirement

  • python

    • ==2.7
  • python packages

  • word embedding

    • If you want to try using word embedding for paraphrase, you should download or train a word embedding first and place it at config.emb_path and set config.emb_path='word_max'.

Language model download

Word embedding download

Running

  • Training language models

    • For each task, first train a backward and a language model:
      set mode='forward' and mode='backward' in config.py successively.
      run python correction.py / paraphrase.py / key-gen.py to train each model.
  • Generation

    • For generating new sample for each tasks:
      set mode='use' and choose proper parameter in config.py.
      give inputs in 'input/input.txt' run python correction.py / paraphrase.py / key-gen.py to generate.
      outputs are in output.
  • Details

    • Make sure that paths for package and data are correctly set in 'config.py'.

cgmh's People

Contributors

ningmiao avatar

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.