Who Leads Now? Token-Level Modality Arbitration for Chart-to-Code Generation
The paper introduces MoCA, a novel framework that employs a Cross-modal Arbitration Block to dynamically separate and coordinate distinct visual and code branches at the token level, thereby overcoming the interference inherent in existing chart-to-code methods and achieving superior performance through structured modality arbitration.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
In the digital age, data is often presented as charts: bar graphs, line plots, and pie charts that turn numbers into visual stories. For decades, computers have been excellent at reading these images to answer simple questions, like "what is the highest value?" or "what color is the largest slice?". However, a more difficult challenge has emerged: asking a computer to not just read a chart, but to rebuild it from scratch using code. This task requires a machine to look at a static image, understand the hidden data and the specific design choices behind it, and then write a set of instructions that can draw an identical picture on a screen. It is a test of two very different skills at once. The machine must be a sharp-eyed observer, capable of noticing subtle details like the exact shade of a line or the precise position of a label, and it must also be a disciplined architect, capable of writing logical, error-free code to reproduce those details.
For a long time, researchers tried to teach computers to do both things at once, blending visual understanding and coding ability into a single, massive brain. The assumption was that a model could learn to see and write code simultaneously. Yet, this approach often led to confusion. When a chart was visually complex, the model might struggle to write the code. When the chart required complex logic, the model might fail to see the details. The two skills, while necessary for the same job, seemed to get in each other's way when forced to share the same internal pathways. A new study from researchers at Zhejiang University, Ant Group, and other institutions suggests that the solution is not to blend these abilities, but to keep them separate and let them take turns leading the work.
The researchers, led by Qinghao Fu and Wei Zhou, developed a system they call MoCA. Instead of forcing a single model to do everything, they built a framework with two distinct pathways: one dedicated to visual understanding and another dedicated to coding. Imagine a construction crew where one team specializes in inspecting the raw materials and the other in the actual building. In MoCA, these two teams work side by side, but they do not merge into a single confused entity. Instead, a small, lightweight decision-maker, which the authors call an arbiter, watches the work in real time. With every single word of code the system generates, this arbiter decides how much help to take from the visual team and how much to rely on the coding team.
This decision-making happens constantly and changes from moment to moment. When the system is trying to figure out the color of a specific bar in a chart, the arbiter leans heavily on the visual pathway. When it needs to decide how to stack those bars or calculate the total height, the arbiter shifts its trust to the coding pathway. The researchers found that this dynamic switching is not random; it follows a structured pattern. In the early stages of generating a chart, the system relies more on visual processing to understand the input. As it moves into the middle of the task, it shifts toward code generation to build the structure. Finally, as it finishes, it may return to visual refinement to ensure the details match the original image. This fluid coordination allows the system to handle charts that are visually messy as well as those that are logically complex, without getting stuck.
To teach this system how to work, the researchers used a two-step training process. First, they showed the model thousands of examples of charts and their corresponding code, but they did not just ask for the final code. They also provided a "thought process," a step-by-step breakdown of how to look at the chart and translate it into instructions. This helped the model learn to connect what it saw with what it needed to write. In the second stage, the system was allowed to practice on its own. It generated code, and if the code ran successfully and the resulting image looked like the original, it received a reward. If the code failed or the image was wrong, it was corrected. This cycle of trial and error, guided by specific rewards for both the logic of the code and the visual accuracy of the result, refined the system's ability to coordinate its two branches.
The results of this approach were tested against several other advanced models on three different benchmarks designed to evaluate chart-to-code generation. The new system, MoCA, outperformed the competition in key areas. On one major test, it successfully generated working code for 88.83 percent of the charts, a significant improvement over other specialized models. It also scored higher on metrics that measured how well the generated code matched the text and structure of the original chart. Perhaps most importantly, the researchers showed that these gains did not come simply because the model was larger or had more training data. When they tested versions of the system that used the same amount of computing power but lacked the dynamic switching mechanism, the performance dropped. This confirmed that the secret to success was not just having more brainpower, but having a smarter way to organize it.
The study also revealed that the system's decision-maker learned to be very specific. It did not apply a fixed rule, such as "always use 50 percent visual help and 50 percent code help." Instead, it adjusted its strategy based on the specific chart it was looking at and the specific part of the code it was writing. For some charts, the visual branch might dominate the entire process. For others, the code branch might take the lead almost immediately. This flexibility allowed the system to adapt to the unique demands of each task, whether it was a simple line graph or a complex, multi-layered diagram.
By separating the skills of seeing and writing, and then giving them a dedicated manager to coordinate their efforts, the researchers solved a problem that had stumped previous attempts. They demonstrated that for complex tasks like rebuilding a chart from an image, the whole is greater than the sum of its parts only if the parts are allowed to function in their own strengths. The system does not try to be a master of everything at once; instead, it knows exactly when to look and when to write, producing results that are both visually faithful and logically sound. This approach offers a new blueprint for how artificial intelligence might handle other tasks that require a mix of very different kinds of intelligence, moving beyond the idea of a single, all-purpose model toward a more coordinated and adaptable future.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.