Skip to main content

straight forward rnn model

Project description

Introduction

PyPI Latest Release GitHub CI

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 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.44.tar.gz (9.3 MB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_sentiment-0.4.44.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.44.tar.gz
Algorithm Hash digest
SHA256 0e0ce0c5aa18e71166175e40b33bd6ca0db32a3592821e6645f8546d64687bf5
MD5 f8c4bc904a9d946fc3043489c4bef504
BLAKE2b-256 eda8c127e04925b7716bd7ba351d9aea19447e8e8d5722d4a354d0a4b90122aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for torch_sentiment-0.4.44-py3-none-any.whl
Algorithm Hash digest
SHA256 88dec6c8d0ceb6212e6f4424da4b8a014ef4c8547411fd2e53c537e980b867f2
MD5 b9e64e46e111b801ddb23f1c508a3fe4
BLAKE2b-256 98b446bd9a30eb50a881ef2ce132099c13077ccd72d053a753fa9986a8bc1249

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