Spaces:
Runtime error
Download COLAB_GUIDE.md from StudyOcean/Study-Ocean-AI_Mentor: direct link, hf CLI and curl.
- Browser
- Download file 3.49 kB
-
https://huggingface.co/spaces/StudyOcean/Study-Ocean-AI_Mentor/resolve/main/COLAB_GUIDE.md
- Command line
-
hf download hf://spaces/StudyOcean/Study-Ocean-AI_Mentor/COLAB_GUIDE.md
-
curl -L -o COLAB_GUIDE.md https://huggingface.co/spaces/StudyOcean/Study-Ocean-AI_Mentor/resolve/main/COLAB_GUIDE.md
π 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
- Go to drive.google.com
- Create a folder:
MyDrive/StudyOcean/ - Upload
StudyOceanPDFs.zipinto that folder - β³ Wait for upload to complete (6 GB β may take 15β30 min on slow wifi)
2. Get a Gemini API Key (Free)
- Go to aistudio.google.com/apikey
- Click Create API Key
- Copy the key β you'll paste it into the notebook
3. Open the Notebook in Colab
- Go to colab.research.google.com
- Click File β Upload notebook
- Upload
StudyOcean_RAG_Colab.ipynbfrom this folder
4. Set T4 GPU Runtime
This is critical β without it, ingestion will be very slow!
- In Colab: Runtime β Change runtime type
- Set Hardware accelerator = T4 GPU
- 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.zipto 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:
# 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.