Closed abhijeetk597 closed 6 months ago
You pass the string "random_text" but not the variable's (random_text
) content. That's why you get the same score.
Try passing it like sent_pipeline(f'{random_text}')
. So in total something like:
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
MODEL = f"cardiffnlp/twitter-roberta-base-sentiment"
tokenizer = AutoTokenizer.from_pretrained(MODEL)
model = AutoModelForSequenceClassification.from_pretrained(MODEL)
sent_pipeline = pipeline("sentiment-analysis",model=model, tokenizer=tokenizer)
import random
random_text = random.choice(df["Text"])
print(random_text)
# here is the change
sent_pipeline(f"{random_text}")
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
System Info
transformers
version: 4.38.2Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
I tried same thing with different model but got same kind of result.
Kaggle Notebook Link
Expected behavior
Sentiment scores should vary as per text given.