Views
No views yet
vinai/bertweet-base for 3-class sentiment analysis on tweets (negative, neutral, positive).1from transformers import pipeline
2
3# Load the model
4classifier = pipeline("sentiment-analysis", model="kluvin/bertweet-tweet-sentiment")
5
6# Make predictions
7result = classifier("I love this product!")
8print(result)
9# [{'label': 'positive', 'score': 0.95}]1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4model = AutoModelForSequenceClassification.from_pretrained("kluvin/bertweet-tweet-sentiment")
5tokenizer = AutoTokenizer.from_pretrained("kluvin/bertweet-tweet-sentiment")
6
7text = "This is the worst day ever"
8inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=64)
9
10with torch.no_grad():
11 outputs = model(**inputs)
12 predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
13
14print(predictions)1@inproceedings{bertweet,
2 title={BERTweet: A pre-trained language model for English Tweets},
3 author={Nguyen, Dat Quoc and Vu, Thanh and Nguyen, Anh Tuan},
4 booktitle={Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations},
5 pages={9--14},
6 year={2020}
7}