# 🎓 Study Ocean RAG — Google Colab Guide > Your laptop stays cool. Colab's **T4 GPU** does all the heavy lifting. --- ## 📋 One-Time Setup (First Time Only) ### 1. Upload ZIP to Google Drive 1. Go to [drive.google.com](https://drive.google.com) 2. Create a folder: `MyDrive/StudyOcean/` 3. Upload `StudyOceanPDFs.zip` into that folder 4. ⏳ Wait for upload to complete (6 GB — may take 15–30 min on slow wifi) ### 2. Get a Gemini API Key (Free) 1. Go to [aistudio.google.com/apikey](https://aistudio.google.com/apikey) 2. Click **Create API Key** 3. Copy the key — you'll paste it into the notebook ### 3. Open the Notebook in Colab 1. Go to [colab.research.google.com](https://colab.research.google.com) 2. Click **File → Upload notebook** 3. Upload `StudyOcean_RAG_Colab.ipynb` from this folder ### 4. Set T4 GPU Runtime > **This is critical — without it, ingestion will be very slow!** 1. In Colab: **Runtime → Change runtime type** 2. Set Hardware accelerator = **T4 GPU** 3. Click **Save** --- ## 🚀 Running the Pipeline ### First Time (Fresh Ingestion) Run cells in order: **Steps 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10** | Step | What it does | Time | |------|-------------|------| | 1 | Verify T4 GPU + mount Drive | 30s | | 2 | Install packages | 2–3 min | | 3 | Configure settings (paste API key here!) | instant | | 4 | Extract PDFs from ZIP | 5–10 min | | 5 | Ingest PDFs & build vector store | **30–60 min** | | 6 | Save vector store to Drive | 2–5 min | | 7 | Test retrieval | instant | | 8 | Build RAG chain | instant | | 9 | Test full pipeline | 5s | | 10 | Launch Gradio chat UI | instant | ### Future Sessions (Vector Store Already Built) Run cells: **Steps 1 → 2 → 3 → 11 → 8 → 10** | Step | What it does | Time | |------|-------------|------| | 11 | Load saved vector store from Drive | 1–2 min | | 8 | Build RAG chain | instant | | 10 | Launch Gradio chat UI | instant | --- ## 💻 Running Locally (After Ingestion) Once the vector store is built, you can run the chat locally: ### Option A — Download via Colab (Step 12) - Run **Step 12** in the notebook - It downloads `vector_store_export.zip` to your computer - Extract it to: `Study_Ocean Rag/data/vector_store/` ### Option B — Download from Google Drive - Go to Drive → `StudyOcean/vector_store/` - Download the folder - Place it at: `Study_Ocean Rag/data/vector_store/` ### Then run locally: ```bash # Make sure .env has your GOOGLE_API_KEY python main.py chat # Web UI at http://localhost:7860 # OR python main.py ask # Terminal Q&A ``` --- ## ⚡ Performance on T4 GPU | Task | CPU (your laptop) | T4 GPU (Colab) | |------|------------------|----------------| | Embedding batch size | 64 | 256 | | ~10,000 chunks | ~45 min | ~8 min | | ~50,000 chunks | ~4 hours | ~35 min | | ~100,000 chunks | ~8 hours | ~70 min | --- ## ❓ Troubleshooting **"ZIP not found" error** → Update `ZIP_DRIVE_PATH` in Step 3 to match your actual Drive path **"CUDA not available"** → You forgot to set T4 GPU runtime! Runtime → Change runtime type → T4 GPU **Colab session disconnects during ingestion** → The vector store saves in batches. Re-run from Step 5 — FAISS will rebuild from scratch. Save to Drive often. **"Invalid API key"** → Make sure you pasted the full Gemini API key in Step 3 **Gradio link doesn't work** → Gradio public links expire after 72 hours. Re-run Step 10 to get a new link.