GoT-CQA: Graph-of-Thought Guided Compositional Reasoning for Chart Question Answering
Lingling Zhang Muye Huang QianYing Wang Yaxian Wang Wenjun Wu Jun Liu







GoT-CQA: Graph-of-Thought Guided Compositional Reasoning for 
 Chart Question Answering
    Lingling Zhang1# Muye Huang1# Qianying Wang2Corresponding author. # These authors contributed to the work equally. Yaxian Wang1 Wenjun Wu1 Jun Liu1

Xi’an Jiaotong University1   Lenovo Research2

{huangmuye, wyx1566, nickjun98}@stu.xjtu.edu.cn   wangqya@Lenovo.com


{zhanglling, liukeen}@xjtu.edu.cn

    September 9, 2024
=================================================================================================================================================================================================================================================================================================================




§ ABSTRACT 
   Chart Question Answering (CQA) aims at answering questions based on the visual chart content, which
plays an important role in chart summarization, business data analysis, and data report generation.
CQA is a challenging multi-modal task because of the strong context dependence and complex reasoning requirement. 
The former refers to answering this question strictly based on the analysis of the visual content or internal data of the given chart, while the latter emphasizes the various logical and numerical reasoning involved in answer prediction process.
In this paper, we pay more attention on the complex reasoning in CQA task, and propose a novel Graph-of-Thought (GoT) guided compositional reasoning model called GoT-CQA to overcome this problem.
At first, we transform the chart-oriented question into a directed acyclic GoT composed of multiple operator nodes, including localization, numerical and logical operator.
It reflects the human brain's solution process to this question intuitively.
After that, we design an efficient auto-compositional reasoning framework guided by the GoT, to excute the multi-step reasoning operations in various types of questions. 
Comprehensive experiments on ChartQA and PlotQA-D datasets show
that GoT-CQA achieves outstanding performance, especially in complex human-written and reasoning questions, comparing with
the latest popular baselines.





§ INTRODUCTION



Charts and figures are an effective visual expression about data statistics, the trends, and outliers, which exist widely in academic articles, technical reports, and various websites.
Chart question answering (CQA) refers to correctly answer the given question based on the visual chart content.
It plays an important role for a range of downstream tasks, such as chart summarization, business data analysis, and data report generation.
With the development of multi-modal understanding and reasoning techniques, CQA task has received growing attentions in recent years <cit.>.



As everyone knows, the hot research visual question answering (VQA) <cit.> is closely related to CQA task, where the former is the question answering (QA) task on natural images and the latter focues on the specific charts. 
Although the performance on VQA task has made break-through progress, CQA is still challenging because of the strong context dependence and the complex reasoning requirement.
On one hand, strong context dependence means answering a question strictly rely on the visual and underlying data information in the given chart, rather than the common sense or priors.
Natural images directly reflect the phenomena in real world, thus the common sense or priors mined from previous QA pairs can help better answer the current question.
As shown in right part of Fig. <ref>, 
the answer “arms” is a very likely candidate for question “Where is the child sitting?”, even if the model does not understand the image context.
However, for the question “How many more descendants of P2 than of P1?”, the locations and values of P1 and P2 must be extracted from given chart, even if the labels P1 and P2 have appeared in other charts.
In this case, the fine-grained parser of charts, including coordinates, legends, point locations, bar heights and other information, is a necessary preliminary work for CQA. 
And current researches <cit.> generally combine multiple technologies, such as object detection, OCR, word embedding, and expert rules, to achieve this goal.

On the other hand, complex reasoning that involves several logical and arithmetic operations after the detailed chart parser is required for the answer prediction in CQA. 
Most previous researches <cit.> regard the CQA as a simple classification task, where the output answers are limited in YES/NO or a fixed vocabulary contained all textual elements in the given chart.
However, the general setting, e.g. answers are not appearing in the chart called out of vocabulary (OOV), is more common in realistic application.
Thus, many CQA models such as ChartT5 <cit.>, ChartReader <cit.>, and Matcha <cit.>, are designed based on the large pre-trained vision-language models for the general setting, which improve the answering performance effectively but are still limited on the complex reasoning questions and have great limitation on model interpretability.
In this paper, we focus more on better performing complex reasoning in CQA task, and summarize the following two key issues in this reasoning process.




