You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RAG-Enhanced SQL Generation: Fine-Tuning TinyLlama-1.1B for Natural Language to SQL Translation
๐ Project Overview
QueryCraft is a Retrieval-Augmented Generation (RAG) system that converts natural language questions into executable SQL queries. Built on the Spider benchmark dataset (7,000 examples across 160 database schemas), it combines:
Fine-tuned LLM using QLoRA (4-bit quantization + LoRA adapters)
RAG pipeline for schema-aware context retrieval
Interactive Gradio demo with 3 databases and live SQL execution (dropdown + natural language modes)
QueryCraft can be deployed as a microservice serving any application
vs Snowflake Cortex AI / Databricks Genie
Both require expensive data warehouse subscriptions
QueryCraft can generate SQL for any database, not just cloud warehouses
Fine-tuning on company data takes 7 minutes vs weeks of enterprise deployment
Companies Deploying NL-to-SQL Technology
FAANG / Big Tech
Company
Product
Technology
Limitation QueryCraft Solves
Google
BigQuery NL
PaLM + SQL
GCP lock-in, per-query cost
Amazon
QuickSight Q
ML + NL-to-SQL
AWS-only, enterprise pricing
Meta
Internal Platform
Custom NLP + SQL
Not publicly available
Apple
Internal BI Tools
ML + SQL Generation
Proprietary, closed-source
Microsoft
Power BI Copilot
GPT-4 + DAX/SQL
$36/user/month, M365 required
Netflix
DJ (DataJunction)
Semantic Layer + SQL
Internal-only tool
Enterprise Software & Database Vendors
Company
Product
Technology
Limitation QueryCraft Solves
Oracle
Select AI
LLM + Autonomous DB
Oracle DB only, expensive
Salesforce
Einstein Analytics
AI + SOQL
Salesforce ecosystem only
SAP
Analytics Cloud
NLP + HANA SQL
SAP HANA required
Snowflake
Cortex AI
LLM + SQL
Snowflake subscription required
Databricks
AI/BI Genie
LLM + Spark SQL
Databricks platform only
IBM
Watson Analytics
NLP + SQL
Enterprise licensing
BI & Analytics Platforms
Company
Product
Technology
Limitation QueryCraft Solves
Tableau
Ask Data
NLP + VizQL
Tableau license, VizQL not SQL
ThoughtSpot
Sage
NL-to-SQL + LLM
Enterprise pricing ($100K+/yr)
Looker (Google)
Looker + Gemini
LLM + LookML
GCP required, LookML not SQL
Qlik
Qlik Sense AI
NLP + Associative Engine
Proprietary engine
Domo
Domo AI
NLP + SQL
SaaS subscription required
Tech Unicorns & Innovators
Company
Product
Technology
Limitation QueryCraft Solves
Uber
Databook
NLP + SQL Discovery
Internal tool, not available
Airbnb
Minerva
Semantic Layer + SQL
Internal, company-specific
LinkedIn
Data Hub
NLP + Metadata SQL
Not publicly deployable
Spotify
Internal Analytics
Beam + SQL
Internal infrastructure
Stripe
Sigma
NLP-assisted SQL
Payment domain only
Palantir
Foundry AIP
LLM + SQL
$1M+ enterprise contracts
๐ Market Opportunity
Metric
Value
Source
BI Tools Market (2024)
$33.3 billion
Gartner
Projected Market (2029)
$54.9 billion
MarketsandMarkets
CAGR
10.5%
Industry reports
Key Growth Driver
Natural language interfaces
Analyst consensus
NL-to-SQL Segment Growth
25%+ annually
Enterprise adoption trends
QueryCraft's Position
QueryCraft addresses the underserved segment of the NL-to-SQL market:
Segment
Current Solutions
QueryCraft Advantage
Startups & SMBs
Can't afford $100K+ enterprise tools
Free, open-source, runs on free Colab
Multi-cloud orgs
Locked into single vendor's NL tool
Database-agnostic, portable SQL
Research & Academia
Need customizable, explainable models
Open weights, transparent RAG, fine-tunable
Regulated industries
Can't send data to cloud LLM APIs
Runs 100% locally, no data leaves the org
Domain specialists
Generic models don't know their schemas
Fine-tune on domain data in 7 minutes
Bottom line: While enterprise solutions cost $50K-500K/year and lock you into one vendor, QueryCraft delivers comparable NL-to-SQL capability for free, on any database, with full transparency and customizability.
Running on public URL: https://xxxxx.gradio.live โ Click this!
Note: Days 1-4 notebooks document the development process (data prep, training iterations, evaluation, demo prototyping). They are included for reference but are not required to run Day 5. The Day 5 notebook is fully self-contained.
"Top countries by invoices", "Products under $100?"
Example Queries Per Database
University:
Count rooms not in Lamberton building
Students in CS with GPA > 3.5
Professors earning more than 100000
Total credits by department
HR:
Employees with salary > 80000
Count employees per department
Average salary by department
Employees hired after 2021
E-commerce:
Top 5 countries by invoices
Total revenue by country
Products under $100
Top spending customers
๐ Evaluation
Metrics
Metric
Description
Exact Match
Strict character-level SQL comparison
Component Match
SQL keyword + structure overlap
Valid SQL Rate
Syntax validation using sqlparse
Has SELECT
Whether output contains SELECT clause
Has FROM
Whether output contains FROM clause
WHERE Match
Correct WHERE clause generation
Error Analysis
Error Type
Count
%
Description
Missing Clauses
4
40%
Missing FROM, WHERE, ORDER BY
Wrong Aggregation
3
30%
Incorrect COUNT, SUM, AVG
Syntax Errors
1
10%
Unparseable SQL
Other
2
20%
Wrong table/column names
Visualizations Generated (Day 5)
results/visualizations/
โโโ 01_hyperparameter_comparison.png # Config A vs B vs C
โโโ 02_model_comparison.png # Baseline vs fine-tuned + radar chart
โโโ 03_rag_comparison.png # No RAG vs With RAG
โโโ 04_error_analysis.png # Error pie + examples + improvements
โโโ 05_training_curves.png # Loss curve + LR schedule
โโโ 06_demo_coverage.png # Demo stats + Spider domains
โโโ 07_final_dashboard.png # Combined summary dashboard