OphVLM-R1 / README_zh.md
QiZishi's picture
Upload folder using huggingface_hub
91e2b20 verified
|
Raw
History Blame Contribute Delete
8.98 kB
---
license: cc-by-nc-sa-4.0
base_model:
- OpenGVLab/InternVL3_5-2B
base_model_relation: finetune
datasets:
- QiZishi/OphReason-Vision
language:
- zh
tags:
- ophthalmology
- multimodal
- reasoning
- reinforcement-learning
---
<p align="center">
<img src="figures/模型图标.png" width="120" alt="OphVLM-R1 项目图标">
</p>
<h1 align="center">OphVLM-R1</h1>
<p align="center"><strong>基于课程强化学习的高效眼科推理模型</strong></p>
<p align="center">
<a href="https://huggingface.co/QiZishi/OphVLM-R1/blob/main/README.md">English</a> · <a href="https://huggingface.co/QiZishi/OphVLM-R1/blob/main/README_zh.md">简体中文</a>
</p>
<p align="center">
<a href="https://qizishi.github.io/OphVLM-R1/"><img src="https://img.shields.io/badge/项目-主页-2b6cb0?style=for-the-badge" alt="项目主页"></a>
<a href="https://github.com/QiZishi/OphAgent/"><img src="https://img.shields.io/badge/代码-OphAgent-181717?style=for-the-badge&logo=github" alt="OphAgent 代码"></a>
</p>
<p align="center">
<a href="https://huggingface.co/QiZishi/OphVLM-R1"><img src="https://img.shields.io/badge/🤗%20模型-Hugging%20Face-FFD21E?style=for-the-badge" alt="Hugging Face 模型"></a>
<a href="https://www.modelscope.cn/models/MoonNight/OphVLM-R1"><img src="https://img.shields.io/badge/模型-ModelScope-624AFF?style=for-the-badge" alt="ModelScope 模型"></a>
</p>
<p align="center">
<a href="https://huggingface.co/datasets/QiZishi/OphReason-Vision"><img src="https://img.shields.io/badge/🤗%20数据集-Hugging%20Face-FFD21E?style=for-the-badge" alt="Hugging Face 数据集"></a>
<a href="https://www.modelscope.cn/datasets/MoonNight/OphReason-Vision"><img src="https://img.shields.io/badge/数据集-ModelScope-624AFF?style=for-the-badge" alt="ModelScope 数据集"></a>
</p>
## 模型简介
**OphVLM-R1** 是一个面向眼科多模态推理的轻量级 2B 参数视觉语言模型。模型以 InternVL3.5-2B 为基座,先通过 LoRA 监督微调(SFT)学习眼科领域知识,再通过四阶段课程强化学习逐步获得更复杂的临床推理能力。训练过程引入 Group Sequence-level Policy Optimization(GSPO)和困难样本动态回溯,以改善长推理轨迹及长尾困难病例的优化效果。
本 README 聚焦模型训练流程、模型框架与算法、实验性能结果。数据集构建流程及数量分布详见下方 OphReason-Vision 数据集仓库。
## 项目资源
- **项目主页**<https://qizishi.github.io/OphVLM-R1/>
- **OphVLM-R1 模型**:[Hugging Face](https://huggingface.co/QiZishi/OphVLM-R1) | [ModelScope](https://www.modelscope.cn/models/MoonNight/OphVLM-R1)
- **OphReason-Vision 数据集**:[Hugging Face](https://huggingface.co/datasets/QiZishi/OphReason-Vision) | [ModelScope](https://www.modelscope.cn/datasets/MoonNight/OphReason-Vision)
- **OphAgent 系统**:[GitHub](https://github.com/QiZishi/OphAgent/)
## 模型与训练框架
OphVLM-R1 以 InternVL3.5-2B 为主干网络。2B 参数规模兼顾多模态临床推理能力与资源受限环境中的部署需求,整体训练分为两个阶段。
![两阶段训练流程](figures/two_stage_training.png)
### 阶段一:LoRA 监督微调
冷启动阶段使用 Low-Rank Adaptation 注入眼科领域知识:
$$ W_0 + \Delta W = W_0 + BA, \qquad h = W_0x + \frac{\alpha}{r}BAx $$
其中 \\(B \in \mathbb{R}^{d \times r}\\)、\\(A \in \mathbb{R}^{r \times k}\\),且 \\(r \ll \min(d,k)\\)。SFT 目标函数为:
$$ \mathcal{L}_{\mathrm{SFT}}=-\mathbb{E}\left[\sum_{t=1}^{\lvert y\rvert}\log\pi_\phi(y_t\mid x,y_{\lt t})\right]. $$
| 配置 | 数值 |
|---|---|
| 训练子集 | 3,418 条冷启动样本 |
| LoRA rank / scaling | \\(r=64\\),\\(\alpha=128\\) |
| 目标投影层 | \\(W_q\\)、\\(W_k\\)、\\(W_v\\)、\\(W_o\\) |
| 学习率 | \\(1\times10^{-4}\\),余弦退火 |
| 批次大小 / 轮数 | 32 / 3 epochs |
| 可训练参数 | 约占总参数的 0.5% |
### 阶段二:课程强化学习
GSPO 在序列级计算策略重要性比率,避免独立裁剪 token-level ratio:
$$ s_i(\phi)=\left(\frac{\pi_\phi(y_i\mid x)}{\pi_{\phi_{\mathrm{old}}}(y_i\mid x)}\right)^{\frac{1}{\lvert y_i\rvert}}=\exp\left(\frac{1}{\lvert y_i\rvert}\sum_{t=1}^{\lvert y_i\rvert}\log\frac{\pi_\phi(y_{i,t}\mid x,y_{i,\lt t})}{\pi_{\phi_{\mathrm{old}}}(y_{i,t}\mid x,y_{i,\lt t})}\right). $$
采用 group-normalized advantage 的 PPO 风格目标函数:
$$ \mathcal{J}_{\mathrm{GSPO}}(\phi)=\mathbb{E}\left[\frac{1}{G}\sum_{i=1}^{G}\min\left(s_i\hat A_i,\operatorname{clip}(s_i,1-\varepsilon,1+\varepsilon)\hat A_i\right)\right]. $$
各阶段使用混合奖励:
$$ r(x,y)=\lambda_1r_{\mathrm{rule}}(x,y)+\lambda_2r_{\mathrm{judge}}(x,y), $$
其中 judge reward 由 Intern-S1-mini 提供。课程难度依照临床诊断路径递增:
1. **病灶定位(Lesion Localization)**:单图像视觉感知。
2. **多图选择(Multi-image Selection)**:跨图像比较。
3. **报告生成(Report Generation)**:结构化长文本综合。
4. **知识问答(Knowledge Q&A)**:视觉发现与临床知识整合。
| 配置 | 数值 |
|---|---|
| 组大小 / 裁剪范围 | \\(G=8\\),\\(\varepsilon=0.2\\) |
| 学习率 | \\(5\times10^{-6}\\) |
| KL 系数 | \\(\beta_{\mathrm{KL}}=0.04\\) |
| 奖励权重 | \\(\lambda_1=0.6\\),\\(\lambda_2=0.4\\) |
| 训练轮数 | 每个课程阶段 2 epochs |
### 困难样本动态回溯
最近 \\(k=5\\) 轮中持续获得低奖励的 prompt 会以 on-policy 方式重新采样:
$$ P_{\mathrm{sample}}(x,y)\propto f(x,y)^\beta, $$
其中 \\(f(x,y)\\) 表示连续失败次数,\\(\beta=2.0\\)。重采样 prompt 每次都生成新的 rollout,且其占比不超过单个 batch 的 30%。
### 训练技术栈
- **硬件**:8 块 NVIDIA GeForce RTX 4090(每块 24 GB)。
- **SFT**:使用 4 块 GPU。
- **强化学习**:6 块 GPU 用于训练,2 块 GPU 用于 vLLM rollout 生成。
- **软件**:ms-swift、DeepSpeed ZeRO-3、AdamW、vLLM 和 EvalScope。
## 模型实验
### 评测基准
| 基准 | 样本数 | 任务 / 来源数 | 用途 |
|---|---:|---:|---|
| In-Domain | 2,000 | 4 个任务 | 留出临床推理评测 |
| Fundus-MMBench | 620 | 31 个任务 | 细粒度眼底分析 |
| OmniMedVQA-Eye | 10,044 | 11 个来源 | 域外 VQA |
### 主要结果
表中指标为准确率(%)。由于不同基准的任务形式、难度和随机基线不同,跨基准平均值仅供参考,应优先进行同一基准内比较。
| 模型 | In-Domain | Fundus | Omni-Eye | 平均* |
|---|---:|---:|---:|---:|
| InternVL3.5-2B | 34.50 | 36.61 | 55.47 | 42.19 |
| InternVL3.5-4B | 36.23 | 42.10 | 77.51 | 51.95 |
| MedVLM-R1-2B | 27.80 | 20.81 | 68.06 | 38.89 |
| Lingshu-7B | **44.20** | 41.29 | 87.42 | **57.64** |
| HuatuoGPT-Vision-7B | 38.30 | 28.06 | 71.78 | 46.05 |
| FundusExpert-8B | 31.20 | **54.84** | 64.71 | 50.25 |
| OphthaReason-Intern-2B | 31.00 | 35.48 | 79.61 | 48.70 |
| OphthaReason-Qwen-3B | 36.60 | 38.87 | 86.86 | 54.11 |
| **OphVLM-R1-2B(本文)** | 38.40 | 42.58 | **88.24** | 56.41 |
OphVLM-R1 在 OmniMedVQA-Eye 和 Fundus-MMBench 上分别达到 88.24% 和 42.58%。其 56.41% 的参考平均值比 InternVL3.5-4B 高 4.46 个百分点,比 OphthaReason-Qwen-3B 高 2.30 个百分点。与 off-the-shelf 7B/8B 模型的比较同时受到训练数据暴露和参数规模差异影响,需要谨慎解读。
### 消融实验
| 配置 | In-Domain | Fundus | Omni-Eye | \\(\Delta\\) Omni |
|---|---:|---:|---:|---:|
| **OphVLM-R1(完整)** | **38.40** | **42.58** | **88.24** | — |
| 仅 SFT | 37.52 | 34.47 | 62.03 | -26.21 |
| SFT + 一次性 RL | 37.96 | 38.62 | 78.14 | -10.10 |
| SFT + 随机课程 RL | 37.73 | 37.85 | 76.48 | -11.76 |
| 移除阶段 1 | 38.14 | 40.43 | 85.62 | -2.62 |
| 移除阶段 2 | 38.02 | 40.17 | 85.13 | -3.11 |
| 移除阶段 3 | 37.88 | 39.72 | 84.38 | -3.86 |
| 移除阶段 4 | 38.07 | 40.31 | 85.47 | -2.77 |
| 使用 token-level GRPO | 37.84 | 39.76 | 84.52 | -3.72 |
| 移除困难样本回溯 | 38.11 | 40.83 | 86.12 | -2.12 |
消融结果表明,有序课程强化学习、序列级优化与困难样本回溯均带来独立贡献。所有结果均来自单次运行,未提供置信区间或显著性检验。此外,GSPO 的方差缩减理论在 per-token log-ratio 相互独立同分布时严格成立;对于自然语言 token 相关的实际情形,该结论是近似的。
## 引用
```bibtex
@inproceedings{qi2026ophvlm,
title={OphVLM-R1: Efficient Ophthalmic Reasoning via Curriculum Reinforcement Learning},
author={Qi, Zishi and Hu, Xiaoya and Pan, Huilin and Gao, Ang and Hou, Jiaxin and Li, Jiankun and Qian, Yongao},
booktitle={Proceedings of the World Artificial Intelligence Conference Academic (WAICA)},
year={2026}
}
```
## 致谢
感谢 [OpenGVLab](https://github.com/OpenGVLab/InternVL) 提供 InternVL 基础模型,并感谢参与数据审核与质量控制的眼科医生。