Giter Site home page Giter Site logo

lipika-dewangan / pyabsa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yangheng95/pyabsa

0.0 0.0 0.0 32.58 MB

ABSA, Text Classification, Text Augmentation, RNA Sequence Classification, Sequence Regression Model, Text Adversarial defense, etc.; 细粒度情感分析,文本分类,文本增强,RNA分类,序列回归,文本对抗防御等等

Home Page: https://pyabsa.readthedocs.io/en/latest/

License: MIT License

Python 61.64% Jupyter Notebook 38.36%

pyabsa's Introduction

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

Note: If you need to find the v1.x version, please visit release. The final release of v1.x is v1.16.27

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.

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.

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
import random

from pyabsa import AspectTermExtraction as ATEPC

config = ATEPC.ATEPCConfigManager.get_atepc_config_english()
config.model = ATEPC.ATEPCModelList.FAST_LCF_ATEPC
config.evaluate_begin = 0
config.max_seq_len = 512
config.pretrained_bert = 'yangheng/deberta-v3-base-absa'
config.l2reg = 1e-8
config.seed = random.randint(1, 100)
config.use_bert_spc = True
config.use_amp = False
config.cache_dataset = False

chinese_sets = ATEPC.ATEPCDatasetList.Multilingual

aspect_extractor = ATEPC.ATEPCTrainer(config=config,
                                      dataset=chinese_sets,
                                      checkpoint_save_mode=1,
                                      auto_device=True
                                      ).load_trained_model()

atepc_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 !'
                  ]
aspect_extractor.batch_predict(inference_source=atepc_examples,  #
                               save_result=True,
                               print_result=True,  # print the result
                               pred_sentiment=True,  # Predict the sentiment of extracted aspect terms
                               )

  1. Inference Example of aspect term extraction
from pyabsa import AspectTermExtraction as ATEPC

# checkpoint_map = available_checkpoints(from_local=False)


aspect_extractor = ATEPC.AspectExtractor('multilingual',
                                         auto_device=True,  # False means load model on CPU
                                         cal_perplexity=True,
                                         )

inference_source = ATEPC.ATEPCDatasetList.SemEval
atepc_result = aspect_extractor.batch_predict(inference_source=inference_source,  #
                                              save_result=True,
                                              print_result=True,  # print the result
                                              pred_sentiment=True,  # Predict the sentiment of extracted aspect terms
                                              )

print(atepc_result)
  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

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:

  • 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

Citation

@misc{YangL2022,
    title = {PyABSA: Open Framework for Aspect-based Sentiment Analysis},
    author = {Yang, Heng and Li, Ke},
    doi = {10.48550/ARXIV.2208.01368},
    url = {https://arxiv.org/abs/2208.01368},
    keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
    publisher = {arXiv},
    year = {2022},
    copyright = {arXiv.org perpetual, non-exclusive license}
}

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.)

pyabsa's People

Contributors

yangheng95 avatar xumayi avatar allcontributors[bot] avatar lpfy avatar jackie930 avatar brightgems avatar francisdacian avatar brieucdandin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.