Firstly, how to implement the multi-step numerical and logical reasoning?
In left part of Fig. <ref>,
for question “How many more descendants of P2 than of P1?”, its reasoning procedure involves finding the bars corresponds to P1 and P2 in chart, estimating the descendant number of them, and finally executing the difference operation.
For the more challenging question “Are the number of descendants of P2 more than the average descendants?”, in addition to identifying the number of bars, the model needs to evaluate the corresponding value of each bar, and perform averaging and comparison operations.
Overall speaking, it is necessary in CQA model to perform multi-step operations such as finding, estimating, comparison, summation, and subtraction.


Secondly, how to establish a unified reasoning framework for various types of questions?
Taking the large-scale dataset PlotQA-D <cit.> as an example, the questions are constructed with 74 templates, and are categorized into three groups: structural understanding, data retrieval, or reasoning.
Apparently, different types of questions involve different inference operations, for instance the inference of question “How many descendants does P2 have?”
is much simpler than
“Are the number of descendants of P2 more than the average descendants?”.
However, designing a reasoning model for each type of question is not only time-consuming and expensive, but also difficult to generalize to new question types. 
Thus it is essential to design a unified and flexible reasoning framework for various questions.


To address the above issues, we propose a novel Graph-of-Thought (GoT) guided compositional reasoning framework for the challenging CQA, which is called GoT-CQA model.
GoT-CQA includes three modules: chart & question parsing, compositional reasoning, and answering module.
Chart & question module applies the pre-trained large-scale models to generate an feature sequence for given chart and a GoT corresponds to the question, where the directed acyclic GoT reflects the types and orders of the reasoning operations need to be performed.
Compositional reasoning module achieves complex reasoning over the chart data-flow under the guidance of GoT.
This module designs the self-data reasoning block and localization, numerical and logical reasoning operation blocks, and the reasoning framework is automatically formed by an orderly combination of these blocks according to the question's GoT. 
The answering module is a general transformer decoder to jointly generate the YES/NO, in-vocabulary, or OOV answers.
Our main contributions can be summarized into four folds:

	
  * We reveal the strong context dependence and complex reasoning requirement for the challenging CQA task. And we propose the novel model GoT-CQA as the first attempt to solve this complex reasoning problem in CQA.
	
  * We transform the question about chart into an interesting directed acyclic GoT to guide the answer reasoning.
	GoT splits the complex reasoning process into several ordered localization, numerical, or logical operations. 
	
  * We present an efficient automatic compositional reasoning pattern that generalizes to various types of chart-oriented questions.
	And it enhances the reasoning interpretability to a certain extent.
	
  * We conduct extensive experiments on dataset ChartQA and PlotQA-D to verify the superiority of GoT-CQA. The results
	show that GoT-CQA achieves a good improvement, especially in complex reasoning questions.





§ METHODOLOGY


Fig. <ref> illustrates the overall framework of GoT-CQA, and it includes three  modules: 1) Chart & question parsing module (Left Part) to extract the visual feature sequence from chart and generate a GoT corresponds to the question;
2) Compositional reasoning module (Center Part) to perform the complex localization, numerical, and logical reasoning over chart's data flow guided by GoT;
3) Answering module (Right Part) to generate the target answer based on reasoning result.
Details of these modules are introduced as follows.




 §.§ Chart & Question Parsing Module


Chart to Sequence-Feature. 
Following to the work <cit.>, we employ the pretrained OCR-free architecture Donut <cit.> as the chart encoder.
Donut is originally designed for document image (e.g.  receipts) understanding, and the work <cit.> testifies its effectiveness on chart parsing.
For any chart C, Donut generates an embedding sequence C_v, following the order from the
top-left corner to the bottom-right corner of this chart.

