Skip to main content

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.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,
  • get the glove 6B 100D dataset
  • place both files in the package data directory
  • run the training script in workflows

Metadata

Release files for torch-sentiment 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torch-sentiment 0.6.0
File Size Uploaded Provenance Actions
torch_sentiment-0.6.0.tar.gz 9.3 MB Without provenance Details for torch_sentiment-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-sentiment 0.6.0
File Interpreter ABI Platform Actions
torch_sentiment-0.6.0-py3-none-any.whl Python 3 none any Details for torch_sentiment-0.6.0-py3-none-any.whl

Total release size: 18.6 MB

Release files / torch_sentiment-0.6.0.tar.gz

Download URL torch_sentiment-0.6.0.tar.gz
Size 9.3 MB
Tags Source
SHA-256 checksum
How to use checksums
584b7ab1cc4bc7c23406bebf86698d5fa521622090c17875a5d006e7220eb36e
BLAKE2b-256 checksum
How to use checksums
3001a36192a5969fdc27057bf50464a8b47973857902f52a46820c3cb606751c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Release files / torch_sentiment-0.6.0-py3-none-any.whl

Download URL torch_sentiment-0.6.0-py3-none-any.whl
Size 9.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2dc5f2ab050f75bd89fd16e8288358ce7c61fb81b9459706bba3aa510b3abf17
BLAKE2b-256 checksum
How to use checksums
73fce3079b6feabccc358130f3933a5979e3fead9edd4c8d845d57c7b257f013
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.0

Security for torch-sentiment 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page