Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
1,103
stars
552
commits
Jupyter Notebook
primary language
Sep 11, 2026
updated
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.
examples-v2/Welcome to PyABSA! This guide will walk you through the initial steps to get you up and running with the framework.
Make sure you have Python 3.8 or later installed on your system. You can check your Python version by running:
python --version
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.
After installation, you can start using PyABSA with just a few lines of code. Here’s a simple example to get you started:
from pyabsa import AspectTermExtraction as ATEPC
# Initialize the aspect extractor
aspect_extractor = ATEPC.AspectExtractor('multilingual', auto_device=True)
# Perform aspect extraction on a sample sentence
result = aspect_extractor.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True
)
available_checkpoints() and auto-downloadSee the Introduction for the full feature list.
| 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
PyPI (recommended):
pip install -U pyabsa
From source (latest mainline):
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.
from pyabsa import AspectTermExtraction as ATEPC, available_checkpoints
# View available checkpoints (local + remote)
print(available_checkpoints())
aspect_extractor = ATEPC.AspectExtractor(
'multilingual',
auto_device=True, # False -> force CPU
cal_perplexity=True
)
# Single instance
aspect_extractor.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True,
ignore_error=True
)
# Batch inference from a built-in dataset
inference_source = ATEPC.ATEPCDatasetList.Restaurant16
result = aspect_extractor.batch_predict(
target_file=inference_source,
save_result=True,
print_result=True,
pred_sentiment=True
)
print(result)
from pyabsa import AspectPolarityClassification as APC, available_checkpoints
print(available_checkpoints(show_ckpts=True))
classifier = APC.SentimentClassifier(
'multilingual',
auto_device=True,
cal_perplexity=True
)
classifier.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True,
ignore_error=True
)
inference_source = APC.APCDatasetList.Laptop14
apc_result = classifier.batch_predict(
target_file=inference_source,
save_result=True,
print_result=True,
pred_sentiment=True
)
print(apc_result)
More examples (training, evaluation, visualization, deployment): see
examples-v2/and Tutorials.
from pyabsa import available_checkpoints
print(available_checkpoints())
APC.APCDatasetList.Laptop14, ATEPC.ATEPCDatasetList.Restaurant16)
to run quick experiments.Have a suggestion? Please open a GitHub Discussion or Issue.
v2 introduced breaking API changes; older scripts may need updates.If you use PyABSA in your research or products, please cite:
CIKM 2023
@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)
@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}
}
Contributions are welcome! You can:
Guidelines
Join our community to stay updated, ask questions, and contribute to the project.
MIT License © PyABSA contributors
Jupyter Notebook
72.6%
Python
27.4%
Sentiment Analysis, Text Classification, Text Augmentation, Text Adversarial defense, etc.;
1,103
stars
552
commits
Jupyter Notebook
primary language
Sep 11, 2026
updated
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.
examples-v2/Welcome to PyABSA! This guide will walk you through the initial steps to get you up and running with the framework.
Make sure you have Python 3.8 or later installed on your system. You can check your Python version by running:
python --version
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.
After installation, you can start using PyABSA with just a few lines of code. Here’s a simple example to get you started:
from pyabsa import AspectTermExtraction as ATEPC
# Initialize the aspect extractor
aspect_extractor = ATEPC.AspectExtractor('multilingual', auto_device=True)
# Perform aspect extraction on a sample sentence
result = aspect_extractor.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True
)
available_checkpoints() and auto-downloadSee the Introduction for the full feature list.
| 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
PyPI (recommended):
pip install -U pyabsa
From source (latest mainline):
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.
from pyabsa import AspectTermExtraction as ATEPC, available_checkpoints
# View available checkpoints (local + remote)
print(available_checkpoints())
aspect_extractor = ATEPC.AspectExtractor(
'multilingual',
auto_device=True, # False -> force CPU
cal_perplexity=True
)
# Single instance
aspect_extractor.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True,
ignore_error=True
)
# Batch inference from a built-in dataset
inference_source = ATEPC.ATEPCDatasetList.Restaurant16
result = aspect_extractor.batch_predict(
target_file=inference_source,
save_result=True,
print_result=True,
pred_sentiment=True
)
print(result)
from pyabsa import AspectPolarityClassification as APC, available_checkpoints
print(available_checkpoints(show_ckpts=True))
classifier = APC.SentimentClassifier(
'multilingual',
auto_device=True,
cal_perplexity=True
)
classifier.predict(
['I love this movie, it is so great!'],
save_result=True,
print_result=True,
ignore_error=True
)
inference_source = APC.APCDatasetList.Laptop14
apc_result = classifier.batch_predict(
target_file=inference_source,
save_result=True,
print_result=True,
pred_sentiment=True
)
print(apc_result)
More examples (training, evaluation, visualization, deployment): see
examples-v2/and Tutorials.
from pyabsa import available_checkpoints
print(available_checkpoints())
APC.APCDatasetList.Laptop14, ATEPC.ATEPCDatasetList.Restaurant16)
to run quick experiments.Have a suggestion? Please open a GitHub Discussion or Issue.
v2 introduced breaking API changes; older scripts may need updates.If you use PyABSA in your research or products, please cite:
CIKM 2023
@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)
@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}
}
Contributions are welcome! You can:
Guidelines
Join our community to stay updated, ask questions, and contribute to the project.
MIT License © PyABSA contributors
Jupyter Notebook
72.6%
Python
27.4%