Question to Graph-of-Thought.
For any question Q, we find its logic structure is relatively clear and easy to dig out.
To achieve this goal, we first define the following three types of unit operators: 1 Localization operator (Loc) means  query the position information for the given input;
2 Numerical operator (Num) means retrieve or simply reasoning the value for the target variable;
And 3 Logical operator (Log) means execute some logical inference on multiple values, such as comparison, summation, and maximum.
Apparently, any question can be decomposed into the ordered operations of the above three unit operators.
Namely question Q can be represented as a directed acyclic graph 𝒢 composed of multiple operator nodes, which is called Graph-of-Thought (GoT).
This procedure can be formalized as:

    𝒢    = {𝒪, ℰ}, 
    𝒪   = {o_1, o_2, ⋯, o_n}, o_i = (o_i, type(o_i)),  
    ℰ    = {e_ij=(o_i,o_j)}⊂𝒪×𝒪,

where 𝒪 is the operator node set, and n records the total number of operators for question Q.
For each node o_i, it is denoted to a tuple  consisting of the operation content o_i and  type(o_i)∈{Loc, Num, Log}. 
ℰ is the edge set, and the edge e_ij exists when there is a chain of thought from node o_i to o_j. 
After analyzing some popular CQA datasets, we found that GoTs can be extracted by pre-defined template rules or the prompted large-scale language models such as GPT.
Fig. <ref> shows several examples of question GoTs.
For question “How many more descendants of P2 than of P1?”, its GoT includes two localization nodes, two numerical nodes, one logical nodes, and four edges between them. 
The edge (o_1,o_3) indicates that the value of P1 can only be measured after finding the location of P1 in chart.
Similarly, edges (o_3,o_5) and (o_4,o_5) indicate that the values of P1  and P2  need to be obtained before the subtraction operation.  



 §.§ Compositional Reasoning Module

Given chart data-flow C_v, this module accomplishs auto-compositional reasoning under the guidance of GoT 𝒢. 
In Fig. <ref>, we design four blocks for self-data reasoning and three types of operation (i.e. {Loc, Num, Log}) reasoning.

Self-Data Reasoning. This block takes visual sequence C_v as input, and performs self-reasoning on the chart to mine the meaning of elements and the relationship between them.
As shown in left part of Fig. <ref>, the pre-process layer is a fully connected layer over C_v. 
Each reasoning layer is designed two encoders with self-attentions, where each encoder computes the query, key, and value, followed by feed-forward, skip connection and normalization. 
After N-layer, the output of this block is denoted as the feature matrix 𝐎_start, which is applyed to the following compositional reasoning.




Loc/Num/Log Reasoning. 
In right part of Fig. <ref>, the architectures of localization, numerical, and logical reasoning blocks are similar.
Note that each operator node o_i in GoT corresponds to a reasoning block.
And its input consists of two parts:
the current guidance information o_i, and the chart data flows  from o_i's precursor nodes pre(o_i).
This procedure is formalized to Eq. (<ref>) with the output data flow matrix 𝐎_i,
and the node set pre(o_i) is arrived at by
Eq. (<ref>). 

    𝐎_i = 
    	Block_type(o_i)(pre(o_i),o_i),                      
    pre(o_i) = 
    	{o_start, o_k;e_ki∈ℰ},    indegree(o_i)≠0
    {o_start},    otherwise

where the function indegree(·) computes the in-degree value of the input operator node.
o_start is a virtual node outside the GoT, and it stores the original chart flow data matrix 𝐎_start that obtained by self-data reasoning block.
Especially, if the in-degree of node o_i is zero, it is the starting node of compositional reasoning with initial data flow 𝐎_start as input.
There is also a pre-process layer in Loc/Num/Log reasoning block.
On the one hand, this layer fuses all the precursor data flows {𝐎_k;o_k∈pre(o_i)} into a new feature matrix. 
On the other hand, it uses the pre-trained language model (e.g. Bert) to extract  the semantic feature of textual guidance information o_i.
For each reasoning layer, there are two types of encoders: self-attention and cross-attention.
The architecture of the former is the same as in the self-data reasoning block.
The latter is designed to interact the information between the guidance and the chart data flow, where the transformer's keys and values are mutually exchanged resulting
a cross-attention.
After N-layer, the output data flow 𝐎_i is the input of the reasoning blocks of o_i's successor nodes.




Compositional Reasoning Guided by GoT.
For any question Q, 
its reasoning network is formed by an orderly combination of localization, numerical, logical blocks under the guidance of GoT 𝒢.
This is a novel auto-compositional reasoning process, which means that the architecture of reasoning network are varies for different questions.
After the construction, all reasoning blocks are executed in multiple steps.
For each step, these blocks whose related precursor nodes 
have been inferred in the current state, are activated and executed.
Taking the question “How many more descendants of P2 than of P1?” as an example, we first execute two localization blocks to find  the location of P1 and P2, then execute numerical blocks for estimating their values, and finally execute logical block for subtraction operation.
The compositional reasoning process of the above CQA example is shown in the center of Fig. <ref>.
Specially, the data flow output by the node whose out-degree is zero in GoT 𝒢, is the result of the reasoning module.
It provides the evidence for answering module in the next section.
We found that there is generally only one such terminal node in the GoT, and  the its output is denoted 𝐎_end for convenience. 




 §.§ Answering Module

For question Q, its answer may be YES/NO, a textual element in chart, or the result of some numerical operation.
Following the latest CQA models <cit.>,
We  design a simple  transformer decoder that takes data flow 𝐎_end as input and generates the final answer for all types of questions.
The traditional cross-entropy loss is applied to train this model.



§ EXPERIMENT








 §.§ Experimental setting


Datasets. 
(1) ChartQA <cit.> is constructed with real-world charts and human-authored question-answer pairs.
It covers 9.6K human-written questions focusing on logical and visual reasoning, and 23.1K
questions generated from human-written chart summaries. 
(2) PlotQA-D <cit.> is another large-scale dataset that includes two benchmarks called PlotQA-D1 and PlotQA-D2.
Different from ChartQA, the charts in PlotQA-D are generated with a programming tool and the questions are created with 74 pre-defined templates that can be grouped into structural understanding, data retrieval, and reasoning.

Competitors.
Nine latest works on CQA task, including PlotQA-M <cit.>, PReFIL <cit.>, CRCT <cit.>, VisionTapas <cit.>, ChartT5 <cit.>, Pix2Struct <cit.>, 
ChartReader <cit.>,
MatCha <cit.>,
and UniChart <cit.>, are applied to compare with our model.
Note that we directly run their publicly available codes or use the published evaluation results on ChartQA and PlotQA-D.



Settings.
In question parsing module, GoTs of questions in ChartQA are generated by large-language model Qwen2-7B[https://https//qwenlm.github.io/blog/qwen2/wen2/], while the GoTs in PlotQA are obtained with a template expert library.
In compositional reasoning module, the layer of self-data reasoning and the Loc/Num/Log reasoning blocks are set to 4 and 1, respectively.
And in answering module, the 12-layer transformer decoder framework from translation model mBART <cit.> is applied.
During training, the pre-trained parameters from Donut encoder are applied to initialize our GoT-CQA.
For ChartQA dataset, similar to <cit.>, we conduct a first-stage pre-training on a extra chart dataset for 200k steps, followed by a second-stage fine-tuning on ChartQA dataset for 5 epochs. For PlotQA dataset, we perform a single-stage training on the PlotQA-D1 and PlotQA-D2 datasets for 200k steps. 
All experiments are completed on two A100 GPUs. 






 §.§ Performance Comparison


 Results on ChartQA. Table <ref> reports the answer scores over human and augmented questions from ChartQA.
From these results, we make the following two observations.
(1) our GoT-CQA consistently perform better than other competitors, in addition to the “Augmented” score obtained by  MatCha.
And GoT-CQA's advantage on “Human” questions is more prominent, which is nearly 3.2% higher than the best comparison result.
This indicates that the proposed GoT guided compositional reasoning is beneficial to CQA task, especially for the challenging human-written questions.
(2) For all methods, the performance scores on “Human” questions are significantly worse than those on “Augmented” questions.
This is reasonable because the human annotated questions are more complex and require the more challenging reasoning compared to these augmented questions.


Results on PlotQA-D. 
Table <ref> reports the scores over structural, data retrieval and reasoning questions, and the overall questions from PlotQA-D1 and PlotQA-D2 test set.
The results are very consistent with those from  ChartQA. 
(1) GoT-CQA still achieves the performance improvement on all test data,  in addition to the overall performance on PlotQA-D2 achieved by MatCha.
This phenomenon further demonstrates the outstanding ability of GoT-CQA on solving the more challenging questions.
Note that the competitor MatCha achieves the outstanding performance on PlotQA-D2. 
This is because MatCha is pre-trained over the large scale MATH  and DROP datasets, which significantly enhances its mathematical calculation abilities <cit.>.
(2) With all methods, the performance scores worsen when the question type changes from structural to data retrieval, then to reasoning. And the answer performance of current models on the reasoning questions is less than 87%.
This is because the structural questions just focus on chart’s structure; data retrieval questions require to search for relevant information from the chart; and reasoning questions involve deep reasoning based on chart data understanding. 






 §.§ Analysis on GoT Guided Compositional Reasoning


GoT Ablation Studies.
As shown in Table <ref>, we conduct a thorough ablation
study on the GoT guided compositional reasoning, to analyze the contribution of key strategies in the proposed
GoT-CQA. 
Here, “w/” and “w/o” GoT represent whether to utilize the graph-of-thought to guide the answer reasoning, respectively.
Namely, the variant “w/o” GoT regards the sentence embedding of entire question as the guidance information.
In addition, the compositional reasoning module includes three types of reasoning blocks corresponds to localization, numerical, logical operators in GoT.
To verify the effectiveness of the operator setting, we combine them together as a model variant, and also combine the localization and numerical operators into the finding (Find) operator as another model variant.
According to the results in Table <ref>, we observe the three points.
(1) Whether setting two or three operators, the overall performance of model variant w/o GoT is lower than model GoT-CQA. 
(2) Compared to one or two operators, the model GoT-CQA with three operators (Loc+Num+Log) could achieve the comparable performance on “Augmented", “S", and “D"  questions, but it is more outstanding on “Human" questions from ChartQA and “Reasoning” questions from PlotQA-D1. 
(3) The model with three operators does not cause too much time overhead.
This benefits from the proposed auto-compositional reasoning pattern.
That is to say, for the complex question, its structure of GoT corresponds to more localization, numerical, and reasoning operators, thus its inference time is longer; for simple question, it still requires fewer blocks and time cost.



Reasoning Architecture Studies.
In this section, we analyze the block architecture in compositional reasoning module from the following three aspects.

1) Analysis on Self-Data Reasoning Layers. 
As shown in the upper part of Table  <ref>, we vary the layer number of self-data reasoning block,
and record the performance scores on test set of ChartQA and PlotQA-D1.
We observe that the GoT-CQA model achieves satisfactory results with 4-layer self-data reasoning.
Moreover, the shallow layers are insufficient for comprehensive self-data understanding, and the deep layers likely to cause the overfitting problem.

2) Analysis on Loc/Num/Log Reasoning Layers. 
As shown in the center part of Table <ref>, we 
set the layer number of Loc, Num, and Log reasoning blocks to be the same, and vary it in range [1,2,3] to record the GoT-CQA's question-answering performance on two datasets. 
The experimental results show that a Loc/Num/Log operator does not require a complex multi-layer reasoning block to implement, and one-layer of attention mechanism could obtain good performance on various type of questions.
Moreover, as the number of layers increases, the compositional reasoning module cannot handle the simple classification questions well.

3) Analysis on Loc/Num/Log Reasoning Architecture.
As shown in the bottom part of Table <ref>, we analyze the effect of different attention mechanisms in reasoning blocks on the CQA performance.
In addition to the cross-stacking mechanism of self- and cross- attentions (i.e. SELF-CROSS),
the pure-stacking mechanisms of cross-attention or self-attention (i.e. CROSS-CROSS or SELF-SELF) are also implemented in the experiment.
From these results, we observe that the GoT-CQA model with SELF-CROSS strategy is a better choice, because both internal and interactive information mining of question guidance and chart data flow are required in the reasoning procedure.
 


 §.§ Case Study


To obtain a more insightful understanding of GoT-CQA model, we demonstrate some case studies in Table <ref>. 

