Compact models can recover enterprise data lineage from code
Researchers developed a 7B model that extracts schema lineage from complex code, significantly improving downstream text-to-SQL accuracy for agents.
Source: Grafy Research LabResearchers have demonstrated that small, specialized language models can effectively reconstruct the complex relationships within enterprise data pipelines. By distilling knowledge from larger frontier models into a 7B parameter model, they achieved performance levels comparable to much larger systems, specifically for the task of schema lineage extraction.
Why is enterprise data lineage difficult for AI?
In large-scale corporate environments, data pipelines often consist of multilingual scripts that contain critical business logic. According to the paper "From Enterprise Pipelines to Agent Context," these scripts encode how data is transformed, aggregated, and moved across various tables. Current coding and data agents frequently struggle to identify the long-range dependencies and transformations required to understand where a specific derived column originated.
Because enterprise scripts are often proprietary, companies face privacy constraints when using frontier models. Furthermore, making a high-cost API call to a massive model for every single column in a database is economically inefficient. This creates a need for compact, locally deployable models that can perform these specific extraction tasks without the overhead of a massive parameter count.
How does the distillation framework work?
To solve this, the authors proposed a two-stage fine-tuning approach using the Qwen2.5-Coder-7B model. The process begins with a "teacher" model, GPT-4.1, which is used to expand expert annotations into detailed reasoning traces and structured answers. To ensure high quality, only the traces that achieve a score above 0.95 under the Schema Lineage Composite Evaluation (SLiCE) metric are used for the first stage of training, known as supervised fine-tuning (SFT).
Following SFT, the researchers applied reinforcement fine-tuning (RFT) using a technique called Group Relative Policy Optimization (GRPO). A key innovation in this stage was the introduction of a "Graded SLiCE" reward. Standard SLiCE metrics can be problematic for training because they use binary multipliers—if a model misses a single source column or fails a formatting requirement, the entire reward drops to zero. This provides no signal for models that are "almost" correct. The Graded SLiCE reward instead provides partial credit for recovering source columns and maintaining semantic correctness, which allows the model to learn more effectively from its mistakes.
What are the performance results?
Under the SLiCE evaluation framework, the fine-tuned 7B model showed significant improvements over the base version. The base Qwen2.5-Coder-7B achieved a pipeline-macro SLiCE of 0.1392, which rose to 0.5233 after SFT, and finally reached 0.5843 after the Graded SLiCE GRPO phase.
This 7B specialist performed at a level comparable to GPT-4o, which scored 0.5764 in the same pipeline-macro category. Notably, the specialized 7B model outperformed the much larger Qwen2.5-Coder-32B baseline, which scored 0.4743. This demonstrates that task-specific adaptation can allow a much smaller model to surpass the general capabilities of larger models in a specialized domain.
Does this help downstream AI agents?
Beyond just extracting the lineage, the researchers tested how this information benefits other AI tasks, specifically text-to-SQL generation. When a text-to-SQL agent was provided with matched metadata but no lineage information, its execution accuracy on lineage-dependent questions was only 27.4%.
However, when the agent was supplied with the lineage extracted by the compact 7B model, its accuracy on those same questions jumped to 75.0%. This suggests that providing structured context about how data is derived is a highly effective way to improve the reliability of agents performing complex database queries.
How to apply these concepts in practice
For developers working with complex codebases or large-scale data structures, the ability to extract structured context from messy scripts is vital. While this specific research focuses on high-level pipeline distillation, the principle of using specialized models to interpret code can be applied to many workflows.
If you are working on developing or debugging complex scripts, you can use Grafy Code to interact with your programming environment. For researchers looking to dive deeper into the mathematical or structural complexities of the papers mentioned in this study, Grafy Reader provides a workspace to query and analyze academic PDFs directly.
Frequently asked questions
What is schema lineage?
Schema lineage is the structured map of how data moves through a system. It identifies the specific source columns, tables, and transformations that contribute to a final output or derived column. It provides the necessary context to understand the provenance and business logic embedded within complex data pipelines.
How does the Graded SLiCE reward improve training?
The Graded SLiCE reward improves training by providing fractional credit for partially correct answers. Unlike standard metrics that might give a zero reward for a single error, this method rewards models for correctly identifying source components and maintaining semantic meaning, which provides a much clearer learning signal during reinforcement learning.
Can a 7B model outperform a 32B model?
Yes, a 7B model can outperform a 32B model if it undergoes intensive task-specific fine-tuning. In this research, the specialized 7B model reached a SLiCE score of 0.5843, which was significantly higher than the 0.4743 score achieved by the much larger Qwen2.5-Coder-32B baseline.
Source: Yi-Wei Chen, Jiaqi Yin, Meng-Lung Lee, Xiya Liu (arXiv:2612.00941)


