All Projects → hpanwar08 → sentence-classification-pytorch

hpanwar08 / sentence-classification-pytorch

Licence: MIT license
Sentiment analysis with variable length sequences in pytorch

Programming Languages

Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to sentence-classification-pytorch

pytorch-sentiment-analysis
char-rnn implementation for sentiment analysis on twitter data
Stars: ✭ 32 (-5.88%)
Mutual labels:  sentiment-analysis
ArSarcasm
This repository contains the Arabic sarcasm dataset (ArSarcasm)
Stars: ✭ 18 (-47.06%)
Mutual labels:  sentiment-analysis
soan
Social Analysis based on Whatsapp data
Stars: ✭ 106 (+211.76%)
Mutual labels:  sentiment-analysis
converse
Conversational text Analysis using various NLP techniques
Stars: ✭ 147 (+332.35%)
Mutual labels:  sentiment-analysis
senticnetapi
Simple API to use SenticNet
Stars: ✭ 69 (+102.94%)
Mutual labels:  sentiment-analysis
sentistrength id
Sentiment Strength Detection in Bahasa Indonesia
Stars: ✭ 32 (-5.88%)
Mutual labels:  sentiment-analysis
rosette-elasticsearch-plugin
Document Enrichment plugin for Elasticsearch
Stars: ✭ 25 (-26.47%)
Mutual labels:  sentiment-analysis
CLUEmotionAnalysis2020
CLUE Emotion Analysis Dataset 细粒度情感分析数据集
Stars: ✭ 3 (-91.18%)
Mutual labels:  sentiment-analysis
pystocklib
Python library to Fetch & Analyze Stock Market data.
Stars: ✭ 23 (-32.35%)
Mutual labels:  sentiment-analysis
twitter-aws-comprehend
An app to analyze tweets using Amazon Comprehend's Sentiment Analysis service
Stars: ✭ 13 (-61.76%)
Mutual labels:  sentiment-analysis
phone-reviews-nlp
Modern NLP and sentiment analysis on amazon mobile phone reviews
Stars: ✭ 21 (-38.24%)
Mutual labels:  sentiment-analysis
Scon-ABSA
[CIKM 2021] Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning
Stars: ✭ 17 (-50%)
Mutual labels:  sentiment-analysis
PlanSum
[AAAI2021] Unsupervised Opinion Summarization with Content Planning
Stars: ✭ 25 (-26.47%)
Mutual labels:  sentiment-analysis
twitter mining
Twitter Mining in Java
Stars: ✭ 25 (-26.47%)
Mutual labels:  sentiment-analysis
Chinese financial sentiment dictionary
A Chinese financial sentiment word dictionary
Stars: ✭ 67 (+97.06%)
Mutual labels:  sentiment-analysis
athena
Opinion mining
Stars: ✭ 25 (-26.47%)
Mutual labels:  sentiment-analysis
Sentiment-Analysis-facebook-comments
Detection and Prediction of Users Attitude Based on Real-Time and Batch Sentiment Analysis of Facebook Comments
Stars: ✭ 63 (+85.29%)
Mutual labels:  sentiment-analysis
Aspect-Based-Sentiment-Analysis
A python program that implements Aspect Based Sentiment Analysis classification system for SemEval 2016 Dataset.
Stars: ✭ 57 (+67.65%)
Mutual labels:  sentiment-analysis
fawkes
🚀🚀 Fetch, parse, categorize, summarize user reviews 🚀🚀
Stars: ✭ 83 (+144.12%)
Mutual labels:  sentiment-analysis
QuestionClustering
Clasificador de preguntas escrito en python 3 que fue implementado en el siguiente vídeo: https://youtu.be/qnlW1m6lPoY
Stars: ✭ 15 (-55.88%)
Mutual labels:  sentiment-analysis

Sentiment Analysis with Variable Length sequences in pytorch

This repo contains the code for the this blog.
Our final aim is to build a simple GRU model with concat pooling [5]. For this post I will use Twitter Sentiment Analysis [1] dataset as this is a much easier dataset compared to the competition. Download dataset from [2]

This post focuses on how to implement sequence classification with variable lengths in pure pytorch.

UPDATE - START - May 2019

Added pytorch 1.0 compatible notebook. It uses pytorch 1.1 and ignite training functions. Also better use of pytorch Dataset and Dataloader. Code is more compact and easy to understand.

What is covered in Notebook Pytorch 1.0

  • Process Data through pytorch Dataset
    • Tokenize tweets
    • Build vocabulary
    • Vectorize tweets
  • Make batches through pytorch Dataloader
    • Pad tweets to the max length in the batch
  • Max Pooling and Average Pooling
    • RNN model (GRU) with concat pooling
  • Ignite training callbacks
    • Define ignite training loops
    • Add callback for epoch loss and accuracy
    • Add callback for ModelCheckpoint
    • Add callback for EarlyStopping

Added a new repository that contains REST API build in Flask to deploy ML models in production.

UPDATE - END

Prerequisites

  • Python 3.6
  • Basic knowledge of Pytorch 0.3.1
  • Understanding of GRU/LSTM [4]

What is covered in the notebook

  1. Load Data
  2. Simple Data Analysis
  3. Build Vocabulary and tokenize
  4. Unpadded dataset and dataloader
  5. Padded dataset and dataloader
  6. Simple GRU model
  7. GRU model with concat pooling
  8. Max Pooling and Average Pooling
  9. Train

Data Overview

Top 5 rows of dataset

Output from GRU and hidden state

GRU output

Concat Pooling model architecture [5]

GRU model with concat pooling

ToDo

  • Add function to make train/validation split
  • Use pretrained embedding
  • Use bidirectional GRU

References

[1] http://thinknook.com/twitter-sentiment-analysis-training-corpus-dataset-2012-09-22/
[2] http://thinknook.com/wp-content/uploads/2012/09/Sentiment-Analysis-Dataset.zip
[3] https://stackoverflow.com/questions/46387661/how-to-correctly-implement-a-batch-input-lstm-network-in-pytorch
[4] https://colah.github.io/posts/2015-08-Understanding-LSTMs/
[5] https://arxiv.org/abs/1801.06146

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].