Downloads · 30 days
13
1% of all-time downloads
likith123/SSAF-FinBert
SSAF-FinBert is a text classification model from likith123. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
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…
Downloads · 30 days
13
1% of all-time downloads
All-time downloads
911
Public
Parameters
110M
878 MB on disk
Likes
2
Public
Click a slice to open those files.
.bin439 MB · 50%
How the weights are stored.
F32110M · 100%
From the Hugging Face model README
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:-
To access the SSAF-FinBert model for sentiment analysis, you can use the following Python code:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
# Load the tokenizer used during fine-tuning
tokenizer = AutoTokenizer.from_pretrained('yiyanghkust/finbert-pretrain')
# Load the fine-tuned model
model_path = "likith123/SSAF-FinBert"
model = AutoModelForSequenceClassification.from_pretrained(model_path)
# Define a function for sentiment prediction
def predict_sentiment(input_text):
# Tokenize the input text
inputs = tokenizer(input_text, return_tensors="pt", truncation=True, padding=True, max_length=512)
# Perform inference
with torch.no_grad():
outputs = model(**inputs)
# Get predicted probabilities for each class
predicted_probs = torch.softmax(outputs.logits, dim=1).squeeze().tolist()
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.
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).
# Example usage
text_data = "This is a positive news article about the stock market."
predicted_sentiment = predict_sentiment(text_data)
print(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.
Access the Code for finetuning Kaggle Notebook. Access the WebAPP StreamLit APP.
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.
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.