mr-checker/yt-tech-comments-dataset
Viewer • Updated • 11k • 23
How to use mr-checker/yt-comments-sentiment-distilbert with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="mr-checker/yt-comments-sentiment-distilbert") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("mr-checker/yt-comments-sentiment-distilbert")
model = AutoModelForSequenceClassification.from_pretrained("mr-checker/yt-comments-sentiment-distilbert")title + comment_text for context import pandas as pd
from transformers import pipeline
# Load your fine-tuned model
sentiment_pipeline = pipeline(
"text-classification",
model="mr-checker/yt-comments-sentiment-distilbert", # replace with your repo/local path
tokenizer="mr-checker/yt-comments-sentiment-distilbert"
)
# Example dataframe (already merged with titles)
eval_df = pd.DataFrame({
"title": ["I Created a $1.000.000 Beauty Brand Using AI"],
"comment_text": ["This video is amazing, but credits are too expensive!"]
})
# Combine title + comment_text
eval_df["text"] = (
eval_df["title"].astype(str)
+ " [SEP] "
+ eval_df["comment_text"].astype(str)
)
# Run inference
results = sentiment_pipeline(
list(eval_df["text"]),
truncation=True,
max_length=256
)
# Attach predictions back to dataframe
eval_df["predicted_label"] = [r["label"] for r in results]
eval_df["confidence"] = [r["score"] for r in results]
print(eval_df[["title", "comment_text", "predicted_label", "confidence"]])
Base model
distilbert/distilbert-base-uncased