zhangyan-ucas/GUI-SD-code

14

stars

4

commits

Python

primary language

May 6, 2026

updated

README

Learn where to Click from Yourself: On-Policy Self-Distillation for GUI Grounding

This is the official repository of the paper GUI-SD.

Yan Zhang, Daiqing Wu, Huawen Shen, Can Ma, Yu Zhou

News

🔥 We are actively seeking job opportunities (research/engineering positions) in the areas of Multimodal LLMs, GUI Agents, and Reinforcement Learning. If you are interested in our work or have relevant openings, please feel free to reach out via email: zhangyan2022@iie.ac.cn

2025/04/30

  • We are the first to introduce on-policy self-distillation for GUI grounding.
  • We release the code and training data.

Installation

  1. Install ms-swift framework following the installation. We recommend installing ms-swift==4.0.0-dev, so that you can directly start our training script.

  2. Manually install the dependencies:

conda create -n GUI-SD python=3.10 -y
conda activate GUI-SD
pip install -r requirements.txt

Data preparation

  1. Download our dataset from Hugging Face:
# Option 1: Using huggingface-cli (recommended)
pip install huggingface_hub
huggingface-cli download yankie123/GUI-SD-data --repo-type dataset --local-dir ./data

# Option 2: Using git lfs
git lfs install
git clone https://huggingface.co/datasets/yankie123/GUI-SD-data ./data

You can also browse and download the dataset directly from the 🤗 Hugging Face Dataset Page.

  1. After downloading, place the dataset file (e.g., gui-sd.jsonl) in your working directory. The training script loads data via the --dataset argument:
--dataset "gui-sd.jsonl"

Training

sh ./GUI-SD_scripts/train.sh

The training script consists of two stages: (1) launching a vLLM rollout server for on-policy generation, and (2) running the OPSD (On-Policy Self-Distillation) trainer. Below are the key arguments we defined:

Core OPSD Arguments:

ArgumentDefaultDescription
--use_opsdfalseEnable On-Policy Self-Distillation mode. Must be set to true to activate GUI-SD training.
--rlhf_type-Set to gkd to use Generalized Knowledge Distillation as the base framework.
--lmbda0.5On-policy probability. With probability λ, the student generates new responses for training; otherwise uses dataset responses. Set to 1 for fully on-policy.
--beta-KL divergence coefficient controlling the distillation strength.
--seq_kdfalseWhether to use sequence-level knowledge distillation. Set to false for token-level KD in GUI-SD.

Teacher Model Arguments:

ArgumentDefaultDescription
--teacher_model-Path or name of the teacher model. In GUI-SD, we use the same model as the student (self-distillation).
--teacher_model_type-Model type of the teacher (e.g., qwen3_vl).
--teacher_deepspeed-DeepSpeed strategy for the teacher model (e.g., zero3).
--opsd_ema_decay0.0EMA decay rate for updating the teacher model. 0=fixed teacher (no update); 0.95=moderate update speed.

Visual Hint (Mask) Arguments:

ArgumentDefaultDescription
--opsd_mask_dircache/opd_cacheDirectory to cache the generated visual hint images for the teacher.
--opsd_mask_modezoom_inVisual hint strategy for the teacher input. Options: zoom_in (crop center region), adaptive (adaptive bbox scaling), gaussian (Gaussian blur around target), original (draw bbox on original image), no_mask (no visual hint).
--opsd_hint_modehintText hint mode for the teacher. none=no hint; hint=add green box + hint text; gt=provide ground-truth coordinates directly.

Token Weight Arguments:

ArgumentDefaultDescription
--opsd_token_weight_modelinearToken-level weight strategy for KD loss. uniform=equal weight 1.0; linear=positional weight (hundreds>tens>ones); uniform-entropy=uniform × teacher confidence; linear-entropy=positional × teacher confidence.
--opsd_non_digit_weight1.0Weight assigned to non-digit tokens in the output. Set to 0.1 to focus distillation on coordinate digits.
--opsd_max_digit_len0Max effective digit length for linear weighting. 0=unlimited; 3=for norm-1000 coordinates (Qwen3-VL); 4=for absolute pixel coordinates (Qwen2.5-VL).

vLLM Rollout Server Arguments:

ArgumentDefaultDescription
--use_vllmtrueEnable vLLM for on-policy response generation.
--vllm_modeservervLLM running mode. server means connecting to an external vLLM server.
--vllm_server_host127.0.0.1Host address of the vLLM rollout server.
--vllm_server_port8192Port of the vLLM rollout server.

Evaluate

sh ./GUI-SD_scripts/test.sh <run_name> <dataset1> [dataset2] [dataset3] ...

Example:

# Evaluate on a single benchmark
sh ./GUI-SD_scripts/test.sh gui-sd screenspotv2

# Evaluate on multiple benchmarks
sh ./GUI-SD_scripts/test.sh gui-sd screenspotpro screenspotv2 uivision

The script automatically iterates over all checkpoints under output/<run_name>/v*/checkpoint-* and evaluates each on the specified datasets.

Supported Datasets:

Dataset NameFile PathDescription
screenspotproground_benchmark/screenspotpro.jsonlScreenSpot-Pro benchmark
screenspotv2ground_benchmark/screenspotv2.jsonlScreenSpot-v2 benchmark
uivisionground_benchmark/ui-vision.jsonlUI-Vision benchmark
mmbenchground_benchmark/mmbench.jsonlMMBench benchmark
osworldgground_benchmark/osworldg.jsonlOSWorld-G benchmark
osworldg_rground_benchmark/osworldg_r.jsonlOSWorld-G (relaxed) benchmark

Key Inference Arguments:

ArgumentValueDescription
--infer_backendptUse PyTorch backend for inference.
--max_new_tokens1024Maximum number of new tokens to generate.
--max_batch_size4Batch size for inference.
--model_typeqwen3_vlModel architecture type.

Results are saved to <checkpoint>/infer_result/<dataset_name>.jsonl.

Statement

This project is for research purpose only. For any other questions please contact zhangyan2022@iie.ac.cn.

Acknowledgements

This project is built upon ms-swift, an efficient and lightweight framework for LLM/VLM fine-tuning and inference. We sincerely thank the ms-swift team for their excellent open-source contribution.

We also thank the open-source dataset ScaleCUA for providing high-quality GUI grounding data.

Contributors

zhangyan-ucas

3 commits

wdqqdw

1 commits

zhangyan-ucas/GUI-SD-code

14

stars

4

commits

Python

primary language

May 6, 2026

updated

README

Learn where to Click from Yourself: On-Policy Self-Distillation for GUI Grounding

This is the official repository of the paper GUI-SD.

Yan Zhang, Daiqing Wu, Huawen Shen, Can Ma, Yu Zhou

News

🔥 We are actively seeking job opportunities (research/engineering positions) in the areas of Multimodal LLMs, GUI Agents, and Reinforcement Learning. If you are interested in our work or have relevant openings, please feel free to reach out via email: zhangyan2022@iie.ac.cn

2025/04/30

  • We are the first to introduce on-policy self-distillation for GUI grounding.
  • We release the code and training data.

Installation

  1. Install ms-swift framework following the installation. We recommend installing ms-swift==4.0.0-dev, so that you can directly start our training script.

  2. Manually install the dependencies:

conda create -n GUI-SD python=3.10 -y
conda activate GUI-SD
pip install -r requirements.txt

Data preparation

  1. Download our dataset from Hugging Face:
# Option 1: Using huggingface-cli (recommended)
pip install huggingface_hub
huggingface-cli download yankie123/GUI-SD-data --repo-type dataset --local-dir ./data

# Option 2: Using git lfs
git lfs install
git clone https://huggingface.co/datasets/yankie123/GUI-SD-data ./data

You can also browse and download the dataset directly from the 🤗 Hugging Face Dataset Page.

  1. After downloading, place the dataset file (e.g., gui-sd.jsonl) in your working directory. The training script loads data via the --dataset argument:
--dataset "gui-sd.jsonl"

Training

sh ./GUI-SD_scripts/train.sh

The training script consists of two stages: (1) launching a vLLM rollout server for on-policy generation, and (2) running the OPSD (On-Policy Self-Distillation) trainer. Below are the key arguments we defined:

Core OPSD Arguments:

