RepositoryPythonSGSingapore
soujanyaporia

soujanyaporia/aspect-extraction

Aspect extraction from product reviews - window-CNN+maxpool+CRF, BiLSTM+CRF, MLP+CRF

159stars
37forks
1issues
1views

Aspect extraction from product reviews with Tensorflow

This repo has multiple sequential models for aspect extraction from product reviews.

Citation

If the code is useful in your research, please cite the following paper:

Poria, S., Cambria, E. and Gelbukh, A., 2016. Aspect extraction for opinion mining with a deep convolutional neural network. Knowledge-Based Systems, 108, pp.42-49.

Task

Given a sentence, the task is to extract aspects. Here is an example

I like the battery life of this phone"

Converting this sentence to IOB would look like this -

I O
like O
the O
battery B-A
life I-A
of O
this O
phone O

Model

Similar to Ma and Hovy.

  • concatenate final states of a bi-lstm on character embeddings to get a character-based representation of each word
  • concatenate this representation to a standard word vector representation (GloVe here)
  • run a bi-lstm on each sentence to extract contextual representation of each word
  • decode with a linear chain CRF

Similar to [Collobert et al.] (http://ronan.collobert.com/pub/matos/2011_nlp_jmlr.pdf)

  • form a window around the word to tag
  • apply MLP on that window
  • obtain logits
  • apply viterbi (CRF) for sequence tagging

Similar to Poria et al.

  • form a window around the word to tag
  • apply CNN on that window
  • apply maxpool on that window (Caution: different from global maxpool)
  • obtain logits
  • apply CRF for sequence tagging

XML to IOB

python xmlToIOB.py

Details

Download Glove embeddings (GloVe: http://nlp.stanford.edu/data/glove.840B.300d.zip )

  1. [DO NOT MISS THIS STEP] Build vocab from the data and extract trimmed glove vectors according to the config in model/config.py.
python build_data.py
  1. Train the model with
python train.py
  1. Evaluate and interact with the model with
python evaluate.py

Data iterators and utils are in model/data_utils.py and the model with training/test procedures is in model/aspect_model.py

Training Data

The training data must be in the following format (identical to the CoNLL2003 dataset).

A default test file is provided to help you getting started.

The	O
duck	B-A
confit	I-A
is	O
always	O
amazing	O
and	O
the	O
foie	B-A
gras	I-A
terrine	I-A
with	I-A
figs	I-A
was	O
out	O
of	O
this	O
world	O

The	O
wine	B-A
list	I-A
is	O
interesting	O
and	O
has	O
many	O
good	O
values	O

Once you have produced your data files, change the parameters in config.py like

# dataset
filename_train = "data/ABSA16_Restaurants_Train_SB1_v2_mod.iob"
filename_dev = "data/EN_REST_SB1_TEST_2016_mod.iob"
filename_test = "data/EN_REST_SB1_TEST_2016_mod.iob"

Result

Chunk based evaluation

Laptop 2014 -> F1 - 79.93

Restaurant 2014 -> F1 - 84.22

Partial matching based evaluation

Laptop 2014 -> F1 - 86.84
Restaurant 2014 -> F1 - 88.42

License

This project is licensed under the terms of the apache 2.0 license (as Tensorflow and derivatives). If used for research, citation would be appreciated.

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
nl8590687/ASRT_SpeechRecognition

A Deep-Learning-Based Chinese Speech Recognition System 基于深度学习的中文语音识别系统

8.4k
Apr 10, 2026
RepositoryPython
ScalaConsultants/Aspect-Based-Sentiment-Analysis

💭 Aspect-Based-Sentiment-Analysis: Transformer & Explainable ML (TensorFlow)

584
Sep 7, 2026
RepositoryPython
jidasheng/bi-lstm-crf

A PyTorch implementation of the BI-LSTM-CRF model.

263
Oct 30, 2024
RepositoryPython
heshenghuan/LSTM-CRF

A (CNN+)RNN(LSTM/BiLSTM)+CRF model for sequence labelling.:smirk:

139
Jan 9, 2018
RepositoryPython
yafangy/Review_aspect_extraction

CNN-based model to realize aspect extraction of restaurant reviews based on pre-trained word embeddings and part-of-speech tagging

102
Jul 12, 2019
RepositoryJupyter Notebook
bentrevett/pytorch-sentiment-analysis

Tutorials on getting started with PyTorch and TorchText for sentiment analysis.

4.6k
Mar 27, 2024
Modeltext-classification
yangheng/deberta-v3-base-absa-v1.1

State-of-the-Art Multilingual Sentiment Analysis Multilingual - English, Chinese, Arabic, Dutch, French, Russian, Spanish, Turkish, etc. Tired of the high costs, slow latency, and massive computational footprint of Large Language Models? This is the...

♥0
47.2k
Aug 12, 2025
Repository
HanXinzi-AI/awesome-NLP-resources

a collection of NLP projects&tools. 自然语言处理方向项目和工具集合。

240
Jun 3, 2024
RepositoryHTML
wayfair-incubator/extra-model

Code to run the ExtRA algorithm for unsupervised topic/aspect extraction on English texts.

53
Aug 12, 2026