Skip to main content

straight forward rnn model

Project description

Introduction

PyPI Latest Release

Beta release now on pypi; 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 update the model get the yelp dataset, then run with the rnn training entry point:

train

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torch_sentiment-0.4.43.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

torch_sentiment-0.4.43-py3-none-any.whl (9.3 MB view details)

Uploaded Python 3

File details

Details for the file torch_sentiment-0.4.43.tar.gz.

File metadata

  • Download URL: torch_sentiment-0.4.43.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

Hashes for torch_sentiment-0.4.43.tar.gz
Algorithm Hash digest
SHA256 e5130bd278d47d217f6d8a180b82184a5f66bb0019b0d0994b0cc119eacabc6d
MD5 c996d891604927b918ee73906063ccbd
BLAKE2b-256 99ce6f319a55ab23255b18be16222f7ddf89a33dee5a9db29d358fc92a512dd1

See more details on using hashes here.

File details

Details for the file torch_sentiment-0.4.43-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_sentiment-0.4.43-py3-none-any.whl
Algorithm Hash digest
SHA256 4c3d52f134498712f1e10d80f9ae8652c51074a5f6fd135611897e2141ee1607
MD5 1593ea81db4858f6c9fc7214a1308bab
BLAKE2b-256 32612d4d0c8887ddac3a833c82be94be5bf2a8a04cff693d8656aba5dff51d4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page