Skip to content

zain-cs/rag-chatbots

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 RAG Chatbot

Ask questions about any document — get instant AI-powered answers.

Python HuggingFace PyTorch Streamlit Status License


📌 Overview

A RAG (Retrieval-Augmented Generation) chatbot that answers questions based on the content of any document. Supports both PDF and TXT files. Runs completely locally — no API key needed.

Core idea: Upload your document. Ask it anything. Get instant answers.


✨ Features

  • 📄 PDF & TXT Support — Upload any document format
  • 🌐 Web UI — Clean Streamlit interface
  • 💻 CLI Mode — Terminal-based chat
  • 🔒 100% Local — No API key or internet required
  • Fast — GPT-2 runs on CPU

🖥️ Web Interface

Run the web app and chat with your documents through a clean browser UI:

streamlit run app.py

💬 Sample Conversation

📄 Document: AI & Machine Learning Guide

You: What is machine learning?
🤖 Bot: Machine learning is a subset of AI that allows systems to learn from data without being explicitly programmed.

You: What are the types of AI?
🤖 Bot: Narrow AI, General AI, and Super AI.

You: What is TensorFlow?
🤖 Bot: TensorFlow is an open source framework by Google for building machine learning models.

🔍 How RAG Works

Your Document (PDF or TXT)
          │
          ▼
Chunk the document into paragraphs
          │
          ▼
Find most relevant chunk for the question (keyword matching)
          │
          ▼
Feed chunk + question to GPT-2
          │
          ▼
Generated Answer

🚀 Quickstart

1. Clone the repository

git clone https://github.com/zain-cs/rag-chatbots.git
cd rag-chatbots

2. Create and activate virtual environment

python -m venv venv

venv\Scripts\activate      # Windows
source venv/bin/activate   # Mac/Linux

3. Install dependencies

pip install -r requirements.txt

4a. Run the Web UI

streamlit run app.py

4b. Run the CLI chatbot

python src/chatbot.py

🗂️ Project Structure

📦 rag-chatbots
┣ 📂 data
┃ ┗ 📄 sample.txt         ← Sample document
┣ 📂 src
┃ ┣ 🐍 chatbot.py         ← CLI chatbot
┃ ┗ 🐍 pdf_loader.py      ← PDF & TXT loader
┣ 🐍 app.py               ← Streamlit web UI
┣ 📄 .gitignore
┣ 📄 requirements.txt
┗ 📄 README.md

🛠️ Tech Stack

Tool Purpose
Python 3.10+ Core language
GPT-2 Local text generation model
HuggingFace Transformers Model loading and inference
PyTorch Deep learning backend
Streamlit Web UI framework
PyMuPDF PDF text extraction

🗺️ Roadmap

  • Document loading and chunking
  • Keyword-based relevant chunk retrieval
  • GPT-2 local text generation
  • Interactive CLI chat loop
  • PDF & TXT support
  • Streamlit web interface
  • Semantic search with embeddings
  • Upgrade to Gemini or GPT-4 API
  • Deploy on Hugging Face Spaces

👤 Author

Zain@zain-cs

Open to freelance ML and AI projects.


📄 License

This project is licensed under the MIT License — free to use, modify, and build on it.

About

A RAG (Retrieval-Augmented Generation) chatbot that answers questions about any document using GPT-2 and HuggingFace Transformers — runs completely locally, no API key needed.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages