TL;DR
GRACE (Generative, Ranked, Adaptive Code Ensemble) is a new multi-agent pipeline that significantly boosts the accuracy of LLMs performing tabular data analysis. By moving beyond "single-try" code generation to a parallel ensemble with a pairwise tournament judge and a domain-specific guardrail, it can recognize when all its attempts are wrong, abstain from answering, and trigger an "adaptive retry" with targeted feedback.
What Problem Does This Paper Address?
When we ask an LLM agent to analyze a dataset (like a CSV file), the standard approach is a "single rollout": the agent writes one Python script, executes it, and returns the result. If the script has a subtle logic error, the user gets a confident but wrong answer.
Existing improvements often rely on "Best-of-N" sampling with majority voting. However, voting has two major flaws in data analysis:
- Complexity: It’s easy to vote on a single number (e.g., "What is the average age?"), but hard to vote on structured outputs like dataframes or charts.
- The "Always-Pick" Problem: Voting systems almost always return a result, even if every single candidate in the pool is incorrect.
The authors tackle the challenge of label-free selection: how can a system judge its own work and decide to retry without knowing the "correct" answer beforehand?
Methods
The GRACE pipeline (illustrated in Figure 1) breaks the analysis task into a multi-stage process:
- Dataframe Description: A dedicated agent creates a compact, semantic schema of the data to ensure all subsequent agents are "looking at the same map."
- Parallel Generation: $N$ agents generate code concurrently. To prevent them from all making the same mistake, they are diversified using Personas (e.g., one agent is "defensive/robust," another is "exploratory/chart-generous").
- Strict Output Contract: Every agent must return a specific Python dictionary containing a pandas DataFrame. This makes structural failures (like returning a raw list instead of a table) easy to catch automatically.
- Selection Stage:
- Pairwise Tournament: Instead of ranking all candidates at once, the system runs a "knockout" tournament where an LLM judge compares two candidates at a time. Research shows LLMs are much more reliable at head-to-head comparisons than absolute scoring.
- Guardrail Selection: A final domain-specialized judge either approves the best candidate or rejects the entire pool if none are defensible.
- Adaptive Retry: If the pool is rejected, the system doesn't just start over. It provides each agent with a specific critique of its previous failure and forces the next attempt to include a new "code invariant" (a structural assertion) to prevent repeating the same logic error.
Datasets
The authors evaluated GRACE on two primary benchmarks:
- InfiAgent-DABench (DAEval): A challenging set of 246 questions requiring multi-step statistical analysis, data preprocessing, and machine learning.
- DataBench: A larger corpus of 400 questions focused on fact-oriented retrieval and simpler aggregations (e.g., "How many billionaires are in the Technology category?").
Table 1 provides examples of the types of questions found in these benchmarks:
Key Insights and Ideas
- Substitutability of Levers: One of the most interesting findings is that "parallel agents" ($N$) and "retry budget" ($r$) are largely interchangeable. If you have a high number of parallel agents, you don't need many retries, and vice versa. This allows developers to choose a "cheap" operating point (like 2 agents with 4 retries) that achieves near-peak accuracy.
- The Power of Abstention: Unlike voting, GRACE can say "I don't know." While the current guardrail is better at picking the best answer than recognizing when all are wrong, the ability to trigger a retry based on a "no-confidence" verdict is a major architectural step forward.
- Personas vs. Temperature: The authors found that injecting diversity through prompt-level personas was more effective for covering the solution space than simply increasing the LLM's sampling temperature.
Key Results
Using the Qwen3.6-35B-A3B model as a backbone:
- DAEval Accuracy: Jumped from 39% (single-rollout baseline) to 71% with GRACE.
- Error Recovery: The system successfully recovered 53% of the questions that the baseline model got wrong.
- DataBench Accuracy: Rose from 70% to 85%.
- Superiority over Voting: In a controlled test, GRACE's tournament+guardrail approach outperformed standard majority voting by 3.8 percentage points, proving that judging the process (code and artifacts) is better than just counting the results.
Limitations and Future Work
- Abstention is the "Weak Link": The guardrail currently only rejects all-wrong pools about 10% of the time. Improving this "abstention axis" is the primary goal for future versions.
- Upstream Data Quality: The study assumes the input CSV is correct. In real-world production, the data itself might be the result of a faulty ETL process, which GRACE does not yet account for.
- Compute Costs: While the authors identified efficient operating points, running multiple agents and a tournament judge is inherently more expensive than a single call. Future work will look at more "compute-matched" comparisons to optimize the budget further.
Summary updated