KAIST Develops AI Technology That Fixes SQL Errors Without Starting Over
“Find the best-selling product from last year.” When an AI system attempts to answer a question like this by querying a company database, even a single reference to a nonexistent item can cause the query to fail. Until now, correcting such an error often required regenerating the entire SQL query from scratch. A KAIST research team has developed a technology that instead identifies and fixes only the erroneous part. The technology is expected to make AI-powered data retrieval faster and more accurate, accelerating the adoption of AI work assistants in enterprise environments.
KAIST (President Choongsik Bae) announced on September 4 that a research team led by Professor Min-Soo Kim from the School of Computing has developed SafeQL, a technology that detects and corrects errors that arise when natural-language questions are translated into Structured Query Language (SQL).
Text-to-SQL technology enables AI systems to convert everyday questions, such as “Which product saw the largest increase in sales last year?” or “Which items are running low in stock?”, into SQL queries. This allows users to retrieve sales, customer, and inventory data using natural language without having to understand complex database commands.
However, AI systems can make mistakes when generating SQL. For example, they may refer to a table or column that does not exist or join tables incorrectly. These errors can prevent the query from running and leave the AI unable to retrieve the requested data.
Conventional correction methods send the database error back to a large language model (LLM) and ask it to regenerate the entire query. This is similar to rewriting an entire report to correct a single word. In the process, parts that were already correct may be altered, new errors may be introduced, and repeated calls to the LLM increase both cost and processing time.
SafeQL takes a different approach. Instead of discarding and regenerating the entire query after an execution failure, it interprets feedback from the database management system to precisely locate the faulty component, such as a relation, attribute, function, or value. It then incrementally repairs that component while preserving the valid structure and logic of the original query.
To achieve this, the research team developed a “safe query space” approach. Among the candidate corrections that can be executed on the database, SafeQL searches for the one closest to the query originally generated by the AI. The system prioritizes the most promising candidates and filters out unsuitable ones in advance, reducing the time required for correction.
The team implemented SafeQL as a PostgreSQL extension and integrated it with the database system’s parser, binder, and type analyzer. This enables SafeQL to precisely locate errors even in complex SQL queries. The system calls the LLM again when search-based refinement cannot resolve the error within a predefined threshold, thereby reducing unnecessary AI use.
The research team evaluated SafeQL using BIRD and Spider, two widely used benchmarks for assessing the database querying capabilities of AI systems.
On the BIRD benchmark, SafeQL resolved execution errors in up to 87.4% of initially erroneous SQL queries and improved execution accuracy by up to 5.8 percentage points over the unrefined baseline. Compared with regenerating the entire query, SafeQL reduced token use by a factor of up to 15.1 and refinement latency by a factor of up to 29.6.
SafeQL is expected to be particularly useful for enterprises that handle large volumes of data requests. If an error occurs while an AI system is searching internal sales, customer, or inventory data, SafeQL can repair only the affected part instead of regenerating the entire query. This can reduce the cost and time required to operate enterprise AI systems and support reliable work automation powered by AI agents and corporate data.
Professor Min-Soo Kim said, “For AI to perform real-world tasks in enterprise environments, it must be able to accurately retrieve the data it needs.”
He added, “When AI makes an error during a database search, SafeQL fixes only the affected part instead of starting over from scratch. By reducing errors, costs, and processing time, we expect the technology to accelerate reliable AI-powered work automation.”
Geonho Lee, a PhD student in the KAIST School of Computing, participated in the study as first author, with Professor Min-Soo Kim serving as corresponding author. The findings will be presented at the International Conference on Very Large Data Bases (VLDB), a leading international database conference, to be held in Boston, USA, from September 1 to 5.
Paper title: SafeQL: Search-based Refinement for Safe and Efficient LLM-based Text-to-SQL
DOI: 10.14778/3819518.3819545
Authors: Geonho Lee (KAIST, first author) and Min-Soo Kim (KAIST, corresponding author)
This research was supported by the National Research Foundation of Korea (NRF) and the SW Star Lab program of the Institute of Information & Communications Technology Planning & Evaluation (IITP), both funded by the Ministry of Science and ICT (MSIT).
KAIST Develops a Soft 3D-Printed Robotic Hand that Gently Grips Everything from Eggs to a 1 kg Water Bottle
3D printers that once could only produce rigid objects can now create products as soft and stretchable as rubber. A team of Korean researchers used AI to identify the optimal "recipe" for a material that can be printed into complex shapes while stretching to more than six times its original length. The material is expected to expand the range of applications for 3D printing, from robotic hands to form-fitting wearable devices and custom medical devices.
KAIST (President Choong-Sik Bae) announced on September 1 that a research team led by Professor Seungchul Lee from the Department of Mechanical Engineering, working with Dr. Jongbeom Na's team at the Korea Institute of Science and Technology’s (KIST, President Sang-Rok Oh) Extreme Materials Research Center and Professor Bumsoo Park from the Department of Manufacturing Systems and Design Engineering (MSDE) at Seoul National University of Science and Technology (SEOULTECH, President Dong-Hwan Kim), had used AI to develop a material that is both 3D-printable and highly stretchable, like rubber.
The need for such materials — soft, stretchable, and capable of forming complex shapes — has been growing as soft robots that come into direct contact with people, wearable devices worn on the body, and medical devices custom-fitted to patients have drawn increasing attention.
The 3D printing technology the team used, Digital Light Processing (DLP), cures a liquid material into a desired shape by exposing it to light. While DLP can quickly produce complex structures, making a material more stretchable and durable tends to raise its viscosity to the point that it no longer flows well enough to be printed. Conversely, thinning the material to make it easier to print reduces its stretchability and strength. Thus, developing a material that is both easy to print and highly stretchable was the central challenge.
The team used AI to identify the optimal "material recipe" that satisfies both conditions. Notably, the training data included not only materials that print well, but also highly viscous materials that are difficult to print.
The researchers cured various liquid material formulations in small molds and measured how stretchable and hard they were, how quickly they cured under light, and how well they flowed. This produced a dataset linking a wide range of material formulations to their respective properties.
The team then used machine learning to examine the relationship between material formulation and performance. Based on this, the AI identified the optimal material combination that is both 3D-printable and highly stretchable.
The material identified by the AI printed reliably on a DLP 3D printer and showed high stretchability, extending to more than six times its original length when pulled, without easily tearing.
To verify its real-world potential, the team 3D-printed a "soft actuator" using the material. A soft actuator is a device that uses air pressure and other means to create gentle, muscle-like movement. When inflated with air, it expanded like a balloon and bent as naturally as a human finger.
A soft robotic hand made by combining several actuators lifted a 1 kg water bottle and successfully and stably grasped objects of varying shapes and rigidity, from fragile eggs to glass bottles, an egg carton, and a computer mouse.
Beyond developing a single highly stretchable material, this research is significant for presenting an AI-based method for more quickly identifying materials with desired properties.
Previously, researchers had to directly formulate and test countless materials to find the optimal combination. Going forward, AI can first identify promising material combinations based on experimental data, which researchers then verify through testing, thereby reducing trial and error and shortening material development time.
"This research is significant as it shows that combining researchers' experimental data with artificial intelligence can efficiently identify optimal material combinations that were previously difficult to find," explained Professor Seungchul Lee. "We expect it to be used to more rapidly develop 3D-printing materials with the performance needed across a range of fields, including soft robots, wearable devices, and custom medical devices."
The study, with Dr. Younghan Song and Professor Bumsoo Park as co-first authors, was published in the international journal Nature Communications on June 4.
Paper title: Machine learning guided formulation design of digital light processing printable elastomers beyond viscosity stretchability tradeoff
DOI: https://doi.org/10.1038/s41467-026-73735-4
This research was supported by the Ministry of Trade, Industry and Resource's Machinery and Equipment Industry Technology Development Program (20023762), and by the Ministry of Science and ICT's Nano & Material Technology Development Program (RS-2026-25534767) and Excellent New Researcher Program (RS-2024-00350423).