Home

Awesome

ScienceQA: Science Question Answering

VQA Science Problems Open Domain Multi-Modal ScienceQA Chain-of-Thought GPT-3 ChatGPT GPT-4 LLMs

Data and code for NeurIPS 2022 Paper "Learn to Explain: Multimodal Reasoning via Thought Chains for Science Question Answering".

For more details, please refer to the project page with dataset exploration and visualization tools: https://scienceqa.github.io.

:bell: If you have any questions or suggestions, please don't hesitate to let us know. You can directly email Pan Lu at UCLA using the email address lupantech@gmail.com, comment on the Twitter, or post an issue on this repository.

๐Ÿ’ฅ News ๐Ÿ’ฅ

๐ŸŒŸ Star History

Star History Chart

:fire: Leaderboard :fire:

Evaluation of different methods on the test split (whole: 4,241, mini: 1,000 examples). The accuracies across various categories and the overall average are reported below.

๐Ÿ˜€ You are invited to contribute your results to the TabMWP test split! Please send your result scores to this email or open a new issue at the github repository.

โš ๏ธโš ๏ธโš ๏ธ Caveat: The data in the leaderboard is collected manually from existing papers. There might be some errors in the data, ambiguous data due to different interpretations, and missing data due to the lack of information in the papers. Make sure to double-check the data before using it. Please contact us at this email if you find any errors or have any suggestions. We appreciate your contributions and feedback.

The interactive leaderboard is available at https://scienceqa.github.io/leaderboard.html.

#ModelMethodLearning#Size#PLinkDateNATSOCLANTXTIMGNOG1-6G7-12Avg
*Human Performance----Link22-09-2090.2384.9787.4889.6087.5088.1091.5982.4288.40
*Random Chance----Link22-09-2040.2846.1329.2547.4540.0833.6639.3540.6739.83
1Mutimodal-T-SciQ_Large ๐Ÿฅ‡LLMFine-tune738M738MLink23-05-0596.8995.1695.5596.5394.7096.7996.4495.7296.18
2MC-CoT_F-Large ๐ŸฅˆVLMFine-tune783M-Link23-11-2397.4790.4493.1896.9793.7594.4995.3094.1394.88
3Honeybee (Vicuna-13B) ๐Ÿฅ‰VLMFine-tune13B-Link23-12-1195.2096.2991.1894.4893.7593.1795.0493.2194.39
4Enigma-COT_LargeLLMFine-tune793M793MLink23-07-2497.5184.7094.7396.6891.3795.8994.4693.4794.11
5MC-CoT_LargeVLMFine-tune738M-Link23-11-2395.4789.9991.8295.1192.6693.2494.2791.7693.37
6DPMM-CoT_LargeVLMFine-tune738M738MLink23-12-1495.5290.3391.3695.5093.2692.6893.2893.4793.35
7LLaVA (GPT-4 judge)VLMFine-tune13B13BLink23-04-1791.5696.7491.0990.6288.9993.5292.7392.1692.53
8CoMD (Vicuna-7B)VLMFine-tune7B-Link23-11-1491.8395.9588.9190.9189.9491.0892.4790.9791.94
9Mutimodal-T-SciQ_BaseLLMFine-tune223M223MLink23-05-0591.5291.4592.4591.9490.3392.2692.1191.1091.75
10Multimodal-CoT_LargeVLMFine-tune738M738MLink23-02-0295.9182.0090.8295.2688.8092.8992.4490.3191.68
11PILL (LLaMA-7B)VLMFine-tune7B45MLink23-11-0390.3695.8489.2789.3988.6591.7192.1189.6591.23
12LLaVA (ViT-L/16-224)VLMFine-tune13B-Link23-12-04--------91.2
13DPMM-CoT_BaseVLMFine-tune223M223MLink23-12-1492.7287.8589.9192.7290.4891.2991.4590.1190.97
14LLaVAVLMFine-tune13B13BLink23-04-1790.3695.9588.0089.4988.0090.6690.9390.9090.92
15LaVIN-13BVLMFine-tune13B5.4MLink23-05-2489.8894.4989.8288.9587.6191.8591.4589.7290.83
16MC-CoT_F-BaseVLMFine-tune248M-Link23-11-2393.5683.5890.7394.1389.2490.9490.9390.3890.73
17MC-CoT_BaseVLMFine-tune223M-Link23-11-2391.8784.5993.0092.2888.3092.7590.6490.6490.64
18LLaMA-SciTuneVLMZero-shot13B-Link23-07-0389.3095.6187.0093.0886.6791.7584.3791.3090.03
19LaVIN-7BVLMFine-tune7B3.8MLink23-05-2489.2594.9485.2488.5187.4688.0890.1688.0789.41
20Flan-T5-XL (LoRA)LLMFine-tune--Link23-11-03--------89.29
21Chat-UniViVLMFine-tune7B-Link23-11-1488.5093.0385.9188.5185.9788.1588.8888.6088.78
22DDCoT (T5)PLMFine-tune223M223MLink23-10-2588.7286.8484.9187.5983.3488.0888.5885.1087.34
23LG-VQA (CLIP)VLMZero-shot--Link23-10-31--------87.22
24Chameleon (GPT-4)Tool-LLMFew-shot1T+-Link23-04-1989.8374.1389.8288.2777.6492.1388.0383.7286.54
25LG-VQA (BLIP-2)VLMZero-shot--Link23-10-31--------86.32
26LLaMA-SciTuneVLMZero-shot7B-Link23-07-0384.5094.1582.9188.3583.6488.7485.0585.6086.11
27Enigma-COT_BaseLLMFine-tune229M229MLink23-07-2488.2878.7485.6488.5184.2886.9085.4385.8985.59
28LLaMA-AdapterVLMFine-tune6B1.2MLink23-03-2884.3788.3084.3683.7280.3286.9085.8384.0585.19
29Multimodal-CoT_BaseVLMFine-tune223M223MLink23-02-0287.5277.1785.8287.8882.9086.8384.6585.3784.91
30IMMO SL+RLVLMFine-tune7B5MLink23-08-19--------84.8
31CoT GPT-4LLMFew-shot1T+-Link23-04-1985.4872.4490.2782.6571.4992.8986.6679.0483.99
32HoT-T5_LargeLLMFine-tune738M738MLink23-08-1184.4679.0884.6482.8975.8188.1583.8882.4783.38
33HoT-T5_BaseLLMFine-tune223M223MLink23-08-1182.4678.0782.0081.1875.2085.0981.8680.6281.42
34DDCoT (ChatGPT)LLMZero-shot175B-Link23-10-2580.1576.7282.8278.8972.5385.0282.8675.2180.15
35Chameleon (ChatGPT)Tool-LLMFew-shot175B+-Link23-04-1981.6270.6484.0079.7770.8086.6281.8676.5379.93
36CoT GPT-3 + DocTool-LLMZero-shot173B-Link23-08-01--------79.91
37UnifiedQA-T-SciQ_BaseLLMFine-tune223M223MLink23-05-0576.5688.9980.4572.9073.8483.4781.0975.1979.41
38CoT ChatGPTLLMFew-shot175B-Link23-04-1978.8270.9883.1877.3767.9286.1380.7274.0378.31
39DDCoT (GPT-3)LLMZero-shot175B-Link23-10-2578.6073.9080.4577.2769.9682.9380.6573.5078.09
40LaVIN-13BVLMZero-shot--Link23-10-13--------77.54
41CoT GPT-3 (ALE)LLMFew-shot173B-Link22-09-2075.4470.8778.0974.6867.4379.9378.2369.6875.17
42LaVIN-7BVLMZero-shot--Link23-10-13--------75.11
43CoT GPT-3 (AE)LLMFew-shot173B-Link22-09-2076.6065.9277.5575.5166.0979.5878.4967.6374.61
44BLIP-2VLMZero-shot--Link23-10-13--------74.17
45CoT UnifiedQAPLMFine-tune223M223MLink22-09-2071.0076.0478.9166.4266.5381.8177.0668.8274.11
46GPT-3 (0-shot)LLMZero-shot173B-Link22-09-2075.0466.5978.0074.2465.7479.5876.3669.8774.04
47GPT-3 (2-shot)LLMFew-shot173B-Link22-09-2074.6469.7476.0074.4467.2877.4276.8068.8973.97
48InstructBLIPVLMZero-shot--Link23-10-13--------73.33
49UnifiedQAPLMFine-tune223M223MLink22-09-2068.1669.1874.9163.7861.3877.8472.9865.0070.12
50ChatGPTLLMZero-shot--Link23-10-13--------69.41
51MetaCLIPVLMZero-shot--Link23-12-10--------68.77
52OpenCLIPVLMZero-shot--Link23-12-10--------67.53
53Flan-T5-XXLLLMZero-shot--Link23-10-13--------67.43
54SAMVLMZero-shot--Link23-12-10--------67.08
55DINOv2VLMZero-shot--Link23-12-10--------64.60
56VisualBERTVLMFine-tune111M111MLink22-09-2059.3369.1861.1862.7162.1758.5462.9659.9261.87
57Patch-TRMVLMFine-tune90M90MLink22-09-2065.1946.7965.5566.9655.2864.9558.0467.5061.42
58ViLTVLMFine-tune113M113MLink22-09-2060.4863.8960.2763.2061.3857.0060.7261.9061.14
59DFAFVQA-NNFine-tune74M74MLink22-09-2064.0348.8263.5565.8854.4964.1157.1267.1760.72
60Chat-UniViVLMZero-shot7B-Link23-11-1458.6161.0861.8257.3358.2561.3962.0456.2359.96
61BANVQA-NNFine-tune112M112MLink22-09-2060.8846.5766.6462.6152.6065.5156.8363.9459.37
62Top-DownVQA-NNFine-tune70M70MLink22-09-2059.5054.3361.8262.9054.8859.7957.2762.1659.02
63MiniGPT4VLMZero-shot--Link23-10-13--------58.70
64LLaMA2-13BLLMZero-shot13B-Link23-10-13--------55.78
65DDCoT (MiniGPT-4)VLMZero-shot--Link23-10-2557.3762.3246.8265.9156.7248.57--55.67
66QVixVLMZero-shot--Link23-12-04--------55.0
67MCANVQA-NNFine-tune95M95MLink22-09-2056.0846.2358.0959.4351.1755.4051.6559.7254.54
68LLaMA-Adapter-V2VLMZero-shot--Link23-10-13--------54.44
69VLISVLMZero-shot--Link23-10-15---53.149.349.1--50.2
70LLaVA-13BVLMZero-shot--Link23-10-13--------47.74
71VPGTransVLMZero-shot--Link23-10-13--------47.00
72MiniGPT-4VLMZero-shot--Link23-10-2543.8348.5943.3655.0142.8441.67--44.71
73LLaMA1-13BLLMZero-shot13B-Link23-10-13--------43.33
74LLaMA2-7BLLMZero-shot7B-Link23-10-13--------43.08
75LLaVA-7BVLMZero-shot--Link23-10-13--------41.10
76OpenFlamingoVLMZero-shot--Link23-10-13--------39.27
77LynxVLMZero-shot--Link23-10-13--------38.28
78mPLUG-OwlVLMZero-shot--Link23-10-13--------37.93
79MultiGPTVLMZero-shot--Link23-10-13--------36.29
80LLaMA1-7BLLMZero-shot7B-Link23-10-13--------36.19
81FromageVLMZero-shot--Link23-10-13--------34.51
-MMICLVLMZero-shot--Link23-09-14----82.10----
-VILA-13B (Llama-2-13B)VLM-13B-Link23-12-12----73.7----
-LLaVA+SIRIVLM-13B-Link23-11-29----72.0----
-LLaVA-1.5 (Vicuna-13B)VLMZero-shot13B-Link23-10-05----71.6----
-InstructBLIPVLMZero-shot--Link23-09-14----71.30----
-ShareGPT4V (Vicuna-7B)VLM-7B-Link23-11-23----68.4----
-Qwen-VL-Chat (Qwen-7B)VLMZero-shot7B-Link23-10-05----68.2----
-Multimodal BardVLMZero-shot--Link23-08-07----68----
-Qwen-VL (Qwen-7B)VLMZero-shot7B-Link23-10-05----67.1----
-LLaVA-1.5 (Vicuna-7B)VLMZero-shot7B-Link23-10-05----66.8----
-Video-LLaVA (Vicuna-7B)VLM-7B-Link23-11-16----66.4----
-InstructBLIP+MoCLEVLMZero-shot7B-Link23-12-19----63.9----
-OtterVLMZero-shot--Link23-09-14----63.10----
-InstructBLIP (Vicuna-13B)VLMZero-shot13B-Link23-10-05----63.1----
-BLIP-2 (Vicuna-13B)VLMZero-shot13B-Link23-10-05----61----
-InstructBLIP (Vicuna-7B)VLMZero-shot7B-Link23-10-05----60.5----
-Ying-VLMVLMZero-shot--Link23-09-14----55.70----
-ShikraVLMZero-shot--Link23-09-14----45.80----
CaCo-CoT (Claude)LLMFew-shot--Link23-08-23---90.8-----
CaCo-CoT (Claude)LLMZero-shot--Link23-08-23---89.9-----
CoT ClaudeLLMFew-shot--Link23-08-23---89.5-----
CaCo-CoT (ChatGPT)LLMFew-shot--Link23-08-23---88.6-----
ClaudeLLMZero-shot--Link23-08-23---86.8-----
CaCo-CoT (ChatGPT)LLMZero-shot--Link23-08-23---86.5-----
CoT ClaudeLLMZero-shot--Link23-08-23---86.5-----

Some notations in the table

:world_map: About ScienceQA

We present Science Question Answering (ScienceQA), a new benchmark that consists of 21,208 multimodal multiple choice questions with a diverse set of science topics and annotations of their answers with corresponding lectures and explanations. The lecture and explanation provide general external knowledge and specific reasons, respectively, for arriving at the correct answer.

<p align="center"> <img src="assets/scienceqa.png" width="80%"> <br> </p>

ScienceQA, in contrast to previous datasets, has richer domain diversity from three subjects: natural science, language science, and social science. ScienceQA features 26 topics, 127 categories, and 379 skills that cover a wide range of domains.

<p align="center"> <img src="assets/domain.png" width="80%"> <br> </p> <p align="center"> <img src="assets/context.png" width="80%"> <br> </p>

We further design language models to learn to generate lectures and explanations as the chain of thought (CoT) to mimic the multi-hop reasoning process when answering ScienceQA questions. ScienceQA demonstrates the utility of CoT in language models, as CoT improves the question answering performance by 1.20% in few-shot GPT-3 and 3.99% in fine-tuned UnifiedQA.

For more details, you can find our project page here and our paper here.

:ghost: Download the Dataset

The text part of the ScienceQA dataset is provided in data/scienceqa/problems.json.

The data examples in problem.json follow the following format:

{
  "(question id)": {
    "question": "question text, e.g., 'Which of these states is farthest north?'", 
    "choices": "question choices, e.g., ['West Virginia', 'Louisiana', 'Arizona', 'Oklahoma']",
    "answer": "index of ground truth answer, e.g., 0",
    "hint": "the textual context, e.g., 'Figure: sturgeon.', could be an empty string",
    "image": "the visual context with an image path, e.g., 'image.png', could be none",
    "task": "task type, e.g., 'closed choice'",
    "grade": "grade level, e.g., 'grade2'",
    "subject": "subject type, e.g., 'social science'",
    "topic": "topic type, e.g., 'geography'",
    "category": "category type, e.g., 'Geography'",
    "skill": "skill type, e.g., 'Read a map: cardinal directions'",
    "lecture": "lecture of the question, e.g., 'Maps have four cardinal directions, or main directions. Those directions are north, south, east, and west.\nA compass rose is a set of arrows that point to the cardinal directions. A compass rose usually shows only the first letter of each cardinal direction.\nThe north arrow points to the North Pole. On most maps, north is at the top of the map.'",
    "solution": "solution to the question, e.g., 'To find the answer, look at the compass rose. Look at which way the north arrow is pointing. West Virginia is farthest north.'",
    "split": "data split, e.g., 'train'"
  }
}

For language models such as UnifiedQA, GPT-3, and GPT-4, you can concatenate the textual hint and the captioning of the image to form the context.

You can download the image data of ScienceQA by running:

. tools/download.sh

Alternatively, you can download ScienceQA from Google Drive and unzip the images under root_dir/data.

๐Ÿ’ฅ The ScienceQA dataset is now available at HuggingFace Datasets!

We have uploaded a demo to illustrate how to access the ScienceQA dataset on Hugging Face, available at demos/Hugging_Face_Dataset_demo.ipynb.

:smiling_imp: Explore ScienceQA

For more details, you can explore the datatset and check the visualizations here: Explore and Visualizations.

<p align="center"> <img src="assets/explore.png" width="80%"> <br> </p>

:octopus: Requirements

python==3.8.10
huggingface-hub
nltk==3.5
numpy==1.23.2
openai==0.23.0
pandas==1.4.3
rouge==1.0.1
sentence-transformers==2.2.2
torch==1.12.1+cu113
transformers==4.21.1

Install all required python dependencies:

pip install -r requirements.txt

:robot: Run the GPT-3 (CoT) Model for ScienceQA

Generate the image captions

We use the image captioning model to generate the text content for images in ScienceQA. The pre-generated image captions are provided in data/captions.json.

(Optionally) You can generate the image captions with user-specific arguments with the following command, which will save the caption data in data/captions_user.json.

cd tools
python generate_caption.py

Run the model

We build a few-shot GPT-3 model via chain-of-thought (CoT) prompting to generate the answer followed by the lecture and the explanation (QCMโ†’ALE). The prompt instruction encoding for the test example in GPT-3 (CoT) is defined as below:

<p align="center"> <img src="assets/prompt.png" width="80%"> <br> </p>

In our final model, we develop GPT-3 (CoT) prompted with two in-context examples and evalute it on the ScienceQA test split:

cd models
python run_gpt3.py \
--label exp1 \
--test_split test \
--test_number -1 \
--shot_number 2 \
--prompt_format QCM-ALE \
--seed 3

Evaluate the results

Our final GPT-3 (CoT) model achieves a state-of-the-art accuracy of 75.17% on the test split. One prediction example is visualized below. We can see that GPT-3 (CoT) predicts the correct answer and generates a reasonable lecture and explanation to mimic the human thought process.

<p align="center"> <img src="assets/prediction.png" width="80%"> <br> </p>

We can get the accuracy metrics on average and across different question classes by running:

cd tools
python evaluate_acc.py

We can run the following command to evaluate the generated lectures and explanations automatically:

cd tools
python evaluate_explaination.py

Try different prompt templates

You can try other prompt templates. For example, if you want the model to take the question, the context, and the multiple options as input, and output the answer after the lecture and explanation (QCMโ†’LEA), you can run the following script:

cd models
python run_gpt3.py \
--label exp1 \
--test_split test \
--test_number -1 \
--shot_number 2 \
--prompt_format QCM-LEA \
--seed 3

:book: Related Work

:warning: Licenses

MIT license

This work is licensed under a MIT License.

CC BY-NC-SA 4.0 license

The ScienceQA dataset is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

:white_check_mark: Cite

If the paper, codes, or the dataset inspire you, please kindly cite us:

@inproceedings{lu2022learn,
    title={Learn to Explain: Multimodal Reasoning via Thought Chains for Science Question Answering},
    author={Lu, Pan and Mishra, Swaroop and Xia, Tony and Qiu, Liang and Chang, Kai-Wei and Zhu, Song-Chun and Tafjord, Oyvind and Clark, Peter and Ashwin Kalyan},
    booktitle={The 36th Conference on Neural Information Processing Systems (NeurIPS)},
    year={2022}
}