Views
No views yet
bart-base to a sentiment classification dataset.1
2from transformers import BartTokenizer, AutoModelForSequenceClassification
3model = AutoModelForSequenceClassification.from_pretrained('mylonasc/bart-base-twitter-sent-ft-001')
4
5import torch
6_phrases = [
7 'this is a great model! I really like it!',
8 'Do you call this a model? This is not even 1B parameters! Get outta here!',
9 'Fine tuning transformers is very easy if you use all the right tools!',
10 "John couldn't write two correct lines of code without ChatGPT if his life depended on it..."
11]
12toks = tokenizer(_phrases, return_tensors='pt', padding = 'longest')
13with torch.no_grad():
14 res = model(**toks)[0]
15is_positive = res.softmax(1)[:,1]
16is_positive
17
18
19>> tensor([0.9994, 0.1362, 0.9995, 0.3840])