{"id":13535163,"url":"https://github.com/songyouwei/ABSA-PyTorch","last_synced_at":"2025-04-02T00:32:40.141Z","repository":{"id":37285126,"uuid":"132771879","full_name":"songyouwei/ABSA-PyTorch","owner":"songyouwei","description":"Aspect Based Sentiment Analysis, PyTorch Implementations.  基于方面的情感分析，使用PyTorch实现。","archived":false,"fork":false,"pushed_at":"2023-06-12T21:30:16.000Z","size":3887,"stargazers_count":2059,"open_issues_count":94,"forks_count":529,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-03-31T03:07:17.581Z","etag":null,"topics":["aspect-based-sentiment-analysis","attention","bert","natural-language-processing","nlp","sentiment-analysis","sentiment-classification"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/songyouwei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-05-09T14:49:33.000Z","updated_at":"2025-03-30T17:04:41.000Z","dependencies_parsed_at":"2024-01-14T02:37:00.844Z","dependency_job_id":"ddc6d489-6338-4356-852d-e53d778b5d3d","html_url":"https://github.com/songyouwei/ABSA-PyTorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songyouwei%2FABSA-PyTorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songyouwei%2FABSA-PyTorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songyouwei%2FABSA-PyTorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/songyouwei%2FABSA-PyTorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/songyouwei","download_url":"https://codeload.github.com/songyouwei/ABSA-PyTorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246735354,"owners_count":20825221,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aspect-based-sentiment-analysis","attention","bert","natural-language-processing","nlp","sentiment-analysis","sentiment-classification"],"created_at":"2024-08-01T08:00:50.586Z","updated_at":"2025-04-02T00:32:40.089Z","avatar_url":"https://github.com/songyouwei.png","language":"Python","readme":"# ABSA-PyTorch\n\n\u003e Aspect Based Sentiment Analysis, PyTorch Implementations.\n\u003e\n\u003e 基于方面的情感分析，使用PyTorch实现。\n\n![LICENSE](https://img.shields.io/packagist/l/doctrine/orm.svg)\n[![Gitter](https://badges.gitter.im/ABSA-PyTorch/community.svg)](https://gitter.im/ABSA-PyTorch/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n## Requirement\n\n* pytorch \u003e= 0.4.0\n* numpy \u003e= 1.13.3\n* sklearn\n* python 3.6 / 3.7\n* transformers\n\nTo install requirements, run `pip install -r requirements.txt`.\n\n* For non-BERT-based models,\n[GloVe pre-trained word vectors](https://github.com/stanfordnlp/GloVe#download-pre-trained-word-vectors) are required, please refer to [data_utils.py](./data_utils.py) for more detail.\n\n## Usage\n\n### Training\n\n```sh\npython train.py --model_name bert_spc --dataset restaurant\n```\n\n* All implemented models are listed in [models directory](./models/).\n* See [train.py](./train.py) for more training arguments.\n* Refer to [train_k_fold_cross_val.py](./train_k_fold_cross_val.py) for k-fold cross validation support.\n\n### Inference\n\n* Refer to [infer_example.py](./infer_example.py) for both non-BERT-based models and BERT-based models.\n\n### Tips\n\n* For non-BERT-based models, training procedure is not very stable.\n* BERT-based models are more sensitive to hyperparameters (especially learning rate) on small data sets, see [this issue](https://github.com/songyouwei/ABSA-PyTorch/issues/27).\n* Fine-tuning on the specific task is necessary for releasing the true power of BERT.\n\n### Framework\nFor flexible training/inference and aspect term extraction, try [PyABSA](https://github.com/yangheng95/PyABSA), which includes all the models in this repository.\n\n## Reviews / Surveys\n\nQiu, Xipeng, et al. \"Pre-trained Models for Natural Language Processing: A Survey.\" arXiv preprint arXiv:2003.08271 (2020). [[pdf]](https://arxiv.org/pdf/2003.08271)\n\nZhang, Lei, Shuai Wang, and Bing Liu. \"Deep Learning for Sentiment Analysis: A Survey.\" arXiv preprint arXiv:1801.07883 (2018). [[pdf]](https://arxiv.org/pdf/1801.07883)\n\nYoung, Tom, et al. \"Recent trends in deep learning based natural language processing.\" arXiv preprint arXiv:1708.02709 (2017). [[pdf]](https://arxiv.org/pdf/1708.02709)\n\n\n## BERT-based models\n\n### BERT-ADA ([official](https://github.com/deepopinion/domain-adapted-atsc))\n\nRietzler, Alexander, et al. \"Adapt or get left behind: Domain adaptation through bert language model finetuning for aspect-target sentiment classification.\" arXiv preprint arXiv:1908.11860 (2019). [[pdf](https://arxiv.org/pdf/1908.11860)]\n\n### BERR-PT ([official](https://github.com/howardhsu/BERT-for-RRC-ABSA))\n\nXu, Hu, et al. \"Bert post-training for review reading comprehension and aspect-based sentiment analysis.\" arXiv preprint arXiv:1904.02232 (2019). [[pdf](https://arxiv.org/pdf/1904.02232)]\n\n### ABSA-BERT-pair ([official](https://github.com/HSLCY/ABSA-BERT-pair))\n\nSun, Chi, Luyao Huang, and Xipeng Qiu. \"Utilizing bert for aspect-based sentiment analysis via constructing auxiliary sentence.\" arXiv preprint arXiv:1903.09588 (2019). [[pdf](https://arxiv.org/pdf/1903.09588.pdf)]\n\n### LCF-BERT ([lcf_bert.py](./models/lcf_bert.py)) ([official](https://github.com/yangheng95/LCF-ABSA))\n\nZeng Biqing, Yang Heng, et al. \"LCF: A Local Context Focus Mechanism for Aspect-Based Sentiment Classification.\" Applied Sciences. 2019, 9, 3389. [[pdf]](https://www.mdpi.com/2076-3417/9/16/3389/pdf)\n\n### AEN-BERT ([aen.py](./models/aen.py))\n\nSong, Youwei, et al. \"Attentional Encoder Network for Targeted Sentiment Classification.\" arXiv preprint arXiv:1902.09314 (2019). [[pdf]](https://arxiv.org/pdf/1902.09314.pdf)\n\n### BERT for Sentence Pair Classification ([bert_spc.py](./models/bert_spc.py))\n\nDevlin, Jacob, et al. \"Bert: Pre-training of deep bidirectional transformers for language understanding.\" arXiv preprint arXiv:1810.04805 (2018). [[pdf]](https://arxiv.org/pdf/1810.04805.pdf)\n\n\n## Non-BERT-based models\n\n### ASGCN ([asgcn.py](./models/asgcn.py)) ([official](https://github.com/GeneZC/ASGCN))\n\nZhang, Chen, et al. \"Aspect-based Sentiment Classification with Aspect-specific Graph Convolutional Networks.\" Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing. 2019. [[pdf]](https://www.aclweb.org/anthology/D19-1464)\n\n### MGAN ([mgan.py](./models/mgan.py))\n\nFan, Feifan, et al. \"Multi-grained Attention Network for Aspect-Level Sentiment Classification.\" Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. 2018. [[pdf]](http://aclweb.org/anthology/D18-1380)\n\n### AOA ([aoa.py](./models/aoa.py))\n\nHuang, Binxuan, et al. \"Aspect Level Sentiment Classification with Attention-over-Attention Neural Networks.\" arXiv preprint arXiv:1804.06536 (2018). [[pdf]](https://arxiv.org/pdf/1804.06536.pdf)\n\n### TNet ([tnet_lf.py](./models/tnet_lf.py)) ([official](https://github.com/lixin4ever/TNet))\n\nLi, Xin, et al. \"Transformation Networks for Target-Oriented Sentiment Classification.\" arXiv preprint arXiv:1805.01086 (2018). [[pdf]](https://arxiv.org/pdf/1805.01086)\n\n### Cabasc ([cabasc.py](./models/cabasc.py))\n\nLiu, Qiao, et al. \"Content Attention Model for Aspect Based Sentiment Analysis.\" Proceedings of the 2018 World Wide Web Conference on World Wide Web. International World Wide Web Conferences Steering Committee, 2018.\n\n### RAM ([ram.py](./models/ram.py))\n\nChen, Peng, et al. \"Recurrent Attention Network on Memory for Aspect Sentiment Analysis.\" Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. 2017. [[pdf]](http://www.aclweb.org/anthology/D17-1047)\n\n### MemNet ([memnet.py](./models/memnet.py)) ([official](https://drive.google.com/open?id=1Hc886aivHmIzwlawapzbpRdTfPoTyi1U))\n\nTang, Duyu, B. Qin, and T. Liu. \"Aspect Level Sentiment Classification with Deep Memory Network.\" Conference on Empirical Methods in Natural Language Processing 2016:214-224. [[pdf]](https://arxiv.org/pdf/1605.08900)\n\n### IAN ([ian.py](./models/ian.py))\n\nMa, Dehong, et al. \"Interactive Attention Networks for Aspect-Level Sentiment Classification.\" arXiv preprint arXiv:1709.00893 (2017). [[pdf]](https://arxiv.org/pdf/1709.00893)\n\n### ATAE-LSTM ([atae_lstm.py](./models/atae_lstm.py))\n\nWang, Yequan, Minlie Huang, and Li Zhao. \"Attention-based lstm for aspect-level sentiment classification.\" Proceedings of the 2016 conference on empirical methods in natural language processing. 2016.\n\n### TD-LSTM ([td_lstm.py](./models/td_lstm.py), [tc_lstm.py](./models/tc_lstm.py)) ([official](https://drive.google.com/open?id=17RF8MZs456ov9MDiUYZp0SCGL6LvBQl6))\n\nTang, Duyu, et al. \"Effective LSTMs for Target-Dependent Sentiment Classification.\" Proceedings of COLING 2016, the 26th International Conference on Computational Linguistics: Technical Papers. 2016. [[pdf]](https://arxiv.org/pdf/1512.01100)\n\n### LSTM ([lstm.py](./models/lstm.py))\n\nHochreiter, Sepp, and Jürgen Schmidhuber. \"Long short-term memory.\" Neural computation 9.8 (1997): 1735-1780. [[pdf](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.676.4320\u0026rep=rep1\u0026type=pdf)]\n\n## Note on running with RTX30*\nIf you are running on RTX30 series there may be some compatibility issues between installed/required versions of torch, cuda.\nIn that case try using `requirements_rtx30.txt` instead of `requirements.txt`.\n\n## Contributors\n\nThanks goes to these wonderful people:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/AlbertoPaz\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/36967362?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlberto Paz\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=AlbertoPaz\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"http://taojiang0923@gmail.com\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/37891032?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ejiangtao \u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=jiangtaojy\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://genezc.github.io\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/24239326?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eWhereIsMyHead\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=GeneZC\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/songyouwei\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/2573291?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003esongyouwei\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=songyouwei\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/yangheng95\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/51735130?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYangHeng\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=yangheng95\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/rmarcacini\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/40037976?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ermarcacini\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=rmarcacini\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/ZhangYikaii\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/46623714?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eYikai Zhang\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=ZhangYikaii\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/anayden\"\u003e\u003cimg src=\"https://avatars0.githubusercontent.com/u/17383?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eAlexey Naiden\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=anayden\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/hbeybutyan\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/16852864?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ehbeybutyan\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=hbeybutyan\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://prasys.info\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/15159757?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003ePradeesh\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/songyouwei/ABSA-PyTorch/commits?author=prasys\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Licence\n\nMIT\n","funding_links":[],"categories":["Python","BERT Sentiment Analysis","Repositories/Resources"],"sub_categories":["Normal Sentiment Analysis Dataset (Coarse-grained)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongyouwei%2FABSA-PyTorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsongyouwei%2FABSA-PyTorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsongyouwei%2FABSA-PyTorch/lists"}