straight forward rnn model
Project description
Introduction
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.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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torch_sentiment-0.6.0.tar.gz.
File metadata
- Download URL: torch_sentiment-0.6.0.tar.gz
- Upload date:
- Size: 9.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
584b7ab1cc4bc7c23406bebf86698d5fa521622090c17875a5d006e7220eb36e
|
|
| MD5 |
791a363c0f9b10c2def930c08f656bb1
|
|
| BLAKE2b-256 |
3001a36192a5969fdc27057bf50464a8b47973857902f52a46820c3cb606751c
|
File details
Details for the file torch_sentiment-0.6.0-py3-none-any.whl.
File metadata
- Download URL: torch_sentiment-0.6.0-py3-none-any.whl
- Upload date:
- Size: 9.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc5f2ab050f75bd89fd16e8288358ce7c61fb81b9459706bba3aa510b3abf17
|
|
| MD5 |
1fc4908884025394624643ac6e78cf17
|
|
| BLAKE2b-256 |
73fce3079b6feabccc358130f3933a5979e3fead9edd4c8d845d57c7b257f013
|