Sarcasm Detection using Neural Networks
URL: https://github.com/rishabhmisra/Sarcasm-Detection-using-NN
Description
This repository is a PyTorch implementation of the work presented in the paper “Modelling Context with User Embeddings for Sarcasm Detection in Social Media” (paper link). The neural network model uses the tweet content and corresponding user embeddings (context) to classify tweets as sarcastic or non-sarcastic. The repository also includes an improved framework for sarcasm detection using a Hybrid Neural Network (HNN) approach (paper link).
Methods and Models
- Model Type: Hybrid Neural Network (HNN)
- Model Inputs:
- Tweet content
- User embeddings (context)
- Approach:
- Original work uses a combination of user embeddings and tweet content to predict sarcasm.
- The extended version implements the HNN architecture for improved sarcasm detection.
System Requirements
- Python 2.7
- PyTorch 0.3.1
- Python packages:
- gensim
- yandex.translate
- ipdb
Instructions for Running the Code
- Pre-requisites:
- Obtain pre-trained word embeddings (e.g., Skip-gram) and user embeddings (user embeddings link).
- Place word embeddings in
DATA/embeddings/and name the filewords.txt. - Place user embeddings in
DATA/embeddings/and name the fileusr2vec.txt.
- Running the Code:
- To run the original code:
python train_CUE_CNN.py - To run the RNN + CNN Hybrid model on the new dataset:
python Headlines_RNN.py
- To run the original code:
Output, Results, and Visualization
- A
progressfolder is generated with subfolders for each run. - Inside each run folder, the following files are generated:
- logs.txt: Contains loss and accuracy on train/test/validation sets after each epoch.
- stats.jpg: Plots the train/test/validation loss and accuracy on a single graph.
Results
No explicit results (accuracy, precision, recall, F1-score) are provided in the repository. However, the paper associated with this work may contain evaluation metrics.
Note
The utility files, pre-trained user embeddings, and raw tweet IDs were obtained from the Original CUE-CNN repository.