Zainab4626 commited on
Commit
25d4110
·
1 Parent(s): 45a6663

Rewrite README for recruiter-facing presentation

Browse files
Files changed (1) hide show
  1. README.md +94 -10
README.md CHANGED
@@ -1,18 +1,102 @@
1
- # AIEngineeringWeek2V1
2
 
3
- LangChain RAG notebook: rag1.ipynb (Week 2 assignment).
4
 
5
- Repository: https://github.com/zainabahmed4626-lab/AIEngineeringWeek2V1
6
 
7
- ## Setup
8
 
9
- - Create a `.env` file locally with your `OPENAI_API_KEY` (do not commit it).
10
- - Place `textbook_1.pdf` and `textbook_2.pdf` next to the notebook (not committed here).
11
 
12
- ## Run
 
 
 
 
13
 
14
- Open `rag1.ipynb` and execute cells in order.
15
 
16
- ## Optional: GitHub helper
17
 
18
- `build_github_push_payload.py` is a small local utility used to generate a JSON payload for GitHub file uploads. It is not required to run the notebook.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Textbook RAG Assistant (LangChain + Chroma + OpenAI)
2
 
3
+ End-to-end **Retrieval-Augmented Generation (RAG)** system built for **Applied AI Engineering** workflows: ingest PDF textbooks, chunk + enrich metadata, embed into a vector database, evaluate retrieval quality, and ship a lightweight **Gradio** UI for interactive Q&A.
4
 
5
+ **Live repo:** https://github.com/zainabahmed4626-lab/AIEngineeringWeek2V1
6
 
7
+ ---
8
 
9
+ ## What this project demonstrates (recruiter-friendly)
 
10
 
11
+ - **Production-shaped RAG**: not “call an LLM”—a full pipeline from documents → chunks → embeddings → retrieval → grounded answers.
12
+ - **Grounding + safety posture**: answers are constrained to retrieved context with an explicit fallback when evidence is insufficient.
13
+ - **Retrieval engineering**: hybrid retrieval (**vector similarity + BM25**) and **metadata-aware filtering** hooks (source / section / date).
14
+ - **Evaluation discipline**: a small eval loop reporting retrieval / faithfulness / correctness style signals (assignment-oriented, extensible).
15
+ - **Product thinking**: a simple **Gradio** interface for manual testing, plus debug panels to inspect retrieved chunks.
16
 
17
+ ---
18
 
19
+ ## Architecture (high level)
20
 
21
+ ```mermaid
22
+ flowchart LR
23
+ PDFs[PDF textbooks] --> Load[LangChain PDF loader]
24
+ Load --> Chunk[RecursiveCharacterTextSplitter + metadata]
25
+ Chunk --> Embed[HuggingFace embeddings]
26
+ Embed --> VS[Chroma vector store]
27
+ VS --> RetV[Vector retriever]
28
+ Chunk --> RetB[BM25 retriever]
29
+ RetV --> Ens[Ensemble retriever]
30
+ RetB --> Ens
31
+ Ens --> QA[RetrievalQA (OpenAI chat)]
32
+ QA --> UI[Gradio UI]
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Tech stack
38
+
39
+ - **Orchestration**: LangChain (`RetrievalQA`, prompts, retrievers)
40
+ - **Embeddings**: `sentence-transformers/all-MiniLM-L6-v2` (via LangChain community integrations)
41
+ - **Vector DB**: Chroma (persistent store)
42
+ - **Hybrid retrieval**: BM25 (`rank-bm25`) + dense vectors (`EnsembleRetriever`)
43
+ - **LLM**: OpenAI chat model (`gpt-3.5-turbo`, temperature configurable)
44
+ - **UI**: Gradio
45
+ - **Notebook**: `rag1.ipynb` (single runnable artifact for the assignment)
46
+
47
+ ---
48
+
49
+ ## Key features implemented
50
+
51
+ - **Step 1 — Load**: PDF ingestion + sanity prints (document count + preview)
52
+ - **Step 2 — Chunk**: `RecursiveCharacterTextSplitter` with two chunking experiments + stats
53
+ - **Step 3 — Embed + Store**: embeddings persisted to Chroma (`./chroma_db`, collection `textbook_rag`)
54
+ - **Step 4 — Retrieval test**: `similarity_search` with annotated relevance notes
55
+ - **Step 5 — RAG chain**: `RetrievalQA` + custom prompt + retriever tuning
56
+ - **Step 6 — Evaluation**: mini eval set + structured reporting + aggregate scores
57
+ - **Hybrid retrieval**: vector + BM25 ensemble for stronger keyword coverage
58
+ - **Metadata enrichment**: `source`, `section`, `date` on chunks + optional filtered retrieval path
59
+ - **UX polish**: greeting handling in the Gradio path for a friendlier chat experience
60
+
61
+ ---
62
+
63
+ ## Quickstart (local)
64
+
65
+ ### 1) Prerequisites
66
+
67
+ - Python 3.10+ recommended (your notebook metadata may show newer; adjust if needed)
68
+ - OpenAI API access
69
+
70
+ ### 2) Configure secrets locally
71
+
72
+ Create a `.env` file in the project folder:
73
+
74
+ ```bash
75
+ OPENAI_API_KEY=...your key...
76
+ ```
77
+
78
+ This repo intentionally **does not** commit `.env`.
79
+
80
+ ### 3) Add your PDFs
81
+
82
+ Place these next to `rag1.ipynb` (not committed here):
83
+
84
+ - `textbook_1.pdf`
85
+ - `textbook_2.pdf`
86
+
87
+ ### 4) Run the notebook
88
+
89
+ Open `rag1.ipynb` and run cells **in order** (setup → load → chunk → embed → retrieval tests → RAG → eval → optional UI).
90
+
91
+ ---
92
+
93
+ ## Notes for hiring managers
94
+
95
+ - This project highlights **applied ML systems engineering**: retrieval quality, prompt constraints, observability (chunk previews), and iterative evaluation—not just prompt writing.
96
+ - The design is intentionally modular: you can swap embeddings, vector DB, rerankers, or swap the LLM provider without rewriting the whole pipeline.
97
+
98
+ ---
99
+
100
+ ## Optional helper script
101
+
102
+ `build_github_push_payload.py` generates a JSON payload for GitHub uploads. It is **not** required to run the RAG notebook.