Edit model card

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:

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.

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).

# 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.

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.

Downloads last month
8
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.