Skip to content

About

An AI-powered RAG document chat app that lets users upload files, build a FAISS vector index, and ask questions using Groq LLM.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

RAG Application Workflow

RAG = Retrieval-Augmented Generation

This project retrieves relevant information from uploaded documents and uses an LLM to generate grounded answers based on the retrieved context.


Full Workflow Diagram

%%{init: {'theme': 'dark', 'themeVariables': {'primaryColor': '#1e1e2e', 'primaryTextColor': '#cdd6f4', 'primaryBorderColor': '#89b4fa', 'lineColor': '#89dceb', 'secondaryColor': '#181825', 'tertiaryColor': '#313244', 'background': '#1e1e2e', 'mainBkg': '#1e1e2e', 'nodeBorder': '#89b4fa', 'clusterBkg': '#181825', 'titleColor': '#cba6f7', 'edgeLabelBackground': '#313244', 'fontFamily': 'monospace'}}}%%
flowchart LR

    A["📂 User Uploads\nPDF · TXT · CSV · DOCX"] --> B["📄 Load & Parse\nLangChain Loaders"] --> C["✂️ Text Chunking\nRecursiveCharSplitter"] --> D["🧩 Chunks\nC1 · C2 · C3 · C4"] --> E["🧠 Embedding Model\nall-MiniLM-L6-v2"] --> F[("🗄️ FAISS Store\nembeddings + index")]

    G["💬 User Question\nStreamlit chat"] --> H["🔢 Query Embedding\nall-MiniLM-L6-v2"] --> I["🔍 Similarity Search\nTop-K · k=3"] --> J["📑 Retrieved Chunks\nTop 1 · 2 · 3"] --> K["📝 Context Prompt\njoin relevant text"] --> L["⚡ Groq LLM\nllama-3.1-8b-instant"] --> M["✅ Answer\nGrounded response"]

    F -->|"similarity search"| I

    classDef upload  fill:#3d2b00,stroke:#fb8c00,stroke-width:2px,color:#ffcc80
    classDef process fill:#0d2137,stroke:#29b6f6,stroke-width:2px,color:#81d4fa
    classDef vector  fill:#0a2818,stroke:#43a047,stroke-width:2px,color:#a5d6a7
    classDef llm     fill:#2d2000,stroke:#fbc02d,stroke-width:2px,color:#fff176
    classDef output  fill:#1a0a2e,stroke:#9c27b0,stroke-width:2px,color:#ce93d8

    class A,G upload
    class B,C,D,H,I,J,K process
    class E,F vector
    class L llm
    class M output
Loading

Indexing Pipeline

Step Component Details
1 User Uploads Files Files are uploaded using the Streamlit file uploader.
2 Load and Parse Documents LangChain loaders extract page_content and metadata.
3 Text Chunking RecursiveCharacterTextSplitter splits documents into smaller overlapping chunks.
4 Embedding Model SentenceTransformer with all-MiniLM-L6-v2 converts text chunks into vectors.
5 FAISS Vector Store FAISS stores embeddings with metadata and saves the index.

Question Answering Pipeline

Step Component Details
1 User Question The user asks a question through the Streamlit chat input.
2 Query Embedding The same all-MiniLM-L6-v2 model converts the question into a vector.
3 Similarity Search FAISS performs Top-K similarity search against stored document vectors.
4 Retrieved Chunks The most relevant chunks are returned from the vector store.
5 Build Context Prompt Retrieved chunks are joined and passed as context to the LLM.
6 LLM Response Groq LLM llama-3.1-8b-instant generates an answer using the retrieved context.
7 Answer in Streamlit UI The final answer is displayed in the Streamlit chat interface.

Tech Stack

Layer Technology
Package Manager uv
UI Streamlit
Document Loading LangChain Community Loaders
Text Splitting RecursiveCharacterTextSplitter
Embedding Model sentence-transformers/all-MiniLM-L6-v2
Vector Store FAISS
LLM Groq API with llama-3.1-8b-instant
Environment Variables python-dotenv locally, Streamlit secrets on deployment

Quick Start

uv sync
uv run streamlit run app.py

Environment Setup

Create a .env file locally:

GROQ_API_KEY=your_groq_api_key_here

For Streamlit Cloud deployment, add the same key in app secrets:

GROQ_API_KEY = "your_groq_api_key_here"

Do not push .env or .streamlit/secrets.toml to GitHub.


Supported File Formats

data/
├── pdf/
│   └── document.pdf
├── text_files/
│   └── notes.txt
└── uploaded_data/
    ├── data.csv
    ├── report.docx
    ├── spreadsheet.xlsx
    └── config.json

Supported formats:

PDF, TXT, CSV, DOCX, XLSX, JSON

About

An AI-powered RAG document chat app that lets users upload files, build a FAISS vector index, and ask questions using Groq LLM.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages