All Projects → chen0040 → Keras Text Summarization

chen0040 / Keras Text Summarization

Licence: mit
Text summarization using seq2seq in Keras

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Keras Text Summarization

Text summarization with tensorflow
Implementation of a seq2seq model for summarization of textual data. Demonstrated on amazon reviews, github issues and news articles.
Stars: ✭ 226 (-13.08%)
Mutual labels:  seq2seq, text-summarization
Text Summarization Tensorflow
Tensorflow seq2seq Implementation of Text Summarization.
Stars: ✭ 527 (+102.69%)
Mutual labels:  seq2seq, text-summarization
Text summurization abstractive methods
Multiple implementations for abstractive text summurization , using google colab
Stars: ✭ 359 (+38.08%)
Mutual labels:  seq2seq, text-summarization
TextSumma
reimplementing Neural Summarization by Extracting Sentences and Words
Stars: ✭ 16 (-93.85%)
Mutual labels:  text-summarization, seq2seq
Text-Summarization
A text document will be provided and it'll produce it's summary
Stars: ✭ 30 (-88.46%)
Mutual labels:  text-summarization
DLCV2018SPRING
Deep Learning for Computer Vision (CommE 5052) in NTU
Stars: ✭ 38 (-85.38%)
Mutual labels:  seq2seq
MoChA-pytorch
PyTorch Implementation of "Monotonic Chunkwise Attention" (ICLR 2018)
Stars: ✭ 65 (-75%)
Mutual labels:  seq2seq
ttslearn
ttslearn: Library for Pythonで学ぶ音声合成 (Text-to-speech with Python)
Stars: ✭ 158 (-39.23%)
Mutual labels:  seq2seq
awesome-text-summarization
Text summarization starting from scratch.
Stars: ✭ 86 (-66.92%)
Mutual labels:  text-summarization
2D-LSTM-Seq2Seq
PyTorch implementation of a 2D-LSTM Seq2Seq Model for NMT.
Stars: ✭ 25 (-90.38%)
Mutual labels:  seq2seq
ai-visual-storytelling-seq2seq
Implementation of seq2seq model for Visual Storytelling Challenge (VIST) http://visionandlanguage.net/VIST/index.html
Stars: ✭ 50 (-80.77%)
Mutual labels:  seq2seq
summarize-webpage
A small NLP SAAS project that summarize a webpage
Stars: ✭ 34 (-86.92%)
Mutual labels:  text-summarization
NeuralTextSimplification
Exploring Neural Text Simplification
Stars: ✭ 64 (-75.38%)
Mutual labels:  seq2seq
dts
A Keras library for multi-step time-series forecasting.
Stars: ✭ 130 (-50%)
Mutual labels:  seq2seq
TextRank-node
No description or website provided.
Stars: ✭ 21 (-91.92%)
Mutual labels:  text-summarization
TextSummarizer
TextRank implementation for C#
Stars: ✭ 29 (-88.85%)
Mutual labels:  text-summarization
chatbot
🤖️ 基于 PyTorch 的任务型聊天机器人(支持私有部署和 docker 部署的 Chatbot)
Stars: ✭ 77 (-70.38%)
Mutual labels:  seq2seq
TaLKConvolutions
Official PyTorch implementation of Time-aware Large Kernel (TaLK) Convolutions (ICML 2020)
Stars: ✭ 26 (-90%)
Mutual labels:  seq2seq
neural-chat
An AI chatbot using seq2seq
Stars: ✭ 30 (-88.46%)
Mutual labels:  seq2seq
abtextsum
Abstractive text summarization based on deep learning and semantic content generalization
Stars: ✭ 14 (-94.62%)
Mutual labels:  text-summarization

keras-text-summarization

Text summarization using seq2seq and encoder-decoder recurrent networks in Keras

Machine Learning Models

The follow neural network models are implemented and studied for text summarization:

Seq2Seq

The seq2seq models encodes the content of an article (encoder input) and one character (decoder input) from the summarized text to predict the next character in the summarized text

The implementation can be found in keras_text_summarization/library/seq2seq.py

There are three variants of seq2seq model implemented for the text summarization

Other RNN models

There are currently 3 other encoder-decoder recurrent models based on some recommendation here

The implementation can be found in keras_text_summarization/library/rnn.py

The trained models are available in the demo/models folder

Usage

The demo below shows how to use seq2seq to do training and prediction, but other models described above also follow the same process of training and prediction.

Train Deep Learning model

To train a deep learning model, say Seq2SeqSummarizer, run the following commands:

pip install requirements.txt

cd demo
python seq2seq_train.py 

The training code in seq2seq_train.py is quite straightforward and illustrated below:

from __future__ import print_function

import pandas as pd
from sklearn.model_selection import train_test_split
from keras_text_summarization.library.utility.plot_utils import plot_and_save_history
from keras_text_summarization.library.seq2seq import Seq2SeqSummarizer
from keras_text_summarization.library.applications.fake_news_loader import fit_text
import numpy as np

LOAD_EXISTING_WEIGHTS = True

np.random.seed(42)
data_dir_path = './data'
report_dir_path = './reports'
model_dir_path = './models'

print('loading csv file ...')
df = pd.read_csv(data_dir_path + "/fake_or_real_news.csv")

print('extract configuration from input texts ...')
Y = df.title
X = df['text']

config = fit_text(X, Y)

summarizer = Seq2SeqSummarizer(config)

if LOAD_EXISTING_WEIGHTS:
    summarizer.load_weights(weight_file_path=Seq2SeqSummarizer.get_weight_file_path(model_dir_path=model_dir_path))

Xtrain, Xtest, Ytrain, Ytest = train_test_split(X, Y, test_size=0.2, random_state=42)

history = summarizer.fit(Xtrain, Ytrain, Xtest, Ytest, epochs=100)

history_plot_file_path = report_dir_path + '/' + Seq2SeqSummarizer.model_name + '-history.png'
if LOAD_EXISTING_WEIGHTS:
    history_plot_file_path = report_dir_path + '/' + Seq2SeqSummarizer.model_name + '-history-v' + str(summarizer.version) + '.png'
plot_and_save_history(history, summarizer.model_name, history_plot_file_path, metrics={'loss', 'acc'})

After the training is completed, the trained models will be saved as cf-v1-. in the video_classifier/demo/models.

Summarization

To use the trained deep learning model to summarize an article, the following code demo how to do this:

from __future__ import print_function

import pandas as pd
from keras_text_summarization.library.seq2seq import Seq2SeqSummarizer
import numpy as np

np.random.seed(42)
data_dir_path = './data' # refers to the demo/data folder
model_dir_path = './models' # refers to the demo/models folder

print('loading csv file ...')
df = pd.read_csv(data_dir_path + "/fake_or_real_news.csv")
X = df['text']
Y = df.title

config = np.load(Seq2SeqSummarizer.get_config_file_path(model_dir_path=model_dir_path)).item()

summarizer = Seq2SeqSummarizer(config)
summarizer.load_weights(weight_file_path=Seq2SeqSummarizer.get_weight_file_path(model_dir_path=model_dir_path))

print('start predicting ...')
for i in range(20):
    x = X[i]
    actual_headline = Y[i]
    headline = summarizer.summarize(x)
    print('Article: ', x)
    print('Generated Headline: ', headline)
    print('Original Headline: ', actual_headline)

Configure to run on GPU on Windows

  • Step 1: Change tensorflow to tensorflow-gpu in requirements.txt and install tensorflow-gpu
  • Step 2: Download and install the CUDA® Toolkit 9.0 (Please note that currently CUDA® Toolkit 9.1 is not yet supported by tensorflow, therefore you should download CUDA® Toolkit 9.0)
  • Step 3: Download and unzip the cuDNN 7.0.4 for [email protected] Toolkit 9.0 and add the bin folder of the unzipped directory to the $PATH of your Windows environment
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].