You Only Read Once ( YORO ): Learning to Internalize Database Knowledge for Text-to- SQL (2025)

Abstract: While significant progress has been made on the text-to-SQL task, recent solutions repeatedly encode the same database schema for every question, resulting in unnecessary high inference cost and often overlooking crucial database knowledge. To address these issues, we propose You Only Read Once (YORO), a novel paradigm that directly internalizes database knowledge into the parametric knowledge of a text-to-SQL model during training and eliminates the need for schema encoding during inference. YORO significantly reduces the input token length by 66%-98%. Despite its shorter inputs, our empirical results demonstrate YORO’s competitive performances with traditional systems on three benchmarks as well as its significant outperformance on large databases. Furthermore, YORO excels in handling questions with challenging value retrievals such as abbreviation.

## introduction the text-to-sql task aims to convert natural language questions (nlqs) into executable sql statements, enabling users without sql expertise to query databases effortlessly. existing text-to-sql systems typically encode both a linearized database schema, which sometimes appended with partial database content @xcite , and an nlq as input to generate a sql query grounded in the database @xcite . however, this conventional approach presents several limitations, as illustrated in figure 1 . first, the repeated encoding of the same schema for every question significantly increases the computational inefficiency, especially when dealing with large database schemas. second, while the linearized schema input represents the high-level structure of the database, it may still omit crucial information, such as all possible cell value choices, relationships among columns and cell values, and domain-specific knowledge. third, when appending schema with partial database content, existing text-to-sql systems usually require a cell value retrieval phase for each question. this process incurs additional retrieval costs and can lead to errors if retrieval misses occur due to challenging value scenarios like abbreviations in the question @xcite , resulting in incorrect sql generation (e.g., it might fail to retrieve the value al given american league in the nlq). to address these limitations, this work introduces a novel training paradigm for the text-to-sql task, dubbed you only read once (yoro). as illustrated on the left side of figure 2 , yoro takes a fundamentally different approach by first conducting a database knowledge acquisition phase. this phase comprehensively understands the database content and directly internalizes database information into the parametric knowledge of a text-to-sql model. we achieve this by fine-tuning a language model on synthetic text-to-sql data generated for target databases. the key advantage of yoro is evident at inference time, where it can convert nlqs into sql queries grounded in the database without requiring schema encoding. this streamlined process contrasts sharply with the multiple steps and potential pitfalls of the conventional approach. furthermore, we propose training text-to-sql expert models, with each expert specializing in a specific our extensive evaluation on popular text-to-sql benchmarks, including spider @xcite , kaggledbqa @xcite , and bird @xcite , demonstrates that yoro performs competitively compared to traditional approaches across different model choices, llama-7b @xcite and mistral-7b @xcite . crucially, yoro achieves this performance while maintaining significantly reduced input lengths. our contributions are three-fold. first, we propose a novel text-to-sql paradigm, yoro, where expert models acquire database knowledge during the training phase and utilize this knowledge to answer questions without having database access in inputs during inference phase. this results in significantly shorter inputs and eliminates dependence on value retrievers. second, experimental results demonstrate that yoro achieves comparable performance with traditional methods. third, our case studies reveal that yoro significantly outperforms traditional methods in large databases and excels at handling questions with challenging value retrievals. ## yoro yoro encompasses a training stage for database comprehension and knowledge acquisition, followed by an inference stage focused on question comprehension and sql generation. as illustrated in figure 2 , we propose a straightforward approach to acquire database knowledge: synthesize a vast collection of high-quality nlq-sql pairs for the target database, then continue training large language models to become text-to-sql experts. once the yoro expert model is ready, we can use it for online inference without accessing schema information. in contrast, traditional text-to-sql systems require constructing a database index and retrieving cell values, a time-consuming process that also incurs index maintenance costs. after cell value retrieval, we must serialize the schema and construct a significantly longer input for model inference. in the next sections, we will delve into the intricacies of our prompt design, training phase, and inference phases. ## conclusion motivated in part by recent studies on compressing instructions and contexts, this work introduced yoro, a new training paradigm for text-to-sql. it enables database knowledge acquisition by finetuning domain experts on text-to-sql synthetic data and answer questions without having database access. yoro outperformed picard baselines with mistral and llama while also surpassing codes baselines with llama.