All Projects → yangheng95 → PyABSA

yangheng95 / PyABSA

Licence: MIT license
Open Framework for Aspect-based Sentiment Analysis based on state-of-the-art Models

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PyABSA

HAST
Aspect Term Extraction with History Attention and Selective Transformation (IJCAI 2018)
Stars: ✭ 53 (-86.68%)
Mutual labels:  aspect-based-sentiment-analysis, aspect-term-extraction
extra-model
Code to run the ExtRA algorithm for unsupervised topic/aspect extraction on English texts.
Stars: ✭ 43 (-89.2%)
Mutual labels:  aspect-based-sentiment-analysis
Scon-ABSA
[CIKM 2021] Enhancing Aspect-Based Sentiment Analysis with Supervised Contrastive Learning
Stars: ✭ 17 (-95.73%)
Mutual labels:  aspect-based-sentiment-analysis
Transferable-E2E-ABSA
Transferable End-to-End Aspect-based Sentiment Analysis with Selective Adversarial Learning (EMNLP'19)
Stars: ✭ 62 (-84.42%)
Mutual labels:  aspect-based-sentiment-analysis
Position-Aware-Tagging-for-ASTE
Code and models for the paper " Position-Aware Tagging for Aspect Sentiment Triplet Extraction", EMNLP 2020.
Stars: ✭ 70 (-82.41%)
Mutual labels:  aspect-based-sentiment-analysis
Covolution over Dependency Tree EMNLP2019
Here is the code for the paper ``Aspect-Level Sentiment Analysis via Convolution over Dependency Tree'' accepted by EMNLP2019.
Stars: ✭ 17 (-95.73%)
Mutual labels:  aspect-based-sentiment-analysis
SA-DL
Sentiment Analysis with Deep Learning models. Implemented with Tensorflow and Keras.
Stars: ✭ 35 (-91.21%)
Mutual labels:  aspect-based-sentiment-analysis
MGAN
Exploiting Coarse-to-Fine Task Transfer for Aspect-level Sentiment Classification (AAAI'19)
Stars: ✭ 44 (-88.94%)
Mutual labels:  aspect-based-sentiment-analysis
AspectBasedSentimentAnalysis
Aspect Based Sentiment Analysis is a special type of sentiment analysis. In an explicit aspect, opinion is expressed on a target(opinion target), this aspect-polarity extraction is known as ABSA.
Stars: ✭ 61 (-84.67%)
Mutual labels:  aspect-based-sentiment-analysis
MemNet ABSA
No description or website provided.
Stars: ✭ 20 (-94.97%)
Mutual labels:  aspect-based-sentiment-analysis
PBAN-PyTorch
A Position-aware Bidirectional Attention Network for Aspect-level Sentiment Analysis, PyTorch implementation.
Stars: ✭ 33 (-91.71%)
Mutual labels:  aspect-based-sentiment-analysis
ACSA
Papers, models and datasets for Aspect-Category Sentiment Analysis.
Stars: ✭ 50 (-87.44%)
Mutual labels:  aspect-based-sentiment-analysis
ABSADatasets
Public & Community-shared datasets for Aspect-based sentiment analysis and Text Classification
Stars: ✭ 49 (-87.69%)
Mutual labels:  pyabsa

PyABSA - Open Framework for Aspect-based Sentiment Analysis

PyPI - Python Version PyPI Downloads Downloads License

total views total views per week total clones total clones per week

PWC

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.

| Overview | HuggingfaceHub | ABDADatasets | ABSA Models | Colab Tutorials | Troubleshooting(常见问题解决)

Try our demos on Huggingface Space

Notice

This repository is based on our papers for ABSA research. Here are the papers that you can cite or refer to for your implementations:

Aspect sentiment polarity classification models
  1. Back to Reality: Leveraging Pattern-driven Modeling to Enable Affordable Sentiment Dependency Learning ( e.g., Fast-LSA, 2020)
  2. Learning for target-dependent sentiment based on local context-aware embedding ( e.g., LCA-Net, 2020)
  3. LCF: A Local Context Focus Mechanism for Aspect-Based Sentiment Classification ( e.g., LCF-BERT, 2019)
Aspect sentiment polarity classification & Aspect term extraction models
  1. A multi-task learning model for Chinese-oriented aspect polarity classification and aspect term extraction] ( e.g., Fast-LCF-ATEPC, 2020)
  2. (Arxiv) A multi-task learning model for Chinese-oriented aspect polarity classification and aspect term extraction

If you are looking for the original proposal of local context focus, here are some introduction at here.

About Performance

Aspect-term extraction
Models Laptop14 (APC-Acc) Laptop14 (ATE-F1) Restaurant14 (APC-Acc) Restaurant14 (ATE-F1)
FAST-LCF-ATEPC (BERT) 80.72 85.75 86.40 89.29
FAST-LCF-ATEPC (DeBERTa) 83.65 89.03 90.52 91.77
FAST-LCF-ATEPC (DeBERTa-Large) 85.06 87.76 90.70 92.50
Aspect-based sentiment analysis
Models Laptop14 (Acc) Restaurant14 (acc) Models Laptop14 (Acc) Restaurant14 (acc)
FAST-LSA-P(DeBERTa) 84.33 89.91 FAST-LSA-P(DeBERTa-Large) 86.00 90.33
FAST-LSA-T(DeBERTa) 84.80 89.91 FAST-LSA-T(DeBERTa-Large) 86.31 90.86
FAST-LSA-S(DeBERTa) 84.17 89.64 FAST-LSA-S(DeBERTa-Large) 86.21 89.38

Package Overview

pyabsa package root (including all interfaces)
pyabsa.functional recommend interface entry
pyabsa.functional.checkpoint checkpoint manager entry, inference model entry
pyabsa.functional.dataset datasets entry
pyabsa.functional.config predefined config manager
pyabsa.functional.trainer training module, every trainer return a inference model

Installation

install via pip

To use PyABSA, install the latest version from pip or source code:

pip install -U pyabsa

install via source

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

Examples

  1. Train a model of aspect term extraction
from pyabsa.functional import ATEPCModelList
from pyabsa.functional import Trainer, ATEPCTrainer
from pyabsa.functional import ABSADatasetList
from pyabsa.functional import ATEPCConfigManager

atepc_config = ATEPCConfigManager.get_atepc_config_english()

atepc_config.pretrained_bert = 'microsoft/deberta-v3-base'
atepc_config.model = ATEPCModelList.FAST_LCF_ATEPC
dataset_path = ABSADatasetList.Restaurant14
# or your local dataset: dataset_path = 'your local dataset path'

aspect_extractor = ATEPCTrainer(config=atepc_config,
                                dataset=dataset_path,
                                from_checkpoint='',  # set checkpoint to train on the checkpoint.
                                checkpoint_save_mode=1,
                                auto_device=True
                                ).load_trained_model()
  1. Inference Example of aspect term extraction
from pyabsa.functional import ABSADatasetList
from pyabsa.functional import ATEPCCheckpointManager

examples = ['But the staff was so nice to us .',
            'But the staff was so horrible to us .',
            r'Not only was the food outstanding , but the little ` perks \' were great .',
            'It took half an hour to get our check , which was perfect since we could sit , have drinks and talk !',
            'It was pleasantly uncrowded , the service was delightful , the garden adorable , '
            'the food -LRB- from appetizers to entrees -RRB- was delectable .',
            'How pretentious and inappropriate for MJ Grill to claim that it provides power lunch and dinners !'
            ]

inference_source = ABSADatasetList.Restaurant14
aspect_extractor = ATEPCCheckpointManager.get_aspect_extractor(checkpoint='multilingual2')
atepc_result = aspect_extractor.extract_aspect(inference_source=inference_source,
                                               save_result=True,
                                               print_result=True,  # print the result
                                               pred_sentiment=True,  # Predict the sentiment of extracted aspect terms
                                               )
  1. Get available checkpoints from Google Drive

PyABSA will check the latest available checkpoints before and load the latest checkpoint from Google Drive. To view available checkpoints, you can use the following code and load the checkpoint by name:

from pyabsa import available_checkpoints

# The results of available_checkpoints() depend on the PyABSA version
checkpoint_map = available_checkpoints()  # show available checkpoints of PyABSA of current version 

If you can not access to Google Drive, you can download our checkpoints and load the unzipped checkpoint manually.

Contribution

We expect that you can help us improve this project, and your contributions are welcome. You can make a contribution in many ways, including:

  • Share your custom dataset in PyABSA and ABSADatasets
  • Integrates your models in PyABSA. (You can share your models whether it is or not based on PyABSA. if you are interested, we will help you)
  • Raise a bug report while you use PyABSA or review the code (PyABSA is a individual project driven by enthusiasm so your help is needed)
  • Give us some advice about feature design/refactor (You can advise to improve some feature)
  • Correct/Rewrite some error-messages or code comment (The comments are not written by native english speaker, you can help us improve documents)
  • Create an example script in a particular situation (Such as specify a SpaCy model, pretrained-bert type, some hyper-parameters)
  • Star this repository to keep it active

License

PyABSA is released under MIT licence, please cite this repo (or papers) or attach the author information in your work (repository, blog, product, etc.)

This repository is developed and maintained by HENG YANG (yangheng95@GitHub), with great contribution from community researchers. You can try donating to help improve PyABSA. Thanks very much!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].