Model Card: SSAF-FinBert
Overview
The SSAF-FinBert model is a fine-tuned version of the FinBert model designed for sentiment analysis on stock market news articles. It is optimized to classify the sentiment expressed in financial text data into three categories: positive, negative, and neutral.
This model was trained on a dataset collected from Kaggle, preprocessed, and then fine-tuned using the FinBert architecture on a GPU cluster for approximately 5 hours. The resulting model achieved an accuracy ranging from 81% to 82%, depending on the platform used for training.
In Inference API Labels Mapping:-
Label_0 = Negative
Label_1 = Neutral
Label_2 = Positive
How to Access the Model
To access the SSAF-FinBert model for sentiment analysis, you can use the following Python code:
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4# Load the tokenizer used during fine-tuning
5tokenizer = AutoTokenizer.from_pretrained('yiyanghkust/finbert-pretrain')
6
7# Load the fine-tuned model
8model_path = "likith123/SSAF-FinBert"
9model = AutoModelForSequenceClassification.from_pretrained(model_path)
10
11# Define a function for sentiment prediction
12def predict_sentiment(input_text):
13 # Tokenize the input text
14 inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True, max_length=512)
15
16 # Perform inference
17 with torch.no_grad():
18 outputs = model(**inputs)
19
20 # Get predicted probabilities for each class
21 predicted_probs = torch.softmax(outputs.logits, dim=1).squeeze().tolist()
22
23 return predicted_probs
This code loads the pre-trained tokenizer and the fine-tuned SSAF-FinBert model. You can then use the predict_sentiment function to analyze the sentiment of financial text data.
How to Use the Model
To use the SSAF-FinBert model for sentiment analysis, you can call the predict_sentiment function with your financial text data as input. The function will return the predicted probabilities for each sentiment class (positive, negative, and neutral).
1# Example usage
2text_data = "This is a positive news article about the stock market."
3predicted_sentiment = predict_sentiment(text_data)
4print(predicted_sentiment)
The predicted_sentiment variable will contain a list of probabilities corresponding to each sentiment class, allowing you to analyze the sentiment expressed in the input text.
Actual Finetunning process:-
Access the Code for finetuning
Kaggle Notebook.
Access the WebAPP
StreamLit APP.
Performance and Limitations
The SSAF-FinBert model has demonstrated strong performance in sentiment analysis tasks related to financial text data. However, it is essential to note that the model's accuracy may vary depending on the nature and complexity of the input text.
While the model excels in classifying sentiment in financial news articles, it may not perform optimally in other domains or with highly specialized financial terminology.
Acknowledgments
The development of the SSAF-FinBert model was made possible through the contributions of the open-source community and the resources provided by Hugging Face. We extend our gratitude to the developers and researchers who have contributed to the development and improvement of transformer-based models for natural language processing tasks.
For more information and updates on the SSAF-FinBert model, please refer to the
model card.