Papers › CodeS: Towards Building Open-source Language Models for Text-to-SQL

CodeS: Towards Building Open-source Language Models for Text-to-SQL

26 Feb 2024arXiv:2402.16347archive 2025-07-28

Haoyang Li, Jing Zhang, Hanbing Liu, Ju Fan, Xiaokang Zhang, Jun Zhu, Renjie Wei, Hongyan Pan, Cuiping Li, Hong Chen

Language models have shown promising performance on the task of translating natural language questions into SQL queries (Text-to-SQL). However, most of the state-of-the-art (SOTA) approaches rely on powerful yet closed-source large language models (LLMs), such as ChatGPT and GPT-4, which may have the limitations of unclear model architectures, data privacy risks, and expensive inference overheads. To address the limitations, we introduce CodeS, a series of pre-trained language models with parameters ranging from 1B to 15B, specifically designed for the text-to-SQL task. CodeS is a fully open-source language model, which achieves superior accuracy with much smaller parameter sizes. This paper studies the research challenges in building CodeS. To enhance the SQL generation abilities of CodeS, we adopt an incremental pre-training approach using a specifically curated SQL-centric corpus. Based on this, we address the challenges of schema linking and rapid domain adaptation through strategic prompt construction and a bi-directional data augmentation technique. We conduct comprehensive evaluations on multiple datasets, including the widely used Spider benchmark, the newly released BIRD benchmark, robustness-diagnostic benchmarks such as Spider-DK, Spider-Syn, Spider-Realistic, and Dr.Spider, as well as two real-world datasets created for financial and academic applications. The experimental results show that our CodeS achieves new SOTA accuracy and robustness on nearly all challenging text-to-SQL benchmarks.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2402.16347")

Code

Syntology Ran 12 of 16 code samples harvested from 1 repository linked to this paper; 4 have no recorded run. Of those that ran: 12 ran with no contract checked.

By repository: official repository: 16 samples from 1 repository, 12 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ruckbreasoning/codes officialmentioned in paperpytorchApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

16 samples harvested; 12 ran; 0 honoured the contract we drafted; 4 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

12ran
4unverified

Licence: 0 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from ruckbreasoning/codes. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

compare_sql ruckbreasoning/codes/evaluate_ex.py official repository ran Apache-2.0 (permissive) · 9c09b83ecd4e3646 · report
extract_large_numbers ruckbreasoning/codes/prepare_sft_datasets.py official repository ran fingerprinted Apache-2.0 (permissive) · fde45273dd27b383 · report
get_schema ruckbreasoning/codes/schema_item_filter.py official repository ran Apache-2.0 (permissive) · 56e8906d4b412b25 · report
get_sequence_length ruckbreasoning/codes/schema_item_filter.py official repository ran Apache-2.0 (permissive) · 8af31230a92da0c1 · report
masked_softmax ruckbreasoning/codes/modeling_gpt_bigcode.py official repository ran Apache-2.0 (permissive) · 49334501abd461a4 · report
prepare_input_ids_and_attention_mask ruckbreasoning/codes/text2sql_few_shot.py official repository ran Apache-2.0 (permissive) · 93d18eb1da1b928c · report
prepare_inputs_and_labels ruckbreasoning/codes/schema_item_filter.py official repository ran Apache-2.0 (permissive) · 379783e2b5131276 · report
remove_similar_comments ruckbreasoning/codes/prepare_sft_datasets.py official repository ran Apache-2.0 (permissive) · c1c7de5d97c5b309 · report
resume_model_and_optimizer ruckbreasoning/codes/train_causal_lm.py official repository ran Apache-2.0 (permissive) · 4a150066109c1a86 · report
text2sql_func ruckbreasoning/codes/text2sql_zero_shot.py official repository ran Apache-2.0 (permissive) · c9ee130e5a1966a9 · report
upcast_masked_softmax ruckbreasoning/codes/modeling_gpt_bigcode.py official repository ran Apache-2.0 (permissive) · 38cab2f301010b6d · report
upcast_softmax ruckbreasoning/codes/modeling_gpt_bigcode.py official repository ran Apache-2.0 (permissive) · 49527b68e554c71a · report
execute_sql ruckbreasoning/codes/evaluate_ex.py official repository unverified Apache-2.0 (permissive) · e4ab0d16733f055d · report
extract_skeleton ruckbreasoning/codes/text2sql_few_shot.py official repository unverified Apache-2.0 (permissive) · 5d9edf7a65f4c0f4 · report
prepare ruckbreasoning/codes/tokenize_pt_corpus.py official repository unverified Apache-2.0 (permissive) · e459a1d6427bf16a · report
prepare_batch_inputs_and_labels ruckbreasoning/codes/train_schema_item_filter.py official repository unverified Apache-2.0 (permissive) · 0f37491b931ec512 · report

Tasks

Data AugmentationDiagnosticDomain AdaptationLanguage ModellingText to SQLText-To-SQL

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutGPT-4Label SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformer

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections