Instructions to use appleboiy/DistilBERT-Sentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use appleboiy/DistilBERT-Sentiment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-classification", model="appleboiy/DistilBERT-Sentiment")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("appleboiy/DistilBERT-Sentiment") model = AutoModelForSequenceClassification.from_pretrained("appleboiy/DistilBERT-Sentiment", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from appleboiy/DistilBERT-Sentiment: direct link, hf CLI and curl.
- Browser
- Download file 874 Bytes
-
https://huggingface.co/appleboiy/DistilBERT-Sentiment/resolve/main/README.md
- Command line
-
hf download hf://appleboiy/DistilBERT-Sentiment/README.md
-
curl -L -o README.md https://huggingface.co/appleboiy/DistilBERT-Sentiment/resolve/main/README.md
874 Bytes
metadata
license: apache-2.0
datasets:
- stanfordnlp/imdb
language:
- en
base_model:
- distilbert/distilbert-base-uncased
pipeline_tag: zero-shot-classification
library_name: transformers
Example code:
# Sample text to predict
text = "I love this movie, it was fantastic!"
# Tokenize the input text
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
# Get model predictions
with torch.no_grad():
outputs = model(**inputs)
# Get the logits (model's raw output)
logits = outputs.logits
# Convert logits to probabilities (if needed) and get the predicted class (0 or 1)
predictions = torch.argmax(logits, dim=-1).item()
# Map the prediction to sentiment labels
labels = {0: "NEGATIVE", 1: "POSITIVE"} # Assuming binary classification
predicted_label = labels[predictions]
print(f"Predicted Sentiment: {predicted_label}")