TLDR: This paper introduces a new framework to identify and resolve ambiguity in natural language instructions for data visualization code generation. It proposes a taxonomy of ambiguity types (semantic, presupposition, underspecification) and metrics to quantify them. The research demonstrates that using multi-turn, pragmatics-inspired dialogues between a user (director) and an AI coding assistant (coder) significantly improves the accuracy of generated code by clarifying user goals, especially in ambiguous situations. The cooperative dialogue strategy proved most effective in enhancing task success.
In the evolving landscape of human-AI collaboration, particularly in generating code from natural language, a significant challenge persists: ambiguity. Users often describe their intentions in ways that can be interpreted in multiple valid forms, leading to AI outputs that, while technically correct, don’t quite match the user’s true goal. This research delves into this critical issue, focusing specifically on the domain of data visualization code generation.
The paper, titled “Identifying & Interactively Refining Ambiguous User Goals for Data Visualization Code Generation,” by Mert Ë™Inan, Anthony Sicilia, Alex Xie, Saujas Vaduguru, Daniel Fried, and Malihe Alikhani, highlights that successful human-AI interaction hinges on establishing shared goals. When natural language instructions are ambiguous, the AI (referred to as the ‘coder’) struggles to generate the precise data visualization code the user (the ‘director’) has in mind. The unique aspect of data visualization, with its visual and code-based contexts, allows for a deep analysis of these ambiguities.
Understanding Ambiguity
The researchers developed a comprehensive taxonomy to categorize the different types of ambiguity that arise in this task. This taxonomy moves beyond simple model uncertainty to focus on the user’s intent:
- Semantic Ambiguity: This occurs when words or phrases have multiple meanings, leading to misinterpretation. For example, terms like “regular matplotlib style plot” or “color plot” can be vague.
- Presupposition: Instructions might assume default parameter values without explicitly stating them. If the coder’s assumptions about defaults differ from the director’s, errors can occur. An example is asking to “keep the distribution plot in blue” when ‘blue’ is the default and not explicitly specified.
- Underspecification: This is when non-default parameters or functions are either omitted or only partially described. This is a common source of ambiguity and includes details like specific color values (e.g., “solid red” without an alpha value), distance (e.g., “enough” space), shape, size, location (e.g., legend position), label, and even the choice of plotting function (e.g., `imshow()` vs. `pcolor()` for a heatmap).
To quantify these ambiguities, the paper proposes several metrics. While traditional methods like Sampling Diversity and Self Verification measure a model’s uncertainty, the new metrics, such as Optimal Result Gap (ORG) and LLM-Based Ambiguity Rating (LAR), are designed to better correlate with human-annotated ambiguity categories, directly addressing the gap between the given instruction and an ideal, unambiguous one.
Also Read:
- Unpacking AI Agent Performance: A New Evaluation Framework
- Unlocking Entity Understanding in Large Language Models
Resolving Ambiguity Through Dialogue
The core solution proposed is the use of multi-turn dialogue to interactively resolve ambiguities. The researchers frame the natural language to code problem as a cooperative dialogue between a director (user) and a coder (AI assistant). This dialogue allows the coder to ask clarifying questions and the director to refine their intent over several turns.
The study explores three pragmatics-inspired dialogue strategies for the AI coder, based on established linguistic frameworks:
- Cooperative: The coder acts as a rational, cooperative agent, anticipating the director’s intent and aiming for quick convergence to the solution.
- Discoursive: The coder’s responses are always connected to the conversation history through specific coherence relations, ensuring a structured flow.
- Inquisitive: The coder explicitly identifies and answers implicit questions posed by the director’s instructions.
Through simulated user studies using the Matplotlib problems from the DS-1000 dataset, the research demonstrates that these pragmatic dialogues significantly reduce ambiguity and improve code accuracy. The cooperative strategy, in particular, showed the most substantial improvements in task success, suggesting that AI models benefit from reasoning about the user’s state of mind.
Even with these improvements, a gap remains between the best-performing dialogue strategy and a theoretical ‘ceiling performance’ (where instructions are perfectly unambiguous), indicating that some level of ambiguity is inherent and challenging to fully resolve in a static task. However, the findings clearly show that dialogue-driven improvements are consistently greater for ambiguous cases than for non-ambiguous ones, confirming the effectiveness of dialogue in disambiguating prompts.
This work provides a principled approach to understanding and resolving ambiguity in human-AI code generation, moving beyond ad hoc uncertainty measures. By integrating pragmatic theories into dialogue strategies, future coding assistants can foster more accurate and human-like collaborations. You can find the full research paper here: Identifying & Interactively Refining Ambiguous User Goals for Data Visualization Code Generation.


