| --- |
| license: mit |
| datasets: |
| - zeroshot/twitter-financial-news-sentiment |
| --- |
| |
| # Financial Sentiment Analysis with FinBERT |
|
|
| This repository contains a financial sentiment analysis model fine-tuned on `ProsusAI/finbert`. The model classifies financial text (like tweets or news headlines) into three categories: **Bullish**, **Bearish**, or **Neutral**. |
|
|
| The project includes scripts for data preprocessing, model training with hyperparameter optimization, and a Streamlit web application for interactive predictions. |
|
|
| ## Model Card |
|
|
| ### Model Description |
|
|
| This model is a `BertForSequenceClassification` based on the `ProsusAI/finbert` architecture. It has been fine-tuned to predict the sentiment of financial text. The model was trained on a dataset of financial tweets and headlines, and it outputs one of three labels: `Bullish`, `Bearish`, or `Neutral`. |
|
|
| ```python |
| from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification |
| |
| MODEL_PATH = "path to your model" |
| |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH) |
| model = AutoModelForSequenceClassification.from_pretrained(MODEL_PATH) |
| |
| pipe = pipeline("text-classification", model=model, tokenizer=tokenizer) |
| |
| # Analyze sentiment |
| results = pipe("Adobe price target raised to $350 vs. $320 at Canaccord") |
| print(results) |
| # [{'label': 'Bullish', 'score': 0.9...}] |
| ``` |
|
|
| ### Training Data |
|
|
| The model was trained on the [Twitter Financial News Sentiment](https://huggingface.co/datasets/zeroshot/twitter-financial-news-sentiment) dataset. The text data undergoes a comprehensive cleaning process (`data_preprocessing.py`) which includes: |