Name | torch-sentiment JSON |
Version |
0.5.1
JSON |
| download |
home_page | |
Summary | straight forward rnn model |
upload_time | 2023-01-24 18:53:57 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.10 |
license | Copyright (c) 2018-Present Edward Yang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
rnn
pytorch
nlp
pytorch
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Introduction
[![PyPI Latest Release](https://img.shields.io/pypi/v/torch-sentiment.svg)](https://pypi.org/project/torch-sentiment/)
![GitHub CI](https://github.com/eddiepyang/torch-sentiment/actions/workflows/ci.yaml/badge.svg)
Beta release, api subject to change. Install with:
```
pip install torch-sentiment
```
This repo contains Neural Nets written with the pytorch framework for sentiment analysis.
A LSTM based torch model can be found in the rnn folder. In spite of large language models (GPT3.5 as of 2023)
dominating the conversation, small models can be pretty effective and are nice to learn from. This model focuses on sentiment analysis and was trained on
a single gpu in minutes and requires less than 1GB of memory.
## Usage
```
# where 0 is very negative and 1 is very positive
from torch_sentiment.rnn.tokenizer import get_trained_tokenizer
from torch_sentiment.rnn.model import get_trained_model
model = get_trained_model(64)
tokenizer = get_trained_tokenizer()
review_text = "greatest pie ever, best in town!"
positive_ids = tokenizer.tokenize_text(review_text)
model.predict(positive_ids)
>>> tensor(0.9701)
```
## Install for development with miniconda:
```
conda create -n {env}
conda install pip
pip install -e .
```
## Retrain model
To rerun the model:
* get the yelp [dataset](https://www.yelp.com/dataset),
* get the glove 6B 100D [dataset](https://nlp.stanford.edu/projects/glove/)
* place both files in the package data directory
* run with the rnn training entry point:
```
train
```
Raw data
{
"_id": null,
"home_page": "",
"name": "torch-sentiment",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "rnn,pytorch,nlp,pytorch",
"author": "",
"author_email": "Edward Yang <edwardpyang@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/4e/70/5fb64a00be802a6f65dba5cbe16c454c6965149b63e6a0e0955c23d69f57/torch_sentiment-0.5.1.tar.gz",
"platform": null,
"description": "# Introduction\n\n[![PyPI Latest Release](https://img.shields.io/pypi/v/torch-sentiment.svg)](https://pypi.org/project/torch-sentiment/)\n![GitHub CI](https://github.com/eddiepyang/torch-sentiment/actions/workflows/ci.yaml/badge.svg)\n \nBeta release, api subject to change. Install with: \n\n```\npip install torch-sentiment\n``` \n \nThis repo contains Neural Nets written with the pytorch framework for sentiment analysis. \nA LSTM based torch model can be found in the rnn folder. In spite of large language models (GPT3.5 as of 2023) \ndominating the conversation, small models can be pretty effective and are nice to learn from. This model focuses on sentiment analysis and was trained on \na single gpu in minutes and requires less than 1GB of memory.\n\n \n## Usage\n```\n# where 0 is very negative and 1 is very positive\nfrom torch_sentiment.rnn.tokenizer import get_trained_tokenizer\nfrom torch_sentiment.rnn.model import get_trained_model\n\nmodel = get_trained_model(64)\ntokenizer = get_trained_tokenizer()\nreview_text = \"greatest pie ever, best in town!\"\npositive_ids = tokenizer.tokenize_text(review_text)\nmodel.predict(positive_ids)\n \n>>> tensor(0.9701)\n```\n\n## Install for development with miniconda: \n```\nconda create -n {env} \nconda install pip \npip install -e . \n```\n\n## Retrain model\nTo rerun the model:\n* get the yelp [dataset](https://www.yelp.com/dataset), \n* get the glove 6B 100D [dataset](https://nlp.stanford.edu/projects/glove/)\n* place both files in the package data directory \n* run with the rnn training entry point:\n\n```\ntrain\n```\n\n",
"bugtrack_url": null,
"license": "Copyright (c) 2018-Present Edward Yang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "straight forward rnn model",
"version": "0.5.1",
"split_keywords": [
"rnn",
"pytorch",
"nlp",
"pytorch"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "84cd81a51c04695ef1b71cdd03c392107c4f16578ead3e4b862a75efeb79a4bf",
"md5": "9a70c4214b355dc73464ce93ba81be23",
"sha256": "9cd83ec8c69328abf0907e5f5c62cc671caf30bfe53b38340e45ece546e970a1"
},
"downloads": -1,
"filename": "torch_sentiment-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9a70c4214b355dc73464ce93ba81be23",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9293888,
"upload_time": "2023-01-24T18:53:52",
"upload_time_iso_8601": "2023-01-24T18:53:52.791461Z",
"url": "https://files.pythonhosted.org/packages/84/cd/81a51c04695ef1b71cdd03c392107c4f16578ead3e4b862a75efeb79a4bf/torch_sentiment-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4e705fb64a00be802a6f65dba5cbe16c454c6965149b63e6a0e0955c23d69f57",
"md5": "51ab39b47a7f131890949f60dfb13030",
"sha256": "aa96412fc3b57a833a03e1581854b3522741b07970086128509eb5516971dc0c"
},
"downloads": -1,
"filename": "torch_sentiment-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "51ab39b47a7f131890949f60dfb13030",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9294161,
"upload_time": "2023-01-24T18:53:57",
"upload_time_iso_8601": "2023-01-24T18:53:57.363781Z",
"url": "https://files.pythonhosted.org/packages/4e/70/5fb64a00be802a6f65dba5cbe16c454c6965149b63e6a0e0955c23d69f57/torch_sentiment-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-24 18:53:57",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "torch-sentiment"
}