A prototype demonstrating the Text2VectorSQL concept - translating natural language queries into hybrid SQL + Vector search queries.
Based on the research paper: Text2VectorSQL: Bridging Text-to-SQL and Vector Search
- 🔍 Natural Language to VectorSQL - Translate plain English queries to hybrid SQL
- 🧠 Chain of Thought Reasoning - See how the query is analyzed and translated
- 📊 Live Query Execution - Run generated queries on real data
- 🎯 Semantic Search - Find products based on meaning, not just keywords
pip install -r requirements.txtEdit .env file with your credentials:
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4.1
DATABASE_URL=postgresql://user:password@host:port/dbnamepython ingest_data.pyThis will:
- Load first 5,000 rows from Amazon reviews CSV
- Generate embeddings for text columns
- Store data with vectors in PostgreSQL
streamlit run app.pytext2vectorsql_demo/
├── .env # Configuration (you fill in)
├── .env.example # Configuration template
├── requirements.txt # Python dependencies
├── config.py # Configuration loader
├── database.py # PostgreSQL + pgvector operations
├── embeddings.py # OpenAI embedding generation
├── ingest_data.py # Data loading script
├── vectorsql_generator.py # LLM-powered query translator
├── app.py # Streamlit demo UI
└── README.md # This file
Try these in the demo:
-
"Find pet products that reviewers describe as durable and long-lasting"
- Uses vector search on review text + category filter
-
"Show me highly-rated office supplies with positive customer feedback"
- Combines semantic search with rating filter
-
"Find products similar to Blue Buffalo dog food with good reviews"
- Product similarity + sentiment analysis
User Query → LLM Analysis → VectorSQL Generation → Execution
↓ ↓ ↓ ↓
"Find..." Identify Generate Query DB
semantic + hybrid SQL with pgvector
structured + VECTOR_SEARCH
components
- PostgreSQL + pgvector - Vector database
- OpenAI GPT-4.1 - Query translation
- OpenAI Embeddings - text-embedding-3-small
- Streamlit - Interactive UI
- Python - Backend logic