Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 AI Research Assistant

A Retrieval-Augmented Generation (RAG) system that answers questions grounded in your own documents — notes, PDFs, DOCX files, or web pages — with source citations, and an explicit refusal when it isn't confident enough to answer reliably.

Why this project

Most RAG demos retrieve context and pass it straight to an LLM, which will happily generate a fluent answer even when nothing relevant was found. This project adds a confidence threshold on retrieval: if no retrieved chunk is similar enough to the query, the system tells the user it doesn't know, instead of guessing. It also includes a small evaluation harness to measure retrieval quality with a concrete number, rather than eyeballing it.

Architecture

Streamlit UI
      │
      ▼
Upload PDFs / URLs / TXT / DOCX
      │
      ▼
Document Loader (core/loader.py)
      │
      ▼
Text Cleaning → Chunking (core/splitter.py)
      │
      ▼
Sentence-Transformer Embeddings (core/embeddings.py)
      │
      ▼
ChromaDB (core/vectorstore.py)
      │
      ▼
Retrieval + confidence threshold (core/retriever.py)
      │
      ├── below threshold → explicit refusal, no LLM call
      │
      ▼
Groq Llama 3.3 (core/llm.py)
      │
      ▼
Answer + Source Citations (pages/2_Chat.py)

See docs/design_decisions.md for the reasoning behind the chunking strategy, the similarity threshold, and other choices.

Features

  • Multi-format ingestion: PDF, TXT, DOCX, and web URLs
  • Two chunking strategies (fixed-size and paragraph-aware) that can be compared empirically via the evaluation harness
  • Confidence-gated generation: refuses to answer rather than hallucinate when retrieval is weak
  • Source citations: every answer links back to the source document, page, and chunk, with similarity score shown
  • Evaluation harness: hand-labeled question set + hit-rate scoring in evaluation/
  • Dashboard: index stats, last-query retrieval scores, and eval results

Setup

git clone <your-repo-url>
cd AI_Research_Assistant

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate

pip install -r requirements.txt

cp .env.example .env
# then edit .env and add your GROQ_API_KEY (free tier: https://console.groq.com)

Running the app

streamlit run app.py

Open the app, go to Upload, and index the file in sample_data/sample.txt (or your own documents) to try it immediately.

Running the evaluation

python evaluation/run_eval.py

This runs the questions in evaluation/eval_questions.json against the current index and reports retrieval hit-rate. Results are saved to evaluation/results/ and shown on the Dashboard page. Edit eval_questions.json to add your own labeled questions once you've indexed your real documents.

Project structure

AI_Research_Assistant/
├── app.py                  # Streamlit entry point
├── rag.py                  # Pipeline orchestrator — read this first
├── config.py                # Settings, loaded from .env
├── prompts.py                # Prompt templates
│
├── core/
│   ├── loader.py            # PDF / TXT / DOCX / URL → raw text
│   ├── splitter.py          # Chunking strategies
│   ├── embeddings.py         # Sentence-transformer wrapper
│   ├── vectorstore.py        # ChromaDB operations
│   ├── retriever.py          # Top-k + confidence threshold + refusal
│   ├── llm.py                # Groq client
│   └── utils.py              # Shared helpers
│
├── pages/                   # Streamlit multi-page UI
├── evaluation/               # Eval question set + hit-rate scoring
├── resources/                # Uploaded files + persisted vector store
├── docs/                     # Architecture + design decision notes
└── sample_data/               # Ready-to-use demo content

Tech stack

  • UI: Streamlit
  • Embeddings: sentence-transformers (all-MiniLM-L6-v2)
  • Vector store: ChromaDB (local, persistent)
  • LLM: Groq (Llama 3.3)
  • Loaders: pypdf, python-docx, beautifulsoup4

Possible next steps

  • Hybrid search (BM25 + vector similarity, merged via reciprocal rank fusion) to catch exact keyword/name matches that embeddings miss
  • Cross-encoder reranking of top-k results before generation
  • Query rewriting for vague user questions before retrieval

About

AI Research Assistant is a Retrieval-Augmented Generation (RAG) application built with Streamlit, ChromaDB, Sentence Transformers, and Groq LLM. It supports PDF, DOCX, TXT, website, and YouTube transcript ingestion, semantic search, and context-aware question answering with an intuitive interface.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages