Team Ai
Modelpublic

marcev/financebert

sourceHugging Facegpl-3.0updated 2y agoView on Hugging Face
0likes176downloads
README.md106 linesDownload Raw Back to root
1---2license: gpl-3.03datasets:4- financial_phrasebank5language:6- en7metrics:8- accuracy : 0.929- f1 : 0.9210library_name: transformers11tags:12- bert13- transformers14- sentiment-analysis15- finance16- english17- text-classification18---19 20# FinanceBERT21 22FinanceBERT is a transformer-based model specifically fine-tuned for sentiment analysis in the financial sector. It's designed to assess sentiments expressed in financial texts, aiding stakeholders in making data-driven financial decisions.23 24## Model Description25 26FinanceBERT uses the BERT architecture, renowned for its deep contextual understanding. This model helps analyze sentiments in financial news articles, reports, and social media content, categorizing them into positive, negative, or neutral sentiments.27 28## How to Use29 30To use FinanceBERT, you can load it with the Transformers library:31 32```python33from transformers import AutoTokenizer, AutoModelForSequenceClassification34import torch35 36tokenizer = AutoTokenizer.from_pretrained('marcev/financebert')37model = AutoModelForSequenceClassification.from_pretrained('marcev/financebert')38 39def predict(text):40    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)41    outputs = model(**inputs)42    predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)43    return predictions44 45text = "Your sample text here."46predict(text)47```48# Examples49Try out these examples to see FinanceBert in action:50 51examples:52  - text: "The company's financial performance exceeded expectations this quarter."53  - text: "There are concerns that the recent scandal could lead to a decrease in shareholder trust."54 55# Evaluation Results56FinanceBERT was evaluated on a held-out test set and achieved the following performance metrics:57 58- Accuracy: 92%59- F1-Score (Weighted): 92%60- Evaluation Loss: 0.32061 62 63# Detailed Performance Metrics64 65Classification Report:66 67Negative Sentiment - class_index: 068  -  precision: 0.8469  -  recall: 0.9070  -  f1_score: 0.8771  -  support: 2972    73Neutral Sentiment - class_index: 174  -  precision: 0.9475  -  recall: 0.9476  -  f1_score: 0.9477  -  support: 19978 79Positive Setniment - class_index: 280  -  precision: 0.9081  -  recall: 0.8882  -  f1_score: 0.8983  -  support: 8384 85Confusion Matrix:86  87| Predicted       | Negative | Neutral | Positive |88|-----------------|----------|---------|----------|89| Actual Negative | 26       | 2       | 1        |90| Actual Neutral  | 4        | 188     | 7        |91| Actual Positive | 1        | 9       | 73       |92 93# Limitations94FinanceBERT has been rigorously trained and tested to ensure reliable performance across a variety of financial texts. However, there are several limitations to consider:95 96- Domain Specificity: Optimized for financial contexts, may not perform well on non-financial texts.97- Language Support: Currently supports English only.98- Data Bias: Reflects the bias inherent in its training data, which may not include diverse global financial perspectives.99- Interpretability: As a deep learning model, it does not offer easy interpretability of its decision-making process.100 101# License102This model is released under the GNU General Public License v3.0 (GPL-3.0), requiring that modifications and derivatives remain open source under the same license.103 104# Acknowledgements105FinanceBERT was developed using the Transformers library by Hugging Face, trained on a curated dataset of financial texts.106