ArgumentDefaultDescription
--use_opsdfalseEnable On-Policy Self-Distillation mode. Must be set to true to activate GUI-SD training.
--rlhf_type-Set to gkd to use Generalized Knowledge Distillation as the base framework.
--lmbda0.5On-policy probability. With probability λ, the student generates new responses for training; otherwise uses dataset responses. Set to 1 for fully on-policy.
--beta-KL divergence coefficient controlling the distillation strength.
--seq_kdfalseWhether to use sequence-level knowledge distillation. Set to false for token-level KD in GUI-SD.

Teacher Model Arguments:

ArgumentDefaultDescription
--teacher_model-Path or name of the teacher model. In GUI-SD, we use the same model as the student (self-distillation).
--teacher_model_type-Model type of the teacher (e.g., qwen3_vl).
--teacher_deepspeed-DeepSpeed strategy for the teacher model (e.g., zero3).
--opsd_ema_decay0.0EMA decay rate for updating the teacher model. 0=fixed teacher (no update); 0.95=moderate update speed.

Visual Hint (Mask) Arguments:

ArgumentDefaultDescription
--opsd_mask_dircache/opd_cacheDirectory to cache the generated visual hint images for the teacher.
--opsd_mask_modezoom_inVisual hint strategy for the teacher input. Options: zoom_in (crop center region), adaptive (adaptive bbox scaling), gaussian (Gaussian blur around target), original (draw bbox on original image), no_mask (no visual hint).
--opsd_hint_modehintText hint mode for the teacher. none=no hint; hint=add green box + hint text; gt=provide ground-truth coordinates directly.

Token Weight Arguments:

ArgumentDefaultDescription
--opsd_token_weight_modelinearToken-level weight strategy for KD loss. uniform=equal weight 1.0; linear=positional weight (hundreds>tens>ones); uniform-entropy=uniform × teacher confidence; linear-entropy=positional × teacher confidence.
--opsd_non_digit_weight1.0Weight assigned to non-digit tokens in the output. Set to 0.1 to focus distillation on coordinate digits.
--opsd_max_digit_len0Max effective digit length for linear weighting. 0=unlimited; 3=for norm-1000 coordinates (Qwen3-VL); 4=for absolute pixel coordinates (Qwen2.5-VL).

vLLM Rollout Server Arguments:

ArgumentDefaultDescription
--use_vllmtrueEnable vLLM for on-policy response generation.
--vllm_modeservervLLM running mode. server means connecting to an external vLLM server.
--vllm_server_host127.0.0.1Host address of the vLLM rollout server.
--vllm_server_port8192Port of the vLLM rollout server.

Evaluate

sh ./GUI-SD_scripts/test.sh <run_name> <dataset1> [dataset2] [dataset3] ...

Example:

# Evaluate on a single benchmark
sh ./GUI-SD_scripts/test.sh gui-sd screenspotv2

# Evaluate on multiple benchmarks
sh ./GUI-SD_scripts/test.sh gui-sd screenspotpro screenspotv2 uivision

The script automatically iterates over all checkpoints under output/<run_name>/v*/checkpoint-* and evaluates each on the specified datasets.

Supported Datasets:

Dataset NameFile PathDescription
screenspotproground_benchmark/screenspotpro.jsonlScreenSpot-Pro benchmark
screenspotv2ground_benchmark/screenspotv2.jsonlScreenSpot-v2 benchmark
uivisionground_benchmark/ui-vision.jsonlUI-Vision benchmark
mmbenchground_benchmark/mmbench.jsonlMMBench benchmark
osworldgground_benchmark/osworldg.jsonlOSWorld-G benchmark
osworldg_rground_benchmark/osworldg_r.jsonlOSWorld-G (relaxed) benchmark

Key Inference Arguments:

ArgumentValueDescription
--infer_backendptUse PyTorch backend for inference.
--max_new_tokens1024Maximum number of new tokens to generate.
--max_batch_size4Batch size for inference.
--model_typeqwen3_vlModel architecture type.

Results are saved to <checkpoint>/infer_result/<dataset_name>.jsonl.

Statement

This project is for research purpose only. For any other questions please contact zhangyan2022@iie.ac.cn.

Acknowledgements

This project is built upon ms-swift, an efficient and lightweight framework for LLM/VLM fine-tuning and inference. We sincerely thank the ms-swift team for their excellent open-source contribution.

We also thank the open-source dataset ScaleCUA for providing high-quality GUI grounding data.

Contributors

zhangyan-ucas

3 commits

wdqqdw

1 commits

Languages

Python

99.7%