Skip to content

Repository files navigation

RAG Pipeline with Metadata Retrieval

image

A production-ready Retrieval-Augmented Generation (RAG) system built to eliminate LLM hallucinations. This project provides context-aware responses by grounding AI generations in verified local document data, complete with source metadata for transparency and reduce unnecessary tokens (10^18 bytes / 1 quintillion data).

Overview

This project handles the end-to-end RAG lifecycle:

  1. Ingestion: Parsing and chunking documents.
  2. Filtering: Filter documents only necessary metadata
  3. Chunking: Used Recursive Text Splitter
  4. Embedding: Converting text to high-dimensional vectors.
  5. Retrieval: Performing similarity searches to find relevant context. (Query of user converted using the same embedding model)
  6. Augmentation: Passing context + metadata to the LLM to ensure factual accuracy.

Tech Stack

  • Backend: Python, Flask
  • Orchestration: LangChain
  • Vector Databases: Pinecone Vector Database
  • Embeddings: llama embed text v2
  • UI: Custom Chatbot Interface (HTML/CSS/JS)

Project Architecture

1. Document Processing & Ingestion

  • Loaders: Utilizes LangChain loaders to process raw data. (PyPDFLoaders)
  • Chunking: Employs RecursiveCharacterTextSplitter to maintain semantic integrity across text segments.
  • Vector Stores: * Pinecone: Used for server side embedding with cloud vector database.

2. Retrieval & Response Generation

  • Context Awareness: The system retrieves the top-$k$ most relevant chunks based on user queries.
  • Metadata Tracking: Unlike standard RAG, this system tracks and displays source metadata (e.g., page numbers) alongside the answer to ensure auditability.
  • Anti-Hallucination: Strictly constrains the LLM to generate answers only from the retrieved context.

⚙️ Setup & Installation

  1. Clone the Repo:

    git clone https://github.com/idAryan/Study_rag-_chatbot.git
    cd Study_rag-_chatbot
  2. Install Requirements:

    pip install -r requirements.txt
  3. Launch: Create a .env file for your API keys:

    flask run

Developed by: Aryan Sharma
B.Tech - Artificial Intelligence & Machine Learning

About

Built an end-to-end document ingestion, retrieval and Augmentation pipeline.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages