Spaces:
Running
Running
File size: 724 Bytes
3fe0726 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import torch
from news_scraper.nlp_models.basemodel import BaseModel
from transformers import AutoTokenizer, AutoModelForSequenceClassification
class RobertaLarge(BaseModel):
"""
A class for performing sentiment analysis using the FinBERT model.
https://huggingface.co/Farshid/roberta-large-financial-phrasebank-allagree1
"""
def __init__(self):
super().__init__("RobertaLarge")
self.tokenizer = AutoTokenizer.from_pretrained("Farshid/roberta-large-financial-phrasebank-allagree1")
self.model = AutoModelForSequenceClassification.from_pretrained("Farshid/roberta-large-financial-phrasebank-allagree1")
self.model.to(self.device)
self.model.eval()
|