Giter VIP home page Giter VIP logo

deep-news-summarization's Introduction

Codacy Badge

News summarization

News summarization using sequence to sequence model in TensorFlow.

Introduction

This repository is a demonstration of abstractive summarization of news article exploiting TensorFlow sequence to sequence model. This model incorporates attention mechanism and uses LSTM cell as both encoder and decoder.

This model is trained on one million Associated Press Worldstream news stories from English Gigaword second edition. The examples below are based on the model trained on AWS EC2 g2.2xlarge instance for 10 epochs, which took around 20 hours.

For more detailed information, please see our project research paper: Headline Generation Using Recurrent Neural Network.

Examples

News 1

News: A roadside bomb killed five people Thursday near a shelter used as a police recruiting center in northeast Baghdad, police said.

Actual headline: Iraqi police: Bomb kills 5 near police recruiting center in northeast Baghdad

Predicted headline: URGENT Explosion kills five people in Baghdad

News 2

News: The euro hit a record high against the dollar Monday in Asia as concerns over the U.S. subprime mortgage crisis remain a heavy weight on the greenback.

Actual headline: Euro hits record high versus dollar in Asian trading

Predicted headline: Euro hits record high against dollar

How to run

For demonstration, we use the sample file (a very small portion of English Gigaword) from LDC as our dataset to train our model. If you want to reproduce the results like the above examples, larger training set is necessary. You can download the trained model parameters which was trained on a larger portion on Gigaword by following the instructions in the Download vocabs and trained model parameters section below. The whole English Gigaword can be obtained from university libraries.

Pre-req

  • Install Python 3
  • Download deep-news-summarization
$ git clone https://github.com/hengluchang/deep-news-summarization.git
  • Install TensorFlow 0.12, pandas, Numpy, nltk, and requests
$ pip install -r requirements.txt
  • Create two folders named "working_dir" and "output" under the deep-news-summarization folder.
$ cd deep-news-summarization
$ mkdir -p working_dir output

Download vocabs and trained model parameters

  • Run download_vocabs_and_trained_params.py file. This will download encoder and decoder vocabularies and trained model parameters to working_dir folder.
$ python download_vocabs_and_trained_params.py ./working_dir
  • Go to Interactive testing section below to reproduce the results as the examples above.

Train your own summarizer

  • Set "mode = train" in seq2seq.ini file.
  • Run split_data.py file to split the dataset into training, evaluation, and testing sets. train_enc.txt, eval_enc.txt, test_enc, train_dec.txt, eval_dec.txt, and test_dec.txt total of six files will be created under ./dataset.
$ python split_data.py
  • Run execute.py file. This will create vocab80000_enc.txt, vocab80000_dec.txt, and checkpoint data under ./working_dir. If you use your own dataset, optimizing bucket sizes to minimize padding in execute.py file can help to get better results. Also, keep training the model until the preplexity of the evaluation sets are under 10 for better performances.
$ python execute.py

Testing

  • Set "mode = test" in seq2seq.ini file.
  • Run execute.py file. This will read the model parameters (seq2seq.ckpt-XXXXX) into your model and create predicted_test_headline.txt under ./output.
$ python execute.py
  • Run evaluation.py file to get BLEU scores between actual headlines and predicted headlines. This will create BLEU.txt file.
$ python evaluation.py

Interactive testing

  • Set "mode = interactive" in seq2seq.ini file.
  • Run execute.py. This will read the model parameters (seq2seq.ckpt-XXXXX) into your model and ask user for an input.
$ python execute.py

References

Research Paper References

deep-news-summarization's People

Contributors

hengluchang avatar hengshengchang avatar xiaoxu193 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.