Human Questions from ChartQA:  including cases Q1.1, Q1.2, Q2.1, and Q2.2.
Obviously, GoT-CQA performs better than the popular competitor MatCha and UniChart, over the human annotated questions.
We also notice that the predicted results of all models are wrong on case Q2.2, possibly due to the limited performance of visual feature extraction with pretrained Donut or the self-data reasoning block.


Structure or Data Retrieval Questions from PlotQA-D:  including cases Q3.1 and Q4.1.
We conclude that the performance of MatCha and GoT-CQA are both satisfactory on these questions. 
This is because these questions pay more attention on  visual elements or their relations in charts, and they does not involve complex reasoning or calculations.

Reasoning Questions from PlotQA-D:  including cases Q3.2, Q3.3, Q4.2, and Q4.3.
Apparently, the predicted results with our GoT-CQA model are closer to the ground-truth compared to MatCha.
This indicates that our compositional reasoning pattern guided by GoT is indeed suitable for parsing and solving the challenging reasoning questions.



§ RELATED WORK


 Chart-to-Table. It aims to identify the constituent components (e.g. bars and legends) in given chart, and extract its underlying data.
Traditional methods <cit.> on this task rely on various heuristic rules which do not work well for new chart types.
ChartOCR <cit.>  combines the advantages of deep-learning and hand-designed rules to achieve outstanding performance on bar, pie, and line charts.
Recently, ChartReader <cit.>  introduces a transformer-based chart component detection module and an extended pre-trained vision-language model, which achieves SOTA performance on chart-to-table.
Intuitively, it is a reasonable CQA pipeline by combining the chart-to-table and table question answering together. 
However, it not only faces the serious time-consuming annotation issue in chart-to-table stage, but also leads to error accumulation.
Moreover, answering questions does not necessarily require understanding the whole underlying data in chart.

Chart-to-Text.
It aims to generate natural language captions or summaries from the chart image or chart metadata.
Current researches <cit.> generally design a deep generation model to achieve this model.
For example, Qian et al. <cit.> formulated the chart-to-text task as a controlled captioning problem, where the deep model FigJAM is proposed by utilizing metadata
information and a joint static and dynamic dictionary.
Recently, Huang et al. <cit.> pointed that the chart captioning in articles can be solved by summarizing the paragraphs mentioning the chart, and the popular pre-trained language model is applied in the baseline model.
Nonetheless, these methods still could not reflect high-level meanings such as data trends in text generation.



Chart Question Answering.
It aims to answer questions related to charts by mining the visual and textual information.
<cit.> pioneered a synthetic CQA corpus called FigureQA, and 
designed a benchmark baseline with the relation network to output binary (Yes/No) answers.
<cit.>
introduced the synthetic DVQA dataset that contains three forms of CQA: structural, data retrieval, and reasoning.
To avoid biases of synthesized data,
 <cit.> provided a more complex dataset LEAF-QA in which charts are extracted from varied real-world data sources.
The above researches regard CQA as a simple classification task.
They assume the answer comes from a ﬁxed size vocabulary or is one textual element within the chart.
To the best of our knowledge, PlotQA-D <cit.> is the first dataset that includes the more challenging regression scenarios, namely the answers are not presented in chart and need more complex numerical reasoning.
After that, 
<cit.> proposed a joint classification-regression model called CRCT for CQA, which achieved the outstanding results on PlotQA.
Besides, latest works including ChartReader <cit.>, MatCha <cit.>, UniChart <cit.>, apply large pre-trained vision-language models such as BERT <cit.> and GPT-3 <cit.> for CQA task, and they collect massive chart data to train the model parameters.
Nonetheless, the current performance of CQA is far from human-level performance.
And the weak reasoning ability of the models is one of the important factors for performance failure.




§ CONCLUSION


In this paper, we propose a novel multi-modal reasoning model named GoT-CQA for challenging CQA task.
The core of GoT-CQA is the compositional reasoning module guided by the interesting graph-of thought (GoT). Note that the GoT transforms the complex question into a operation sequence with several simple operators, and the auto-compositional reasoning pattern is suitable to various type of chart-oriented questions.
Extensive experiments on ChartQA and PlotQA-D show the effectiveness and superiority of GoT-CQA. 
In the future, we intend to improve the GoT-CQA’s ability by exploring more reasonable operators.



ieee_fullname



