vipplavai/MSME_Chat_Bot

0

stars

3

commits

Jupyter Notebook

primary language

Jul 12, 2025

updated

README

๐Ÿค– MSME Scheme Assistant Chatbot

An AI-powered chatbot built using LLMs, sentence embeddings, and MongoDB to assist Indian MSMEs with discovering relevant government schemes. Also includes support for Telugu translations and PDF-based Q&A.


๐Ÿง  Features

  • Udyam ID-based enterprise profiling
  • Manual enterprise profile input
  • LLM-generated search queries based on profile
  • Embedding-based scheme recommendation
  • Field-level answers (eligibility, benefits, documents, etc.) using LLM
  • Telugu translation support via IndicTrans2
  • Upload your own PDF and query it
  • Built-in Gradio UI for seamless interaction

๐Ÿ› ๏ธ Tech Stack

  • ๐Ÿค— Transformers: LLMs & Tokenizers
  • ๐Ÿง  SentenceTransformers: Semantic similarity
  • ๐Ÿ—ƒ๏ธ MongoDB: Vector database for profiles, schemes, and uploaded PDFs
  • ๐Ÿงฉ LangChain: Prompt templates
  • ๐Ÿ“š IndicTrans2: English โ†’ Telugu translation
  • ๐Ÿ–ผ๏ธ Gradio: UI interface
  • ๐Ÿงฎ PyMuPDF: PDF text extraction

๐Ÿš€ Getting Started

๐Ÿ”ง Installation

pip install pymongo sentence-transformers torch transformers langchain_community pymupdf tools
pip install bitsandbytes scipy accelerate datasets sentencepiece

โš ๏ธ Run in Google Colab for seamless PDF uploads using google.colab.files.


๐Ÿ“ MongoDB Setup

Ensure your MongoDB contains:

  • udyam_profiles โ€“ MSME profile data
  • schemes_chunks_only โ€“ Chunked scheme embeddings
  • schemes_embedded โ€“ Full scheme info
  • uploaded_pdf_temp โ€“ Temporary collection for uploaded PDFs

Update the mongo_uri in the script with your connection string.


๐Ÿค– LLMs Used

  • Gemma-2B-IT base model + LoRA fine-tuned model: Vipplav/gemma-finetuned-faq
  • Embedding model: BAAI/bge-small-en-v1.5
  • Translator model: ai4bharat/indictrans2-en-indic-1B

๐Ÿงช Usage

๐ŸŸข Launch Chatbot

Run the script to start the Gradio interface.

๐Ÿ’ฌ Chat Flow

  1. Enter Udyam Registration Number or type manual
  2. If manual:
    • Fill enterprise details interactively
  3. Type show related schemes
  4. Ask about eligibility, apply, or documents

๐ŸŒ Translate Response

  • Click ๐ŸŒ Translate Last Scheme Reply for Telugu version

๐Ÿ“„ PDF Chat

  1. Upload a text-based PDF
  2. Click ๐Ÿ“„ Enable PDF Chat
  3. Ask questions related to uploaded document
  4. Use ๐ŸŒ Translate PDF Answer for Telugu translation

๐Ÿ“ฆ File Structure

  • final_msme_chatbot.py: End-to-end chatbot + PDF handler
  • README.md: You're reading it

๐Ÿง  Logic Highlights

  • Profile summarization โ†’ LLM prompt โ†’ Query
  • Query embedding โ†’ MongoDB chunk similarity match
  • Top schemes retrieved and displayed
  • Further questions answered via LLM on stored chunk metadata
  • Uploaded PDFs stored temporarily, chunked, and queried using top-k similarity

๐Ÿ“ Notes

  • Only text-based PDFs are supported (no scanned images or heavy tables).
  • Queries and translations are optimized for short, user-friendly outputs.
  • You can switch between scheme-based chat and PDF chat seamlessly.

๐Ÿ“ TODOs / Improvements

  • OCR for scanned PDFs (e.g., Tesseract)
  • Streamlit-based deployment option
  • Caching for repeated query embedding
  • Feedback/rating collection

๐Ÿ“œ License

MIT License

Contributors

vipplavai

3 commits

vipplavai/MSME_Chat_Bot

