File size: 1,115 Bytes
eb22b1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
title: SQL Books RAG
emoji: 📚
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: "6.6.0"
app_file: app.py
pinned: false
---

# 📚 SQL Books RAG

A Retrieval-Augmented Generation (RAG) system that answers SQL questions using content from 5 SQL textbooks.

## How It Works

1. **Retrieval** – Your question is embedded using `all-MiniLM-L6-v2` and matched against a FAISS index of ~500-word chunks extracted from the books.
2. **Generation** – The top-5 most relevant chunks are fed as context to `Llama 3.1-8B` via the Groq API to produce a detailed, grounded answer.

## Data Sources

| Book | Author |
|------|--------|
| Practical SQL: A Beginner's Guide to Storytelling with Data | Anthony DeBarros |
| SQL for Data Scientists | Renee M. Teate |
| SQL for Data Analysis | Cathy Tanimura |
| The Art of SQL | Stéphane Faroult |
| Learning SQL: Generate, Manipulate, and Retrieve Data | Alan Beaulieu |

## Tech Stack

- **Embeddings**: `sentence-transformers/all-MiniLM-L6-v2`
- **Vector Store**: FAISS (IndexFlatL2)
- **LLM**: `Llama 3.1-8B-Instant` via Groq API (free tier)
- **UI**: Gradio