Spaces:
Running
Running
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| from news_scraper.nlp_models.basemodel import BaseModel | |
| class FinBertSentimentAnalyzer_ProsusAI(BaseModel): | |
| """ | |
| A class for performing sentiment analysis using the FinBERT model. | |
| https://huggingface.co/ProsusAI/finbert | |
| """ | |
| def __init__(self): | |
| """Initialize the FinBERT sentiment analyzer.""" | |
| super().__init__("ProsusAI/finbert") | |
| self.tokenizer = AutoTokenizer.from_pretrained("ProsusAI/finbert") | |
| self.model = AutoModelForSequenceClassification.from_pretrained("ProsusAI/finbert") | |
| self.model.to(self.device) | |
| self.model.eval() | |