TL;DR
FINER-SQL introduces a novel reinforcement learning framework designed to elevate Small Language Models (SLMs $\le$ 3B parameters) to the level of massive LLMs for Text-to-SQL tasks. By replacing sparse binary rewards with fine-grained, dense feedback—specifically memory-based reasoning alignment and atomic operation rewards—it prevents training collapse and allows a 3B model to outperform 14B+ baselines while running efficiently on consumer hardware.
What Problem Does This Paper Address?
Translating natural language into executable SQL queries (Text-to-SQL) is a highly challenging task requiring schema linking, compositional reasoning, and strict formatting. While Large Language Models (LLMs) excel here, they are computationally expensive, suffer from high latency, and raise data privacy concerns when sensitive enterprise schemas are sent to external APIs.
Small Language Models (SLMs, 0.5B–3B parameters) offer a private, lightweight, and cost-effective alternative for on-premise deployment. However, they suffer from weak reasoning capabilities and poor instruction following. Standard reinforcement learning (RL) methods fail to bridge this gap because they rely on sparse binary rewards (1 for a perfectly correct query, 0 otherwise). Since SLMs generate incorrect or unexecutable SQL most of the time during early training, they receive zero learning signals, causing the RL process to stagnate or collapse.
Methods
The authors propose FINER-SQL, a two-stage framework that replaces sparse supervision with dense, interpretable feedback:
- Distillation (Diverse Reasoning Style): The authors first collect diverse reasoning paths from a pool of large teacher models (DeepSeek-R1, GPT-4o, Qwen-2.5-72B) to construct a "Reasoning Bank." The SLM undergoes Supervised Fine-Tuning (SFT) on this data to learn structured reasoning enclosed within
<think>tags. - Reinforcement Learning via GRPO: The model is optimized using Group Relative Policy Optimization (GRPO), a critic-free RL algorithm. Instead of a binary success/failure signal, FINER-SQL introduces a dense composite reward function:
- Format Reward: Gated reward ensuring the model adheres to the
<think>tag structure. - Execution Reward: Grants partial credit (1.0) if the SQL executes without syntax errors, and full credit (2.0) if the execution results match the ground truth exactly.
- Memory Reward: Measures the semantic similarity of the generated reasoning trace against a centroid of verified successful traces retrieved from other databases using a vector database (ChromaDB).
- Atomic Reward: Deconstructs the SQL query into clause-level atomic operations (e.g., specific
JOIN,WHERE_PRED,GROUP BYelements) and computes a Jaccard similarity against enriched reference queries to reward structural partial correctness.
The interplay of these rewards across different execution outcomes is visualized below:
Datasets
The framework was evaluated on two major Text-to-SQL benchmarks:
- Spider: A widely used cross-domain dataset containing 7,000 training samples across 200 databases.
- BIRD: A significantly more challenging, large-scale benchmark containing 9,428 training samples across 95 databases. BIRD features massive databases (averaging 549K rows) and requires external knowledge evidence, making it a robust test for real-world applicability.
Key Insights and Ideas
- Dense Rewards Overcome the Cold Start Problem: For small models, binary execution rewards are a dead end. Breaking down the reward into atomic SQL operations and reasoning similarity provides a continuous gradient for improvement, ensuring the model learns even from incorrect queries.
- Cross-Database Memory Regularization: The memory reward retrieves successful traces only from different databases. This clever design choice prevents the model from overfitting to specific schema tokens and instead forces it to learn generalized, abstract reasoning patterns (e.g., the logical flow of a subquery).
- RL Enforces Conciseness: Interestingly, RL training actually shortens the reasoning length. Before RL, the model generates long, rambling, and confused chains; after RL, the reasoning becomes highly goal-oriented and concise, mitigating schema confusion.
Key Results
- Outperforming Larger Models: The FINER-SQL 3B model achieved an impressive 67.73% execution accuracy (EX%) on BIRD dev, outperforming much larger open-source models like CodeS-15B (58.47%) and Reasoning-SQL 14B (65.31%).
- Spider Performance: It reached 85.0% EX% on Spider dev, matching or beating 7B and 14B alternatives.
- Efficiency and Cost: Inference latency for the 3B model was just 5.57 seconds per sample, compared to over 1800 seconds for some heavy open-source RL baselines. It requires only ~10GB of VRAM, making it fully deployable on a single consumer GPU like an RTX 4090.
Limitations and Future Work
While the paper demonstrates remarkable efficiency gains, a few limitations are apparent:
- Dependency on Schema Linking: The framework relies on an external schema-linking step (the authors used GRAST-SQL 0.6B) to filter down large schemas to the top 30 columns before generation. Performance might degrade if this initial filtering step fails.
- Teacher Reliance: The distillation phase still requires initial access to large proprietary or open-source teacher models to seed the Reasoning Bank.
- Future Directions: Promising future work includes exploring completely self-hosted reward generation without any teacher initialization, or extending this fine-grained feedback mechanism to other code-generation tasks like Python or Bash scripting.
Summary updated