Skip to content

bmirra01/code4all_RAG_finalProject

Repository files navigation

Family Personal Assistant — RAG Final Project

A Retrieval-Augmented Generation (RAG) system that answers family-focused questions across three domains: Health & First Aid, Nutrition & Recipes, and Children's Education. Built as a final project for a RAG/LLM certification.


What It Does

  • Ingests 3 public PDF documents (first aid, nutrition, education) into a Pinecone vector store
  • Classifies user queries and applies role-based access control (Parent / Child / Guest)
  • Answers questions using 4 different retrieval strategies, compared via RAGAS evaluation
  • Provides an interactive Gradio chat interface

Architecture

Models

Model Use
text-embedding-3-small (1536d) Document & query embeddings
gpt-4o-mini (temp=0.3) Answer generation
gpt-3.5-turbo (temp=0) Topic classification (deterministic)

Vector Store

  • Pinecone serverless index (family-assistant, AWS us-east-1, cosine similarity)
  • Two namespaces: main_chunks (604 vectors) and child_chunks (1,166 vectors)

Chunking

Type Size Overlap
Parent 2000 chars 400
Child 500 chars 75
Regular 1000 chars 200

Access Control

Role Accessible Topics
Parent all, parents, kids
Child all, kids
Guest all

Health documents are parents-only; Nutrition and Education are open to all.


Retrieval Strategies

  1. Baseline — Simple k=3 similarity search on main chunks
  2. Parent-Child — Search child chunks, return full parent chunks for richer context
  3. Multi-Query + Reranking — Expand query into 3 variations, retrieve k=5, rerank top 4 with FlashRank cross-encoder
  4. All Combined — Parent-Child + Multi-Query + Reranking (most comprehensive)

All strategies share: topic classification filtering, role-based access control, and 5-turn conversation memory.


RAG Pipeline

PDF → Clean text → Auto-detect topic (LLM) → Enrich metadata → Store (main + child namespaces)
Query → Classify topic → Filter by role → Retrieve → [Rerank] → Prompt → gpt-4o-mini → Answer

Evaluation

Uses RAGAS with 4 metrics across 6 ground-truth Q&A pairs (2 per topic):

Metric Measures
Faithfulness Answer grounded in context (no hallucinations)
Answer Relevancy Answer addresses the question
Context Precision Relevant docs ranked at the top
Context Recall All needed information was retrieved

Setup

Designed to run in Google Colab.

Requirements

langchain-openai langchain-pinecone pypdf langchain ragas
datasets gradio flashrank python-dotenv

API Keys

Set the following secrets in Colab (or a .env file for local use):

  • OPENAI_API_KEY
  • PINECONE_API_KEY

Data

Upload the 3 PDFs to the Colab file browser. The notebook auto-detects and ingests any .pdf files present.


Source Documents

  1. St John Ambulance — First Aid Reference Guide (Health)
  2. Georgetown University — Family Food and Fitness Guide (Nutrition)
  3. U.S. Department of Education — Parent's Guide to Student Success (Education)

Author

Bruno Mirrado — family_assistant_v1

About

Final Project for a certification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors