Home

Awesome

πŸ“Š CharXiv

🏠Home | πŸ€—Data | πŸ₯‡Leaderboard | πŸ“„Paper | Current Version: v1.0

This repository contains the code to evaluate models on CharXiv from the paper CharXiv: Charting Gaps in Realistic Chart Understanding in Multimodal LLMs.

πŸ€— We are first-time evaluation suite builders and this codebase is released for the first-time. We are committed to improving it. If you have any questions, feel free to raise issues and/or submit pull requests for new features of bug fixes.

πŸ”Š An 80-second video teaser of CharXiv

https://github.com/princeton-nlp/CharXiv/assets/59942464/ab9b293b-8fd6-4735-b8b3-0079ee978b61

πŸ“° News

[07/26/2024] πŸš€ Upcoming this week: we'll be releasing scores for GPT-4o-mini as well as the largest and most capable open-weight VLM in our benchmark: InternVL2 LLaMA-3 76B. Alongside scores, we find some interesting patterns in the trend of model improvement with respect to differnet chart understanding benchmarks on X. [07/24/2024] πŸš€ We released the full evaluation pipeline (i.e., v1.0).
[07/23/2024] πŸš€ We released our evaluation results on all 34 MLLMs that we have tested so far -- this includes all models' responses to CharXiv's challenging questions, scores graded by GPT-4o, as well as aggregated stats.
[07/14/2024] πŸš€ We further evaluated the latest InternVL Chat V2.0 26B and Cambrian 34B models on CharXiv with some State-of-the-Art results. More analysis are here.

πŸ‘‹ Introduction

Chart understanding plays a pivotal role when applying Multimodal Large Language Models (MLLMs) to real-world tasks such as analyzing scientific papers or financial reports. However, existing datasets often focus on oversimplified and homogeneous charts with template-based questions, leading to an over-optimistic measure of progress. In this work, we propose CharXiv, a comprehensive evaluation suite involving 2,323 natural, challenging, and diverse charts from scientific papers. CharXiv includes two types of questions: (1) descriptive questions about examining basic chart elements and (2) reasoning questions that require synthesizing information across complex visual elements in the chart. To ensure quality, all charts and questions are handpicked, curated, and verified by human experts. Our results reveal a substantial, previously underestimated gap between the reasoning skills of the strongest proprietary model (i.e., GPT-4o), which achieves 47.1% accuracy, and the strongest open-source model (i.e., InternVL Chat V1.5), which achieves 29.2%. All models lag far behind human performance of 80.5%, underscoring weaknesses in the chart understanding capabilities of existing MLLMs. We hope CharXiv facilitates future research on MLLM chart understanding by providing a more realistic and faithful measure of progress.

Comparison of model performance

πŸ› οΈ Evaluate Your Models

Setup

Download the images:

git clone https://github.com/princeton-nlp/CharXiv.git
cd images
wget https://huggingface.co/datasets/princeton-nlp/CharXiv/resolve/main/images.zip
unzip images.zip && rm images.zip
<details> <summary> (Optional) A short tour for the codebase </summary> * `data` folder contains all QAs and metadata for images, descriptive questions, and reasoning questions. Answers for the test split are intentionally made to `null` to prevent testing data from leaking into the public. * `images` folder contains all images where their identifiers range from 0 to 2399. Note that there are only 2333 images in total and the numberings are **not** consecutive. * `results` folder contains all response generation and scoring results. * `src` folder contains all python code for CharXiv: * `constants.py` stores all the prompts and mappings from question ids to actual questions. * `descriptive_utils.py` contains all code to build queries for response generation and grading, as well as saving all artifacts for descriptive questions. * `reasoning_utils.py` contains all code to build queries for response generation and grading, as well as saving all artifacts for reasoning questions. * `evaluate.py` is the main function to evaluate model responses against the answer with gpt API calls. * `generate.py` is the main function to loop QAs for model to generate responses. * `get_stats.py` is the main function to print the reasoning and descriptive question statistics. * `generate_lib` contains a series of implementations that enable one to generate response on their models. * `run.sh` is the script to evaluate models </details>

Response generation

CharXiv doesn't require any third-party python library when prompting your models to generate responses to the chart-question pairs. Therefore, to set up your model, you should implement the custom_evaluate function in generate.py. Specifically, this function takes queries as the input, which contain all the charts and questions CharXiv uses to evaluate models. It has the following structure:

{
    figure_id:{
        'question': ...<str>
        'figure_path': ...<str>
    },
    ...
    figure_id:{
        'question': ...<str>
        'figure_path': ...<str>
    },
}

To run CharXiv for your model, go to src/generate_lib/ directory and create a new python file e.g.,custom.py. You can put whatever auxiliary code (e.g., model split function, image processing function, etc) inside this file, but you need to implement the generate_response function which takes in model_path and queries by default. Inside the function, you load your models and all preprocessing functions, and let your model generate responses. The below script is a simple example of usage. If you need more references, you can look at existing *.py files how these functions are implemented for different models.

for k in tqdm(queries):
    query = queries[k]['question'] # This will be a single question with instructions
    image = queries[k]["figure_path"] # This will be the path to the figure associated with the above query
    query, image = preprocess(query, image) #TODO
    response = model.chat(query, image) #TODO
    queries[k]['response'] = response

Once you finish implementing the generate_response function, go to src/generate_lib/utils.py and modify the get_generate_fn to include the function you implemented. Say if your model's checkpoint folder is called custom_1 and you implement the generate_response function in the custom.py file, then all you need to do it to add the follwing code:

...
elif model_name in ['custom_1']:
    from .custom import generate_response
...

Then, to generate model responses:

python src/generate.py \
    --model_name $model_name \
    --split $split \
    --mode $mode \
    --model_path $model_path 

⚠️The first three arguments are required and you should not delete them. It is your responsibility to ensure the correctness and integrity of the evaluation pipeline if you change them. In particular,

βœ…The last argument i.e., --model_path is a custom argument and feel free to delete it, modify it or add more args as you see fit. Correspondingly, you should consider changing the input argument of your generate_response function and the function that calls generate_response if you change --model_path.

πŸ—„οΈ Once the process ends, you will find a file in results folder named: gen-<model_name>-<mode>_<split>.json. This file stores your model's responses.

Note: if you are evaluating a model that is hosted on cloud and can only be accessed via an API, the --model_path argument will correspond to the name of the model e.g., gpt-4o-2024-05-13. Also, in creating the custom file in the src/generate_lib directory, you need to implement an additional function i.e., get_client_model that takes in the model_path argument and the api_key argument. In addition, you need to add another elif statement in get_client_fn inside src/generate_lib/utils.py with instructions similar to the above. Specific instructions to implement get_client_model function differ by API providers, and examples are provided in gpt.py, gemini.py, reka.py, claude.py, and qwen.py. Note: you may see a header like:

### HEADER START ###
import os
vlm_codebase = os.environ['VLM_CODEBASE_DIR']

import sys
sys.path.append(vlm_codebase + '/<codebase>')
### HEADER END ###

in existing implementations in generate_lib. This becomes convenient when the model needs to be run with some author-provided code, and you want to load/call the model with their code. In this way, you have a local directory which contains their code (i.e., if you are developing a model or cloning a codebase from github), and you append the directory to the system PATH.

Evaluation

⚠️ Make sure the openai python API library is installed in your evaluation environment. If not, pip install openai first.

python src/evaluate.py \
    --model_name $model_name \
    --split $split \
    --mode $mode \
    --api_key $openai_key

The first three arguments are same as the above (response generation), except that you need to provide an openai API key to evaluate your model's responses.

This python script will automatically match the gen-<model_name>-<mode>_<split>.json file in the results folder and the <mode>_<split>.json file in the data folder.

πŸ—„οΈ Once the process ends, you will find a file in results folder named: scores-<model_name>-<mode>_<split>.json. This file stores your model's evaluation results graded by LLMs.

Finally, run this:

python src/get_stats.py \
    --model_name $model_name \
    --split $split 

This python script will automatically match the scores-<model_name>-<mode>_<split>.json file in the results folder to calculate the stats for aggregated scores. Calling this function will automatically generate stats-<model_name>-<mode>_<split>.json in the results folder.

πŸ“… Results from Existing Models

We release full results on the validation set (i.e., generated responses, grading done by LLMs and the aggregated stats) for all models we tested in our HuggingFace Repo. If you are interested in doing some fine-grained analysis on these results or calculate some customized metrics, feel free to use them.

πŸ† Leaderboard

Please refer to our official website by clicking the model name for detailed model information (e.g., huggingface model version or API version).

