Hi, there! Please star this repo if it helps you! Each Star helps PyABSA go further, many thanks. PyABSA is a free and open-source tool for everyone, but please do not forget to attach the (informal or formal) author information and project address in your works, products and publications, etc.
Apart from the paper, there are two new features in PyABSA: Aspect sentiment triplet extraction and Aspect quadruple extraction. We have deployed the demos on Huggingface Space, you can try them online.
We have prepared many examples for different tasks. Please refer to Examples for more usage examples.
To use PyABSA, install the latest version from pip or source code:
pip install -U pyabsa
git clone https://github.com/yangheng95/PyABSA --depth=1
cd PyABSA
python setup.py install
from pyabsa import AspectTermExtraction as ATEPC, available_checkpoints
# you can view all available checkpoints by calling available_checkpoints()
checkpoint_map = available_checkpoints()
aspect_extractor = ATEPC.AspectExtractor('multilingual',
auto_device=True, # False means load model on CPU
cal_perplexity=True,
)
# instance inference
aspect_extractor.predict(['I love this movie, it is so great!'],
save_result=True,
print_result=True, # print the result
ignore_error=True, # ignore the error when the model cannot predict the input
)
inference_source = ATEPC.ATEPCDatasetList.Restaurant16
atepc_result = aspect_extractor.batch_predict(target_file=inference_source, #
save_result=True,
print_result=True, # print the result
pred_sentiment=True, # Predict the sentiment of extracted aspect terms
)
print(atepc_result)
from pyabsa import AspectPolarityClassification as APC, available_checkpoints
# you can view all available checkpoints by calling available_checkpoints()
checkpoint_map = available_checkpoints(show_ckpts=True)
classifier = APC.SentimentClassifier('multilingual',
auto_device=True, # False means load model on CPU
cal_perplexity=True,
)
# instance inference
classifier.predict(['I love this movie, it is so great!'],
save_result=True,
print_result=True, # print the result
ignore_error=True, # ignore the error when the model cannot predict the input
)
inference_source = APC.APCDatasetList.Laptop14
apc_result = classifier.batch_predict(target_file=inference_source, #
save_result=True,
print_result=True, # print the result
pred_sentiment=True, # Predict the sentiment of extracted aspect terms
)
print(apc_result)
please refer to the documentation: PyABSA Documentation. If you have any questions about the docs, please feel free to raise an issue. Also, you can join to improve the docs.
This repository is based on our papers for ABSA research. Here are the papers that you can cite or refer to for your implementations:
If you are looking for the original proposal of local context focus, here are some introduction at here.
@inproceedings{YangZL23,
author = {Heng Yang and
Chen Zhang and
Ke Li},
editor = {Ingo Frommholz and
Frank Hopfgartner and
Mark Lee and
Michael Oakes and
Mounia Lalmas and
Min Zhang and
Rodrygo L. T. Santos},
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, Birmingham, United Kingdom,
October 21-25, 2023},
pages = {5117--5122},
publisher = {{ACM}},
year = {2023},
url = {https://doi.org/10.1145/3583780.3614752},
doi = {10.1145/3583780.3614752},
timestamp = {Thu, 23 Nov 2023 13:25:05 +0100},
biburl = {https://dblp.org/rec/conf/cikm/0008ZL23.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
This repository is developed and maintained by HENG YANG (yangheng95@GitHub), with great contribution from community researchers. We expect that you can help us improve this project, and your contributions are welcome. You can make a contribution in many ways, including:
PyABSA is released under MIT licence, please cite this repo (or papers) or attach the author information in your work (repository, blog, product, etc.)