--- license: mit --- # 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: ```python 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). ```python # 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](https://www.kaggle.com/code/meruvulikith/finbert-fine-tuning). Access the WebAPP [StreamLit APP](https://stock-sentiment-finbert.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](https://huggingface.co/likith123/SSAF-FinBert).