pyabsa

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;

https://github.com/yangheng95/pyabsa

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
    Links to: acm.org
  • Committers with academic emails
    2 of 15 committers (13.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.7%) to scientific vocabulary

Keywords

adversarial aspect-based-sentiment-analysis aspect-sentiment-triplet-extraction aspect-term-extraction lcf-bert pyabsa pytorch regression
Last synced: 6 months ago · JSON representation ·

Repository

Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;

Basic Info
  • Host: GitHub
  • Owner: yangheng95
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: v2
  • Homepage: https://pyabsa.readthedocs.io
  • Size: 36.8 MB
Statistics
  • Stars: 1,051
  • Watchers: 12
  • Forks: 171
  • Open Issues: 65
  • Releases: 14
Topics
adversarial aspect-based-sentiment-analysis aspect-sentiment-triplet-extraction aspect-term-extraction lcf-bert pyabsa pytorch regression
Created over 6 years ago · Last pushed 6 months ago
Metadata Files
Readme License Citation

README.MD

PyABSA: A Modularized Framework for Reproducible Aspect-based Sentiment Analysis

PyPI Paper Views/Week Clones/Week License

PyABSA is a modular, reproducible framework for Aspect-based Sentiment Analysis (ABSA) — from research to production. It unifies training/evaluation/inference across ABSA subtasks, ships with ready-to-use checkpoints, and offers dataset tooling and metric visualization.

  • 📄 Paper: CIKM 2023 [ACM DL]
  • 📚 Docs: https://pyabsa.readthedocs.io/
  • 🧪 Examples: examples-v2/
  • 🧰 Dataset hub: ABSADatasets
  • 🌐 Online demos: see links below

Getting Started

Welcome to PyABSA! This guide will walk you through the initial steps to get you up and running with the framework.

Prerequisites

Make sure you have Python 3.8 or later installed on your system. You can check your Python version by running:

python --version

Installation

For a straightforward installation, you can use pip:

pip install -U pyabsa

This command installs the core components of PyABSA. For more advanced features like text augmentation and visualization, you may need to install additional dependencies.

Your First Code

After installation, you can start using PyABSA with just a few lines of code. Here’s a simple example to get you started:

python3 from pyabsa import AspectTermExtraction as ATEPC

```python3

Initialize the aspect extractor

aspectextractor = ATEPC.AspectExtractor('multilingual', autodevice=True) ```

```python3

Perform aspect extraction on a sample sentence

result = aspectextractor.predict( ['I love this movie, it is so great!'], saveresult=True, print_result=True ) ```


Features at a Glance

  • Unified API for training / evaluation / inference across ABSA tasks
  • Model Zoo with available_checkpoints() and auto-download
  • Visualization for evaluation metrics
  • Human-in-the-loop dataset annotation helpers
  • Text augmentation for classification & adversarial defense
  • Automatic device selection; simple CPU/GPU switching

See the Introduction for the full feature list.


Supported Tasks

| Task | What it does | Python API entry | Demo | |--------------------------------------------------------------|-------------------------------------------------------------|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| | APC (Aspect Polarity Classification) | Classify sentiment for a given aspect | pyabsa.AspectPolarityClassification | Multilingual APC (HF Space) | | ATEPC (Aspect Term Extraction & Polarity Classification) | Extract aspect terms and their sentiment | pyabsa.AspectTermExtraction | ATEPC (HF Space) | | ASTE (Aspect Sentiment Triplet Extraction) | Extract (aspect, opinion, sentiment) triplets | pyabsa.AspectSentimentTripletExtraction | Triplet Extraction (HF Space) | | ASQP / ACOS | Extract (aspect, category, opinion, sentiment) quadruples | pyabsa.AspectCategoryOpinionSentimentTripletExtraction | Quadruple Extraction (HF Space) | | Others | Text classification, adversarial defense, etc. | pyabsa.TextClassification, pyabsa.TextAdversarialDefense, ... | – |

Full list and

tutorials: Supported Tasks · Tutorials


Installation

PyPI (recommended):

bash pip install -U pyabsa

From source (latest mainline):

bash git clone https://github.com/yangheng95/PyABSA --depth=1 cd PyABSA python setup.py install

Requirements: Python >= 3.8; PyTorch and Transformers will be installed as dependencies. For advanced/optional dependencies (augmentation, visualization, demos), see the Installation guide.


Quickstart

1) Extract aspect terms and classify their sentiments (ATEPC)

```python from pyabsa import AspectTermExtraction as ATEPC, available_checkpoints

View available checkpoints (local + remote)

print(available_checkpoints())

aspectextractor = ATEPC.AspectExtractor( 'multilingual', autodevice=True, # False -> force CPU cal_perplexity=True )

Single instance

aspectextractor.predict( ['I love this movie, it is so great!'], saveresult=True, printresult=True, ignoreerror=True )

Batch inference from a built-in dataset

inferencesource = ATEPC.ATEPCDatasetList.Restaurant16 result = aspectextractor.batchpredict( targetfile=inferencesource, saveresult=True, printresult=True, predsentiment=True ) print(result) ```

2) Aspect-based sentiment classification (APC)

```python from pyabsa import AspectPolarityClassification as APC, available_checkpoints

print(availablecheckpoints(showckpts=True))

classifier = APC.SentimentClassifier( 'multilingual', autodevice=True, calperplexity=True )

classifier.predict( ['I love this movie, it is so great!'], saveresult=True, printresult=True, ignore_error=True )

inferencesource = APC.APCDatasetList.Laptop14 apcresult = classifier.batchpredict( targetfile=inferencesource, saveresult=True, printresult=True, predsentiment=True ) print(apc_result) ```

More examples (training, evaluation, visualization, deployment): see examples-v2/ and Tutorials.


Model Zoo & Checkpoints

  • List all available checkpoints: python from pyabsa import available_checkpoints print(available_checkpoints())
  • PyABSA resolves checkpoints across local/remote registries and auto-downloads when needed. See the docs for * CheckpointManager* and API Reference.

Datasets

  • Public & community-contributed datasets: ABSADatasets
  • To prepare your own datasets (format, semi-automatic annotation, naming conventions), see Integrated Datasets and Notice in the docs.
  • You can also use built-in dataset enums (e.g., APC.APCDatasetList.Laptop14, ATEPC.ATEPCDatasetList.Restaurant16) to run quick experiments.

Documentation


Roadmap (indicative)

  • Python 3.13 compatibility verification and wheels
  • Extended dataset templates & validators
  • Streamlined model registry and checkpoint metadata
  • Better Hugging Face integration (Spaces & model cards)
  • Optional plugins: advanced augmentation, evaluation dashboards

Have a suggestion? Please open a GitHub Discussion or Issue.


Known Limitations

  • v2 introduced breaking API changes; older scripts may need updates.
  • Some checkpoints require a one-time download at first use.
  • GPU is optional but recommended for training and large-scale inference.
  • Certain advanced features have extra dependencies; see the Installation guide.

Citation

If you use PyABSA in your research or products, please cite:

CIKM 2023

bibtex @inproceedings{YangZL23, author = {Heng Yang and Chen Zhang and Ke Li}, title = {PyABSA: A Modularized Framework for Reproducible Aspect-based Sentiment Analysis}, booktitle = {Proceedings of the 32nd ACM International Conference on Information and Knowledge Management (CIKM 2023)}, pages = {5117--5122}, year = {2023}, doi = {10.1145/3583780.3614752} }

arXiv 2022 (optional)

bibtex @article{YangL22, author = {Heng Yang and Ke Li}, title = {PyABSA: Open Framework for Aspect-based Sentiment Analysis}, journal = {CoRR}, volume = {abs/2208.01368}, year = {2022}, doi = {10.48550/arXiv.2208.01368} }


Contributing

Contributions are welcome! You can:

  • Share custom datasets via ABSADatasets
  • Integrate your models (with or without PyABSA base—we can help adapt)
  • Report bugs, improve messages & docs, or add example scripts
  • Propose features or refactors

Guidelines

  • Use Python 3.8+; please run at least one GPU and one CPU pass for examples before submitting.
  • Keep changes reproducible (seeds, configs) and scoped.
  • In PR description, summarize motivation and impact.

Community and Support

Join our community to stay updated, ask questions, and contribute to the project.

  • GitHub Discussions: For questions, feature requests, and discussions.
  • Issue Tracker: To report bugs and track issues.
  • Contributing: We welcome contributions! Please see our contributing guidelines for more details.

License

MIT License © PyABSA contributors


Owner

  • Name: Heng Yang
  • Login: yangheng95
  • Kind: user
  • Location: Exeter, UK

University of Exeter

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: >-
  PyABSA - Open Framework for Aspect-based Sentiment
  Analysis
message: 'https://github.com/yangheng95/PyABSA'
type: software
authors:
  - given-names: HENG
    name-particle: YANG
    email: hy345@exeter.ac.uk
    affiliation: University of Exeter
    orcid: 'https://orcid.org/0000-0002-6831-196X'

GitHub Events

Total
  • Issues event: 4
  • Watch event: 105
  • Issue comment event: 9
  • Push event: 271
  • Pull request event: 4
  • Fork event: 11
Last Year
  • Issues event: 4
  • Watch event: 105
  • Issue comment event: 9
  • Push event: 271
  • Pull request event: 4
  • Fork event: 11

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 711
  • Total Committers: 15
  • Avg Commits per committer: 47.4
  • Development Distribution Score (DDS): 0.53
Top Committers
Name Email Commits
yangheng95 y****g@m****n 334
Yang Heng y****5@1****m 235
yangheng h****5@e****k 63
XuMayi 1****9@1****m 27
YangHeng 5****5@u****m 20
allcontributors[bot] 4****]@u****m 12
lpfy l****y@m****m 5
jackie j****l@1****m 4
george.pan g****n@u****m 3
kmywykajps6q7ulgikxm5m56mhmlxi3rbasjl3tnglmos46ywmvq b****s@l****n 2
XuMayi 5****i@u****m 2
杨恒 y****g@y****l 1
Ryan 2****5@q****m 1
杨恒 y****g@y****n 1
brieucdandin b****1@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 151
  • Total pull requests: 38
  • Average time to close issues: 11 days
  • Average time to close pull requests: about 5 hours
  • Total issue authors: 100
  • Total pull request authors: 5
  • Average comments per issue: 3.4
  • Average comments per pull request: 0.71
  • Merged pull requests: 30
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 4
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 minutes
  • Issue authors: 4
  • Pull request authors: 2
  • Average comments per issue: 0.25
  • Average comments per pull request: 0.5
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ningmiaokai (7)
  • christianjosef27 (4)
  • LaurentVeyssier (4)
  • Winnieliu0504 (4)
  • yaoysyao (3)
  • KadriMufti (3)
  • Kensvin28 (3)
  • BBabuRAA (3)
  • combokang (3)
  • ImSanjayChintha (3)
  • lisabecker-ml6 (2)
  • cheemsbaby (2)
  • Jai-Agarwal-04 (2)
  • karimmahalian (2)
  • BLM3826 (2)
Pull Request Authors
  • yangheng95 (30)
  • boba-and-beer (2)
  • surabhiwaingankar (2)
  • brightgems (2)
  • christianjosef27 (1)
Top Labels
Issue Labels
bug (29)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 4,629 last-month
  • Total docker downloads: 45
  • Total dependent packages: 1
  • Total dependent repositories: 4
  • Total versions: 234
  • Total maintainers: 1
pypi.org: pyabsa

This tool provides the state-of-the-art models for aspect term extraction (ATE), aspect polarity classification (APC), and text classification (TC).

  • Versions: 234
  • Dependent Packages: 1
  • Dependent Repositories: 4
  • Downloads: 4,629 Last month
  • Docker Downloads: 45
Rankings
Stargazers count: 2.3%
Docker downloads count: 3.7%
Downloads: 3.8%
Forks count: 4.1%
Average: 4.4%
Dependent packages count: 4.8%
Dependent repos count: 7.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/python-package.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v3 composite
docs/requirements.txt pypi
  • Cython *
  • Sphinx *
  • autocuda *
  • boostaug *
  • findfile *
  • gitpython *
  • ipykernel *
  • ipython *
  • ipython-genutils *
  • ipywidgets *
  • metric-visualizer *
  • nbclient *
  • nbconvert *
  • nbsphinx *
  • networkx *
  • pyabsa *
  • pytorch_warmup *
  • recommonmark *
  • scipy *
  • sentencepiece *
  • seqeval *
  • spacy *
  • sphinx-autoapi *
  • sphinx-autobuild *
  • sphinx-copybutton *
  • sphinx-markdown-tables *
  • sphinx-rtd-theme *
  • sphinxcontrib-applehelp *
  • sphinxcontrib-devhelp *
  • sphinxcontrib-htmlhelp *
  • sphinxcontrib-jsmath *
  • sphinxcontrib-qthelp *
  • sphinxcontrib-serializinghtml *
  • sqlitedict *
  • stanza *
  • tensorboard-data-server *
  • tensorboard-plugin-wit *
  • termcolor *
  • torch *
  • tqdm *
  • transformers *
  • typing_extensions *
  • update-checker *
  • widgetsnbextension *
requirements.txt pypi
  • arxiv *
  • autocuda *
  • boostaug *
  • datasets *
  • findfile *
  • gensim *
  • gitpython *
  • gradio *
  • metric-visualizer *
  • networkx *
  • nlpaug *
  • nltk *
  • numpy *
  • packaging *
  • pandas *
  • protobuf <4.0.0
  • pyabsa *
  • pytorch_warmup *
  • requests *
  • scikit-learn *
  • sentencepiece *
  • seqeval *
  • setuptools *
  • spacy *
  • tensorflow *
  • tensorflow_hub *
  • termcolor *
  • tokenizers *
  • torch >1.0.0
  • tqdm *
  • transformers *
  • typing_extensions *
  • update-checker *
setup.py pypi
  • autocuda >=0.16
  • boostaug >=2.3.5
  • findfile >=2.0.0
  • gitpython *
  • metric-visualizer >=0.9.6
  • networkx *
  • pandas *
  • protobuf <4.0.0
  • pytorch_warmup *
  • sentencepiece *
  • seqeval *
  • spacy *
  • termcolor *
  • torch >=1.0.0
  • tqdm *
  • transformers >=4.29.0
  • typing_extensions *
  • update-checker *
.github/workflows/traffic2badge.yml actions
  • actions/checkout v2.3.4 composite
  • actions/github-script v3.1.0 composite
  • peaceiris/actions-gh-pages v3 composite
  • peaceiris/actions-gh-pages v3.7.3 composite
  • yi-Xu-0100/traffic-to-badge v1.4.0 composite
docs/environment.yml conda
  • python 3.9.*
  • pytorch
  • pytorch-cuda