Uber’s QueryGPT is an advanced AI-powered system that translates natural language inputs into optimized SQL queries, significantly enhancing data accessibility and operational efficiency. Built upon Large Language Models (LLMs), vector databases, and retrieval-augmented generation (RAG), QueryGPT streamlines the SQL query-writing process by automating dataset selection, query structuring, and optimization.
Uber processes approximately 1.2 million interactive queries monthly, with its Operations team contributing to a significant portion of these. Traditionally, writing an SQL query requires understanding table schemas, locating relevant datasets, and manually constructing the query, which could take 10 minutes or more per query. QueryGPT accelerates this process, reducing query generation time to just 3 minutes, dramatically improving efficiency and decision-making speed.
Initially developed during Uber’s Generative AI Hackdays in May 2023, QueryGPT started as a Retrieval-Augmented Generation (RAG) system that vectorized user queries, performed similarity searches against SQL samples and schemas, and guided LLMs in selecting the appropriate schema and tables.
To improve accuracy, efficiency, and cost-effectiveness, Uber enhanced QueryGPT with the following components:
QueryGPT’s workflow consists of multiple stages to ensure accuracy, efficiency, and reliability in SQL query generation:
Using vector-based semantic search, QueryGPT first interprets the natural language prompt and classifies it under an appropriate business domain. For example, a query related to ride cancellations would be mapped to the Mobility workspace.
Once the domain is identified, Table Agents perform similarity searches against Uber’s metadata store, selecting relevant tables based on historical SQL queries and predefined relationships. Users can override these selections to ensure accuracy.
To prevent unnecessary data retrieval, Column Prune Agents analyze the selected tables and filter out irrelevant columns. This improves efficiency by reducing the token count passed to the LLM and minimizes computational overhead.
After preprocessing, QueryGPT retrieves relevant SQL examples from the workspace and feeds them, along with user inputs, into the LLM using Retrieval-Augmented Generation (RAG). The LLM then generates an SQL query while ensuring:
Once the query is generated, QueryGPT:
Uber has implemented a structured evaluation framework to ensure QueryGPT consistently delivers accurate and optimized SQL queries:
QueryGPT has already demonstrated tangible benefits at Uber, saving an estimated 140,000 hours per month in query-writing efforts. By automating complex SQL generation, it enables teams to focus on data-driven insights rather than spending time manually constructing queries.
As AI-powered query generation tools evolve, they are expected to play a pivotal role in the broader enterprise data ecosystem, making self-service data access more efficient and scalable.
For businesses outside Uber seeking a robust text to SQL solution, Sequel.sh provides a powerful SaaS platform for converting all your natural language queries into SQL. Sequel.sh offers advanced data analysis, visualisation and ease of use for any team in your organisation without writing a single line of SQL.
Sequel offers several powerful features that simplify the SQL querying process:
With these features, Sequel saves time and boosts productivity, making it an ideal solution for data teams.
Save hours of time writing SQL queries. Get started for free.