Text Classification
Transformers
PyTorch
Safetensors
English
deberta-v2
Text Classification
Pytorch
Sentiment_Analysis
Deberta
text-embeddings-inference
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("RashidNLP/Amazon-Deberta-Base-Sentiment")
model = AutoModelForSequenceClassification.from_pretrained("RashidNLP/Amazon-Deberta-Base-Sentiment")Quick Links
Deberta for Sentiment Analysis
This is a Deberta model finetuned on over 1 million reviews from Amazon's multi-reviews dataset.
How to use the model
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
def get_sentiment(sentence):
bert_dict = {}
vectors = tokenizer(sentence, return_tensors='pt').to(device)
outputs = bert_model(**vectors).logits
probs = torch.nn.functional.softmax(outputs, dim = 1)[0]
bert_dict['neg'] = round(probs[0].item(), 3)
bert_dict['neu'] = round(probs[1].item(), 3)
bert_dict['pos'] = round(probs[2].item(), 3)
return bert_dict
MODEL_NAME = 'RashidNLP/Amazon-Deberta-Base-Sentiment'
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
bert_model = AutoModelForSequenceClassification.from_pretrained(MODEL_NAME, num_labels = 3).to(device)
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
get_sentiment("This is quite a mess you have made")
- Downloads last month
- 25
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="RashidNLP/Amazon-Deberta-Base-Sentiment")