Introduction
Modern data management is currently bifurcated into two distinct worlds: the structured world of relational databases, queried via SQL, and the unstructured world of text and images, queried via semantic vector search. While Text-to-SQL has made structured data more accessible, it remains "blind" to the rich semantics in unstructured content. Conversely, vector search lacks the precise filtering and analytical power of SQL.
Integrating these two—a paradigm known as VectorSQL—has traditionally been a manual, expert-heavy process. Text2VectorSQL introduces a unified framework for translating natural language into queries that simultaneously handle structured relational data and unstructured semantic search. By providing a massive new benchmark (VectorSQLBench) and a specialized family of open-source models (UniVectorSQL), the researchers demonstrate that open-source models can now outperform proprietary counterparts like GPT-4o in complex, hybrid data retrieval tasks.
The Text2VectorSQL Framework
The authors built a foundational ecosystem to bridge the gap between structured and unstructured data retrieval, focusing on three core pillars: semantic filtering, multimodal matching, and retrieval acceleration.
To realize this framework, the researchers developed several key components:
- VectorSQLGen Pipeline: Since no public datasets existed for this task, the authors developed a four-stage pipeline to synthesize high-quality training data. It augments existing relational databases with vector columns, generates complex hybrid queries, and uses "back-translation" to turn those queries into natural language questions.
- UniVectorSQL Models: They fine-tuned a family of models (7B, 14B, and 32B parameters) based on Qwen2.5-Coder. Crucially, they used a "data mixture" strategy, training on both new VectorSQL data and traditional Text-to-SQL data to ensure the models didn't lose their ability to handle standard SQL analytics.
- Hybrid Chain-of-Thought (CoT): The models are trained to follow a structured reasoning process: decomposing the user's intent, linking schema elements, and then formulating the final hybrid query. This helps the model separate "hard" SQL filters from "soft" semantic search intents.
Datasets and Benchmarking
The study introduces two critical resources for the community:
- VectorSQLBench: The first large-scale benchmark for this task, featuring 2,997 high-quality samples. It covers 12 combinations of database backends (SQLite, PostgreSQL, ClickHouse) and data sources (BIRD, Spider, arXiv, Wikipedia).
- SynVecSQL-24k: A synthetic training dataset of 24,000 samples used to train the UniVectorSQL models.
The benchmark includes diverse linguistic styles (formal, vague, colloquial) and varies in complexity across both structural SQL (JOINs, subqueries) and vectorial integration depth.
Key Insights
- The Recall Degradation Challenge: A significant discovery is the "silent recall failure." In many systems, "post-filtering" is used—searching the vector index first and then applying SQL filters. In complex queries (especially those involving
JOINoperations), this can lead to over 30% of correct results being discarded. - Syntax Divergence: Vector operations are not standardized across databases. For example, PostgreSQL uses the
<->operator, while ClickHouse usesL2Distance(). A successful Text2VectorSQL model must be "multilingual" across these database dialects. - Decomposed Accuracy: Standard LLMs often fail because they try to "smush" structured filters into the semantic search string rather than keeping them as distinct SQL clauses. Measuring SQL skeleton accuracy and vector component accuracy separately reveals these distinct failure modes.
Performance Results
- SOTA Performance: The UniVectorSQL-32B model established a new state-of-the-art, achieving an average nDCG@10 of 42.7.
- Beating Proprietary Models: UniVectorSQL-32B outperformed top-tier proprietary models, including GPT-4o (42.0), Grok-3 (39.6), and Claude-3.7-Sonnet (38.5).
- The Power of CoT: Using Chain-of-Thought reasoning provided a consistent boost, improving the 32B model's performance by 3.2 points and significantly increasing query reliability.
- Reliability: UniVectorSQL-32B achieved a 93.9% execution success rate, meaning it almost always produces syntactically correct code that actually runs on the target database.
Limitations and Future Work
While the model generates correct queries, the underlying database's execution strategy (pre-filtering vs. post-filtering) still heavily impacts final quality. Future work should focus on "co-optimizing" query generation and database execution. Additionally, expanding the framework to more complex image, audio, and video retrieval within SQL is a logical next step, as is handling dynamic indexing where indices might need to be created on-the-fly.
Summary updated