nvAgent: Automated Data Visualization from Natural Language via Collaborative Agent Workflow

Geliang Ouyang, Jingyao Chen, Zhihe Nie, Yi Gui, Yao Wan, Hongyu Zhang, Dongping Chen

Introduction

The field of Natural Language to Visualization (NL2VIS) seeks to democratize data analysis by allowing users to generate complex charts through simple natural language queries. However, current Large Language Model (LLM) approaches often struggle with complex queries, particularly those involving multi-table schemas. Common failure modes include incorrect table joins, "schema linking" errors, and logical hallucinations. Most existing systems rely on a "one-forward" generation approach, where a single error in the generated code leads to total failure.

To address these challenges, we present nvAgent, a multi-agent framework that decomposes the visualization task into specialized sub-tasks. By moving away from monolithic code generation in favor of a collaborative workflow and an intermediate Visualization Query Language (VQL), nvAgent significantly enhances robustness and accuracy in automated data visualization.

Methodology: The nvAgent Framework

nvAgent employs a "divide-and-conquer" strategy involving three specialized agents that work together to transform a user query into a validated visualization:

  1. Processor Agent: This agent acts as a database administrator. It performs schema filtering to remove irrelevant tables and columns, generates "augmented explanations" to clarify foreign key relationships, and classifies query complexity to guide downstream processing.
  2. Composer Agent: Acting as the central planner, the Composer uses a "sketch-and-fill" approach to generate Visualization Query Language (VQL). VQL is a SQL-like intermediate representation that abstracts away low-level plotting syntax, allowing the model to focus on data transformations and visualization logic.
  3. Validator Agent: This agent provides quality control by translating VQL into executable Python code (e.g., Matplotlib). It executes the code in a sandboxed environment and captures runtime or logical errors. If an error occurs, the Validator provides the specific error message back to the Composer for iterative refinement.
The nvAgent framework architecture featuring Processor, Composer, and Validator agents.

This modular architecture allows for Chain-of-Thought reasoning and self-correction, ensuring that the final output is both syntactically correct and semantically aligned with the user's intent.

Experimental Setup

The framework was evaluated using the VisEval benchmark, which is built upon the well-known nvBench dataset. The evaluation suite includes:

  • Scope: 1,150 distinct visualizations and 2,524 (Natural Language, Visualization) pairs.
  • Complexity: 146 different databases categorized into four difficulty levels: Easy, Medium, Hard, and Extra Hard.
  • Scenarios: Both single-table and multi-table queries were tested to assess the system's ability to handle complex relational data structures.

Results and Discussion

nvAgent was benchmarked against leading NL2VIS systems, including Chat2Vis, LIDA, and CoML4Vis, across several backbone models such as GPT-4o, GPT-3.5-turbo, and Qwen2.5-7B.

Pass rate comparison of nvAgent against state-of-the-art baselines across various LLM backbones.

Quantitative Performance

As shown in the experimental results, nvAgent consistently outperforms existing baselines. Using GPT-4o, nvAgent achieved a Pass Rate of 85.63% in single-table scenarios and 81.07% in multi-table scenarios. This represents an improvement of approximately 8% and 9% respectively over the previous state-of-the-art methods. Notably, the framework enables smaller models like GPT-3.5-turbo to achieve performance levels that are highly competitive with much larger "one-forward" models.

Key Insights

  • VQL as a Robust Bridge: The use of an intermediate VQL reduces the high variance associated with direct Python code generation, providing a structured syntax that is easier for the model to debug and refine.
  • The Power of Specialization: Ablation studies indicate that the Composer's "sketch-and-fill" logic is the most critical component; without it, performance drops by nearly 60%.
  • Iterative Refinement: The Validator's ability to loop back with specific error messages (e.g., "missing GROUP BY clause") allows the system to recover from common LLM logic gaps before the user sees the output.

Conclusion

nvAgent demonstrates that a collaborative, multi-agent workflow is superior to single-pass generation for complex data visualization tasks. By specializing agents for processing, planning, and validation, the system achieves a new state-of-the-art in NL2VIS. Future work will focus on improving temporal reasoning for complex time-series data and integrating Retrieval-Augmented Generation (RAG) to handle massive database schemas more efficiently.

Summary updated

BibTeX
@inproceedings{ouyang2025nvagent,
  author = {Geliang Ouyang and Jingyao Chen and Zhihe Nie and Yi Gui and Yao Wan and Hongyu Zhang and Dongping Chen},
  title = {{nvAgent: Automated Data Visualization from Natural Language via Collaborative Agent Workflow}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure