stanfordnlp/sentiment140
Updated • 1.49k • 29
How to use Arskye/my-sentiment-model with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Arskye/my-sentiment-model") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Arskye/my-sentiment-model")
model = AutoModelForSequenceClassification.from_pretrained("Arskye/my-sentiment-model", device_map="auto")Fine-tuned DistilBERT for 3-class sentiment classification (negative, neutral, positive).
This model is a fine-tuned version of DistilBERT-base-uncased for sentiment analysis. It has been trained to classify text into three sentiment categories:
This model is intended for sentiment analysis tasks on English text. It can be used to:
The model achieves the following performance on the test set:
Install the required dependencies:
pip install transformers torch
Load and use the model:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "your-username/my-sentiment-model"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prepare text
text = "I love this product!"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
# Get prediction
with torch.no_grad():
outputs = model(**inputs)
probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(probabilities, dim=-1).item()
# Map prediction to label
labels = {0: "negative", 1: "neutral", 2: "positive"}
confidence = probabilities[0][predicted_class].item()
print(f"Text: {text}")
print(f"Sentiment: {labels[predicted_class]} (confidence: {confidence:.2%})")
If you use this model in your research, please cite:
@misc{my-sentiment-model,
author = {Your Name},
title = {Fine-tuned DistilBERT for Sentiment Analysis},
year = {2025},
publisher = {Hugging Face},
url = {https://huggingface.co/your-username/my-sentiment-model}
}
This model is released under the MIT License.
Base model
distilbert/distilbert-base-uncased