ReasoningDescriptive
TC = Text-in-ChartINEX = Information Extraction
TG = Text-in-GeneralENUM = Enumeration
NC = Number-in-ChartPATT = Pattern Recognition
NG = Number-in-GeneralCNTG = Counting
COMP = Compositionality
MetadataReasoningDescriptive
ModelWeightSize [V/L] (B)OverallTCTGNCNGOverallINEXENUMPATTCNTGCOMP
πŸŽ–οΈHumanN/AUnknown80.5077.2777.7884.9183.4192.1091.4091.2095.6393.3892.86
πŸ₯‡Claude 3.5 SonnetProprietaryUnknown60.2061.1478.7963.7946.7284.3082.6288.8690.6190.0848.66
πŸ₯ˆGPT-4oProprietaryUnknown47.1050.0061.6247.8434.5084.4582.4489.1890.1785.5059.82
πŸ₯‰Gemini 1.5 ProProprietaryUnknown43.3045.6856.5745.6930.5771.9781.7964.7379.4876.3415.18
InternVL Chat V2.0 ProProprietaryUnknown39.8040.0060.6144.4025.7676.8377.1184.6777.0778.8827.23
InternVL Chat V2.0 76BOpen5.9 / 7038.9040.0059.6042.6724.0275.1777.1178.6976.2079.1332.14
GPT-4VProprietaryUnknown37.1038.1857.5837.9325.3379.9278.2985.7988.2180.9241.07
GPT-4o MiniProprietaryUnknown34.1035.2347.4732.3327.9574.9274.9182.8169.2179.1335.71
Gemini 1.5 FlashProprietaryUnknown33.9036.3654.5530.6023.58------
InternVL Chat V2.0 26BOpen5.9 / 2033.4033.1851.5241.8117.4762.4071.3561.0255.9067.946.25
Claude 3 SonnetProprietaryUnknown32.2031.5950.5131.4726.2073.6575.7481.9276.6472.268.48
Claude 3 HaikuProprietaryUnknown31.8029.7745.4534.4827.0765.0869.8769.9864.8561.838.04
Phi-3 VisionOpen0.3 / 431.6031.3646.4635.7821.4060.4867.6261.1854.5965.396.25
MiniCPM-V2.6 (Upsize+CoT)Open0.4 / 831.0030.0041.4137.9321.4057.0567.8549.5653.4962.8514.29
Claude 3 OpusProprietaryUnknown30.2026.3650.5133.6225.3371.5575.6273.6973.5870.4826.79
InternVL Chat V1.5Open5.9 / 2029.2030.0045.4532.3317.4758.5069.6352.9553.0664.635.80
GLM 4V 9BOpen4.4 / 929.1030.6842.4233.1916.1657.6267.9761.6643.4545.048.48
Reka CoreProprietaryUnknown28.9027.5041.4128.4526.6455.6058.9050.5265.7271.2510.71
Ovis 1.5 Gemma2 9BOpen0.4 / 928.4026.1444.4433.1920.9662.6064.2971.7556.3366.165.80
Ovis 1.5 Llama3 8BOpen0.4 / 828.2027.2749.4931.0317.9060.1561.3968.9356.3361.837.14
Cambrian 34BOpen1.9 / 3427.3024.5544.4427.5924.8959.7359.3170.9453.2864.635.36
MiniCPM-V2.6 (Upsize)Open0.4 / 827.1021.5945.4535.3421.4061.6269.2855.9360.4872.0119.64
Reka FlashProprietaryUnknown26.6026.5939.3930.6017.0356.4561.3948.5969.8772.527.14
Mini Gemini HD Yi 34BOpen0.5 / 3425.0026.5943.4327.1611.7952.6853.8655.0465.5053.942.23
InternLM XComposer2 4KHDOpen0.3 / 725.0023.8643.4329.3114.8554.6561.0954.0851.5359.806.70
MiniCPM-V2.5Open0.4 / 824.9025.2343.4325.4315.7259.2762.2861.9056.7768.9610.27
Qwen VL MaxProprietaryUnknown24.7026.1441.4124.5714.8541.4850.4228.4153.7151.154.46
VILA 1.5 40BOpen5.9 / 3424.0021.5941.4125.0020.0938.6742.8829.6251.3150.899.82
Reka EdgeProprietaryUnknown23.5020.2332.3230.6018.7833.6536.6528.4934.7252.164.91
Gemini 1.0 ProProprietaryUnknown22.8020.9148.4818.1020.0954.3767.9739.2360.4862.608.93
LLaVA 1.6 Yi 34BOpen0.3 / 3422.5020.4537.3723.7118.7851.0546.3863.4456.1151.915.80
Mini Gemini HD Llama3 8BOpen0.5 / 819.0019.7736.3621.127.8644.4249.4139.2351.0955.981.79
CogAgentOpen4.4 / 718.8016.8232.3220.6914.8536.3045.1426.8043.2337.156.70
InternLM XComposer2Open0.3 / 718.7016.1438.3821.9811.7938.7534.1043.5846.7252.935.80
MiniCPM-V2Open0.4 / 2.418.5017.9533.3319.4012.2335.7739.7436.5626.4244.535.36
IDEFICS 2Open0.4 / 718.2015.4535.3517.2417.0332.7736.1227.2840.8343.263.12
IDEFICS 2 ChattyOpen0.4 / 717.8015.4534.3419.8313.1041.5534.8854.5645.6344.276.70
MoAIOpen0.3 / 717.509.3236.3621.1221.4028.7031.2021.2339.9640.467.59
DeepSeek VLOpen0.5 / 717.1016.3632.3219.839.1745.8049.1145.2042.7960.314.91
DocOwl 1.5 ChatDomain-specific0.3 / 717.0014.3234.3415.0916.5937.4036.8349.2336.6822.903.12
SPHINX V2Open1.9 / 1316.1013.8628.2817.6713.5430.2535.5924.3741.0529.521.79
Qwen VL PlusProprietaryUnknown16.0015.4545.4512.078.3028.9333.3317.9232.1056.232.23
UReaderDomain-specific0.3 / 714.3011.3618.1815.5217.0318.9810.2027.6033.4120.365.36
ChartLlamaDomain-specific0.3 / 1314.208.1834.349.9121.4019.2317.1412.1943.8928.756.70
LLaVA 1.6 Mistral 7BOpen0.3 / 713.9011.3632.3216.817.8635.4034.7033.9848.9142.498.48
ChartGemmaDomain-specific0.4 / 212.5011.5924.2416.814.8021.3027.5818.9714.1919.594.46
ChartAssistantDomain-specific1.9 / 1311.709.0927.2710.3411.3516.9316.4316.8716.5727.742.68
ChartInstruct-FlanT5Domain-specific0.3 / 311.707.9532.329.4812.2315.4711.6817.5915.9429.526.70
Random (GPT-4o)N/AUnknown10.804.3239.395.6016.1619.8521.6516.7123.8025.705.36
DocOwl 1.5 OmniDomain-specific0.3 / 79.105.4514.149.4813.5425.7034.4617.9231.8817.564.46
ChartInstruct-Llama2Domain-specific0.3 / 78.804.0923.237.7612.6621.4023.3115.5033.1927.484.91
TinyChartDomain-specific0.4 / 38.305.0013.136.4714.4116.1513.8214.6124.6728.503.12
UniChart-ChartQADomain-specific1.9 / 85.703.416.063.4512.2319.329.9138.2612.2319.080.45
TextMonkeyDomain-specific8-Feb3.902.504.043.027.4212.4512.1617.928.736.362.68

πŸ“œ License

Our original data contributions (all data except the charts) are distributed under the CC BY-SA 4.0 license. Our code is licensed under Apache 2.0 license. The copyright of the charts belong to the original authors, where you can find the source in image_metadata_val.json and image_metadata_test.json under the data folder.

πŸ₯Ί Cite

If you use our work and are inspired by our work, please consider cite us (available soon):

@article{wang2024charxiv,
  title={CharXiv: Charting Gaps in Realistic Chart Understanding in Multimodal LLMs},
  author={Wang, Zirui and Xia, Mengzhou and He, Luxi and Chen, Howard and Liu, Yitao and Zhu, Richard and Liang, Kaiqu and Wu, Xindi and Liu, Haotian and Malladi, Sadhika and Chevalier, Alexis and Arora, Sanjeev and Chen, Danqi},
  journal={arXiv preprint arXiv:2406.18521},
  year={2024}
}

πŸ™Œ Contributors and Acknowledgement

πŸ“Š CharXiv is built by a team consisting of:
Zirui Wang, Mengzhou Xia, Luxi He, Howard Chen, Yitao Liu, Richard Zhu, Kaiqu Liang, Xindi Wu, Haotian Liu, Sadhika Malladi, Alexis Chevalier, Sanjeev Arora, Danqi Chen

Princeton Language and Intelligence, Princeton University
University of Wisconsin, Madison
The University of Hong Kong

πŸ€— We adapted part of the MathVista's codebase in building our evaluation framework, and we greatly appreciate their contributions to the MLLM community.
πŸ€— The lyrics in the teaser video are created by GPT-4o from our abstract, and the music is created by Suno. Video is manually edited using CapCut.

We’ve received multiple requests for scripts that batch convert vector images to raster images from arXiv source files that we used to construct CharXiv. While the code is not part of this codebase, we are happy to provide them. Please send an email to Zirui Wang for inquiries.