Skip to content

maroofiums/AI-Research-Assistant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Research Assistant

A Retrieval-Augmented Generation (RAG) application built using FastAPI, LangChain, ChromaDB, and Mistral AI.

This project allows users to upload PDF documents and ask questions about their content. The system retrieves the most relevant document chunks from a vector database and generates grounded answers using Mistral AI.


Features

  • PDF document ingestion
  • Automatic text chunking
  • Mistral Embeddings
  • ChromaDB vector storage
  • Semantic search and retrieval
  • Mistral-powered answer generation
  • Source citations
  • FastAPI REST API
  • Interactive Swagger documentation

Tech Stack

Backend

  • FastAPI
  • Uvicorn

RAG Framework

  • LangChain

Embeddings

  • Mistral AI Embeddings

Vector Database

  • ChromaDB

Large Language Model

  • Mistral Small

Document Processing

  • PyPDF

Project Structure

├── app
│   ├── ingest.py
│   ├── main.py
│   ├── rag.py
│   └── schemas.py
│
├── data
│   └── deeplearning.pdf
│
├── vectorstore
│   └── chroma.sqlite3
│
├── README.md
└── requirements.txt

Installation

Clone the Repository

git clone https://github.com/maroofiums/AI-Research-Assistant.git

cd AI-Research-Assistant

Create Virtual Environment

python -m venv .venv

Activate:

Windows:

.venv\Scripts\activate

Linux/macOS:

source .venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Environment Variables

Create a .env file in the project root.

MISTRAL_API_KEY=your_mistral_api_key

Build Vector Database

Place a PDF inside the data directory.

Example:

data/
└── deeplearning.pdf

Run:

from app.ingest import create_vectorstore

create_vectorstore("data/deeplearning.pdf")

This process:

  1. Loads the PDF
  2. Splits text into chunks
  3. Generates embeddings
  4. Stores vectors in ChromaDB

Run the Application

Start FastAPI:

uvicorn app.main:app --reload

Server URL:

http://127.0.0.1:8000

Swagger Documentation:

http://127.0.0.1:8000/docs

API Endpoints

Home

GET /

Response:

{
  "message": "Welcome to AI Research Assistant"
}

Upload PDF

POST /upload

Upload a PDF file to create embeddings and store them in ChromaDB.

Response:

{
  "message": "Document uploaded",
  "chunks": 125
}

Ask Questions

POST /ask

Request:

{
  "question": "What is backpropagation?"
}

Response:

{
  "answer": "Backpropagation is a training algorithm used to update neural network weights by propagating errors backward through the network.",
  "sources": [
    {
      "page": 12,
      "source": "data/deeplearning.pdf",
      "preview": "Backpropagation computes gradients..."
    }
  ]
}

RAG Pipeline

PDF
 ↓
PyPDFLoader
 ↓
RecursiveCharacterTextSplitter
 ↓
Mistral Embeddings
 ↓
ChromaDB
 ↓
Retriever
 ↓
Prompt Template
 ↓
Mistral Small
 ↓
Answer + Sources

Example Workflow

  1. Upload a PDF document
  2. Generate embeddings
  3. Store vectors in ChromaDB
  4. Ask questions
  5. Retrieve relevant chunks
  6. Generate grounded answers
  7. Return answer with citations

Future Improvements

  • Multi-document support
  • Chat history
  • Streaming responses
  • Hybrid Search (BM25 + Vector Search)
  • Reranking
  • LangGraph integration
  • Docker deployment
  • PostgreSQL + PGVector
  • User authentication

Known Issues

  • Large PDFs may take time to embed.
  • Mistral Embeddings require a valid API key.
  • Network interruptions may cause embedding failures during ingestion.

About

AI Research Assistant is a RAG system using FastAPI, LangChain, ChromaDB, and Mistral AI. It lets users upload PDFs, stores embeddings, retrieves relevant chunks via semantic search, and generates grounded answers with citations. Includes REST APIs and Swagger docs for interaction.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages