Git Product home page Git Product logo

mta-lstm's Introduction

MTA-LSTM

We focus on essay generation, which is a challenging task that generates a paragraph-level text with multiple topics. Progress towards understanding different topics and expressing diversity in this task requires more powerful generators and richer training and evaluation resources. To address this, we develop a multi-topic-aware long short-term memory (MTA-LSTM) network. In this model, we maintain a novel multi-topic coverage vector, which learns the weight of of each topic and is sequentially updated during the decoding process. Afterwards this vector is fed to an attention model to guide the generator.

The code in this repository is written in Python 2.7/TensorFlow 1.4.0. And if you use other versions of Python or TensorFlow, you should modify some code.

Data Set

Composition Data Set: Download

Zhihu Data Set: Download

Usage

Data

In Data/ respository, you need to prepare two files TrainingData.txt and vec.txt(word embedding trained by word2vec), which is created from text dataset mentioned above.

Training

Before train the model, you should set some parameters of this model in Config.py file. Then, you need to run Preprocess.py file for creating coverage_data file(convert trainingdata into binary formats of TensorFlow, and more detail about this can be found in the blog), word_vec.pkl file(this is word embedding) and word_vec.pkl file(vocabulary of text). At the same time, you should set total_step parameter in Train.py whose value is got from output of Preprocess.py

Start training the model using Train.py:

$ python Train.py

Generation

After you train the model, you can generate the text in the control of word set. You should modify Generation.py file and set test_word to a set of words. Then, if you want, you can also set some parameters for generation in Config.py file. Generate text by run:

$ python Generation.py

mta-lstm's People

Contributors

hit-computer avatar

Watchers

James Cloos avatar TheShiHuaxing 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.