Skip to content

junaidzeb123/financial-sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Financial PhraseBank Sentiment Analysis & Topic Modeling with LLMs

Overview

This project provides a full pipeline for analyzing financial news sentences using state-of-the-art NLP techniques. It includes:

  • Data cleaning and exploratory analysis
  • Topic modeling with LDA
  • Sentiment classification using FinBERT and open-source LLMs
  • Retrieval-Augmented Generation (RAG) for improved LLM performance
  • Fine-tuning FinBERT for domain-specific sentiment analysis

Steps

  1. Preprocessing & EDA:

    • Load and clean the Financial PhraseBank dataset.
    • Analyze sentiment distribution and text statistics.
  2. Topic Modeling:

    • Apply LDA to discover and interpret latent topics in financial text.
  3. Sentiment Analysis:

    • Use FinBERT for sentiment prediction.
    • Evaluate with accuracy, F1-score, and confusion matrix.
  4. Local LLM Sentiment Analysis:

    • Run Mistral-7B or similar LLMs for zero-shot/few-shot sentiment classification.
    • Compare with FinBERT results.
  5. RAG:

    • Retrieve similar examples using FAISS and sentence-transformers.
    • Augment LLM prompts for better sentiment prediction.
  6. Fine-Tuning:

    • Fine-tune FinBERT on the dataset.
    • Visualize and evaluate the improved model.

Outputs

  • Preprocessed data and topic assignments
  • Sentiment predictions from FinBERT, LLM, and RAG
  • Evaluation metrics and visualizations
  • Fine-tuned FinBERT model

Requirements

  • Python (with Jupyter Notebook)
  • pandas, numpy, matplotlib, seaborn, nltk, scikit-learn
  • torch, transformers, sentence-transformers, faiss

Usage

Open DLP_Assignment_3.ipynb and run the cells step by step. Follow the comments for guidance.

About

Developed an end-to-end financial sentiment analysis system using FinBERT and Mistral-7B. Implemented Retrieval-Augmented Generation (RAG) with FAISS to boost LLM zero-shot performance and fine-tuned transformers for maximum accuracy on the Financial PhraseBank.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors