← all repositories
ScalaConsultants/Aspect-Based-Sentiment-Analysis

BERT that explains itself: sentiment analysis with a built-in skeptic

A TensorFlow package for aspect-based sentiment analysis that adds a "professor" layer to second-guess and explain model predictions.

583 stars Python Language ModelsOther AI
Aspect-Based-Sentiment-Analysis
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

This package classifies sentiment toward specific aspects in potentially long texts—think “price” or “slack” in a product review—using BERT-based transformers. It wraps the whole process in a pipeline that tokenizes, encodes, predicts, and then reviews its own work before handing you an answer.

The interesting bit

The authors bolt on a Professor component that supervises predictions using a BasicPatternRecognizer. This auxiliary model inspects self-attention weights to generate approximate explanations—weighted token patterns that hint at why BERT leaned positive or negative. The authors are admirably upfront that this is heuristic, not proven causation, and that attention-based explanations can mislead.

Key highlights

  • Ready-to-use pretrained models for restaurant and laptop domains (SemEval 2014)
  • Pipeline exposes every stage: preprocess → tokenize → encode → predict → review → postprocess
  • Long documents get split via SpaCy’s CNN sentence segmenter to avoid fuzzy neutral drift
  • BasicPatternRecognizer generates visual pattern summaries for human inspection
  • Python 3.7, pip-installable, with Colab-era TensorFlow compatibility

Caveats

  • The pattern recognizer is explicitly rule-based and born from “prior knowledge,” not trained; the README warns against interpreting explanations too literally
  • Performance on SemEval 2014 trails SOTA (LCF-ATEPC, BERT-ADA) by 3–5 points
  • Python 3.7 requirement dates the project; no commits or updates are visible in the provided sources

Verdict

Worth a look if you need aspect-level sentiment with any transparency at all—rare in this space. Skip if you need bleeding accuracy or a maintained, modern stack; this is research cleanup, not production infrastructure.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.