Diagnosing Context Bank Rot and Mapping Text-to-SQL Generalization with CAT
Summary:The paper reframes enterprise text-to-SQL context banks as a semantic-consistency problem. By comparing queries at the decision level with a fast scorer distilled from human-calibrated LLM judges, it detects conflicting conventions that survive entry-by-entry SQL correctness checks. On BIRD-train, fine-tuning with the cleaned bank beats a same-size random subset by 2.6 points on average at every epoch; examples following one convention outperform opposite-convention examples by 13.3 points, whil
The paper treats enterprise text-to-SQL artifacts accumulated over time, including example queries, metric definitions, and domain knowledge, as a context bank. Its central observation is that the main failure mode is often not an individually invalid SQL statement, but mutually incompatible conventions across entries. The proposed CAT pipeline then turns the question of whether a model is reusing organizational conventions or genuinely generalizing into a measurable distance curve.
Core Finding: Local Correctness Does Not Guarantee Global Consistency
A context bank can be represented as B = {(q_i, sql_i, d_i)}, where d_i captures the business decisions behind a query, such as entity definition, aggregation grain, time window, filters, and source-of-truth tables. Conventional review checks whether entry i answers its own question, represented by local correctness C_i. Production systems instead need pairwise semantic consistency E_ij across entries. The former does not imply the latter.
For example, two SQL statements may each answer their own questions correctly while defining an active order as either a paid order or a non-refunded order, or choosing order data versus post-refund transaction data as the fact source. If both entries enter the retrieval context or fine-tuning corpus, the model must guess which convention to follow. The paper labels this long-term accumulation of individually plausible but globally conflicting records as context bank rot.
Mechanism: Decision-Level Comparison Rather Than String Matching
Instead of treating SQL as ordinary text for similarity matching, the paper compares queries decision by decision. Human-calibrated LLM judges provide teacher signals that are distilled into a fast scorer suitable for repeated auditing. The intended engineering division of labor is straightforward: an LLM judge can handle semantic judgments but remains expensive, slow, and stochastic, while a distilled scorer can scan an entire bank and concentrate expensive review on a small set of conflict candidates.
A deployed implementation could decompose the comparison into fact table, aggregation grain, filter boundaries, null handling, temporal semantics, and join path. The abstract does not disclose the paper's formal rubric, teacher and student models, distillation data, or scorer accuracy, so these dimensions should be treated as practical mappings rather than claims about the undisclosed algorithm.
Decision-level comparison also avoids treating harmless syntactic differences as conflicts. Aliases, keyword ordering, CTE structure, and equivalent join paths can change query text without changing semantics. Conversely, two SQL statements can use nearly identical syntax yet encode opposite business decisions. The cost is that a distilled scorer may inherit judge errors around subtle grain, time, or policy assumptions, making automatic deletion unsafe without execution checks and human review.
Measured Results: Consistency Matters More Than Raw Bank Size
On BIRD-train, fine-tuning with the cleaned context bank outperforms a same-size random subset at every epoch, with an average gain of 2.6 points. The size-matched comparison is important because it reduces the alternative explanation that more examples simply help. Under a roughly comparable coverage budget, semantic consistency is the more plausible source of the gain.
The audit results support targeted pruning. Among removed entries, 92.4 percent had SQL confirmed as requiring correction by independent expert review, while 45.6 percent of the broader audited set required correction. These groups do not have identical denominators, so the percentages should not be mechanically subtracted, but the comparison indicates that conflict-driven selection is more likely to identify genuinely defective records than random deletion.
The in-context experiment is even more revealing. Examples following one convention outperform examples following the opposite convention by 13.3 points, while mixing conflicting conventions performs only marginally better than providing no context. Supplying several mutually incompatible answers does not create richer supervision; it can make the target behavior unidentifiable.
CAT Turns Generalization into a Distance Curve
The paper introduces Context-Aware Testing, or CAT. It generates questions near a context bank while controlling how novel those questions are relative to the bank, allowing retrieval and fine-tuning to be evaluated over distinct ranges of familiarity. Although the exact distance formula is not disclosed, the statement that benefits largely disappear when roughly three quarters of a question's logic is new indicates that the novelty of query logic is a central control variable.
On CAT-BIRD, gains from both retrieval and fine-tuning decline stepwise as the distance increases. When approximately 75 percent of the question logic is new, the benefit of the bank is largely gone. On CAT-Spider, the retrieval benefit shrinks with distance as well. Context therefore appears to activate existing organizational conventions and query patterns more reliably than it transfers those patterns to unfamiliar decision structures.
This is more useful operationally than a single aggregate score. A test set that closely resembles the training bank can produce strong Text-to-SQL results while masking fragility on new metrics, table grains, or business rules. CAT makes that hidden applicability radius explicit.
Engineering Trade-offs: Cleaning, Scoring, and Testing All Carry Costs
- Cleaning can reduce coverage. Conflicting business entries should not be deleted indiscriminately, especially when they represent rare scenarios. A production system must optimize semantic consistency, domain coverage, and sample diversity together rather than ranking entries solely by conflict score.
- Automatic scoring introduces false positives and false negatives. Equal result sets do not always imply equal business semantics, and different SQL can accidentally agree because of the current data distribution. The fast scorer should triage candidates, not execute destructive actions by itself.
- Retrieval and fine-tuning fail differently. Fine-tuning embeds conventions into model parameters and avoids runtime retrieval, but it becomes harder to correct when a new question conflicts with learned behavior. Retrieval can swap context dynamically, yet it consumes context-window capacity and can retrieve mutually contradictory entries together.
- The CAT generator may introduce bias. If generated questions still reuse bank table names, templates, or phrasing, the measured distance may be overstated. Deliberate rewriting can also alter difficulty or create unnatural language, confounding novelty with generator style.
Benchmark Credibility: Strong Controls, Important Missing Details
The same-size random-subset baseline, human-calibrated judges, and independent expert audits provide stronger controls than reporting only final accuracy. The current arXiv abstract, however, does not disclose the model list, data splits, confidence intervals, agreement between the scorer and experts, CAT's exact distance formula, generation cost, inference latency, or code availability. BIRD and Spider cover representative Text-to-SQL settings, but enterprise databases differ substantially in metric definitions, permission boundaries, and temporal semantics, leaving cross-organization generalization unverified.
The reported 2.6-point and 13.3-point gains should therefore be interpreted as directional evidence under the paper's setup rather than universal improvement guarantees. In particular, the claim that benefits largely vanish when 75 percent of the logic is new requires a precise distance definition, quality checks for generated questions, and statistical variance estimates before it can become a capacity-planning threshold.
Developer Rollout: Treat the Bank as an Executable Specification
- Create a decision registry. For each metric, record its fact table, primary-key grain, time window, filters, null policy, permitted join paths, and authoritative owner. Business semantics should become versioned objects instead of remaining implicit in SQL text.
- Run semantic conflict detection. Normalize SQL ASTs before comparing decision dimensions, and separately flag queries that return the same values under different policies. Use the automatic scorer for ranking and triage rather than deletion.
- Repair conflict clusters while preserving coverage. Group contradictory definitions, ask a domain owner to select the canonical version, and then quarantine, correct, or deprecate old entries. Maintain a coverage matrix so cleanup does not remove low-frequency but important scenarios.
- Evaluate retrieval and fine-tuning separately. Compare them with the same models, prompts, budgets, and query sets, then report accuracy by CAT-style distance buckets instead of relying on near-duplicate test sets.
- Add regression gates. Scan for decision conflicts whenever an example, metric definition, or schema changes. Require human approval for high-impact entries and retain scorer versions, audit decisions, and rollback paths.
- Pilot on non-critical traffic. Connect cleanup, repair, and distance-based evaluation to shadow traffic first. Measure false removals, false alarms, latency, and reviewer cost before replacing an existing retrieval corpus or fine-tuning dataset.
Bottom Line
A context bank is not a longer prompt attachment; it is an executable organizational specification that must be maintained continuously. The paper's key contribution is to separate a large but contradictory bank from genuine generalization: consistent cleaning improves fine-tuning, unified conventions change how examples affect generation, and CAT shows that both retrieval and fine-tuning lose effectiveness as questions move away from the existing bank.
— END —Source: ArXiv NLP/LLM (cs.CL) (2026-11-23)
Tags: #Text-to-SQL #Context Banks #Semantic Consistency #CAT Evaluation #Retrieval-Augmented Generation
Editorial & Fact-Checking Note: This article is compiled from primary research, official release documentation, and source papers by the ZICQ Newsroom pipeline with automated entity verification and human editorial review. If you notice any technical inaccuracy, please submit a correction via our corrections policy or email our editorial desk directly.
Community Comments