Schema on the Inside: A Two-Phase Fine-Tuning Method for High-Efficiency Text-to-SQL at Scale
This paper presents a specialized 8B-parameter model for the Dream11 ecosystem that achieves high-precision, low-latency Text-to-SQL performance by using a novel two-phase fine-tuning method to internalize the database schema, thereby reducing input tokens by over 99% and outperforming state-of-the-art proprietary API-based models in a large-scale production environment.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Big Problem: The "Heavy Backpack" Approach
Imagine you have a brilliant but very expensive librarian (a Large Language Model, or LLM) who lives in a different country. Every time you ask them a question about a specific library, you have to mail them a giant, 17,000-page encyclopedia describing every single book, shelf, and rule in that library, just so they know where to look.
This is how most companies currently build "Text-to-SQL" tools (where you ask a question in English, and the computer writes a database query).
- The Cost: Since the librarian charges by the page they read, mailing them a 17,000-page book for every single question is incredibly expensive.
- The Speed: It takes a long time to mail, read, and reply. The user has to wait seconds (or even minutes) for an answer.
- The Result: It's slow, costly, and frustrating.
The Solution: "Baking" the Knowledge In
The team at Dream11 (a massive fantasy sports app in India) wanted to build a chatbot that could answer complex cricket questions instantly. They realized that mailing the encyclopedia every time was a bad idea.
Instead, they decided to teach the librarian the entire library by heart before they ever started answering questions. They wanted the librarian to carry the "encyclopedia" inside their own brain, so they wouldn't need to be sent the book every time.
They called this "Schema Internalization." Think of it like moving from a tourist with a map to a local who knows every shortcut.
How They Did It: The Two-Phase Training Camp
To turn a general AI into a cricket expert who knows the database by heart, they used a clever two-step training method (Fine-Tuning).
Phase 1: The "Classroom" (Learning the Rules)
First, they put the AI in a classroom with a massive textbook.
- The Lesson: They showed the AI thousands of examples where the question, the full database map (schema), and the correct answer were all visible at once.
- The Homework: They also gave the AI a specific test: "Here is a secret code (a database ID). Just repeat the entire database map back to me."
- The Goal: This forced the AI to memorize the structure of the database, not just the answers. It was like teaching a student to memorize the periodic table and how to use it, rather than just looking it up.
Phase 2: The "Exam" (Using the Memory)
Once the AI had studied hard in Phase 1, they moved to Phase 2.
- The Change: They stopped sending the 17,000-page encyclopedia. Now, they only sent a tiny note with the user's question and the "secret code" (the database ID).
- The Magic: Because the AI had memorized the map in Phase 1, seeing the code triggered its memory. It instantly recalled the database structure from its own "brain" and wrote the correct answer.
- The Result: The input size dropped from 17,000 tokens to less than 100. That's like shrinking a 17,000-page book down to a single sticky note.
The Results: Fast, Cheap, and Accurate
When they switched to this new method, the results were amazing:
- Speed: Because they stopped mailing the giant encyclopedia, the answers came back almost instantly.
- Cost: They stopped paying the expensive "per-page" fees to the third-party API. Now, they run the AI on their own servers, which is a fixed, predictable cost.
- Accuracy: Surprisingly, the AI got better at answering questions.
- Old Way (The Tourist): 95.6% accuracy.
- New Way (The Local): 98.4% accuracy.
Why This Matters (The "So What?")
Think of it like this:
- Before: You were hiring a taxi driver who didn't know the city, so you had to give them a GPS map for every single turn. It was slow and expensive.
- After: You hired a local driver who grew up in that city. You just say "Go to the stadium," and they know exactly how to get there without needing a map.
The Takeaway:
For companies that have a specific, unchanging set of data (like a sports database, a legal code, or a product manual), it is much smarter to train a specialized AI to know that data inside out than to keep feeding a generic AI huge chunks of text every time. It saves money, speeds things up, and actually makes the AI smarter.
This paper proves that you don't always need the biggest, most expensive AI model to get the best results; sometimes, you just need the right teacher and the right training method.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.