Taro Logo
2
0 Likes

Why Text-to-SQL Fails and How to Fix It

In this lesson we discuss why large language models do well on public text-to-SQL tests but fail on real data warehouses. We also look at what Stonebraker’s team is doing to improve results and why he thinks future AI systems will rely on database techniques.

  • Public benchmarks such as Spider and Bird show about 85% accuracy, but on benchmarks built from four real production warehouses, models scored 0%, rising to about 10% with retrieval and about 35% when given the correct tables and joins. The causes are that warehouse data isn’t in the training data, queries are far longer (often about 100 lines of SQL), schemas are messy with redundant views and cryptic column names, and the data is idiosyncratic, such as MIT’s January “J-term.”
  • His team published the Beaver benchmark and found that the model needs the query broken into simpler pieces, with the FROM clause and join terms provided. To combine data from sources like a warehouse, a CRM, CAD files and regulations in the Munich transportation project, he turns everything into tables and joins them in SQL with a query optimizer, instead of asking an LLM to do the join.
  • A skilled human with the schema and clear text gets very high accuracy on the same task, and he expects read-write agents to become a distributed database problem that needs atomicity and consistency.