0

stars

3

commits

Jupyter Notebook

primary language

Jul 12, 2025

updated

README

๐Ÿค– MSME Scheme Assistant Chatbot

An AI-powered chatbot built using LLMs, sentence embeddings, and MongoDB to assist Indian MSMEs with discovering relevant government schemes. Also includes support for Telugu translations and PDF-based Q&A.


๐Ÿง  Features

  • Udyam ID-based enterprise profiling
  • Manual enterprise profile input
  • LLM-generated search queries based on profile
  • Embedding-based scheme recommendation
  • Field-level answers (eligibility, benefits, documents, etc.) using LLM
  • Telugu translation support via IndicTrans2
  • Upload your own PDF and query it
  • Built-in Gradio UI for seamless interaction

๐Ÿ› ๏ธ Tech Stack

  • ๐Ÿค— Transformers: LLMs & Tokenizers
  • ๐Ÿง  SentenceTransformers: Semantic similarity
  • ๐Ÿ—ƒ๏ธ MongoDB: Vector database for profiles, schemes, and uploaded PDFs
  • ๐Ÿงฉ LangChain: Prompt templates
  • ๐Ÿ“š IndicTrans2: English โ†’ Telugu translation
  • ๐Ÿ–ผ๏ธ Gradio: UI interface
  • ๐Ÿงฎ PyMuPDF: PDF text extraction

๐Ÿš€ Getting Started

๐Ÿ”ง Installation

pip install pymongo sentence-transformers torch transformers langchain_community pymupdf tools
pip install bitsandbytes scipy accelerate datasets sentencepiece

โš ๏ธ Run in Google Colab for seamless PDF uploads using google.colab.files.


๐Ÿ“ MongoDB Setup

Ensure your MongoDB contains:

  • udyam_profiles โ€“ MSME profile data
  • schemes_chunks_only โ€“ Chunked scheme embeddings
  • schemes_embedded โ€“ Full scheme info
  • uploaded_pdf_temp โ€“ Temporary collection for uploaded PDFs

Update the mongo_uri in the script with your connection string.


๐Ÿค– LLMs Used

  • Gemma-2B-IT base model + LoRA fine-tuned model: Vipplav/gemma-finetuned-faq
  • Embedding model: BAAI/bge-small-en-v1.5
  • Translator model: ai4bharat/indictrans2-en-indic-1B

๐Ÿงช Usage

๐ŸŸข Launch Chatbot

Run the script to start the Gradio interface.

๐Ÿ’ฌ Chat Flow

  1. Enter Udyam Registration Number or type manual
  2. If manual:
    • Fill enterprise details interactively
  3. Type show related schemes
  4. Ask about eligibility, apply, or documents

๐ŸŒ Translate Response

  • Click ๐ŸŒ Translate Last Scheme Reply for Telugu version

๐Ÿ“„ PDF Chat

  1. Upload a text-based PDF
  2. Click ๐Ÿ“„ Enable PDF Chat
  3. Ask questions related to uploaded document
  4. Use ๐ŸŒ Translate PDF Answer for Telugu translation

๐Ÿ“ฆ File Structure

  • final_msme_chatbot.py: End-to-end chatbot + PDF handler
  • README.md: You're reading it

๐Ÿง  Logic Highlights

  • Profile summarization โ†’ LLM prompt โ†’ Query
  • Query embedding โ†’ MongoDB chunk similarity match
  • Top schemes retrieved and displayed
  • Further questions answered via LLM on stored chunk metadata
  • Uploaded PDFs stored temporarily, chunked, and queried using top-k similarity

๐Ÿ“ Notes

  • Only text-based PDFs are supported (no scanned images or heavy tables).
  • Queries and translations are optimized for short, user-friendly outputs.
  • You can switch between scheme-based chat and PDF chat seamlessly.

๐Ÿ“ TODOs / Improvements

  • OCR for scanned PDFs (e.g., Tesseract)
  • Streamlit-based deployment option
  • Caching for repeated query embedding
  • Feedback/rating collection

๐Ÿ“œ License

MIT License

Contributors

vipplavai

3 commits

Languages

Jupyter Notebook

76.4%

Python

23.6%