{"id":16269533,"url":"https://github.com/hiyouga/pban-pytorch","last_synced_at":"2025-09-11T00:33:28.100Z","repository":{"id":111025175,"uuid":"177273757","full_name":"hiyouga/PBAN-PyTorch","owner":"hiyouga","description":"A Position-aware Bidirectional Attention Network for Aspect-level Sentiment Analysis, PyTorch implementation.","archived":false,"fork":false,"pushed_at":"2019-11-23T08:57:41.000Z","size":1354,"stargazers_count":36,"open_issues_count":3,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-29T13:32:19.449Z","etag":null,"topics":["aspect-based-sentiment-analysis","attention-model","deep-learning","natural-language-processing","nlp","pytorch","sentiment-analysis"],"latest_commit_sha":null,"homepage":null,"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/hiyouga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-23T10:12:28.000Z","updated_at":"2024-12-03T20:24:38.000Z","dependencies_parsed_at":"2024-03-15T12:34:02.342Z","dependency_job_id":null,"html_url":"https://github.com/hiyouga/PBAN-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/hiyouga%2FPBAN-PyTorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FPBAN-PyTorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FPBAN-PyTorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hiyouga%2FPBAN-PyTorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hiyouga","download_url":"https://codeload.github.com/hiyouga/PBAN-PyTorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232581248,"owners_count":18545416,"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-model","deep-learning","natural-language-processing","nlp","pytorch","sentiment-analysis"],"created_at":"2024-10-10T18:08:33.511Z","updated_at":"2025-01-05T11:40:59.420Z","avatar_url":"https://github.com/hiyouga.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PBAN-PyTorch\n\n\u003e [PyTorch](https://pytorch.org/) implementation of [Gu et al.'s COLING 2018](https://aclweb.org/anthology/C18-1066) work.\n\n[![LICENSE](https://img.shields.io/packagist/l/doctrine/orm.svg)](LICENSE)\n\n## Requirement\n\n* PyTorch \u003e= 0.4.0\n* NumPy \u003e= 1.13.3\n* Python 3.6\n* GloVe pre-trained word vectors:\n  * Download pre-trained word vectors [here](https://github.com/stanfordnlp/GloVe#download-pre-trained-word-vectors).\n  * Extract the [glove.twitter.27B.zip](http://nlp.stanford.edu/data/wordvecs/glove.twitter.27B.zip) and [glove.42B.300d.zip](http://nlp.stanford.edu/data/wordvecs/glove.42B.300d.zip) to the `\\glove\\` folder.\n\n## Dataset\n\nBased on the restaurant and laptop dataset of [SemEval-2014 Task 4](http://alt.qcri.org/semeval2014/task4/).\n\n### Restaurant Dataset\n\n| Polarity | #Positive | #Negative | #Neutral |\n| -------- | --------- | --------- | -------- |\n| Train    | 2164      | 807       | 637      |\n| Test     | 728       | 196       | 196      |\n\n### Laptop Dataset\n\n| Polarity | #Positive | #Negative | #Neutral |\n| -------- | --------- | --------- | -------- |\n| Train    | 994       | 870       | 464      |\n| Test     | 341       | 128       | 169      |\n\n## Usage\n\nTrain the model:\n\n```sh\npython train.py --model_name pban --dataset restaurant\n```\n\nShow help message and exit:\n\n```sh\npython train.py -h\n```\n\n## Implemented models\n\n### LSTM\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](assets/lstm.png)\n\n### ATAE-LSTM\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. [[pdf]](http://www.aclweb.org/anthology/D16-1058)\n\n![atae_lstm](assets/atae_lstm.png)\n\n### PBAN\n\nGu, Shuqin, et al. \"A Position-aware Bidirectional Attention Network for Aspect-level Sentiment Analysis.\" Proceedings of the 27th International Conference on Computational Linguistics. 2018. [[pdf]](http://www.aclweb.org/anthology/C18-1066)\n\n![pban](assets/pban.png)\n\n## Performance\n\n### Restaurant Dataset\n\n#### Three-class\n\n| Model     | In Paper  | This Code |\n| --------- | --------- | --------- |\n| LSTM      | 74.28     | 77.68     |\n| ATAE-LSTM | 77.20     | 78.30     |\n| PBAN      | **81.16** | **80.89** |\n\n#### Two-class\n\n| Model     | In Paper  | This Code |\n| --------- | --------- | --------- |\n| LSTM      | -         | -         |\n| ATAE-LSTM | 90.90     | 90.26     |\n| PBAN      | **91.67** | **92.32** |\n\n### Laptop Dataset\n\n#### Three-class\n\n| Model     | In Paper  | This Code |\n| --------- | --------- | --------- |\n| LSTM      | 66.45     | 71.00     |\n| ATAE-LSTM | 68.70     | 71.32     |\n| PBAN      | **74.12** | **74.76** |\n\n#### Two-class\n\n| Model     | In Paper  | This Code |\n| --------- | --------- | --------- |\n| LSTM      | -         | -         |\n| ATAE-LSTM | 87.60     | **87.63** |\n| PBAN      | **87.81** | 87.42     |\n\n## Acknowledgements\n\n* Some of the code is borrowed from [songyouwei](https://github.com/songyouwei/ABSA-PyTorch).\n* Using this code means you have read and accepted the copyrights set by the dataset providers.\n\n## License\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiyouga%2Fpban-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhiyouga%2Fpban-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhiyouga%2Fpban-pytorch/lists"}