Skip to content

Repository files navigation

InteractScience: Programmatic and Visually-Grounded Evaluation of Interactive Scientific Demonstration Code Generation

HF DatasetApache 2.0 License

InteractScience is a benchmark specifically designed to evaluate the capability of large language models in generating interactive scientific demonstration code. This project provides a complete evaluation pipeline including model inference, automated testing, and multi-dimensional assessment.

📁 Directory Structure

.
├── data/ # Benchmark dataset
│ ├── interactscience.jsonl # Main dataset file containing problems and references
│ └── snapshots/ # Reference screenshot directory
│ ├── *_Snapshot-1.png
│ ├── *_Snapshot-2.png
│ └── ...
├── PFT_tests/ # Program Functionality Testing (PFT) scripts
│ ├── *.spec.js # Playwright test scripts
│ └── ...
├── VQT_tests/ # Visual Quality Testing (VQT) scripts
│ ├── *.spec.js # Playwright test scripts
│ └── ...
├── eval/ # Model inference results
│ ├── interactscience_lm_*.jsonl # Language model inference results
│ ├── interactscience_vlm_*.jsonl # Vision-language model inference results
│ └── ...
├── results/ # Test result data
│ ├── lm_results/ # Language model test results
│ │ ├── PFT_test_results/ # Program functionality test results
│ │ ├── VQT_test_results/ # Visual quality test results
│ │ ├── VQT_clip_results/ # CLIP scoring results
│ │ └── VQT_vlm_judge_results/ # VLM scoring results
│ └── vlm_results/ # Vision-language model test results
├── run_generation.sh # Model inference script
├── run_benchmark.sh # Automated testing script
├── run_vlm_as_judge.sh # VLM scoring script
├── cal_metrics.py # Metrics calculation script
├── test_llm.py # Language model testing main program
├── vlm_as_judge.py # VLM scoring main program
├── clip_score.py # CLIP score calculation
└── extract_and_save_code.py # Code extraction and saving

🚀 Usage Tutorial

1. Environment Setup

First install Node.js and npm, then install the Playwright testing environment:

# Install project dependencies
npm install
# Install Playwright browsers
npx playwright install

2. Model Inference

Use the run_generation.sh script for model inference:

# Edit the model path and parameters in the script
vim run_generation.sh
# Run inference (requires model path configuration)
bash run_generation.sh

Script Description:

  • Starts vLLM API server
  • Calls test_llm.py for inference
  • Results saved to eval/ directory

3. Automated Testing

Use the run_benchmark.sh script for automated testing:

# Set the model name to testexport MODEL="your_model_name"# Run tests
bash run_benchmark.sh

Testing Process:

  1. Extract HTML code from inference results (extract_and_save_code.py)
  2. Execute Program Functionality Testing (PFT) using playwright_PFT.config.js
  3. Execute Visual Quality Testing (VQT) using playwright_VQT.config.js
  4. Calculate CLIP similarity scores (clip_score.py)
  5. Results saved to results/ directory

4. VLM Scoring

Use run_vlm_as_judge.sh for VLM-as-Judge evaluation:

# Edit model and path configuration in the script
vim run_vlm_as_judge.sh
# Run VLM scoring
bash run_vlm_as_judge.sh

Scoring Description:

  • Uses vision-language models to score generated results
  • Compares reference screenshots with generated screenshots
  • Evaluation based on predefined checklists

5. Results Analysis

Use cal_metrics.py and cal_vlm_as_judege_score.py to calculate final metrics:

python cal_metrics.py
python cal_vlm_as_judege_score.py

📊 Dataset Description

interactscience.jsonl

Main dataset file, each line contains a test sample:

  • id: Unique identifier
  • question: Detailed HTML implementation plan
  • lm_system_prompt: Language model system prompt
  • vlm_system_prompt: Vision-language model system prompt
  • image_path: List of reference screenshot paths
  • snapshot_checklists: Visual verification checklists

Reference Screenshots

Located in data/snapshots/ directory, naming format:

  • {task_id}_Snapshot-{number}.png

🧪 Test Types

1. Program Functionality Testing (PFT)

  • Validates functional correctness of HTML code
  • Checks interactive element behavior
  • Tests JavaScript logic

2. Visual Quality Testing (VQT)

  • Generates page screenshots
  • Compares with reference screenshots
  • Calculates perceptual similarity (CLIP scores)
  • Calculates semantic correctness (VLM-judge scores)

🛠️ Core Scripts Description

test_llm.py

Language model testing main program:

python test_llm.py \
--dataset_path data/interactscience.jsonl \
--prompt_type lm_system_prompt \
--dump_path eval/result.jsonl \
--model_path your_model_path \
--base_url http://localhost:8000/v1 \
--api_key EMPTY

vlm_as_judge.py

VLM scoring main program:

python vlm_as_judge.py \
--reference_image_dir data/snapshots \
--generated_image_dir generated_images \
--checklist_file data/checklists.jsonl \
--output_path results/vlm_judge.jsonl \
--base_url your_api_endpoint \
--api_key your_api_key

📈 Evaluation Metrics

  • Program Functionality Test Pass Rate: Percentage of PFT test cases passed
  • Visual Quality Score: Visual similarity based on CLIP model
  • VLM Score: Comprehensive score given by multimodal models

Experiments

We have evaluated 30 state-of-the-art large language models on the InteractScience benchmark. The results are available in the results/ directory.

ModelPFT Overall (%)PFT Average (%)PFT Perfect (%)VQT Action (%)VQT CLIPVQT VLM-judge
Closed-Source Large Language Models
GPT-539.4737.6116.0889.6671.9557.02
GPT-4.137.0734.0811.1989.1571.2152.84
GPT-4o28.2727.095.5985.9367.1142.45
o334.9332.0913.9989.8372.2452.82
o4-mini37.3334.9013.2988.6471.7951.90
Gemini-2.5-Pro35.3334.6211.1986.7870.6554.69
Gemini-2.5-Flash31.6031.0710.4986.9569.5949.34
Claude-Sonnet-4-2025051441.4737.4013.2989.6673.5055.42
Claude-Opus-4-2025051440.2736.3411.1989.3273.2254.93
Claude-3.5-Sonnet33.3331.459.7990.1772.3249.43
Open-Source Large Language Models
DeepSeek-R1-052833.8732.028.3988.3169.5449.46
DeepSeek-V3-032431.7330.5710.4985.9368.6849.46
Kimi-K231.6031.229.7987.2970.1150.04
GLM-4.529.3326.658.3970.5155.9038.57
Intern-S131.8728.937.6987.4668.7445.27
gpt-oss-120b28.0027.789.7990.8572.1349.57
gpt-oss-20b15.2012.973.5080.5154.6821.40
Qwen3-235B-A22B-Instruct-250733.3331.4613.2978.1470.0245.14
Qwen3-32B27.2024.095.5987.4666.4639.69
Qwen3-14B24.1323.587.6985.0866.4636.53
Qwen3-8B20.0018.854.2081.5364.1334.67
Qwen3-4B14.6713.102.8082.0360.9028.33
Qwen3-1.7B6.536.221.4075.7659.6520.33
Qwen2.5-Coder-32B-Instruct27.2025.107.6984.5851.6738.51
Qwen2.5-Coder-14B-Instruct22.5320.614.9085.4264.4735.72
Qwen2.5-Coder-7B-Instruct12.4010.510.7082.3765.1726.97
Qwen2.5-VL-72B-Instruct23.7322.826.9987.1264.3337.30
Qwen2.5-VL-7B-Instruct7.476.720.7070.0049.4920.41
Llama-3.1-70B-Instruct18.6718.044.9088.6459.5633.36
Llama-3.1-8B-Instruct11.3310.163.5080.0065.4222.75

Comparison Across Difficulty Levels

Comparison Across Disciplines

Results on Multimodal LLMs with Reference Snapshots as Input

Example Cases

Citation

@article{InteractScience,
author = {Qiaosheng Chen and Yang Liu and Lei Li and Kai Chen and Qipeng Guo and Gong Cheng and Fei Yuan},
title = {InteractScience: Programmatic and Visually-Grounded Evaluation of Interactive Scientific Demonstration Code Generation}, journal = {arXiv preprint arXiv:2510.09724},
year = {2025}
}

About

No description, website, or topics provided.

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages