Master-Shi commited on
Commit
dfac9e2
·
verified ·
1 Parent(s): f2071d2

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +3 -0
  2. MedEvalKit/LLaVA-NeXT/.dockerignore +21 -0
  3. MedEvalKit/LLaVA-NeXT/.editorconfig +18 -0
  4. MedEvalKit/LLaVA-NeXT/.gitattributes +29 -0
  5. MedEvalKit/LLaVA-NeXT/.gitignore +73 -0
  6. MedEvalKit/LLaVA-NeXT/LICENSE +201 -0
  7. MedEvalKit/LLaVA-NeXT/README.md +247 -0
  8. MedEvalKit/LLaVA-NeXT/cog.yaml +37 -0
  9. MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Interleave.md +53 -0
  10. MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Video.md +81 -0
  11. MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Video_0716.md +42 -0
  12. MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT.md +93 -0
  13. MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision.md +121 -0
  14. MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision_Chat.md +157 -0
  15. MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision_Tutorials.ipynb +397 -0
  16. MedEvalKit/LLaVA-NeXT/docs/LLaVA_Video_1003.md +134 -0
  17. MedEvalKit/LLaVA-NeXT/docs/README.md +18 -0
  18. MedEvalKit/LLaVA-NeXT/docs/onevision_trial.py +111 -0
  19. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Dockerfile +76 -0
  20. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Dockerfile.legacy +72 -0
  21. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/LICENSE +201 -0
  22. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Makefile +18 -0
  23. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/README.md +33 -0
  24. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/assets/baselines.md +53 -0
  25. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/baselines/qwen2_5_vl_3b_clevr.sh +19 -0
  26. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/baselines/qwen2_5_vl_3b_geoqa8k.sh +19 -0
  27. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/config.yaml +96 -0
  28. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/caption_format.jinja +1 -0
  29. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/math_format.jinja +1 -0
  30. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/r1v_format.jinja +1 -0
  31. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/llama3.2v_critic_grpo.sh +29 -0
  32. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/mimo_vl_7b_llava_critic_grpo.sh +19 -0
  33. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/mimo_vl_rl_7b_llava_critic_grpo.sh +19 -0
  34. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/qwen2_5_vl_7b_llava_critic_grpo.sh +19 -0
  35. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/__pycache__/caption.cpython-310.pyc +0 -0
  36. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/__pycache__/math.cpython-310.pyc +0 -0
  37. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/caption.py +46 -0
  38. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/math.py +46 -0
  39. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/r1v.py +47 -0
  40. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/runtime_env.yaml +9 -0
  41. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/thinklite_vl_7b_llava_critic_grpo.sh +19 -0
  42. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/init +1 -0
  43. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/pyproject.toml +39 -0
  44. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/requirements.txt +19 -0
  45. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/scripts/model_merger.py +187 -0
  46. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/setup.py +61 -0
  47. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/PKG-INFO +262 -0
  48. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/SOURCES.txt +133 -0
  49. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/dependency_links.txt +1 -0
  50. MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/requires.txt +23 -0
.gitattributes CHANGED
@@ -65,3 +65,6 @@ benchmarks/Medical_Multimodal_Evaluation_Data/images/ADI-ELGHPIYS.tif filter=lfs
65
  benchmarks/Medical_Multimodal_Evaluation_Data/images/LYM-EMNVSPDD.tif filter=lfs diff=lfs merge=lfs -text
66
  benchmarks/Medical_Multimodal_Evaluation_Data/images/MUS-GHCNLWQY.tif filter=lfs diff=lfs merge=lfs -text
67
  benchmarks/Medical_Multimodal_Evaluation_Data/images/Prime_FULL_Prime_FULL_01-040_W36_OS_fundus_W36.tif filter=lfs diff=lfs merge=lfs -text
 
 
 
 
65
  benchmarks/Medical_Multimodal_Evaluation_Data/images/LYM-EMNVSPDD.tif filter=lfs diff=lfs merge=lfs -text
66
  benchmarks/Medical_Multimodal_Evaluation_Data/images/MUS-GHCNLWQY.tif filter=lfs diff=lfs merge=lfs -text
67
  benchmarks/Medical_Multimodal_Evaluation_Data/images/Prime_FULL_Prime_FULL_01-040_W36_OS_fundus_W36.tif filter=lfs diff=lfs merge=lfs -text
68
+ benchmarks/Medical_Multimodal_Evaluation_Data/images/LYM-GENSPYEH.tif filter=lfs diff=lfs merge=lfs -text
69
+ benchmarks/Medical_Multimodal_Evaluation_Data/images/Prime_FULL_Prime_FULL_01-014_W92_OS_fundus_W92.tif filter=lfs diff=lfs merge=lfs -text
70
+ benchmarks/Medical_Multimodal_Evaluation_Data/images/Prime_FULL_Prime_FULL_02-031_W52_OD_fundus_OD_W52.tif filter=lfs diff=lfs merge=lfs -text
MedEvalKit/LLaVA-NeXT/.dockerignore ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The .dockerignore file excludes files from the container build process.
2
+ #
3
+ # https://docs.docker.com/engine/reference/builder/#dockerignore-file
4
+
5
+ # Exclude Git files
6
+ .git
7
+ .github
8
+ .gitignore
9
+
10
+ # Exclude Python cache files
11
+ __pycache__
12
+ .mypy_cache
13
+ .pytest_cache
14
+ .ruff_cache
15
+
16
+ # Exclude Python virtual environment
17
+ /venv
18
+
19
+ # Exclude some weights
20
+ /openai
21
+ /liuhaotian
MedEvalKit/LLaVA-NeXT/.editorconfig ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ root = true
2
+
3
+ # Unix-style newlines with a newline ending every file
4
+ [*]
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ trim_trailing_whitespace = true
8
+ charset = utf-8
9
+
10
+ # 4 space indentation
11
+ [*.{py,json}]
12
+ indent_style = space
13
+ indent_size = 4
14
+
15
+ # 2 space indentation
16
+ [*.{md,sh,yaml,yml}]
17
+ indent_style = space
18
+ indent_size = 2
MedEvalKit/LLaVA-NeXT/.gitattributes ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # https://git-scm.com/docs/gitattributes
2
+
3
+ # Set the default behavior, in case people don't have core.autocrlf set.
4
+ # https://git-scm.com/docs/gitattributes#_end_of_line_conversion
5
+ * text=auto
6
+
7
+ # common python attributes, taken from https://github.com/alexkaratarakis/gitattributes/blob/710900479a2bedeec7003d381719521ffbb18bf8/Python.gitattributes
8
+ # Source files
9
+ # ============
10
+ *.pxd text diff=python
11
+ *.py text diff=python
12
+ *.py3 text diff=python
13
+ *.pyw text diff=python
14
+ *.pyx text diff=python
15
+ *.pyz text diff=python
16
+ *.pyi text diff=python
17
+
18
+ # Binary files
19
+ # ============
20
+ *.db binary
21
+ *.p binary
22
+ *.pkl binary
23
+ *.pickle binary
24
+ *.pyc binary export-ignore
25
+ *.pyo binary export-ignore
26
+ *.pyd binary
27
+
28
+ # Jupyter notebook
29
+ *.ipynb text eol=lf
MedEvalKit/LLaVA-NeXT/.gitignore ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__
3
+ *.pyc
4
+ *.egg-info
5
+ dist
6
+
7
+ # Log
8
+ *.log
9
+ *.log.*
10
+ # *.json
11
+ # *.jsonl
12
+
13
+ # Data
14
+ !**/alpaca-data-conversation.json
15
+ # Editor
16
+ .idea
17
+ *.swp
18
+ .vscode
19
+
20
+ # Other
21
+ .DS_Store
22
+ wandb
23
+ output
24
+ llavavid
25
+
26
+ checkpoints
27
+ project_checkpoints
28
+ debug_checkpoints
29
+ playground/data
30
+ playground/cc3m_llava34b_cap
31
+ ckpts*
32
+
33
+ .ipynb_checkpoints
34
+ chunyl_scripts
35
+ *.ipynb
36
+
37
+ # DevContainer
38
+ !.devcontainer/*
39
+
40
+ # Demo
41
+ serve_images/
42
+ notebooks/
43
+ logs
44
+ scripts/dist_*
45
+ logs/
46
+ submissions/
47
+ cn_scripts/
48
+ internal_project_checkpoints/
49
+ work_dirs
50
+ scripts/i18n/*
51
+ playground/.nfs028b000000010add00000001
52
+ HIP
53
+ playground/.nfs028b0000017bff2c00000012
54
+ scripts/qwen
55
+ scripts/vicuna
56
+ scripts/mistral
57
+ scripts/baseline_rep
58
+ scripts/cn_boli01_hl
59
+ scripts/cn_boli01_lf
60
+ scripts/cn_lf
61
+ scripts/cn_lq
62
+ scripts/cn_yg
63
+ scripts/cn_yg_hao
64
+ scripts/eva_encoder
65
+ scripts/i18n
66
+ scripts/i18n_higher_res
67
+ scripts/multi-images
68
+ scratchpad
69
+ build/
70
+ playground/*.json
71
+ mlx_configs/
72
+ data_processing/
73
+ # demo/
MedEvalKit/LLaVA-NeXT/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
MedEvalKit/LLaVA-NeXT/README.md ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center" width="100%">
2
+ <img src="https://i.postimg.cc/pL17YtG4/WX20240508-220230-2x.png" width="80%" height="80%">
3
+ </p>
4
+
5
+ # LLaVA-NeXT: Open Large Multimodal Models
6
+ [![Static Badge](https://img.shields.io/badge/llava_video-paper-green)](http://arxiv.org/abs/2410.02713)
7
+ [![Static Badge](https://img.shields.io/badge/llava_onevision-paper-green)](https://arxiv.org/abs/2408.03326)
8
+ [![llava_next-blog](https://img.shields.io/badge/llava_next-blog-green)](https://llava-vl.github.io/blog/)
9
+
10
+ [![llava_onevision-demo](https://img.shields.io/badge/llava_onevision-demo-red)](https://llava-onevision.lmms-lab.com/)
11
+ [![llava_next-video_demo](https://img.shields.io/badge/llava_video-demo-red)](https://huggingface.co/spaces/WildVision/vision-arena)
12
+ [![llava_next-interleave_demo](https://img.shields.io/badge/llava_next-interleave_demo-red)](https://huggingface.co/spaces/lmms-lab/LLaVA-NeXT-Interleave-Demo)
13
+ [![Openbayes Demo](https://img.shields.io/static/v1?label=Demo&message=OpenBayes%E8%B4%9D%E5%BC%8F%E8%AE%A1%E7%AE%97&color=green)](https://openbayes.com/console/public/tutorials/gW0ng9jKXfO)
14
+
15
+ [![llava_video-checkpoints](https://img.shields.io/badge/llava_video-checkpoints-blue)](https://huggingface.co/collections/lmms-lab/llava-next-video-661e86f5e8dabc3ff793c944)
16
+ [![llava_onevision-checkpoints](https://img.shields.io/badge/llava_onevision-checkpoints-blue)](https://huggingface.co/collections/lmms-lab/llava-onevision-66a259c3526e15166d6bba37)
17
+ [![llava_next-interleave_checkpoints](https://img.shields.io/badge/llava_next-interleave_checkpoints-blue)](https://huggingface.co/collections/lmms-lab/llava-next-interleave-66763c55c411b340b35873d1)
18
+ [![llava_next-image_checkpoints](https://img.shields.io/badge/llava_next-image_checkpoints-blue)](https://huggingface.co/lmms-lab)
19
+
20
+ ## Release Notes
21
+ - **[2025/08/29] 🔥 LLaVA-Critic-R1** We release LLaVA-Critic-R1, a family of generative critic VLM trained through GRPO using pairwise critic data. LLaVA-Critic-R1 not only demonstrates strong critic capability, but also achieves state-of-the-art policy performance at the 7B scale. Refer to [LLaVA-Critic-R1](llava-critic-r1/EasyR1/README.md) for more training details.
22
+
23
+ 📄 **Explore more**:
24
+ - [LLaVA-Critic-GRPO Dataset](https://huggingface.co/datasets/lmms-lab/LLaVA-Critic-GRPO-dataset): Download the dataset.
25
+ - [LLaVA-Critic-R1-7B](https://huggingface.co/lmms-lab/LLaVA-Critic-R1-7B): LLaVA-Critic-R1 trained based on Qwen-2.5-VL-7B.
26
+ - [LLaVA-Critic-R1-7B-Plus-Qwen](https://huggingface.co/lmms-lab/LLaVA-Critic-R1-7B-Plus-Qwen): LLaVA-Critic-R1+ trained based on ThinkLite-VL-7B.
27
+ - [LLaVA-Critic-R1-7B-Plus-Mimo](https://huggingface.co/lmms-lab/LLaVA-Critic-R1-7B-Plus-Mimo): LLaVA-Critic-R1+ trained based on MiMo-VL-7B-RL-2508.
28
+ - [LLaVA-Critic-R1-7B-Plus-LLaMA32v](https://huggingface.co/lmms-lab/LLaVA-Critic-R1-7B-LLaMA32v): LLaVA-Critic-R1+ trained based on Llama-3.2-11B-Vision-Instruct.
29
+ - [Paper](https://arxiv.org/abs/2509.00676): Detailed information about LLaVA-Critic-R1.
30
+
31
+
32
+ - **[2024/10/04] 🔥 LLaVA-Video** (formerly LLaVA-NeXT-Video) has undergone a major upgrade! We are excited to release **LLaVA-Video-178K**, a high-quality synthetic dataset for video instruction tuning. This dataset includes:
33
+
34
+ - 178,510 caption entries
35
+ - 960,792 open-ended Q&A pairs
36
+ - 196,198 multiple-choice Q&A items
37
+
38
+ Along with this, we’re also releasing the **LLaVA-Video 7B/72B models**, which deliver competitive performance on the latest video benchmarks, including [Video-MME](https://video-mme.github.io/home_page.html#leaderboard), [LongVideoBench](https://longvideobench.github.io/), and [Dream-1K](https://tarsier-vlm.github.io/).
39
+
40
+ 📄 **Explore more**:
41
+ - [LLaVA-Video-178K Dataset](https://huggingface.co/datasets/lmms-lab/LLaVA-Video-178K): Download the dataset.
42
+ - [LLaVA-Video Models](https://huggingface.co/collections/lmms-lab/llava-video-661e86f5e8dabc3ff793c944): Access model checkpoints.
43
+ - [Paper](http://arxiv.org/abs/2410.02713): Detailed information about LLaVA-Video.
44
+ - [LLaVA-Video Documentation](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/docs/LLaVA_Video_1003.md): Guidance on training, inference and evaluation.
45
+
46
+ - [2024/09/13] 🔥 **🚀 [LLaVA-OneVision-Chat](docs/LLaVA_OneVision_Chat.md)**. The new LLaVA-OV-Chat (7B/72B) significantly improves the chat experience of LLaVA-OV. 📄
47
+
48
+ ![](docs/ov_chat_images/chat_results.png)
49
+
50
+ - [2024/08/06] 🔥 **🚀 [LLaVA-OneVision (OV)](https://llava-vl.github.io/blog/2024-08-05-llava-onevision/)!** The new LLaVA-OV models (0.5B/7B/72B) achieve new state-of-the-art performance across single-image, multi-image, and video benchmarks, sometimes rivaling top commercial models on 47 diverse benchmarks. 📄 Explore More:
51
+ * [[Paper]](https://arxiv.org/abs/2408.03326): In-depth insights, new emegerging scenarios, ie, strong video understadning through task transfer from images.
52
+ * [[LLaVA-OV Doc]](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/docs/LLaVA_OneVision.md): Model inference and evaluation guidance.
53
+ * [[Scripts]](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/scripts/train): Start training models on your single-image/multi-image/video data.
54
+
55
+ - [2024/07/16] 🔥 **LLaVA-NeXT-Video** has been upgraded. The new 32B model achieves the best open-source performance on several video benchmarks, including [Video-MME](https://video-mme.github.io/home_page.html#leaderboard). Please refer to [this page](docs/LLaVA-NeXT-Video_0716.md) for details, refer to [llava_next-video_demo](https://huggingface.co/spaces/WildVision/vision-arena) for demo.
56
+
57
+
58
+ - [2024/06/23] 🔥 **LLaVA-NeXT-Interleave** is released. We utilize image-text interleaved format to unify multi-image, video, and 3D tasks in one LLM and achieve **SoTA** performance on a wide range of benchmarks. Check out [paper](https://arxiv.org/pdf/2407.07895), [blog](https://llava-vl.github.io/blog/2024-06-16-llava-next-interleave/), and [checkpoints](https://huggingface.co/collections/lmms-lab/llava-next-interleave-66763c55c411b340b35873d1) to see new capabilities and improved performance! We have released 0.5b, 7b, and 7b-dpo models.
59
+ * An all-round LLM for multi-image, video, and 3D with strong performance \[[demo](https://huggingface.co/spaces/lmms-lab/LLaVA-NeXT-Interleave-Demo)\]
60
+ * Construct interleave training data [**M4-Instruct**](https://huggingface.co/datasets/lmms-lab/M4-Instruct-Data)
61
+ * Construct multi-image benchmark [**LLaVA-Interleave Bench**](https://huggingface.co/datasets/lmms-lab/LLaVA-NeXT-Interleave-Bench)
62
+
63
+
64
+ - [2024/05/25] 🔥 Wondering "[What Else Influences Visual Instruction Tuning Beyond Data?](https://llava-vl.github.io/blog/2024-05-25-llava-next-ablations/)" Our new [blog](https://llava-vl.github.io/blog/2024-05-25-llava-next-ablations/) summarizes empirical explorations to ablate the various design choices in improving LMMs except instruct data itself. Meanwhile, open-source the recapioned high-quality data using LLaVA-NeXT-34B on [[COCO]](https://huggingface.co/datasets/lmms-lab/LLaVA-ReCap-118K) [[LCS]](https://huggingface.co/datasets/lmms-lab/LLaVA-ReCap-558K) [[CC3M]](https://huggingface.co/datasets/lmms-lab/LLaVA-ReCap-CC3M).
65
+ * Architectures (LMM & Vision Encoder)
66
+ * Visual Representations (Resolution & # Tokens)
67
+ * Training Strategies (High-quality data & Trainable modules)
68
+
69
+ - [2024/05/10] 🔥 **LLaVA-NeXT** (Stronger) models are released, with support of stronger LMM inlcuding LLama-3 (8B) and Qwen-1.5 (72B/110B) Check out [[blog](https://llava-vl.github.io/blog/2024-05-10-llava-next-stronger-llms/)] and [[checkpoints](https://huggingface.co/lmms-lab)] to see improved performance!
70
+ - [2024/05/10] 🔥 **LLaVA-NeXT** (Video) is released. The image-only-trained LLaVA-NeXT model is surprisingly strong on video tasks with zero-shot modality transfer. DPO training with AI feedback on videos can yield significant improvement. [[Blog](https://llava-vl.github.io/blog/2024-04-30-llava-next-video/)], [[checkpoints](https://huggingface.co/collections/lmms-lab/llava-next-video-661e86f5e8dabc3ff793c944)] and [[sglang](https://github.com/sgl-project/sglang)]
71
+ - [2024/01/30] 🔥 **LLaVA-NeXT** is out! With additional scaling to LLaVA-1.5, LLaVA-NeXT-34B outperforms Gemini Pro on some benchmarks. It can now process 4x more pixels and perform more tasks/applications than before. Check out the [blog post](https://llava-vl.github.io/blog/2024-01-30-llava-next/), and explore the [demo](https://llava.hliu.cc/)! Models are available in [Model Zoo](https://github.com/haotian-liu/LLaVA/blob/main/docs/MODEL_ZOO.md). Training/eval data and scripts coming soon.
72
+ <details>
73
+ <summary>More</summary>
74
+
75
+ - [2024/03/10] 🔥 Releasing **LMMs-Eval**, a highly efficient evaluation pipeline we used when developing LLaVA-NeXT. It supports the evaluation of LMMs on dozens of public datasets and allows new dataset onboarding, making the dev of new LMMs much faster. [[Blog](https://lmms-lab.github.io/lmms-eval-blog/lmms-eval-0.1/)] [[Codebase](https://github.com/EvolvingLMMs-Lab/lmms-eval)]
76
+
77
+ - [2023/11/10] [LLaVA-Plus](https://llava-vl.github.io/llava-plus/) is released: Learning to Use Tools for Creating Multimodal Agents, with LLaVA-Plus (LLaVA that Plug and Learn to Use Skills). [[Project Page](https://llava-vl.github.io/llava-plus/)] [[Demo](https://llavaplus.ngrok.io/)] [[Code](https://github.com/LLaVA-VL/LLaVA-Plus-Codebase)] [[Paper](https://arxiv.org/abs/2311.05437)]
78
+ - [2023/11/02] [LLaVA-Interactive](https://llava-vl.github.io/llava-interactive/) is released: Experience the future of human-AI multimodal interaction with an all-in-one demo for Image Chat, Segmentation, Generation and Editing. [[Project Page](https://llava-vl.github.io/llava-interactive/)] [[Demo](https://llavainteractive.ngrok.io/)] [[Code](https://github.com/LLaVA-VL/LLaVA-Interactive-Demo)] [[Paper](https://arxiv.org/abs/2311.00571)]
79
+ - [2023/10/26] 🔥 LLaVA-1.5 with LoRA achieves comparable performance as full-model finetuning, with a reduced GPU RAM requirement ([ckpts](https://github.com/haotian-liu/LLaVA/blob/main/docs/MODEL_ZOO.md#llava-v15), [script](https://github.com/haotian-liu/LLaVA#train)). We also provide a [doc](https://github.com/haotian-liu/LLaVA/blob/main/docs/Finetune_Custom_Data.md) on how to finetune LLaVA-1.5 on your own dataset with LoRA.
80
+ - [2023/10/12] Check out the Korean LLaVA (Ko-LLaVA), created by ETRI, who has generously supported our research! [[🤗 Demo](https://huggingface.co/spaces/etri-vilab/Ko-LLaVA)]
81
+ - [2023/10/05] 🔥 LLaVA-1.5 is out! Achieving SoTA on 11 benchmarks, with just simple modifications to the original LLaVA, utilizes all public data, completes training in ~1 day on a single 8-A100 node, and surpasses methods like Qwen-VL-Chat that use billion-scale data. Check out the [technical report](https://arxiv.org/abs/2310.03744), and explore the [demo](https://llava.hliu.cc/)! Models are available in [Model Zoo](https://github.com/haotian-liu/LLaVA/blob/main/docs/MODEL_ZOO.md). The training data and scripts of LLaVA-1.5 are released [here](https://github.com/haotian-liu/LLaVA#train), and evaluation scripts are released [here](https://github.com/haotian-liu/LLaVA/blob/main/docs/Evaluation.md)!
82
+ - [2023/09/26] LLaVA is improved with reinforcement learning from human feedback (RLHF) to improve fact grounding and reduce hallucination. Check out the new SFT and RLHF checkpoints at project [[LLavA-RLHF]](https://llava-rlhf.github.io/)
83
+ - [2023/09/22] [LLaVA](https://arxiv.org/abs/2304.08485) is accepted by NeurIPS 2023 as **oral presentation**, and [LLaVA-Med](https://arxiv.org/abs/2306.00890) is accepted by NeurIPS 2023 Datasets and Benchmarks Track as **spotlight presentation**.
84
+ - [2023/11/06] Support **Intel** dGPU and CPU platforms. [More details here.](https://github.com/haotian-liu/LLaVA/tree/intel/docs/intel)
85
+ - [2023/10/12] LLaVA is now supported in [llama.cpp](https://github.com/ggerganov/llama.cpp/pull/3436) with 4-bit / 5-bit quantization support!
86
+ - [2023/10/11] The training data and scripts of LLaVA-1.5 are released [here](https://github.com/haotian-liu/LLaVA#train), and evaluation scripts are released [here](https://github.com/haotian-liu/LLaVA/blob/main/docs/Evaluation.md)!
87
+ - [2023/10/10] [Roboflow Deep Dive](https://blog.roboflow.com/first-impressions-with-llava-1-5/): First Impressions with LLaVA-1.5.
88
+ - [2023/09/20] We summarize our empirical study of training 33B and 65B LLaVA models in a [note](https://arxiv.org/abs/2309.09958). Further, if you are interested in the comprehensive review, evolution and trend of multimodal foundation models, please check out our recent survey paper [``Multimodal Foundation Models: From Specialists to General-Purpose Assistants''.](https://arxiv.org/abs/2309.10020)
89
+ <p align="center">
90
+ <img src="https://github.com/Computer-Vision-in-the-Wild/CVinW_Readings/blob/main/images/mfm_evolution.jpeg?raw=true" width=50%/>
91
+ </p>
92
+
93
+ - [2023/07/19] 🔥 We release a major upgrade, including support for LLaMA-2, LoRA training, 4-/8-bit inference, higher resolution (336x336), and a lot more. We release [LLaVA Bench](https://github.com/haotian-liu/LLaVA/blob/main/docs/LLaVA_Bench.md) for benchmarking open-ended visual chat with results from Bard and Bing-Chat. We also support and verify training with RTX 3090 and RTX A6000. Check out [LLaVA-from-LLaMA-2](https://github.com/haotian-liu/LLaVA/blob/main/docs/LLaVA_from_LLaMA2.md), and our [model zoo](https://github.com/haotian-liu/LLaVA/blob/main/docs/MODEL_ZOO.md)!
94
+ - [2023/06/26] [CVPR 2023 Tutorial](https://vlp-tutorial.github.io/) on **Large Multimodal Models: Towards Building and Surpassing Multimodal GPT-4**! Please check out [[Slides](https://datarelease.blob.core.windows.net/tutorial/vision_foundation_models_2023/slides/Chunyuan_cvpr2023_tutorial_lmm.pdf)] [[Notes](https://arxiv.org/abs/2306.14895)] [[YouTube](https://youtu.be/mkI7EPD1vp8)] [[Bilibli](https://www.bilibili.com/video/BV1Ng4y1T7v3/)].
95
+ - [2023/06/11] We released the preview for the most requested feature: DeepSpeed and LoRA support! Please see documentations [here](./docs/LoRA.md).
96
+ - [2023/06/01] We released **LLaVA-Med: Large Language and Vision Assistant for Biomedicine**, a step towards building biomedical domain large language and vision models with GPT-4 level capabilities. Checkout the [paper](https://arxiv.org/abs/2306.00890) and [page](https://github.com/microsoft/LLaVA-Med).
97
+ - [2023/05/06] We are releasing [LLaVA-Lighting-MPT-7B-preview](https://huggingface.co/liuhaotian/LLaVA-Lightning-MPT-7B-preview), based on MPT-7B-Chat! See [here](#LLaVA-MPT-7b) for more details.
98
+ - [2023/05/02] 🔥 We are releasing LLaVA-Lighting! Train a lite, multimodal GPT-4 with just $40 in 3 hours! See [here](#train-llava-lightning) for more details.
99
+ - [2023/04/27] Thanks to the community effort, LLaVA-13B with 4-bit quantization allows you to run on a GPU with as few as 12GB VRAM! Try it out [here](https://github.com/oobabooga/text-generation-webui/tree/main/extensions/llava).
100
+ - [2023/04/17] 🔥 We released **LLaVA: Large Language and Vision Assistant**. We propose visual instruction tuning, towards building large language and vision models with GPT-4 level capabilities. Checkout the [paper](https://arxiv.org/abs/2304.08485) and [demo](https://llava.hliu.cc/).
101
+
102
+ </details>
103
+
104
+ <!-- <a href="https://llava.hliu.cc/"><img src="assets/demo.gif" width="70%"></a> -->
105
+
106
+ **Usage and License Notices**: This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses, including but not limited to the [OpenAI Terms of Use](https://openai.com/policies/terms-of-use) for the dataset and the specific licenses for base language models for checkpoints trained using the dataset (e.g. [Llama-1/2 community license](https://ai.meta.com/llama/license/) for LLaMA-2 and Vicuna-v1.5, [Tongyi Qianwen RESEARCH LICENSE AGREEMENT](https://huggingface.co/Qwen/Qwen1.5-0.5B-Chat/blob/main/LICENSE) and [Llama-3 Research License](https://llama.meta.com/llama3/license/)). This project does not impose any additional constraints beyond those stipulated in the original licenses. Furthermore, users are reminded to ensure that their use of the dataset and checkpoints is in compliance with all applicable laws and regulations.
107
+
108
+ ## Models & Scripts
109
+
110
+ ### Installation
111
+
112
+ #### 1. **Clone this repository and navigate to the LLaVA folder:**
113
+ ```bash
114
+ git clone https://github.com/LLaVA-VL/LLaVA-NeXT
115
+ cd LLaVA-NeXT
116
+ ```
117
+
118
+ #### 2. **Install the inference package:**
119
+ ```bash
120
+ conda create -n llava python=3.10 -y
121
+ conda activate llava
122
+ pip install --upgrade pip # Enable PEP 660 support.
123
+ pip install -e ".[train]"
124
+ ```
125
+
126
+ ### Project Navigation
127
+ Please checkout the following page for more inference & evaluation details.
128
+
129
+ #### - **LLaVA-OneVision: Easy Task Transfer**
130
+ - [LLaVA-OneVision](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/docs/LLaVA_OneVision.md): for demo inference. The evaluation code is in [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval).
131
+
132
+ #### - **LLaVA-NeXT: Stronger LLMs Supercharge Multimodal Capabilities in the Wild**
133
+ - [LLaVA-NeXT-Image](./docs/LLaVA-NeXT.md): for image demo inference and evaluation of stronger LMMs using [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval).
134
+
135
+
136
+ #### - LLaVA-NeXT: A Strong Zero-shot Video Understanding Model
137
+ - [LLaVA-NeXT-Video](./docs/LLaVA-NeXT-Video.md): for video inference and evaluation scripts. We recommend to use [LMMs-video](https://lmms-lab.github.io/posts/lmms-eval-0.2/) for evaluation.
138
+
139
+ #### - LLaVA-NeXT: Tackling Multi-image, Video, and 3D in Large Multimodal Models
140
+ - [LLaVA-NeXT-Interleave](./docs/LLaVA-NeXT-Interleave.md): for multi-image demo and evaluation scripts.
141
+
142
+ ## SGLang for SpeedUp Inference and Deployment
143
+
144
+ We use [SGLang](https://github.com/sgl-project/sglang) to speed up inference and deployment of LLaVA-NeXT. You could make LLaVA-NeXT as a backend API service with SGLang.
145
+
146
+ **Prepare Environment**:
147
+ Following the instruction in the [sglang](https://github.com/sgl-project/sglang?tab=readme-ov-file#install)
148
+
149
+ ### LLaVA-NeXT/OneVision
150
+
151
+ Checkout the HTTP Post/Get and SRT usage at [sglang/examples/runtime/llava_onevision](https://github.com/sgl-project/sglang/tree/main/examples/runtime/llava_onevision)
152
+
153
+ ### LLaVA-NeXT (Video)
154
+
155
+ **Launch and Run on (K) Nodes**:
156
+ - Go to sglang project
157
+ ```
158
+ cd PATH_TO/sglang
159
+ ```
160
+ - First node:
161
+ ```sh
162
+ bash examples/usage/llava_video/srt_example_llava_v.sh K 0 YOUR_VIDEO_PATH YOUR_MODEL_PATH FRAMES_PER_VIDEO
163
+ (e.g. bash examples/usage/llava_video/srt_example_llava_v.sh K 0 examples/usage/llava_video/videos/Q98Z4OTh8RwmDonc.mp4 lmms-lab/LLaVA-NeXT-Video-7B-DPO 16)
164
+ ```
165
+ - Second node:
166
+ ```sh
167
+ bash examples/usage/llava_video/srt_example_llava_v.sh K 1 YOUR_VIDEO_PATH YOUR_MODEL_PATH FRAMES_PER_VIDEO
168
+ ```
169
+ - The K node:
170
+ ```sh
171
+ bash examples/usage/llava_video/srt_example_llava_v.sh K K-1 YOUR_VIDEO_PATH YOUR_MODEL_PATH FRAMES_PER_VIDEO
172
+ ```
173
+
174
+
175
+ ## Citation
176
+
177
+ If you find it useful for your research and applications, please cite related papers/blogs using this BibTeX:
178
+ ```bibtex
179
+ @article{li2024llava,
180
+ title={LLaVA-NeXT-Interleave: Tackling Multi-image, Video, and 3D in Large Multimodal Models},
181
+ author={Li, Feng and Zhang, Renrui and Zhang, Hao and Zhang, Yuanhan and Li, Bo and Li, Wei and Ma, Zejun and Li, Chunyuan},
182
+ journal={arXiv preprint arXiv:2407.07895},
183
+ year={2024}
184
+ }
185
+
186
+ @misc{li2024llavanext-ablations,
187
+ title={LLaVA-NeXT: What Else Influences Visual Instruction Tuning Beyond Data?},
188
+ url={https://llava-vl.github.io/blog/2024-05-25-llava-next-ablations/},
189
+ author={Li, Bo and Zhang, Hao and Zhang, Kaichen and Guo, Dong and Zhang, Yuanhan and Zhang, Renrui and Li, Feng and Liu, Ziwei and Li, Chunyuan},
190
+ month={May},
191
+ year={2024}
192
+ }
193
+
194
+ @misc{li2024llavanext-strong,
195
+ title={LLaVA-NeXT: Stronger LLMs Supercharge Multimodal Capabilities in the Wild},
196
+ url={https://llava-vl.github.io/blog/2024-05-10-llava-next-stronger-llms/},
197
+ author={Li, Bo and Zhang, Kaichen and Zhang, Hao and Guo, Dong and Zhang, Renrui and Li, Feng and Zhang, Yuanhan and Liu, Ziwei and Li, Chunyuan},
198
+ month={May},
199
+ year={2024}
200
+ }
201
+
202
+ @misc{zhang2024llavanext-video,
203
+ title={LLaVA-NeXT: A Strong Zero-shot Video Understanding Model},
204
+ url={https://llava-vl.github.io/blog/2024-04-30-llava-next-video/},
205
+ author={Zhang, Yuanhan and Li, Bo and Liu, haotian and Lee, Yong jae and Gui, Liangke and Fu, Di and Feng, Jiashi and Liu, Ziwei and Li, Chunyuan},
206
+ month={April},
207
+ year={2024}
208
+ }
209
+
210
+ @misc{liu2024llavanext,
211
+ title={LLaVA-NeXT: Improved reasoning, OCR, and world knowledge},
212
+ url={https://llava-vl.github.io/blog/2024-01-30-llava-next/},
213
+ author={Liu, Haotian and Li, Chunyuan and Li, Yuheng and Li, Bo and Zhang, Yuanhan and Shen, Sheng and Lee, Yong Jae},
214
+ month={January},
215
+ year={2024}
216
+ }
217
+
218
+ @misc{liu2023improvedllava,
219
+ title={Improved Baselines with Visual Instruction Tuning},
220
+ author={Liu, Haotian and Li, Chunyuan and Li, Yuheng and Lee, Yong Jae},
221
+ publisher={arXiv:2310.03744},
222
+ year={2023},
223
+ }
224
+
225
+ @misc{liu2023llava,
226
+ title={Visual Instruction Tuning},
227
+ author={Liu, Haotian and Li, Chunyuan and Wu, Qingyang and Lee, Yong Jae},
228
+ publisher={NeurIPS},
229
+ year={2023},
230
+ }
231
+ ```
232
+
233
+ ## Acknowledgement
234
+
235
+ - [Vicuna](https://github.com/lm-sys/FastChat): the codebase we built upon, and our base model Vicuna-13B that has the amazing language capabilities!
236
+ - The LLaVA-NeXT project is currently maintained by the team along with our contributors (listed alphabetically by the first names): [Bo Li](https://brianboli.com/), [Dong Guo](https://www.linkedin.com/in/dongguoset/), [Feng Li](https://scholar.google.com/citations?hl=zh-CN&user=ybRe9GcAAAAJ&view_op=list_works&sortby=pubdate), [Hao Zhang](https://scholar.google.com/citations?user=B8hPxMQAAAAJ&hl=en), [Kaichen Zhang](https://www.linkedin.com/in/kaichen-zhang-014b17219/?originalSubdomain=sg), [Renrui Zhang](https://zrrskywalker.github.io/), [Yuanhan Zhang](https://zhangyuanhan-ai.github.io/), led by [Chunyuan Li](https://chunyuan.li/) and with the guidance and help from [Haotian Liu](https://hliu.cc/).
237
+ - The `lmms-eval` framework and its core contributors, including Peiyuan Zhang, Fanyi Pu, Joshua Adrian Cahyono, and Kairui Hu, for their support on the evaluation side.
238
+
239
+ ## Related Projects
240
+
241
+ - [Instruction Tuning with GPT-4](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM)
242
+ - [LLaVA-Med: Training a Large Language-and-Vision Assistant for Biomedicine in One Day](https://github.com/microsoft/LLaVA-Med)
243
+ - [Otter: In-Context Multi-Modal Instruction Tuning](https://github.com/Luodian/Otter)
244
+
245
+ For future project ideas, please check out:
246
+ - [SEEM: Segment Everything Everywhere All at Once](https://github.com/UX-Decoder/Segment-Everything-Everywhere-All-At-Once)
247
+ - [Grounded-Segment-Anything](https://github.com/IDEA-Research/Grounded-Segment-Anything) to detect, segment, and generate anything by marrying [Grounding DINO](https://github.com/IDEA-Research/GroundingDINO) and [Segment-Anything](https://github.com/facebookresearch/segment-anything).
MedEvalKit/LLaVA-NeXT/cog.yaml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Configuration for Cog ⚙️
2
+ # Reference: https://github.com/replicate/cog/blob/main/docs/yaml.md
3
+
4
+ build:
5
+ gpu: true
6
+
7
+ python_version: "3.11"
8
+
9
+ python_packages:
10
+ - "torch==2.0.1"
11
+ - "accelerate==0.21.0"
12
+ - "bitsandbytes==0.41.0"
13
+ - "deepspeed==0.9.5"
14
+ - "einops-exts==0.0.4"
15
+ - "einops==0.6.1"
16
+ - "gradio==3.35.2"
17
+ - "gradio_client==0.2.9"
18
+ - "httpx==0.24.0"
19
+ - "markdown2==2.4.10"
20
+ - "numpy==1.26.0"
21
+ - "peft==0.4.0"
22
+ - "scikit-learn==1.2.2"
23
+ - "sentencepiece==0.1.99"
24
+ - "shortuuid==1.0.11"
25
+ - "timm==0.6.13"
26
+ - "tokenizers==0.13.3"
27
+ - "torch==2.0.1"
28
+ - "torchvision==0.15.2"
29
+ - "transformers==4.31.0"
30
+ - "wandb==0.15.12"
31
+ - "wavedrom==2.0.3.post3"
32
+ - "Pygments==2.16.1"
33
+ run:
34
+ - curl -o /usr/local/bin/pget -L "https://github.com/replicate/pget/releases/download/v0.0.3/pget" && chmod +x /usr/local/bin/pget
35
+
36
+ # predict.py defines how predictions are run on your model
37
+ predict: "predict.py:Predictor"
MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Interleave.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # LLaVA-NeXT: Tackling Multi-image, Video, and 3D in Large Multimodal Models
3
+
4
+ ## Contents
5
+ - [Demo](#demo)
6
+ - [Evaluation](#evaluation)
7
+
8
+ ## Demo
9
+
10
+ > make sure you installed the LLaVA-NeXT model files via outside REAME.md
11
+
12
+ 1. **Example model:** `lmms-lab/llava-next-interleave-7b`
13
+
14
+
15
+ To run a demo, execute:
16
+ ```bash
17
+ # If you find any bug when running the demo, please make sure checkpoint path contains 'qwen'.
18
+ # You can try command like 'mv llava-next-interleave-7b llava-next-interleave-qwen-7b'
19
+ python playground/demo/interleave_demo.py --model_path path/to/ckpt
20
+ ```
21
+
22
+ ## Evaluation
23
+
24
+ ### Preparation
25
+
26
+ Please download the evaluation data and its metadata from the following links:
27
+
28
+ 1. **llava-interleave-bench:** [here](https://huggingface.co/datasets/lmms-lab/llava-interleave-bench).
29
+
30
+ Unzip eval_images.zip and there are Split1 and Split2 in it.
31
+ Organize the downloaded data into the following structure:
32
+ ```
33
+
34
+ interleave_data
35
+ ├── Split1
36
+ │ ├── ...
37
+ │ └── ...
38
+ |
39
+ ├── Split2
40
+ | ├── ...
41
+ │ └── ...
42
+ ├── multi_image_in_domain.json
43
+ ├── multi_image_out_domain.json
44
+ └── multi_view_in_domain.json
45
+ ```
46
+
47
+ ### Inference and Evaluation
48
+ Example:
49
+ Please first edit /path/to/ckpt to the path of checkpoint, /path/to/images to the path of "interleave_data" in scripts/interleave/eval_all.sh and then run
50
+ ```bash
51
+ bash scripts/interleave/eval_all.sh
52
+ ```
53
+
MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Video.md ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # LLaVA-NeXT: A Strong Zero-shot Video Understanding Model
3
+
4
+ ## Contents
5
+ - [Demo](#demo)
6
+ - [Evaluation](#evaluation)
7
+
8
+ ## Demo
9
+
10
+ > make sure you installed the LLaVA-NeXT model files via outside REAME.md
11
+
12
+ 1. **Example model:** `lmms-lab/LLaVA-NeXT-Video-7B-DPO`
13
+
14
+ 2. **Prompt mode:** `vicuna_v1` (use `mistral_direct` for `lmms-lab/LLaVA-NeXT-Video-34B-DPO`)
15
+
16
+ 3. **Sampled frames:** `32` (Defines how many frames to sample from the video.)
17
+
18
+ 4. **Spatial pooling stride:** `2` (With original tokens for one frame at 24x24, if stride=2, then the tokens for one frame are 12x12.)
19
+
20
+ 5. **Spatial pooling mode:** `average` (Options: `average`, `max`.)
21
+
22
+ 6. **Local video path:** `./data/llava_video/video-chatgpt/evaluation/Test_Videos/v_Lf_7RurLgp0.mp4`
23
+
24
+ To run a demo, execute:
25
+ ```bash
26
+ bash scripts/video/demo/video_demo.sh ${Example model} ${Prompt mode} ${Sampled frames} ${Spatial pooling stride} ${Spatial pooling mode} grid True ${Video path at local}
27
+ ```
28
+ Example:
29
+ ```bash
30
+ bash scripts/video/demo/video_demo.sh lmms-lab/LLaVA-NeXT-Video-7B-DPO vicuna_v1 32 2 average no_token True playground/demo/xU25MMA2N4aVtYay.mp4
31
+ ```
32
+
33
+ **IMPORTANT** Please refer to [Latest video model](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/inference/docs/LLaVA-NeXT-Video_0716.md) for the runnning of the latest model.
34
+
35
+ ## Evaluation
36
+
37
+ ### Preparation
38
+
39
+ Please download the evaluation data and its metadata from the following links:
40
+
41
+ 1. **video-chatgpt:** [here](https://github.com/mbzuai-oryx/Video-ChatGPT/blob/main/quantitative_evaluation/README.md#video-based-generative-performance-benchmarking).
42
+ 2. **video_detail_description:** [here](https://mbzuaiac-my.sharepoint.com/personal/hanoona_bangalath_mbzuai_ac_ae/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fhanoona%5Fbangalath%5Fmbzuai%5Fac%5Fae%2FDocuments%2FVideo%2DChatGPT%2FData%5FCode%5FModel%5FRelease%2FQuantitative%5FEvaluation%2Fbenchamarking%2FTest%5FHuman%5FAnnotated%5FCaptions%2Ezip&parent=%2Fpersonal%2Fhanoona%5Fbangalath%5Fmbzuai%5Fac%5Fae%2FDocuments%2FVideo%2DChatGPT%2FData%5FCode%5FModel%5FRelease%2FQuantitative%5FEvaluation%2Fbenchamarking&ga=1).
43
+ 3. **activity_qa:** [here](https://mbzuaiac-my.sharepoint.com/personal/hanoona_bangalath_mbzuai_ac_ae/_layouts/15/onedrive.aspx?id=%2Fpersonal%2Fhanoona%5Fbangalath%5Fmbzuai%5Fac%5Fae%2FDocuments%2FVideo%2DChatGPT%2FData%5FCode%5FModel%5FRelease%2FData%2FActivityNet%5FTest%2D1%2D3%5Fvideos%2Ezip&parent=%2Fpersonal%2Fhanoona%5Fbangalath%5Fmbzuai%5Fac%5Fae%2FDocuments%2FVideo%2DChatGPT%2FData%5FCode%5FModel%5FRelease%2FData&ga=1) and [here](https://github.com/MILVLG/activitynet-qa/tree/master/dataset).
44
+
45
+ Organize the downloaded data into the following structure:
46
+ ```
47
+ LLaVA-NeXT
48
+ ├── llava
49
+ ├── scripts
50
+ └── data
51
+ └── llava_video
52
+ ├── video-chatgpt
53
+ │ ├── Test_Videos
54
+ │ ├── consistency_qa.json
55
+ │ ├── consistency_qa_test.json
56
+ │ ├── consistency_qa_train.json
57
+ ├── video_detail_description
58
+ │ └── Test_Human_Annotated_Captions
59
+ └── ActivityNet-QA
60
+ ├── all_test
61
+ ├── test_a.json
62
+ └── test_b.json
63
+ ```
64
+
65
+ ### Inference and Evaluation
66
+
67
+ Example for video detail description evaluation (additional scripts are available in `scripts/eval`):
68
+ ```bash
69
+ bash scripts/video/eval/video_detail_description_eval_shard.sh ${Example model} ${Prompt mode} ${Sampled frames} ${Spatial pooling stride} True 8
70
+ ```
71
+ Example:
72
+ ```bash
73
+ bash scripts/eval/video_detail_description_eval_shard.sh liuhaotian/llava-v1.6-vicuna-7b vicuna_v1 32 2 True 8
74
+ ```
75
+
76
+ ### GPT Evaluation Example (Optional if the above step is completed)
77
+
78
+ Assuming you have `pred.json` (model-generated predictions) for model `llava-v1.6-vicuna-7b` at `./work_dirs/eval_video_detail_description/llava-v1.6-vicuna-7b_vicuna_v1_frames_32_stride_2`:
79
+ ```bash
80
+ bash scripts/video/eval/video_description_eval_only.sh llava-v1.6-vicuna-7b_vicuna_v1_frames_32_stride_2
81
+ ```
MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT-Video_0716.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## LLaVA-NeXT-Video is upgraded 🚀
2
+
3
+ In our [LLaVA-Video blog](https://llava-vl.github.io/blog/2024-04-30-llava-next-video/) released this April, we shared two key observations:
4
+ - 🎬 AnyRes provides a shared and flexible representation between images and videos, and thus accommodates capability transfer between the two most common vision signals. Therefore, stronger image LMMs can naturally lead to stronger zero-shot video LMMs.
5
+ - 🗂️ There is a lack of high-quality language-video data, including video instruction-following data, and thus naive tuning on existing public data at that time results in performance degradation. Therefore, there is an urgent need to build high-quality video captions and QA datasets to train LMMs for improved video performance.
6
+
7
+ Based on the insights, the new LLaVA-NeXT-Video in this release improves from two aspects:
8
+
9
+ - 🎬 A stronger image LMMs ([LLaVA-NeXT-32B-Qwen](https://huggingface.co/lmms-lab/llava-next-qwen-32b)), which is built by initializing from Qwen-1.5 32B LLM. We further initialize our video training from this image checkpoint.
10
+ - 🗂️ A new high-quality video dataset with 830k samples. It is combined with LLaVA-1.6 image training data, and applying the same image-video mixed training procedure leads to the new video model.
11
+ The new model achieves the best open-source performance in several video benchmarks including [Video-MME](https://video-mme.github.io/home_page.html#leaderboard).
12
+
13
+ ### Resources
14
+ - **Model Card**: [LLaVA-NeXT-Video-32B-Qwen on Hugging Face](https://huggingface.co/lmms-lab/LLaVA-NeXT-Video-32B-Qwen)
15
+ - **Inference Script**:
16
+ ```bash
17
+ bash scripts/video/demo/video_demo.sh lmms-lab/LLaVA-NeXT-Video-32B-Qwen qwen_1_5 32 2 average grid True playground/demo/xU25MMA2N4aVtYay.mp4
18
+ ```
19
+
20
+ ### Evaluation Results
21
+ | Model | NextQA-MC | video-mme(overall) | | Egochema | Perception Test (val) |
22
+ |-----------------------------|-----------|--------------------|--------|----------|------------------------|
23
+ | | | w/o subs | w subs | | |
24
+ | **Proprietary** | | | | | |
25
+ | GPT-4o | - | 71.9 | 77.2 | 72.2 | - |
26
+ | Gemini 1.5 Pro | - | 75.0 | 81.3 | 72.2 | - |
27
+ | **Open-Source** | | | | | |
28
+ | VideoLLaMA 2 (8x7B) | 76.3* | 47.9 | 50.3 | 53.3 | 51.2* |
29
+ | VILA-1.5-34B | 67.89* | 60.1 | 61.1 | 58.04* | 54 |
30
+ | LLaVA-NeXT-Video (Qwen-32B) | 77.31 | 60.2 | 63.0 | 60.85 | 59.38 |
31
+
32
+ _*Results are reproduced by [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval). Please refer to the lmms-eval to reproduce the results._
33
+
34
+ ### Citations
35
+ ```bibtex
36
+ @misc{zhang2024llavanextvideo,
37
+ title={LLaVA-NeXT: A Strong Zero-shot Video Understanding Model},
38
+ url={https://llava-vl.github.io/blog/2024-04-30-llava-next-video/},
39
+ author={Zhang, Yuanhan and Li, Bo and Liu, haotian and Lee, Yong jae and Gui, Liangke and Fu, Di and Feng, Jiashi and Liu, Ziwei and Li, Chunyuan},
40
+ month={April},
41
+ year={2024}
42
+ }
MedEvalKit/LLaVA-NeXT/docs/LLaVA-NeXT.md ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLaVA-NeXT: Stronger LLMs Supercharge Multimodal Capabilities in the Wild
2
+
3
+ ## Quick Start With HuggingFace
4
+ First please install our repo with code and environments: `pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git`
5
+
6
+ Here is a quick inference code using [`llavanext-llama3-8B`](https://huggingface.co/lmms-lab/llama3-llava-next-8b) as an example. You will need to install [`flash-attn`](https://github.com/Dao-AILab/flash-attention) to use this code snippet. If you don't want to install it, you can set `attn_implementation=None` when load_pretrained_model
7
+ ```python
8
+ from llava.model.builder import load_pretrained_model
9
+ from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
10
+ from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
11
+ from llava.conversation import conv_templates, SeparatorStyle
12
+
13
+ from PIL import Image
14
+ import requests
15
+ import copy
16
+ import torch
17
+
18
+ pretrained = "lmms-lab/llama3-llava-next-8b"
19
+ model_name = "llava_llama3"
20
+ device = "cuda"
21
+ device_map = "auto"
22
+ tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map) # Add any other thing you want to pass in llava_model_args
23
+
24
+ model.eval()
25
+ model.tie_weights()
26
+
27
+ url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
28
+ image = Image.open(requests.get(url, stream=True).raw)
29
+ image_tensor = process_images([image], image_processor, model.config)
30
+ image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
31
+
32
+ conv_template = "llava_llama_3" # Make sure you use correct chat template for different models
33
+ question = DEFAULT_IMAGE_TOKEN + "\nWhat is shown in this image?"
34
+ conv = copy.deepcopy(conv_templates[conv_template])
35
+ conv.append_message(conv.roles[0], question)
36
+ conv.append_message(conv.roles[1], None)
37
+ prompt_question = conv.get_prompt()
38
+
39
+ input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
40
+ image_sizes = [image.size]
41
+
42
+
43
+ cont = model.generate(
44
+ input_ids,
45
+ images=image_tensor,
46
+ image_sizes=image_sizes,
47
+ do_sample=False,
48
+ temperature=0,
49
+ max_new_tokens=256,
50
+ # Modalities should be the same size as the batch size
51
+ modalities=["image"]*input_ids.shape[0]
52
+ )
53
+ text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)
54
+ print(text_outputs)
55
+ # The image shows a radar chart, also known as a spider chart or a web chart, which is a type of graph used to display multivariate data in the form of a two-dimensional chart of three or more quantitative variables represented on axes starting from the same point. Each axis represents a different variable, and the values are plotted along each axis and connected to form a polygon.\n\nIn this particular radar chart, there are several axes labeled with different variables, such as "MM-Vet," "LLaVA-Bench," "SEED-Bench," "MMBench-CN," "MMBench," "TextVQA," "VizWiz," "GQA," "BLIP-2," "InstructBLIP," "Owen-VL-Chat," and "LLaVA-1.5." These labels suggest that the chart is comparing the performance of different models or systems across various benchmarks or tasks, such as machine translation, visual question answering, and text-based question answering.\n\nThe chart is color-coded, with each color representing a different model or system. The points on the chart are connected to form a polygon, which shows the relative performance of each model across the different benchmarks. The closer the point is to the outer edge of the
56
+ ```
57
+
58
+ ## Evaluation
59
+
60
+ **Install the evaluation package:**
61
+ ```bash
62
+ # make sure you installed the LLaVA-NeXT model files via outside REAME.md
63
+ pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
64
+ ```
65
+
66
+ ### Check the evaluation results with [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval)
67
+ Our models' evaluation results can be fully reproduced by using the [`lmms-eval`](https://github.com/EvolvingLMMs-Lab/lmms-eval) toolkit. After you install lmms-eval and llava, you can run the evaluation using the following commands. To run following commands, you will have to install [`flash-attn`](https://github.com/Dao-AILab/flash-attention). If you do not want to install it, you can disable the flash-attn by specifying it in `--model_args pretrained=lmms-lab/llama3-llava-next-8b,conv_template=llava_llama_3,attn_implementation=None`.
68
+
69
+ Please note that different torch versions might causing the results to vary.
70
+
71
+ ```shell
72
+ # Evaluating Llama-3-LLaVA-NeXT-8B on multiple datasets
73
+ accelerate launch --num_processes=8 \
74
+ -m lmms_eval \
75
+ --model llava \
76
+ --model_args pretrained=lmms-lab/llama3-llava-next-8b,conv_template=llava_llama_3 \
77
+ --tasks ai2d,chartqa,docvqa_val,mme,mmbench_en_dev \
78
+ --batch_size 1 \
79
+ --log_samples \
80
+ --log_samples_suffix llava_next \
81
+ --output_path ./logs/
82
+
83
+ # Evaluating LLaVA-NeXT-72B on multiple datasets
84
+ accelerate launch --num_processes=1 \
85
+ -m lmms_eval \
86
+ --model llava \
87
+ --model_args pretrained=lmms-lab/llava-next-72b,conv_template=qwen_1_5,model_name=llava_qwen,device_map=auto \
88
+ --tasks ai2d,chartqa,docvqa_val,mme,mmbench_en_dev \
89
+ --batch_size 1 \
90
+ --log_samples \
91
+ --log_samples_suffix llava_next \
92
+ --output_path ./logs/
93
+ ```
MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision.md ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLaVA OneVision
2
+
3
+ ## Model Details
4
+
5
+ LLaVA OneVision is a multi-modal model capable of processing images, text, image-text interleaved inputs, and videos. The model is trained in multiple stages:
6
+
7
+ 1. Stage-1: Initial training on 558K samples from the LCS dataset.
8
+ 2. Stage-1.5: Training on 4M high-quality samples with detailed captions, OCR and knowledge data.
9
+ 3. Stage-2:
10
+ - Single-Image: Training on 3.2M instruction-following image samples.
11
+ - OneVision: Training on 1.6M single-image, multi-image and video samples with instructions.
12
+
13
+ Key features:
14
+ - Supports various input resolutions up to 2304 * 2304 pixels.
15
+ - Single image input is represented by 729 * (9+1) tokens at most under `anyres_max_9` mode.
16
+ - Supports multi-image and video inputs. Multi-image input is represented by 729 token for each image, and video input is represented by 196 token for each frame.
17
+ - Available in three sizes: 0.5B, 7B and 72B parameter versions, fit for different memory and inference latency requirements.
18
+
19
+ Some Implementation Details:
20
+ - Trained using a combination of vision-specific (AdamW, 2e-6) and language model (AdamW, 1e-5) learning rates.
21
+ - Each stage is trained for 1 epoch.
22
+
23
+ The model uses [SO400M](https://huggingface.co/collections/google/siglip-659d5e62f0ae1a57ae0e83ba) as the vision encoder and [Qwen-2.0](https://huggingface.co/docs/transformers/model_doc/qwen2) as the language model, with trainable components including a projector and the full model in later stages.
24
+
25
+ We recommend to use the scripts in [training](../scripts/) to get the details of the training process.
26
+
27
+ ## Inference Guidance
28
+
29
+ We recommend to follow the [tutorial](./LLaVA_OneVision_Tutorials.ipynb) to get started on using our most basic 0.5B model for image, text, image-text interleaved, and video input. We use our 0.5B version as an example. This could be running on a GPU with 4GB memory. And with the following examples, you could see it's surprisingly have promising performance on understanding the image, interleaved image-text, and video. Tiny but mighty!
30
+
31
+ ## Evaluation Guidance
32
+
33
+ We use the [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) toolkit to evaluate our models. Ensure you have installed the LLaVA-NeXT model files as per the instructions in the main README.md.
34
+
35
+ Install lmms-eval:
36
+
37
+ > pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
38
+
39
+ ### Reproducing Evaluation Results
40
+
41
+ Our models' evaluation results can be fully reproduced using the lmms-eval toolkit. After installing lmms-eval and llava, you can run the evaluation using the following commands.
42
+
43
+ Note: These commands require flash-attn. If you prefer not to install it, disable flash-attn by adding `attn_implementation=None` to the `--model_args` parameter.
44
+
45
+ Important: Different torch versions may cause slight variations in results. By default in `lmms-eval`, the requirement for torch version is set to the latest version. In `llava` repo, the torch version is set to `2.1.2`. Torch version `2.1.2` would be stable for both `llava` and `lmms-eval`
46
+
47
+ ### Evaluating LLaVA-OneVision on multiple datasets
48
+
49
+ We recommend the developers and researchers to thoroughly evaluate the models on more datasets to get a comprehensive understanding of their performance in different scenarios. So we provide a comprehensive list of datasets for evaluation, and welcome to incoporate more evaluation tasks. Please refer to the [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) for more details.
50
+
51
+
52
+ Task: single-image tasks.
53
+
54
+ ```bash
55
+ # image tasks
56
+ accelerate launch --num_processes=8 \
57
+ -m lmms_eval \
58
+ --model llava_onevision \
59
+ --model_args pretrained=lmms-lab/llava-onevision-qwen2-0.5b-si,conv_template=qwen_1_5,model_name=llava_qwen \
60
+ --tasks ai2d,chartqa,docvqa_val,infovqa_val,mme,realworldqa,mathvista_testmini,llava_in_the_wild,mmvet,mmbench_en_dev,ocrbench,mmmu,mathverse_testmini_vision_intensive,mathverse_testmini_vision_only,seedbench,scienceqa_img,mmstar \
61
+ --batch_size 1 \
62
+ --log_samples \
63
+ --log_samples_suffix llava_onevision \
64
+ --output_path ./logs/
65
+ ```
66
+
67
+ ## Data Visualization
68
+
69
+ We provide visualization scripts to analyze the training data distribution in the notebook [llava_ov_plot.ipynb](../llava_ov_plot.ipynb). The notebook includes:
70
+
71
+ - **Training Data Distribution by Category**: Visualizes data across Doc/Chart/Screen, General, Pure Language, Math/Reasoning, and General OCR categories with nested pie charts showing detailed dataset contributions.
72
+ - **Training Data Distribution by Modality**: Shows the breakdown of single-image, multi-image, and video data with percentage calculations.
73
+ - **Polar/Radar Charts**: Advanced visualizations for comparing model performance across different benchmarks.
74
+ - **Timeline Visualizations**: Tracks the evolution of model capabilities over time.
75
+
76
+ Task: video tasks. The video tasks are more computationally expensive. We recommend running them on a machine with a GPU with at least 16GB memory.
77
+
78
+ ```bash
79
+ # video tasks
80
+ accelerate launch --num_processes=8 \
81
+ -m lmms_eval \
82
+ --model llava_onevision \
83
+ --model_args pretrained=lmms-lab/llava-onevision-qwen2-0.5b-ov,conv_template=qwen_1_5,model_name=llava_qwen \
84
+ --tasks activitynetqa,videochatgpt,nextqa_mc_test,egoschema,video_dc499,videmme,videomme_w_subtitle,perceptiontest_val_mc \
85
+ --batch_size 1 \
86
+ --log_samples \
87
+ --log_samples_suffix llava_onevision \
88
+ --output_path ./logs/
89
+ ```
90
+
91
+ ## Data Visualization
92
+
93
+ We provide visualization scripts to analyze the training data distribution in the notebook [llava_ov_plot.ipynb](../playground/llava_ov_plot.ipynb). The notebook includes:
94
+
95
+ - **Training Data Distribution by Category**: Visualizes data across Doc/Chart/Screen, General, Pure Language, Math/Reasoning, and General OCR categories with nested pie charts showing detailed dataset contributions.
96
+ - **Training Data Distribution by Modality**: Shows the breakdown of single-image, multi-image, and video data with percentage calculations.
97
+ - **Polar/Radar Charts**: Advanced visualizations for comparing model performance across different benchmarks.
98
+ - **Timeline Visualizations**: Tracks the evolution of model capabilities over time.
99
+
100
+ Task: interleave tasks (`llava-interleave-bench` already contains most of existing image-text tasks). `mmmu_test` contains single image and multiple images as input, we run the model to obtain a submission file and you need to submit it to the [leaderboard](https://eval.ai/web/challenges/challenge-page/1700/overview) to get the accuracy for MMMU (multi-image) result.
101
+
102
+ ```bash
103
+ accelerate launch --num_processes=8 \
104
+ -m lmms_eval \
105
+ --model llava_onevision \
106
+ --model_args pretrained=lmms-lab/llava-onevision-qwen2-0.5b-ov,conv_template=qwen_1_5,model_name=llava_qwen \
107
+ --tasks llava-interleave-bench,muirbench,mmmu_test \
108
+ --batch_size 1 \
109
+ --log_samples \
110
+ --log_samples_suffix llava_onevision \
111
+ --output_path ./logs/
112
+ ```
113
+
114
+ ## Data Visualization
115
+
116
+ We provide visualization scripts to analyze the training data distribution in the notebook [llava_ov_plot.ipynb](../playground/llava_ov_plot.ipynb). The notebook includes:
117
+
118
+ - **Training Data Distribution by Category**: Visualizes data across Doc/Chart/Screen, General, Pure Language, Math/Reasoning, and General OCR categories with nested pie charts showing detailed dataset contributions.
119
+ - **Training Data Distribution by Modality**: Shows the breakdown of single-image, multi-image, and video data with percentage calculations.
120
+ - **Polar/Radar Charts**: Advanced visualizations for comparing model performance across different benchmarks.
121
+ - **Timeline Visualizations**: Tracks the evolution of model capabilities over time.
MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision_Chat.md ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLaVA-OneVision-Chat: Improving Chat with Preference Learning
2
+
3
+ [LLaVA-OneVision](https://arxiv.org/abs/2408.03326) has demonstrated strong multimodal capabilities, showing excellent performance on various benchmarks in single-image, multi-image and video scenarios. However, we see potential for further improvement, particularly in its visual chat abilities. To achieve this, we've focused on enhancing the model through preference alignment, and our early experiments have produced some promising insights.
4
+
5
+ ### Key Observations:
6
+
7
+ - **Impact of Preference Learning**: By incorporating alignment learning—whether through human feedback or AI-generated feedback—we've observed a notable improvement in LLaVA-OneVision's chat experience. This progress is reflected in the significant performance gains recorded on both the LLaVA-W and WildVision benchmarks.
8
+ - **Success of Self-Generated Feedback**: In LLaVA-OneVision's case, leveraging self-generated feedback data has proven to be a highly effective strategy for enhancing its visual chat capabilities. Specifically, [LLaVA-Critic](https://llava-vl.github.io/blog/2024-10-03-llava-critic/) is a utilized as a generalist evaluator to generate the scoring feedback for preference learning. This approach allows the model to refine its responses autonomously, leading to more natural and coherent conversations.
9
+
10
+ ----
11
+
12
+ ### Release
13
+
14
+ - 🤗 Model Checkpoints: [[OV-7b-Chat]](https://huggingface.co/lmms-lab/llava-onevision-qwen2-7b-ov-chat) | [[OV-72b-Chat]](https://huggingface.co/lmms-lab/llava-onevision-qwen2-72b-ov-chat)
15
+ - 💬 Demo: [https://llava-onevision.lmms-lab.com](https://llava-onevision.lmms-lab.com/)
16
+
17
+ ----
18
+
19
+
20
+ ### Results
21
+
22
+ The figure below illustrates the performance gain of LLaVA-OV-Chat across 5 benchmarks. The delta numbers shown on top of the bars indicate the improvement of the chat model variant(7b/72b) over its base model LLaVA-OV.
23
+
24
+ ![](ov_chat_images/chat_results.png)
25
+
26
+ | Model Name | WildVision | LLaVA-W | LLaVA-Wilder | LiveBench | Video Detailed Description |
27
+ |---------------------|------------|---------|--------------|-----------|----------------------------|
28
+ | LLaVA-OV-7b | 54.0 | 90.7 | 67.8 | 77.1 | 3.75 |
29
+ | LLaVA-OV-7b-Chat | 67.3 | 100.3 | 71.6 | 84.5 | 3.87 |
30
+ | LLaVA-OV-72b | 51.7 | 93.5 | 72.0 | 81.5 | 3.60 |
31
+ | LLaVA-OV-72b-Chat | 70.0 | 104.4 | 75.9 | 88.5 | 3.86 |
32
+ | GPT-4V | 79.8 | 98.0 | 81.0 | 73.7 | 4.00 |
33
+
34
+ LLaVA-OV-Chat consistently showcases exceptional visual chat capabilities across five open-ended multimodal tasks. Notably, compared to its base version, LLaVA-OV, which was trained using next-token prediction, LLaVA-OV-Chat—enhanced through alignment learning—receives significantly higher preference on four image-based tasks. The *[WildVision Bench](https://huggingface.co/datasets/WildVision/wildvision-bench)* simulates real-world multimodal interactions based on human preferences, mirroring scenarios from the online platform [WildVision-Arena (WV-Arena)](https://huggingface.co/spaces/WildVision/vision-arena). Both *[LLaVA-W](https://huggingface.co/datasets/lmms-lab/llava-bench-in-the-wild)* and *[LLaVA-Wilder](https://huggingface.co/datasets/lmms-lab/LLaVA-Bench-Wilder)* tackle daily-life visual tasks, with the former focusing on simpler cases and the latter on more challenging ones. The *[Multimodal Live-Bench](https://huggingface.co/spaces/lmms-lab/LiveBench)* leverages continuously updating news and online forums to test models' ability to generalize unobserved knowledge. Despite the alignment learning being conducted solely with images, LLaVA-OV-Chat also excels in *[Video Detailed Captioning](https://llava-vl.github.io/blog/2024-04-30-llava-next-video/)*, demonstrating that its improved chat capabilities generalize effectively from image to video contexts.
35
+
36
+ #### Examples
37
+
38
+ | Example 1 |
39
+ | -- |
40
+ | <div align="right" style="display: inline;"><img src="ov_chat_images/example1_tree.png" style="height:250px" align="right"></div><div align="left" style="display: inline"><div><b>[Question]</b>: How likely is it to snow after this picture was taken? What would change with this type of tree before it's likely to snow? </div></div> |
41
+ | **[LLaVA-OneVision]**: It is highly unlikely that it would snow immediately after this picture was taken, as the lush green leaves suggest it's either late spring or summer. Before snowfall, which typically occurs in late autumn or winter, this type of tree, likely an oak, would shed its leaves, and the branches would appear bare. |
42
+ | **[LLaVA-OneVision-Chat]**: Given the lush green leaves and the overall vibrancy of the tree in the image, it is highly unlikely that snow would follow immediately. This type of tree, which appears to be a deciduous species, typically sheds its leaves in autumn as a preparation for winter. Before it's likely to snow, the tree would undergo several changes:<br><br>1. **Color Change**: The leaves would change color from green to shades of yellow, orange, red, or brown as the chlorophyll breaks down, revealing other pigments. <br>2. **Leaf Fall**: As the days shorten and temperatures cool, the tree would gradually shed its leaves. This process is triggered by hormonal changes within the tree that cause the cells at the base of each leaf to weaken and eventually break, allowing the leaves to fall.<br>3. **Dormancy**: The tree would enter a state of dormancy, during which its metabolic processes slow down significantly. This helps the tree conserve energy and survive the cold winter months.<br>4. **Bark Changes**: The bark may become more rugged and textured as the tree ages and prepares for winter. This is a natural defense mechanism against cold temperatures and potential pests.<br>5. **Root Activity**: The roots would continue to absorb water and nutrients until the ground freezes, after which they would go dormant as well.<br>6. **Snow Preparation**: Once the tree has shed its leaves and entered dormancy, it would be better prepared to withstand snow and ice accumulation on its branches without the added weight of leaves.<br><br>In summary, the tree would need to go through the full autumn cycle of leaf color change and fall, followed by entering dormancy, before it would be likely to snow. This process can take several weeks to a few months, depending on the specific species of the tree and the local climate conditions.|
43
+
44
+ | Example 2 |
45
+ | -- |
46
+ | <div align="right" style="display: inline;"><img src="ov_chat_images/example2_dog.jpg" style="height:230px" align="right"></div><div align="left" style="display: inline"><div><b>[Question]</b>: Discuss how this creative twist on a classic work of art might be interpreted differently by various audiences. </div></div>|
47
+ | **[LLaVA-OneVision]**: Different audiences might interpret this creative twist on the Mona Lisa in various ways. Art enthusiasts might appreciate the skillful execution and the playful reinterpretation of a classic, seeing it as a commentary on the universality of beauty and expression across species. Dog lovers could find joy in seeing their favorite breed portrayed with such dignity and elegance. Some might view it as a humorous take on high art, making it more accessible and relatable. Others might see it as a statement on the anthropomorphism of pets, reflecting how we often attribute human-like qualities to animals. Overall, the varied interpretations highlight the versatility of art in engaging diverse perspectives and emotions. |
48
+ | **[LLaVA-OneVision-Chat]**: This creative twist on the Mona Lisa, featuring a dog's face, can be interpreted in various ways by different audiences. For art enthusiasts, it might be seen as a playful commentary on the nature of portraiture and the human tendency to anthropomorphize animals. It challenges traditional notions of beauty and subjectivity in art, inviting viewers to reconsider what makes a portrait compelling.<br><br>For dog lovers and pet owners, the image could evoke a sense of joy and familiarity, as they see their beloved pets reflected in one of the most iconic artworks in history. It might also highlight the deep bond between humans and their pets, suggesting that animals share in our cultural heritage.<br><br>In a broader social context, this image could be interpreted as a reflection of contemporary society's obsession with internet culture and memes. The substitution of the Mona Lisa's face with a dog's could be seen as a satirical take on how viral content often overshadows classical art in modern media.<br><br>Academically, this piece could spark discussions about copyright, artistic originality, and the public domain. It raises questions about the boundaries between homage and appropriation in art, encouraging critical thinking about intellectual property rights and creative freedom.<br><br>Overall, the diverse interpretations of this image underscore the power of art to engage, provoke, and connect people across different backgrounds and perspectives. |
49
+
50
+ ********
51
+
52
+ ### Iterative DPO for Enhanced Performance
53
+
54
+ #### Feedback Data
55
+
56
+ To optimize LLaVA-OneVision’s in-the-wild conversational abilities, we've employed an iterative Direct Preference Optimization (DPO) process. Through this method, we found that feedback from two primary sources is particularly effective:
57
+
58
+ 1. **Human Feedback from [LLaVA-RLHF](https://llava-rlhf.github.io/)**: Real-world human input plays a crucial role in guiding the model toward more intuitive and user-friendly responses.
59
+
60
+ 2. **AI Feedback from LLaVA-OV’s Self-Generated Responses**: Additionally, the AI's own self-generated feedback allows it to continuously improve and adapt, making this a valuable source for iterative learning. [LLaVA-Critic](https://llava-vl.github.io/blog/2024-10-03-llava-critic/) is a utilized as a generalist evaluator to generate the scoring feedback for preference learning
61
+
62
+ By experimenting with either of these two forms of feedback, we've been able to significantly enhance LLaVA-OneVision's conversation capabilities, bringing it closer to achieving seamless visual chat interactions in dynamic, real-world environments.
63
+
64
+ #### Alignment Learning with Iterative DPO
65
+
66
+ We provide a breakdown of the process for enhancing LLaVA-OneVision’s visual chat capabilities through iterative DPO.
67
+
68
+ ##### Requirements:
69
+
70
+ 1. **SFT Checkpoint**: We begin with a pretrained LLaVA-OneVision SFT (Supervised Fine-Tuning) model as the initial checkpoint for response generation.
71
+ 2. **Preference Data**: The dataset used in our experiments consists of (language-image prompt, response, preference) pairs sourced from human feedback or AI feedback, which serves as the training data for the model to align with user preference to improve chat experience.
72
+
73
+ ##### Step 1: Response Generation
74
+
75
+ For each langauge-image prompt in the dataset, we randomly generate `k = 5` candidate responses from the starting checkpoint. To ensure diversity in the generated responses, we employ random decoding with the following parameters: `temperature = 0.7`, `top-p (nucleus sampling) = 0.9`. These settings encourage the generation of varied responses by balancing randomness and precision, giving us a broad spectrum of potential answers for further evaluation.
76
+
77
+ ##### Step 2: Scoring and Acquiring Feedback Data
78
+
79
+ Once the candidate responses are generated, we utilize a feedback source (e.g., the reward signals from LLaVA-RLHF or reward signals from LLaVA-Critic) to score each of them. The reward model is responsible for evaluating the quality of the responses based on relevance, coherence, and appropriateness in relation to the given image-question pair. From the scored responses, we then select:
80
+
81
+ - The **best** response (highest score)
82
+ - The **worst** response (lowest score)
83
+
84
+ These two responses serve as **pairwise feedback data** for the next phase of the training process.
85
+
86
+ ##### Step 3: Training with Iterative DPO
87
+
88
+ Using the feedback data obtained in `Step 2`, we conduct DPO training in an iterative fashion. The process is as follows:
89
+
90
+ 1. In the $i^{th}$ round of training, we start with the pretrained model from the previous round $(i-1)^{th}$.
91
+ 2. We generate new candidate responses by repeating the response generation process outlined in `Step 1`.
92
+ 3. The reward source evaluates these new responses, and pairwise feedback data is acquired, as described in `Step 2`.
93
+ 4. Finally, we apply DPO training to the model using the feedback data. Each round of DPO training lasts for **`1 epoch`**.
94
+
95
+ This iterative process is repeated for `N=3` rounds in total, with each round refining the model’s ability to generate high-quality visual chat responses by progressively incorporating feedback from both human and AI assessments.
96
+
97
+ **Training script and data format**
98
+
99
+ - Example training script: [`/scripts/train/dpo_ov7b.sh`](../scripts/train/dpo_ov7b.sh)
100
+ - Format of training data:
101
+ ~~~json
102
+ {
103
+ "id": "<image-id>",
104
+ "image": "<image path under args.image_folder>",
105
+ "prompt": "<input prompt/question>",
106
+ "chosen": "<chosen model response>",
107
+ "rejected": "<rejected model response>"
108
+ }
109
+ ~~~
110
+
111
+
112
+ ------
113
+
114
+ Check out on how we develop AI feedback for self-improvement LMMs, using [LLaVA-Critic](https://llava-vl.github.io/blog/2024-10-03-llava-critic/) as a generalist evaluator to generate the scoring feedback for preference learning!
115
+
116
+ *Contributors to LLaVA-OneVision-Chat: [Tianyi Xiong](https://tyxiong23.github.io/), [Bo Li](https://brianboli.com/), [Dong Guo](https://www.linkedin.com/in/dongguoset/), [Huizhuo Yuan](https://scholar.google.com/citations?user=8foZzX4AAAAJ), [Quanquan Gu](https://web.cs.ucla.edu/~qgu/), [Chunyuan Li](https://scholar.google.com/citations?user=Zd7WmXUAAAAJ)*
117
+
118
+
119
+
120
+ ### Citation
121
+
122
+ If you find it useful for your research and applications, please cite related papers/blogs using this BibTeX:
123
+ ```bibtex
124
+ @misc{xiong2024llavaovchat,
125
+ title={LLaVA-OneVision-Chat: Improving Chat with Preference Learning},
126
+ url={https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/docs/LLaVA_OneVision_Chat.md},
127
+ author={Xiong, Tianyi and Li, Bo and Guo, Dong and Yuan, Huizhuo and Gu, Quanquan and Li, Chunyuan},
128
+ month={September},
129
+ year={2024}
130
+ }
131
+
132
+ @article{xiong2024llavacritic,
133
+ title={LLaVA-Critic: Learning to Evaluate Multimodal Models},
134
+ author={Xiong, Tianyi and Wang, Xiyao and Guo, Dong and Ye, Qinghao and Fan, Haoqi and Gu, Quanquan and Huang, Heng and Li, Chunyuan},
135
+ year={2024},
136
+ eprint={2410.02712},
137
+ archivePrefix={arXiv},
138
+ primaryClass={cs.CV},
139
+ url={https://arxiv.org/abs/2410.02712},
140
+ }
141
+
142
+ @article{li2024llavaov,
143
+ title={Llava-onevision: Easy visual task transfer},
144
+ author={Li, Bo and Zhang, Yuanhan and Guo, Dong and Zhang, Renrui and Li, Feng and Zhang, Hao and Zhang, Kaichen and Li, Yanwei and Liu, Ziwei and Li, Chunyuan},
145
+ journal={arXiv preprint arXiv:2408.03326},
146
+ year={2024}
147
+ }
148
+
149
+ @article{sun2023aligning,
150
+ title={Aligning large multimodal models with factually augmented rlhf},
151
+ author={Sun, Zhiqing and Shen, Sheng and Cao, Shengcao and Liu, Haotian and Li, Chunyuan and Shen, Yikang and Gan, Chuang and Gui, Liang-Yan and Wang, Yu-Xiong and Yang, Yiming and Keutzer, Kurt and Darrell, Trevor},
152
+ journal={arXiv preprint arXiv:2309.14525},
153
+ year={2023}
154
+ }
155
+ ```
156
+
157
+
MedEvalKit/LLaVA-NeXT/docs/LLaVA_OneVision_Tutorials.ipynb ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# (Frustratingly Easy) LLaVA OneVision Tutorial\n",
8
+ "\n",
9
+ "We know that it's always beneficial to have a unified interface for different tasks. So we are trying to unify the interface for image, text, image-text interleaved, and video input. And in this tutorial, we aim to provide the most straightforward way to use our model. \n",
10
+ "\n",
11
+ "We use our 0.5B version as an example. This could be running on a GPU with 4GB memory. And with the following examples, you could see it's surprisingly have promising performance on understanding the image, interleaved image-text, and video. Tiny but mighty!\n",
12
+ "\n",
13
+ "The same code could be used for 7B model as well.\n",
14
+ "\n",
15
+ "## Inference Guidance\n",
16
+ "\n",
17
+ "First please install our repo with code and environments: pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git\n",
18
+ "\n",
19
+ "Here is a quick inference code using [lmms-lab/qwen2-0.5b-si](https://huggingface.co/lmms-lab/llava-onevision-qwen2-0.5b-si) as an example. You will need to install `flash-attn` to use this code snippet. If you don't want to install it, you can set `attn_implementation=None` when load_pretrained_model\n",
20
+ "\n",
21
+ "### Image Input\n",
22
+ "Tackling the single image input with LLaVA OneVision is pretty straightforward."
23
+ ]
24
+ },
25
+ {
26
+ "cell_type": "code",
27
+ "execution_count": null,
28
+ "metadata": {},
29
+ "outputs": [],
30
+ "source": [
31
+ "from llava.model.builder import load_pretrained_model\n",
32
+ "from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token\n",
33
+ "from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX\n",
34
+ "from llava.conversation import conv_templates, SeparatorStyle\n",
35
+ "\n",
36
+ "from PIL import Image\n",
37
+ "import requests\n",
38
+ "import copy\n",
39
+ "import torch\n",
40
+ "\n",
41
+ "import sys\n",
42
+ "import warnings\n",
43
+ "\n",
44
+ "warnings.filterwarnings(\"ignore\")\n",
45
+ "pretrained = \"lmms-lab/llava-onevision-qwen2-0.5b-si\"\n",
46
+ "model_name = \"llava_qwen\"\n",
47
+ "device = \"cuda\"\n",
48
+ "device_map = \"auto\"\n",
49
+ "llava_model_args = {\n",
50
+ " \"multimodal\": True,\n",
51
+ " \"attn_implementation\": \"sdpa\",\n",
52
+ "}\n",
53
+ "tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map, **llava_model_args) # Add any other thing you want to pass in llava_model_args\n",
54
+ "\n",
55
+ "model.eval()\n",
56
+ "\n",
57
+ "url = \"https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true\"\n",
58
+ "image = Image.open(requests.get(url, stream=True).raw)\n",
59
+ "image_tensor = process_images([image], image_processor, model.config)\n",
60
+ "image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]\n",
61
+ "\n",
62
+ "conv_template = \"qwen_1_5\" # Make sure you use correct chat template for different models\n",
63
+ "question = DEFAULT_IMAGE_TOKEN + \"\\nWhat is shown in this image?\"\n",
64
+ "conv = copy.deepcopy(conv_templates[conv_template])\n",
65
+ "conv.append_message(conv.roles[0], question)\n",
66
+ "conv.append_message(conv.roles[1], None)\n",
67
+ "prompt_question = conv.get_prompt()\n",
68
+ "\n",
69
+ "input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors=\"pt\").unsqueeze(0).to(device)\n",
70
+ "image_sizes = [image.size]\n",
71
+ "\n",
72
+ "\n",
73
+ "cont = model.generate(\n",
74
+ " input_ids,\n",
75
+ " images=image_tensor,\n",
76
+ " image_sizes=image_sizes,\n",
77
+ " do_sample=False,\n",
78
+ " temperature=0,\n",
79
+ " max_new_tokens=4096,\n",
80
+ ")\n",
81
+ "text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)\n",
82
+ "print(text_outputs)"
83
+ ]
84
+ },
85
+ {
86
+ "cell_type": "markdown",
87
+ "metadata": {},
88
+ "source": [
89
+ "You could use the following code to make it streaming in terminal, this would be pretty useful when creating a chatbot."
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": null,
95
+ "metadata": {},
96
+ "outputs": [],
97
+ "source": [
98
+ "from threading import Thread\n",
99
+ "from transformers import TextIteratorStreamer\n",
100
+ "import json\n",
101
+ "\n",
102
+ "url = \"https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true\"\n",
103
+ "image = Image.open(requests.get(url, stream=True).raw)\n",
104
+ "image_tensor = process_images([image], image_processor, model.config)\n",
105
+ "image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]\n",
106
+ "\n",
107
+ "conv_template = \"qwen_1_5\"\n",
108
+ "question = DEFAULT_IMAGE_TOKEN + \"\\nWhat is shown in this image?\"\n",
109
+ "conv = copy.deepcopy(conv_templates[conv_template])\n",
110
+ "conv.append_message(conv.roles[0], question)\n",
111
+ "conv.append_message(conv.roles[1], None)\n",
112
+ "prompt_question = conv.get_prompt()\n",
113
+ "\n",
114
+ "input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors=\"pt\").unsqueeze(0).to(device)\n",
115
+ "image_sizes = [image.size]\n",
116
+ "\n",
117
+ "max_context_length = getattr(model.config, \"max_position_embeddings\", 2048)\n",
118
+ "num_image_tokens = question.count(DEFAULT_IMAGE_TOKEN) * model.get_vision_tower().num_patches\n",
119
+ "\n",
120
+ "streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True, timeout=15)\n",
121
+ "\n",
122
+ "max_new_tokens = min(4096, max_context_length - input_ids.shape[-1] - num_image_tokens)\n",
123
+ "\n",
124
+ "if max_new_tokens < 1:\n",
125
+ " print(\n",
126
+ " json.dumps(\n",
127
+ " {\n",
128
+ " \"text\": question + \"Exceeds max token length. Please start a new conversation, thanks.\",\n",
129
+ " \"error_code\": 0,\n",
130
+ " }\n",
131
+ " )\n",
132
+ " )\n",
133
+ "else:\n",
134
+ " gen_kwargs = {\n",
135
+ " \"do_sample\": False,\n",
136
+ " \"temperature\": 0,\n",
137
+ " \"max_new_tokens\": max_new_tokens,\n",
138
+ " \"images\": image_tensor,\n",
139
+ " \"image_sizes\": image_sizes,\n",
140
+ " }\n",
141
+ "\n",
142
+ " thread = Thread(\n",
143
+ " target=model.generate,\n",
144
+ " kwargs=dict(\n",
145
+ " inputs=input_ids,\n",
146
+ " streamer=streamer,\n",
147
+ " **gen_kwargs,\n",
148
+ " ),\n",
149
+ " )\n",
150
+ " thread.start()\n",
151
+ "\n",
152
+ " generated_text = \"\"\n",
153
+ " for new_text in streamer:\n",
154
+ " generated_text += new_text\n",
155
+ " print(generated_text, flush=True)\n",
156
+ " # print(json.dumps({\"text\": generated_text, \"error_code\": 0}), flush=True)\n",
157
+ "\n",
158
+ " print(\"Final output:\", generated_text)"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "markdown",
163
+ "metadata": {},
164
+ "source": [
165
+ "### Image-Text Interleaved Input\n",
166
+ "\n",
167
+ "Now switching to our onevision model for more complex tasks. You should start to use `llava-onevision-qwen2-0.5b-ov` for image-text interleaved input and video input.\n",
168
+ "\n",
169
+ "Processing image-text interleaved input is a bit more complicated. But following the code below should work."
170
+ ]
171
+ },
172
+ {
173
+ "cell_type": "code",
174
+ "execution_count": null,
175
+ "metadata": {},
176
+ "outputs": [],
177
+ "source": [
178
+ "# Load model\n",
179
+ "pretrained = \"lmms-lab/llava-onevision-qwen2-0.5b-ov\"\n",
180
+ "model_name = \"llava_qwen\"\n",
181
+ "device = \"cuda\"\n",
182
+ "device_map = \"auto\"\n",
183
+ "llava_model_args = {\n",
184
+ " \"multimodal\": True,\n",
185
+ " }\n",
186
+ "overwrite_config = {}\n",
187
+ "overwrite_config[\"image_aspect_ratio\"] = \"pad\"\n",
188
+ "llava_model_args[\"overwrite_config\"] = overwrite_config\n",
189
+ "tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map, **llava_model_args)\n",
190
+ "\n",
191
+ "model.eval()\n",
192
+ "\n",
193
+ "# Load two images\n",
194
+ "url1 = \"https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true\"\n",
195
+ "url2 = \"https://raw.githubusercontent.com/haotian-liu/LLaVA/main/images/llava_logo.png\"\n",
196
+ "\n",
197
+ "image1 = Image.open(requests.get(url1, stream=True).raw)\n",
198
+ "image2 = Image.open(requests.get(url2, stream=True).raw)\n",
199
+ "\n",
200
+ "images = [image1, image2]\n",
201
+ "image_tensors = process_images(images, image_processor, model.config)\n",
202
+ "image_tensors = [_image.to(dtype=torch.float16, device=device) for _image in image_tensors]\n",
203
+ "\n",
204
+ "# Prepare interleaved text-image input\n",
205
+ "conv_template = \"qwen_1_5\"\n",
206
+ "question = f\"{DEFAULT_IMAGE_TOKEN} This is the first image. Can you describe what you see?\\n\\nNow, let's look at another image: {DEFAULT_IMAGE_TOKEN}\\nWhat's the difference between these two images?\"\n",
207
+ "\n",
208
+ "conv = copy.deepcopy(conv_templates[conv_template])\n",
209
+ "conv.append_message(conv.roles[0], question)\n",
210
+ "conv.append_message(conv.roles[1], None)\n",
211
+ "prompt_question = conv.get_prompt()\n",
212
+ "\n",
213
+ "input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors=\"pt\").unsqueeze(0).to(device)\n",
214
+ "image_sizes = [image.size for image in images]\n",
215
+ "\n",
216
+ "# Generate response\n",
217
+ "cont = model.generate(\n",
218
+ " input_ids,\n",
219
+ " images=image_tensors,\n",
220
+ " image_sizes=image_sizes,\n",
221
+ " do_sample=False,\n",
222
+ " temperature=0,\n",
223
+ " max_new_tokens=4096,\n",
224
+ ")\n",
225
+ "text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)\n",
226
+ "print(text_outputs[0])"
227
+ ]
228
+ },
229
+ {
230
+ "cell_type": "markdown",
231
+ "metadata": {},
232
+ "source": [
233
+ "### Video Input\n",
234
+ "\n",
235
+ "Now let's try video input. It's the same as image input, but you need to pass in a list of video frames. And remember to set the `<image>` token only once in the prompt, e.g. \"<image>\\nWhat is shown in this video?\", not \"<image>\\n<image>\\n<image>\\nWhat is shown in this video?\". Since we trained on this format, it's important to keep the format consistent."
236
+ ]
237
+ },
238
+ {
239
+ "cell_type": "code",
240
+ "execution_count": 1,
241
+ "metadata": {},
242
+ "outputs": [
243
+ {
244
+ "name": "stderr",
245
+ "output_type": "stream",
246
+ "text": [
247
+ "/home/tiger/miniconda3/envs/public_llava/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
248
+ " from .autonotebook import tqdm as notebook_tqdm\n",
249
+ "/home/tiger/miniconda3/envs/public_llava/lib/python3.10/site-packages/huggingface_hub/file_download.py:1150: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.\n",
250
+ " warnings.warn(\n",
251
+ "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n"
252
+ ]
253
+ },
254
+ {
255
+ "name": "stdout",
256
+ "output_type": "stream",
257
+ "text": [
258
+ "Loaded LLaVA model: lmms-lab/llava-onevision-qwen2-7b-ov\n"
259
+ ]
260
+ },
261
+ {
262
+ "name": "stderr",
263
+ "output_type": "stream",
264
+ "text": [
265
+ "Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.\n",
266
+ "You are using a model of type llava to instantiate a model of type llava_qwen. This is not supported for all configurations of models and can yield errors.\n"
267
+ ]
268
+ },
269
+ {
270
+ "name": "stdout",
271
+ "output_type": "stream",
272
+ "text": [
273
+ "Loading vision tower: google/siglip-so400m-patch14-384\n"
274
+ ]
275
+ },
276
+ {
277
+ "name": "stderr",
278
+ "output_type": "stream",
279
+ "text": [
280
+ "Loading checkpoint shards: 100%|██████████| 4/4 [00:08<00:00, 2.07s/it]\n"
281
+ ]
282
+ },
283
+ {
284
+ "name": "stdout",
285
+ "output_type": "stream",
286
+ "text": [
287
+ "Model Class: LlavaQwenForCausalLM\n",
288
+ "(16, 1024, 576, 3)\n",
289
+ "The video features a person standing on a stage, dressed in a black shirt and dark pants. A large hand appears from the background, reaching towards the person's pocket. The text 'Source: Joshua AG' is displayed at the top left corner of the frames, and 'EVAN CARMICHAEL' is shown in the top right corner. The text 'Anyone know what this pocket is for?' appears as the hand continues to reach into the pocket. The person then looks down at their pocket, and the text 'I've always wondered that' appears. The hand finally pulls out a small white device labeled 'iPod Nano'. The person holds up the iPod Nano, and the text 'is the new iPod Nano' appears. The video concludes with a close-up of the person holding the iPod Nano, showing it from different angles.\n"
290
+ ]
291
+ }
292
+ ],
293
+ "source": [
294
+ "from operator import attrgetter\n",
295
+ "from llava.model.builder import load_pretrained_model\n",
296
+ "from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token\n",
297
+ "from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX\n",
298
+ "from llava.conversation import conv_templates, SeparatorStyle\n",
299
+ "\n",
300
+ "import torch\n",
301
+ "import cv2\n",
302
+ "import numpy as np\n",
303
+ "from PIL import Image\n",
304
+ "import requests\n",
305
+ "import copy\n",
306
+ "import warnings\n",
307
+ "from decord import VideoReader, cpu\n",
308
+ "\n",
309
+ "warnings.filterwarnings(\"ignore\")\n",
310
+ "# Load the OneVision model\n",
311
+ "pretrained = \"lmms-lab/llava-onevision-qwen2-7b-ov\"\n",
312
+ "model_name = \"llava_qwen\"\n",
313
+ "device = \"cuda\"\n",
314
+ "device_map = \"auto\"\n",
315
+ "llava_model_args = {\n",
316
+ " \"multimodal\": True,\n",
317
+ "}\n",
318
+ "tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map, attn_implementation=\"sdpa\", **llava_model_args)\n",
319
+ "\n",
320
+ "model.eval()\n",
321
+ "\n",
322
+ "\n",
323
+ "# Function to extract frames from video\n",
324
+ "def load_video(video_path, max_frames_num):\n",
325
+ " if type(video_path) == str:\n",
326
+ " vr = VideoReader(video_path, ctx=cpu(0))\n",
327
+ " else:\n",
328
+ " vr = VideoReader(video_path[0], ctx=cpu(0))\n",
329
+ " total_frame_num = len(vr)\n",
330
+ " uniform_sampled_frames = np.linspace(0, total_frame_num - 1, max_frames_num, dtype=int)\n",
331
+ " frame_idx = uniform_sampled_frames.tolist()\n",
332
+ " spare_frames = vr.get_batch(frame_idx).asnumpy()\n",
333
+ " return spare_frames # (frames, height, width, channels)\n",
334
+ "\n",
335
+ "\n",
336
+ "# Load and process video\n",
337
+ "video_path = \"jobs.mp4\"\n",
338
+ "video_frames = load_video(video_path, 16)\n",
339
+ "print(video_frames.shape) # (16, 1024, 576, 3)\n",
340
+ "image_tensors = []\n",
341
+ "frames = image_processor.preprocess(video_frames, return_tensors=\"pt\")[\"pixel_values\"].half().cuda()\n",
342
+ "image_tensors.append(frames)\n",
343
+ "\n",
344
+ "# Prepare conversation input\n",
345
+ "conv_template = \"qwen_1_5\"\n",
346
+ "question = f\"{DEFAULT_IMAGE_TOKEN}\\nDescribe what's happening in this video.\"\n",
347
+ "\n",
348
+ "conv = copy.deepcopy(conv_templates[conv_template])\n",
349
+ "conv.append_message(conv.roles[0], question)\n",
350
+ "conv.append_message(conv.roles[1], None)\n",
351
+ "prompt_question = conv.get_prompt()\n",
352
+ "\n",
353
+ "input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors=\"pt\").unsqueeze(0).to(device)\n",
354
+ "image_sizes = [frame.size for frame in video_frames]\n",
355
+ "\n",
356
+ "# Generate response\n",
357
+ "cont = model.generate(\n",
358
+ " input_ids,\n",
359
+ " images=image_tensors,\n",
360
+ " image_sizes=image_sizes,\n",
361
+ " do_sample=False,\n",
362
+ " temperature=0,\n",
363
+ " max_new_tokens=4096,\n",
364
+ " modalities=[\"video\"],\n",
365
+ ")\n",
366
+ "text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)\n",
367
+ "print(text_outputs[0])"
368
+ ]
369
+ }
370
+ ],
371
+ "metadata": {
372
+ "kernelspec": {
373
+ "display_name": "Python 3.9.2 64-bit",
374
+ "language": "python",
375
+ "name": "python3"
376
+ },
377
+ "language_info": {
378
+ "codemirror_mode": {
379
+ "name": "ipython",
380
+ "version": 3
381
+ },
382
+ "file_extension": ".py",
383
+ "mimetype": "text/x-python",
384
+ "name": "python",
385
+ "nbconvert_exporter": "python",
386
+ "pygments_lexer": "ipython3",
387
+ "version": "3.10.14"
388
+ },
389
+ "vscode": {
390
+ "interpreter": {
391
+ "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6"
392
+ }
393
+ }
394
+ },
395
+ "nbformat": 4,
396
+ "nbformat_minor": 2
397
+ }
MedEvalKit/LLaVA-NeXT/docs/LLaVA_Video_1003.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLaVA Video
2
+
3
+ ## Table of Contents
4
+
5
+ 1. [Model Summary](##model-summary)
6
+ 2. [Inference](##inference)
7
+ 3. [Training](##training)
8
+ 4. [Evaluation](##evaluation-guidance)
9
+ 6. [Citation](##citation)
10
+
11
+ ## Model Summary
12
+
13
+ The LLaVA-Video models are 7/72B parameter models trained on [LLaVA-Video-178K](https://huggingface.co/datasets/lmms-lab/LLaVA-Video-178K) and [LLaVA-OneVision Dataset](https://huggingface.co/datasets/lmms-lab/LLaVA-OneVision-Data), based on Qwen2 language model with a context window of 32K tokens.
14
+
15
+
16
+ ## Inference
17
+
18
+ We provide the simple generation process for using our model. For more details, you could refer to [Github](https://github.com/LLaVA-VL/LLaVA-NeXT).
19
+
20
+ ```python
21
+ # pip install git+https://github.com/LLaVA-VL/LLaVA-NeXT.git
22
+ from llava.model.builder import load_pretrained_model
23
+ from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
24
+ from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
25
+ from llava.conversation import conv_templates, SeparatorStyle
26
+ from PIL import Image
27
+ import requests
28
+ import copy
29
+ import torch
30
+ import sys
31
+ import warnings
32
+ from decord import VideoReader, cpu
33
+ import numpy as np
34
+ warnings.filterwarnings("ignore")
35
+ def load_video(self, video_path, max_frames_num,fps=1,force_sample=False):
36
+ if max_frames_num == 0:
37
+ return np.zeros((1, 336, 336, 3))
38
+ vr = VideoReader(video_path, ctx=cpu(0),num_threads=1)
39
+ total_frame_num = len(vr)
40
+ video_time = total_frame_num / vr.get_avg_fps()
41
+ fps = round(vr.get_avg_fps()/fps)
42
+ frame_idx = [i for i in range(0, len(vr), fps)]
43
+ frame_time = [i/fps for i in frame_idx]
44
+ if len(frame_idx) > max_frames_num or force_sample:
45
+ sample_fps = max_frames_num
46
+ uniform_sampled_frames = np.linspace(0, total_frame_num - 1, sample_fps, dtype=int)
47
+ frame_idx = uniform_sampled_frames.tolist()
48
+ frame_time = [i/vr.get_avg_fps() for i in frame_idx]
49
+ frame_time = ",".join([f"{i:.2f}s" for i in frame_time])
50
+ spare_frames = vr.get_batch(frame_idx).asnumpy()
51
+ # import pdb;pdb.set_trace()
52
+ return spare_frames,frame_time,video_time
53
+ pretrained = "lmms-lab/LLaVA-Video-7B-Qwen2"
54
+ model_name = "llava_qwen"
55
+ device = "cuda"
56
+ device_map = "auto"
57
+ tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, torch_dtype="bfloat16", device_map=device_map) # Add any other thing you want to pass in llava_model_args
58
+ model.eval()
59
+ video_path = "XXXX"
60
+ max_frames_num = "64"
61
+ video,frame_time,video_time = load_video(video_path, max_frames_num, 1, force_sample=True)
62
+ video = image_processor.preprocess(video, return_tensors="pt")["pixel_values"].cuda().bfloat16()
63
+ video = [video]
64
+ conv_template = "qwen_1_5" # Make sure you use correct chat template for different models
65
+ time_instruciton = f"The video lasts for {video_time:.2f} seconds, and {len(video[0])} frames are uniformly sampled from it. These frames are located at {frame_time}.Please answer the following questions related to this video."
66
+ question = DEFAULT_IMAGE_TOKEN + f"{time_instruciton}\nPlease describe this video in detail."
67
+ conv = copy.deepcopy(conv_templates[conv_template])
68
+ conv.append_message(conv.roles[0], question)
69
+ conv.append_message(conv.roles[1], None)
70
+ prompt_question = conv.get_prompt()
71
+ input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
72
+ cont = model.generate(
73
+ input_ids,
74
+ images=video,
75
+ modalities= ["video"],
76
+ do_sample=False,
77
+ temperature=0,
78
+ max_new_tokens=4096,
79
+ )
80
+ text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)[0].strip()
81
+ print(text_outputs)
82
+ ```
83
+
84
+ ## Data Preparation
85
+
86
+ 1. **Download LLaVA-OneVision**
87
+ Refer to the official instructions here: [LLaVA-OneVision Data](https://github.com/LLaVA-VL/LLaVA-NeXT/tree/main/scripts/train#about-the-llava-onevision-data). Make sure to follow the guidelines provided to obtain and organize the data correctly.
88
+
89
+ 2. **Download LLaVA-Video-178K**
90
+ The dataset is available on Hugging Face: [LLaVA-Video-178K](https://huggingface.co/datasets/lmms-lab/LLaVA-Video-178K). After downloading, place it in your desired directory.
91
+
92
+ 3. **Update `exp.yaml`**
93
+ In the [`exp.yaml` file](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/main/scripts/video/train/exp.yaml), update the file paths to point to the directories where you stored the datasets:
94
+ - **Line 186-Line 263**: Specify the path for the LLaVA-Video-178K dataset.
95
+ - For other data references, update them to point to your local LLaVA-OneVision data directory.
96
+
97
+ ## Training
98
+
99
+ [[Scripts]](https://github.com/LLaVA-VL/LLaVA-NeXT/blob/yhzhang/video_dev/scripts/video/train/SO400M_Qwen2_72B_ov_to_video_am9_aug6.sh): Start training models on your single-image/multi-image/video data.
100
+
101
+
102
+ ## Evaluation Guidance
103
+
104
+ We use the [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) toolkit to evaluate our models. Ensure you have installed the LLaVA-NeXT model files as per the instructions in the main README.md.
105
+
106
+ Install lmms-eval:
107
+
108
+ > pip install git+https://github.com/EvolvingLMMs-Lab/lmms-eval.git
109
+
110
+ ### Reproducing Evaluation Results
111
+
112
+ Our models' evaluation results can be fully reproduced using the lmms-eval toolkit. After installing lmms-eval and llava, you can run the evaluation using the following commands.
113
+
114
+ Note: These commands require flash-attn. If you prefer not to install it, disable flash-attn by adding `attn_implementation=None` to the `--model_args` parameter.
115
+
116
+ Important: Different torch versions may cause slight variations in results. By default in `lmms-eval`, the requirement for torch version is set to the latest version. In `llava` repo, the torch version is set to `2.1.2`. Torch version `2.1.2` would be stable for both `llava` and `lmms-eval`
117
+
118
+ ### Evaluating LLaVA-Video on multiple datasets
119
+
120
+ We recommend the developers and researchers to thoroughly evaluate the models on more datasets to get a comprehensive understanding of their performance in different scenarios. So we provide a comprehensive list of datasets for evaluation, and welcome to incoporate more evaluation tasks. Please refer to the [lmms-eval](https://github.com/EvolvingLMMs-Lab/lmms-eval) for more details.
121
+
122
+ ```bash
123
+ # video tasks
124
+ accelerate launch --num_processes=8 \
125
+ -m lmms_eval \
126
+ --model llava_vid \
127
+ --model_args pretrained=lmms-lab/LLaVA-Video-7B-Qwen2,conv_template=qwen_1_5,max_frames_num=64,mm_spatial_pool_mode=average \
128
+ --tasks activitynetqa,videochatgpt,nextqa_mc_test,egoschema,video_dc499,videmme,videomme_w_subtitle,perceptiontest_val_mc \
129
+ --batch_size 1 \
130
+ --log_samples \
131
+ --log_samples_suffix llava_vid \
132
+ --output_path ./logs/
133
+ ```
134
+
MedEvalKit/LLaVA-NeXT/docs/README.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLaVA-NeXT Documentation
2
+
3
+ Welcome to the LLaVA-NeXT documentation. This guide provides an overview of the different components and features of LLaVA-NeXT. Please refer to the following documents for detailed information on specific topics:
4
+
5
+ 1. [LLaVA OneVision](LLaVA_OneVision.md): Learn about the most advanced and unified version: LLaVA OneVision.
6
+ - [LLaVA OneVision: Inference Tutorials](LLaVA_OneVision_Tutorials.ipynb): Learn how to use LLaVA OneVision for inference.
7
+ - [LLaVA OneVision: Data Visualization](../llava_ov_plot.ipynb): Visualization scripts for analyzing training data distribution and model performance.
8
+ - [LLaVA Onevision Chat](LLaVA_OneVision_Chat.md): Improving Chat with Preference Learning
9
+
10
+ 2. [LLaVA-NeXT Interleave](LLaVA-NeXT-Interleave.md): Explore the interleaved training approach used in LLaVA-NeXT.
11
+
12
+ 3. [LLaVA-NeXT Video (0716)](LLaVA-NeXT-Video_0716.md): Discover the video processing capabilities of LLaVA-NeXT (version 0716).
13
+
14
+ 4. [LLaVA-NeXT Video](LLaVA-NeXT-Video.md): Get information about the latest video processing features in LLaVA-NeXT.
15
+
16
+ 5. [LLaVA-NeXT Overview](LLaVA-NeXT.md): Read a comprehensive overview of the LLaVA-NeXT project, including its architecture, features, and capabilities.
17
+
18
+ These documents provide in-depth information on various aspects of LLaVA-NeXT. Please refer to them for detailed explanations, implementation details, and usage instructions.
MedEvalKit/LLaVA-NeXT/docs/onevision_trial.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from llava.model.builder import load_pretrained_model
2
+ from llava.mm_utils import get_model_name_from_path, process_images, tokenizer_image_token
3
+ from llava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN, IGNORE_INDEX
4
+ from llava.conversation import conv_templates, SeparatorStyle
5
+
6
+ from PIL import Image
7
+ import requests
8
+ import copy
9
+ import torch
10
+
11
+ import sys
12
+ import warnings
13
+
14
+ warnings.filterwarnings("ignore")
15
+
16
+ pretrained = "lmms-lab/llava-onevision-qwen2-0.5b-si"
17
+ model_name = "llava_qwen"
18
+ device = "cuda"
19
+ device_map = "auto"
20
+ tokenizer, model, image_processor, max_length = load_pretrained_model(pretrained, None, model_name, device_map=device_map) # Add any other thing you want to pass in llava_model_args
21
+
22
+ model.eval()
23
+
24
+ url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
25
+ image = Image.open(requests.get(url, stream=True).raw)
26
+ image_tensor = process_images([image], image_processor, model.config)
27
+ image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
28
+
29
+ conv_template = "qwen_1_5" # Make sure you use correct chat template for different models
30
+ question = DEFAULT_IMAGE_TOKEN + "\nWhat is shown in this image?"
31
+ conv = copy.deepcopy(conv_templates[conv_template])
32
+ conv.append_message(conv.roles[0], question)
33
+ conv.append_message(conv.roles[1], None)
34
+ prompt_question = conv.get_prompt()
35
+
36
+ input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
37
+ image_sizes = [image.size]
38
+
39
+
40
+ cont = model.generate(
41
+ input_ids,
42
+ images=image_tensor,
43
+ image_sizes=image_sizes,
44
+ do_sample=False,
45
+ temperature=0,
46
+ max_new_tokens=4096,
47
+ )
48
+ text_outputs = tokenizer.batch_decode(cont, skip_special_tokens=True)
49
+ print(text_outputs)
50
+
51
+ from threading import Thread
52
+ from transformers import TextIteratorStreamer
53
+ import json
54
+
55
+ url = "https://github.com/haotian-liu/LLaVA/blob/1a91fc274d7c35a9b50b3cb29c4247ae5837ce39/images/llava_v1_5_radar.jpg?raw=true"
56
+ image = Image.open(requests.get(url, stream=True).raw)
57
+ image_tensor = process_images([image], image_processor, model.config)
58
+ image_tensor = [_image.to(dtype=torch.float16, device=device) for _image in image_tensor]
59
+
60
+ conv_template = "qwen_1_5"
61
+ question = DEFAULT_IMAGE_TOKEN + "\nWhat is shown in this image?"
62
+ conv = copy.deepcopy(conv_templates[conv_template])
63
+ conv.append_message(conv.roles[0], question)
64
+ conv.append_message(conv.roles[1], None)
65
+ prompt_question = conv.get_prompt()
66
+
67
+ input_ids = tokenizer_image_token(prompt_question, tokenizer, IMAGE_TOKEN_INDEX, return_tensors="pt").unsqueeze(0).to(device)
68
+ image_sizes = [image.size]
69
+
70
+ max_context_length = getattr(model.config, "max_position_embeddings", 2048)
71
+ num_image_tokens = question.count(DEFAULT_IMAGE_TOKEN) * model.get_vision_tower().num_patches
72
+
73
+ streamer = TextIteratorStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True, timeout=15)
74
+
75
+ max_new_tokens = min(4096, max_context_length - input_ids.shape[-1] - num_image_tokens)
76
+
77
+ if max_new_tokens < 1:
78
+ print(
79
+ json.dumps(
80
+ {
81
+ "text": question + "Exceeds max token length. Please start a new conversation, thanks.",
82
+ "error_code": 0,
83
+ }
84
+ )
85
+ )
86
+ else:
87
+ gen_kwargs = {
88
+ "do_sample": False,
89
+ "temperature": 0,
90
+ "max_new_tokens": max_new_tokens,
91
+ "images": image_tensor,
92
+ "image_sizes": image_sizes,
93
+ }
94
+
95
+ thread = Thread(
96
+ target=model.generate,
97
+ kwargs=dict(
98
+ inputs=input_ids,
99
+ streamer=streamer,
100
+ **gen_kwargs,
101
+ ),
102
+ )
103
+ thread.start()
104
+
105
+ generated_text = ""
106
+ for new_text in streamer:
107
+ generated_text += new_text
108
+ sys.stdout.write(new_text)
109
+ sys.stdout.flush()
110
+
111
+ print("\nFinal output:", generated_text)
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Dockerfile ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Start from the NVIDIA official image (ubuntu-22.04 + cuda-12.6 + python-3.10)
2
+ # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-24-08.html
3
+ FROM nvcr.io/nvidia/pytorch:24.08-py3
4
+
5
+ # Define environments
6
+ ENV MAX_JOBS=32
7
+ ENV VLLM_WORKER_MULTIPROC_METHOD=spawn
8
+ ENV DEBIAN_FRONTEND=noninteractive
9
+ ENV NODE_OPTIONS=""
10
+ ENV PIP_ROOT_USER_ACTION=ignore
11
+ ENV HF_HUB_ENABLE_HF_TRANSFER="1"
12
+
13
+ # Define installation arguments
14
+ ARG APT_SOURCE=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
15
+ ARG PIP_INDEX=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
16
+
17
+ # Set apt source
18
+ RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
19
+ { \
20
+ echo "deb ${APT_SOURCE} jammy main restricted universe multiverse"; \
21
+ echo "deb ${APT_SOURCE} jammy-updates main restricted universe multiverse"; \
22
+ echo "deb ${APT_SOURCE} jammy-backports main restricted universe multiverse"; \
23
+ echo "deb ${APT_SOURCE} jammy-security main restricted universe multiverse"; \
24
+ } > /etc/apt/sources.list
25
+
26
+ # Install systemctl
27
+ RUN apt-get update && \
28
+ apt-get install -y -o Dpkg::Options::="--force-confdef" systemd && \
29
+ apt-get clean
30
+
31
+ # Install tini
32
+ RUN apt-get update && \
33
+ apt-get install -y tini && \
34
+ apt-get clean
35
+
36
+ # Change pip source
37
+ RUN pip config set global.index-url "${PIP_INDEX}" && \
38
+ pip config set global.extra-index-url "${PIP_INDEX}" && \
39
+ python -m pip install --upgrade pip
40
+
41
+ # Uninstall nv-pytorch fork
42
+ RUN pip uninstall -y torch torchvision torchaudio \
43
+ pytorch-quantization pytorch-triton torch-tensorrt \
44
+ transformer_engine flash_attn apex megatron-core \
45
+ xgboost opencv grpcio
46
+
47
+ # Fix cv2
48
+ RUN rm -rf /usr/local/lib/python3.10/dist-packages/cv2
49
+
50
+ # Install torch-2.6.0+cu124 + vllm-0.8.4
51
+ # torch-2.6.0+cu124: cxx11abi=False
52
+ # torch-2.6.0+cu126: cxx11abi=True
53
+ # see https://github.com/flashinfer-ai/flashinfer/issues/911
54
+ RUN pip install --no-cache-dir "vllm==0.8.4" "torch==2.6.0" "torchvision==0.21.0" "torchaudio==2.6.0" tensordict torchdata \
55
+ "transformers[hf_xet]>=4.51.0" accelerate datasets peft hf-transfer \
56
+ "numpy<2.0.0" "pyarrow>=15.0.0" pandas \
57
+ ray[default] codetiming hydra-core pylatexenc qwen-vl-utils wandb liger-kernel mathruler \
58
+ pytest yapf py-spy pyext pre-commit ruff
59
+
60
+ # Install flash-attn-2.7.4.post1 (cxx11abi=False)
61
+ RUN wget -nv https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl && \
62
+ pip install --no-cache-dir flash_attn-2.7.4.post1+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
63
+
64
+ # Install flashinfer-0.2.2.post1+cu124 (cxx11abi=False)
65
+ # vllm-0.8.3 does not support flashinfer>=0.2.3
66
+ # see https://github.com/vllm-project/vllm/pull/15777
67
+ RUN wget -nv https://github.com/flashinfer-ai/flashinfer/releases/download/v0.2.2.post1/flashinfer_python-0.2.2.post1+cu124torch2.6-cp38-abi3-linux_x86_64.whl && \
68
+ pip install --no-cache-dir flashinfer_python-0.2.2.post1+cu124torch2.6-cp38-abi3-linux_x86_64.whl
69
+
70
+ # Fix packages
71
+ RUN pip uninstall -y pynvml nvidia-ml-py && \
72
+ pip install --no-cache-dir --upgrade "nvidia-ml-py>=12.560.30" "fastapi[standard]>=0.115.0" "optree>=0.13.0" "pydantic>=2.9" "grpcio>=1.62.1"
73
+
74
+ # Reset pip config
75
+ RUN pip config unset global.index-url && \
76
+ pip config unset global.extra-index-url
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Dockerfile.legacy ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Start from the NVIDIA official image (ubuntu-22.04 + cuda-12.6 + python-3.10)
2
+ # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes/rel-24-08.html
3
+ FROM nvcr.io/nvidia/pytorch:24.08-py3
4
+
5
+ # Define environments
6
+ ENV MAX_JOBS=32
7
+ ENV VLLM_WORKER_MULTIPROC_METHOD=spawn
8
+ ENV DEBIAN_FRONTEND=noninteractive
9
+ ENV NODE_OPTIONS=""
10
+ ENV PIP_ROOT_USER_ACTION=ignore
11
+ ENV HF_HUB_ENABLE_HF_TRANSFER="1"
12
+
13
+ # Define installation arguments
14
+ ARG APT_SOURCE=https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
15
+ ARG PIP_INDEX=https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
16
+ ARG VLLM_COMMIT=227578480d71fc94ef46ca77fb69496412158d68
17
+
18
+ # Set apt source
19
+ RUN cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
20
+ { \
21
+ echo "deb ${APT_SOURCE} jammy main restricted universe multiverse"; \
22
+ echo "deb ${APT_SOURCE} jammy-updates main restricted universe multiverse"; \
23
+ echo "deb ${APT_SOURCE} jammy-backports main restricted universe multiverse"; \
24
+ echo "deb ${APT_SOURCE} jammy-security main restricted universe multiverse"; \
25
+ } > /etc/apt/sources.list
26
+
27
+ # Install systemctl
28
+ RUN apt-get update && \
29
+ apt-get install -y -o Dpkg::Options::="--force-confdef" systemd && \
30
+ apt-get clean
31
+
32
+ # Install tini
33
+ RUN apt-get update && \
34
+ apt-get install -y tini && \
35
+ apt-get clean
36
+
37
+ # Change pip source
38
+ RUN pip config set global.index-url "${PIP_INDEX}" && \
39
+ pip config set global.extra-index-url "${PIP_INDEX}" && \
40
+ python -m pip install --upgrade pip
41
+
42
+ # Uninstall nv-pytorch fork
43
+ RUN pip uninstall -y torch torchvision torchaudio \
44
+ pytorch-quantization pytorch-triton torch-tensorrt \
45
+ transformer_engine flash_attn apex megatron-core \
46
+ xgboost opencv grpcio
47
+
48
+ # Fix cv2
49
+ RUN rm -rf /usr/local/lib/python3.10/dist-packages/cv2
50
+
51
+ # Install vllm-0.7.4-nightly
52
+ RUN pip install --no-cache-dir vllm --pre --extra-index-url "https://wheels.vllm.ai/${VLLM_COMMIT}" && \
53
+ git clone -b verl_v1 https://github.com/hiyouga/vllm.git && \
54
+ cp -r vllm/vllm/ /usr/local/lib/python3.10/dist-packages/
55
+
56
+ # Install torch-2.5.1
57
+ RUN pip install --no-cache-dir "torch==2.5.1" "torchvision==0.20.1" "torchaudio==2.5.1" tensordict torchdata \
58
+ "transformers>=4.49.0" accelerate datasets peft hf-transfer \
59
+ ray[default] codetiming hydra-core pandas "pyarrow>=15.0.0" pylatexenc qwen-vl-utils wandb liger-kernel mathruler \
60
+ pytest yapf py-spy pyext pre-commit ruff
61
+
62
+ # Install flash_attn-2.7.4.post1
63
+ RUN wget -nv https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.4.post1/flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl && \
64
+ pip install --no-cache-dir flash_attn-2.7.4.post1+cu12torch2.5cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
65
+
66
+ # Fix packages
67
+ RUN pip uninstall -y pynvml nvidia-ml-py && \
68
+ pip install --no-cache-dir --upgrade "nvidia-ml-py>=12.560.30" "fastapi[standard]>=0.115.0" "optree>=0.13.0" "pydantic>=2.9" "grpcio>=1.62.1"
69
+
70
+ # Reset pip config
71
+ RUN pip config unset global.index-url && \
72
+ pip config unset global.extra-index-url
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/Makefile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: build commit quality style
2
+
3
+ check_dirs := examples scripts verl setup.py
4
+
5
+ build:
6
+ python3 setup.py sdist bdist_wheel
7
+
8
+ commit:
9
+ pre-commit install
10
+ pre-commit run --all-files
11
+
12
+ quality:
13
+ ruff check $(check_dirs)
14
+ ruff format --check $(check_dirs)
15
+
16
+ style:
17
+ ruff check $(check_dirs) --fix
18
+ ruff format $(check_dirs)
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/README.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # EasyR1 for LLaVA-Critic-R1
2
+
3
+ This codebase is a customized extension of [EasyR1](https://github.com/hiyouga/EasyR1), specifically modified to support RL training using LLaMA-3.2-Vision-11B-Instruct as the base model. For RL training using Qwen-2.5-VL and Mimo-VL as base models, please use the original EasyR1 codebase. We will integrate support for all models into a unified codebase in the future.
4
+
5
+ ## Training based on Qwen-2.5-VL
6
+
7
+ ```
8
+ bash ./examples/qwen2_5_vl_7b_llava_critic_grpo.sh
9
+ ```
10
+
11
+ ## Training based on ThinkLite-VL
12
+
13
+ ```
14
+ bash ./examples/thinklite_vl_7b_llava_critic_grpo.sh
15
+ ```
16
+
17
+ ## Training based on Mimo-VL
18
+
19
+ ### SFT checkpoint
20
+ ```
21
+ bash ./examples/mimo_vl_7b_llava_critic_grpo.sh
22
+ ```
23
+
24
+ ### RL checkpoint
25
+ ```
26
+ bash ./examples/mimo_vl_rl_7b_llava_critic_grpo.sh
27
+ ```
28
+
29
+ ## Training based on LLaMA-3.2-Vision
30
+
31
+ ```
32
+ bash ./examples/llama3.2v_critic_grpo.sh
33
+ ```
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/assets/baselines.md ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Baselines
2
+
3
+ Environment: [hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.3-flashinfer0.2.2-cxx11abi0](https://hub.docker.com/layers/hiyouga/verl/ngc-th2.6.0-cu126-vllm0.8.3-flashinfer0.2.2-cxx11abi0/images/sha256-335ed6cd1fe73090e458409cfa4394d6abf4cd0503ca44dbafdc28ff72e5ed20)
4
+
5
+ EasyR1 version: [v0.3.0](https://github.com/hiyouga/EasyR1/tree/v0.3.0)
6
+
7
+ Welcome to contribute new data points!
8
+
9
+ ## Algorithm Baselines
10
+
11
+ ### [Qwen2.5-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) on [Math12k](https://huggingface.co/datasets/hiyouga/math12k)
12
+
13
+ | Size | Algorithm | Bits | LR | KL | Test Score |
14
+ | ---- | ----------- | ---- | ---- | ---- | ---------- |
15
+ | 7B | GRPO | AMP | 1e-6 | 1e-2 | 0.73->0.79 |
16
+
17
+ ### [Qwen2.5-VL-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) on [Geometry3k](https://huggingface.co/datasets/hiyouga/geometry3k)
18
+
19
+ | Size | Algorithm | Bits | LR | KL | Test Score |
20
+ | ---- | ----------- | ---- | ---- | ---- | ---------- |
21
+ | 7B | GRPO | AMP | 1e-6 | 1e-2 | 0.39->0.52 |
22
+ | 7B | GRPO | BF16 | 1e-6 | 1e-2 | 0.39->0.52 |
23
+ | 7B | GRPO | AMP | 1e-6 | 1e-3 | 0.39->0.52 |
24
+ | 7B | RLOO | AMP | 1e-6 | 1e-2 | 0.39->0.53 |
25
+ | 3B | GRPO | AMP | 1e-6 | 1e-2 | 0.27->0.44 |
26
+ | 32B | GRPO | BF16 | 1e-6 | 1e-2 | 0.46->0.61 |
27
+
28
+ > [!NOTE]
29
+ > The hyper-parameters not listed are all the same as the default values.
30
+
31
+ ## Performance Baselines
32
+
33
+ ### [Qwen2.5-VL-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) on [Geometry3k](https://huggingface.co/datasets/hiyouga/geometry3k)
34
+
35
+ | Size | GPU Type | Bits | Batch Size | vLLM Util | vLLM TP | Peak Mem | Peak VRAM | Throughput | Sec per step | Actor MFU |
36
+ | ---- | ------------- | ---- | ---------- | --------- | ------- | -------- | --------- | ---------- | ------------ | --------- |
37
+ | 3B | 8 * H100 80GB | AMP | 4 / 16 | 0.6 | 2 | 120GB | 35GB | 1200 | 180s | 6.3% |
38
+ | 7B | 8 * H100 80GB | AMP | 4 / 16 | 0.6 | 2 | 140GB | 60GB | 1200 | 180s | 13.6% |
39
+ | 7B | 8 * H100 80GB | AMP | 10 / 20 | 0.6 | 2 | 150GB | 75GB | 1400 | 170s | 19.2% |
40
+ | 7B | 8 * L20 48GB | AMP | 4 / 16 | 0.6 | 2 | 150GB | 44GB | 410 | 580s | 26.5% |
41
+ | 7B | 8 * H100 80GB | BF16 | 4 / 16 | 0.6 | 2 | 150GB | 50GB | 1280 | 190s | 13.9% |
42
+ | 32B | 8 * H100 80GB | BF16 | 1 / 8 | 0.6 | 8 | 240GB | 68GB | 360 | 860s | 11.2% |
43
+
44
+ - Batch Size: micro_batch_size_per_device_for_update / micro_batch_size_per_device_for_experience
45
+ - vLLM Util: rollout.gpu_memory_utilization
46
+ - vLLM TP: rollout.tensor_parallel_size
47
+ - Peak Mem: Peak CPU memory usage
48
+ - Peak VRAM: Peak GPU memory usage
49
+ - Throughput: Number of tokens per second per GPU by one training step
50
+ - Sec per step: Average time per step in seconds
51
+
52
+ > [!NOTE]
53
+ > The hyper-parameters not listed are all the same as the default values.
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/baselines/qwen2_5_vl_3b_clevr.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -x
4
+
5
+ export PYTHONUNBUFFERED=1
6
+
7
+ MODEL_PATH=Qwen/Qwen2.5-VL-3B-Instruct # replace it with your local file path
8
+
9
+ python3 -m verl.trainer.main \
10
+ config=examples/config.yaml \
11
+ data.train_files=BUAADreamer/clevr_count_70k@train \
12
+ data.val_files=BUAADreamer/clevr_count_70k@test \
13
+ data.format_prompt=./examples/format_prompt/r1v_format.jinja \
14
+ worker.actor.model.model_path=${MODEL_PATH} \
15
+ worker.rollout.tensor_parallel_size=1 \
16
+ worker.reward.reward_type=sequential \
17
+ worker.reward.reward_function=./examples/reward_function/r1v.py:compute_score \
18
+ trainer.experiment_name=qwen2_5_vl_3b_clevr \
19
+ trainer.n_gpus_per_node=2
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/baselines/qwen2_5_vl_3b_geoqa8k.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -x
4
+
5
+ export PYTHONUNBUFFERED=1
6
+
7
+ MODEL_PATH=Qwen/Qwen2.5-VL-3B-Instruct # replace it with your local file path
8
+
9
+ python3 -m verl.trainer.main \
10
+ config=examples/config.yaml \
11
+ data.train_files=leonardPKU/GEOQA_8K_R1V@train \
12
+ data.val_files=leonardPKU/GEOQA_8K_R1V@test \
13
+ data.format_prompt=./examples/format_prompt/r1v_format.jinja \
14
+ worker.actor.model.model_path=${MODEL_PATH} \
15
+ worker.rollout.tensor_parallel_size=1 \
16
+ worker.reward.reward_type=sequential \
17
+ worker.reward.reward_function=./examples/reward_function/r1v.py:compute_score \
18
+ trainer.experiment_name=qwen2_5_vl_3b_geoqa8k \
19
+ trainer.n_gpus_per_node=8
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/config.yaml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ data:
2
+ train_files: hiyouga/math12k@train
3
+ val_files: hiyouga/math12k@test
4
+ prompt_key: problem
5
+ answer_key: answer
6
+ image_key: image
7
+ max_prompt_length: 4096
8
+ max_response_length: 2048
9
+ rollout_batch_size: 256
10
+ val_batch_size: 1024
11
+ format_prompt: ./examples/format_prompt/math_format.jinja
12
+ override_chat_template: null
13
+ shuffle: true
14
+ seed: 1
15
+ max_pixels: 4194304
16
+ min_pixels: 262144
17
+ filter_overlong_prompts: true
18
+
19
+ algorithm:
20
+ adv_estimator: grpo
21
+ disable_kl: false
22
+ use_kl_loss: true
23
+ kl_penalty: low_var_kl
24
+ kl_coef: 1.0e-2
25
+
26
+ worker:
27
+ actor:
28
+ global_batch_size: 128
29
+ micro_batch_size_per_device_for_update: 4
30
+ micro_batch_size_per_device_for_experience: 8
31
+ max_grad_norm: 1.0
32
+ padding_free: true
33
+ ulysses_sequence_parallel_size: 1
34
+ is_entropy_reg: False
35
+ entropy_coef: 0.001
36
+ model:
37
+ model_path: Qwen/Qwen2.5-7B-Instruct
38
+ enable_gradient_checkpointing: true
39
+ trust_remote_code: true
40
+ freeze_vision_tower: false
41
+ optim:
42
+ lr: 1.0e-6
43
+ weight_decay: 1.0e-2
44
+ strategy: adamw # {adamw, adamw_bf16}
45
+ lr_warmup_ratio: 0.0
46
+ fsdp:
47
+ enable_full_shard: true
48
+ enable_cpu_offload: false
49
+ enable_rank0_init: true
50
+ offload:
51
+ offload_params: true # true: more CPU memory; false: more GPU memory
52
+ offload_optimizer: true # true: more CPU memory; false: more GPU memory
53
+
54
+ rollout:
55
+ n: 8
56
+ temperature: 1.0
57
+ top_p: 0.99
58
+ gpu_memory_utilization: 0.6
59
+ max_num_batched_tokens: 8192
60
+ max_model_len: 8192
61
+ enforce_eager: false
62
+ enable_chunked_prefill: false
63
+ tensor_parallel_size: 2
64
+ limit_images: 10
65
+ val_override_config:
66
+ temperature: 0.5
67
+ n: 1
68
+
69
+ ref:
70
+ fsdp:
71
+ enable_full_shard: true
72
+ enable_cpu_offload: true # true: more CPU memory; false: more GPU memory
73
+ enable_rank0_init: true
74
+ offload:
75
+ offload_params: false
76
+
77
+ reward:
78
+ reward_type: batch
79
+ reward_function: ./examples/reward_function/math.py:compute_score
80
+
81
+ trainer:
82
+ total_epochs: 15
83
+ max_steps: null
84
+ project_name: easy_r1
85
+ experiment_name: qwen2_5_7b_math_grpo
86
+ logger: ["console", "wandb"]
87
+ nnodes: 1
88
+ n_gpus_per_node: 8
89
+ val_freq: -1 # -1 to disable
90
+ val_before_train: false
91
+ val_only: false
92
+ val_generations_to_log: 3
93
+ save_freq: 10 # -1 to disable
94
+ save_limit: -1 # -1 to disable
95
+ save_checkpoint_path: null
96
+ load_checkpoint_path: null
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/caption_format.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {{ content | trim }} You FIRST describe the given image in a detailed manner, THEN think about the reasoning process as an internal monologue based on the generated description and given question and then provide the final answer. The description MUST BE enclosed within <caption> </caption> tags. The reasoning process MUST BE enclosed within <think> </think> tags. The final answer MUST BE put in \boxed{}.
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/math_format.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {{ content | trim }} You FIRST think about the reasoning process as an internal monologue and then provide the final answer. The reasoning process MUST BE enclosed within <think> </think> tags. The final answer MUST BE put in \boxed{}.
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/format_prompt/r1v_format.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {{ content | trim }} A conversation between User and Assistant. The user asks a question, and the Assistant solves it. The assistant first thinks about the reasoning process in the mind and then provides the user with the answer. The reasoning process and answer are enclosed within <think> </think> and <answer> </answer> tags, respectively, i.e., <think> reasoning process here </think><answer> answer here </answer>
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/llama3.2v_critic_grpo.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -x
4
+
5
+ export PYTHONUNBUFFERED=1
6
+
7
+ MODEL_PATH=meta-llama/Llama-3.2-11B-Vision-Instruct # replace it with your local file path
8
+
9
+ python3 -m verl.trainer.main \
10
+ config=examples/config.yaml \
11
+ data.train_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
12
+ data.val_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
13
+ data.shuffle=True \
14
+ data.format_prompt=./examples/format_prompt/math_format.jinja \
15
+ data.rollout_batch_size=256 \
16
+ data.max_prompt_length=4096 \
17
+ data.prompt_key=question \
18
+ worker.actor.is_entropy_reg=False \
19
+ worker.actor.global_batch_size=128 \
20
+ worker.actor.optim.lr=5.0e-7 \
21
+ worker.actor.micro_batch_size_per_device_for_update=4 \
22
+ worker.actor.micro_batch_size_per_device_for_experience=8 \
23
+ worker.actor.model.model_path=${MODEL_PATH} \
24
+ worker.rollout.tensor_parallel_size=8 \
25
+ worker.rollout.limit_images=1 \
26
+ worker.rollout.gpu_memory_utilization=0.6 \
27
+ worker.reward.reward_function=./examples/reward_function/math.py:compute_score \
28
+ trainer.experiment_name=llama3.2v_critic_grpo \
29
+ trainer.n_gpus_per_node=8
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/mimo_vl_7b_llava_critic_grpo.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ MODEL_PATH=XiaomiMiMo/MiMo-VL-7B-SFT-2508
4
+
5
+ python3 -m verl.trainer.main \
6
+ config=examples/config.yaml \
7
+ data.train_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
8
+ data.val_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
9
+ data.filter_overlong_prompts=True \
10
+ data.prompt_key=question \
11
+ data.max_prompt_length=6142 \
12
+ worker.actor.is_entropy_reg=False \
13
+ worker.actor.global_batch_size=128 \
14
+ worker.actor.micro_batch_size_per_device_for_update=4 \
15
+ worker.actor.micro_batch_size_per_device_for_experience=8 \
16
+ worker.actor.model.model_path=${MODEL_PATH} \
17
+ trainer.experiment_name=mimo_vl_7b_llava_critic_grpo \
18
+ trainer.n_gpus_per_node=8
19
+
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/mimo_vl_rl_7b_llava_critic_grpo.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ MODEL_PATH=XiaomiMiMo/MiMo-VL-7B-RL-2508
4
+
5
+ python3 -m verl.trainer.main \
6
+ config=examples/config.yaml \
7
+ data.train_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
8
+ data.val_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
9
+ data.filter_overlong_prompts=True \
10
+ data.prompt_key=question \
11
+ data.max_prompt_length=6142 \
12
+ worker.actor.is_entropy_reg=False \
13
+ worker.actor.global_batch_size=128 \
14
+ worker.actor.micro_batch_size_per_device_for_update=4 \
15
+ worker.actor.micro_batch_size_per_device_for_experience=8 \
16
+ worker.actor.model.model_path=${MODEL_PATH} \
17
+ trainer.experiment_name=mimo_vl_rl_7b_llava_critic_grpo \
18
+ trainer.n_gpus_per_node=8
19
+
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/qwen2_5_vl_7b_llava_critic_grpo.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ MODEL_PATH=Qwen/Qwen2.5-VL-7B-Instruct
4
+
5
+ python3 -m verl.trainer.main \
6
+ config=examples/config.yaml \
7
+ data.train_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
8
+ data.val_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
9
+ data.filter_overlong_prompts=True \
10
+ data.prompt_key=question \
11
+ data.max_prompt_length=6142 \
12
+ worker.actor.is_entropy_reg=False \
13
+ worker.actor.global_batch_size=128 \
14
+ worker.actor.micro_batch_size_per_device_for_update=4 \
15
+ worker.actor.micro_batch_size_per_device_for_experience=8 \
16
+ worker.actor.model.model_path=${MODEL_PATH} \
17
+ trainer.experiment_name=qwen2_5_vl_7b_llava_critic_grpo \
18
+ trainer.n_gpus_per_node=8
19
+
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/__pycache__/caption.cpython-310.pyc ADDED
Binary file (1.3 kB). View file
 
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/__pycache__/math.cpython-310.pyc ADDED
Binary file (1.27 kB). View file
 
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/caption.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import re
16
+ from typing import Dict, List
17
+
18
+ from mathruler.grader import extract_boxed_content, grade_answer
19
+
20
+
21
+ def format_reward(predict: str) -> float:
22
+ pattern = re.compile(r"<caption>.*</caption>.*<think>.*</think>.*\\boxed\{.*\}.*", re.DOTALL)
23
+ format_match = re.fullmatch(pattern, predict)
24
+ return 1.0 if format_match else 0.0
25
+
26
+
27
+ def accuracy_reward(predict: str, ground_truth: str) -> float:
28
+ answer = extract_boxed_content(predict)
29
+ return 1.0 if grade_answer(answer, ground_truth) else 0.0
30
+
31
+
32
+ def compute_score(predicts: List[str], ground_truths: List[str], format_weight: float = 0.1) -> List[Dict[str, float]]:
33
+ scores = []
34
+ for predict, ground_truth in zip(predicts, ground_truths):
35
+ predict = re.sub(r"\s*(<|>|/)\s*", r"\1", predict) # handle qwen2.5vl-32b format
36
+ format_score = format_reward(predict)
37
+ accuracy_score = accuracy_reward(predict, ground_truth)
38
+ scores.append(
39
+ {
40
+ "overall": (1 - format_weight) * accuracy_score + format_weight * format_score,
41
+ "format": format_score,
42
+ "accuracy": accuracy_score,
43
+ }
44
+ )
45
+
46
+ return scores
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/math.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import re
16
+ from typing import Dict, List
17
+
18
+ from mathruler.grader import extract_boxed_content, grade_answer
19
+
20
+
21
+ def format_reward(predict: str) -> float:
22
+ pattern = re.compile(r"<think>.*</think>.*\\boxed\{.*\}.*", re.DOTALL)
23
+ format_match = re.fullmatch(pattern, predict)
24
+ return 1.0 if format_match else 0.0
25
+
26
+
27
+ def accuracy_reward(predict: str, ground_truth: str) -> float:
28
+ answer = extract_boxed_content(predict)
29
+ return 1.0 if grade_answer(answer, ground_truth) else 0.0
30
+
31
+
32
+ def compute_score(predicts: List[str], ground_truths: List[str], format_weight: float = 0.1) -> List[Dict[str, float]]:
33
+ scores = []
34
+ for predict, ground_truth in zip(predicts, ground_truths):
35
+ predict = re.sub(r"\s*(<|>|/)\s*", r"\1", predict) # handle qwen2.5vl-32b format
36
+ format_score = format_reward(predict)
37
+ accuracy_score = accuracy_reward(predict, ground_truth)
38
+ scores.append(
39
+ {
40
+ "overall": (1 - format_weight) * accuracy_score + format_weight * format_score,
41
+ "format": format_score,
42
+ "accuracy": accuracy_score,
43
+ }
44
+ )
45
+
46
+ return scores
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/reward_function/r1v.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import re
16
+ from typing import Dict
17
+
18
+ from mathruler.grader import grade_answer
19
+
20
+
21
+ def format_reward(predict: str) -> float:
22
+ pattern = re.compile(r"<think>.*?</think>\s*<answer>.*?</answer>", re.DOTALL)
23
+ format_match = re.fullmatch(pattern, predict)
24
+ return 1.0 if format_match else 0.0
25
+
26
+
27
+ def accuracy_reward(predict: str, ground_truth: str) -> float:
28
+ try:
29
+ content_match = re.search(r"<answer>(.*?)</answer>", predict)
30
+ given_answer = content_match.group(1).strip() if content_match else predict.strip()
31
+ if grade_answer(given_answer, ground_truth.strip()):
32
+ return 1.0
33
+
34
+ except Exception:
35
+ pass
36
+
37
+ return 0.0
38
+
39
+
40
+ def compute_score(predict: str, ground_truth: str, format_weight: float = 0.5) -> Dict[str, float]:
41
+ format_score = format_reward(predict)
42
+ accuracy_score = accuracy_reward(predict, ground_truth)
43
+ return {
44
+ "overall": (1 - format_weight) * accuracy_score + format_weight * format_score,
45
+ "format": format_score,
46
+ "accuracy": accuracy_score,
47
+ }
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/runtime_env.yaml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ working_dir: ./
2
+ excludes: ["/.git/"]
3
+ env_vars:
4
+ TOKENIZERS_PARALLELISM: "true"
5
+ NCCL_DEBUG: "WARN"
6
+ VLLM_LOGGING_LEVEL: "WARN"
7
+ TORCH_NCCL_AVOID_RECORD_STREAMS: "1"
8
+ PYTORCH_CUDA_ALLOC_CONF: "expandable_segments:False"
9
+ PYTHONUNBUFFERED: "1"
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/examples/thinklite_vl_7b_llava_critic_grpo.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ MODEL_PATH=russwang/ThinkLite-VL-7B
4
+
5
+ python3 -m verl.trainer.main \
6
+ config=examples/config.yaml \
7
+ data.train_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
8
+ data.val_files=lmms-lab/LLaVA-Critic-GRPO-dataset@train \
9
+ data.filter_overlong_prompts=True \
10
+ data.prompt_key=question \
11
+ data.max_prompt_length=6142 \
12
+ worker.actor.is_entropy_reg=False \
13
+ worker.actor.global_batch_size=128 \
14
+ worker.actor.optim.lr=5.0e-7 \
15
+ worker.actor.micro_batch_size_per_device_for_update=4 \
16
+ worker.actor.micro_batch_size_per_device_for_experience=8 \
17
+ worker.actor.model.model_path=${MODEL_PATH} \
18
+ trainer.experiment_name=thinklite_vl_7b_llava_critic_grpo \
19
+ trainer.n_gpus_per_node=8
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/init ADDED
@@ -0,0 +1 @@
 
 
1
+
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/pyproject.toml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "verl"
7
+ dynamic = [
8
+ "version",
9
+ "dependencies",
10
+ "optional-dependencies",
11
+ "requires-python",
12
+ "authors",
13
+ "description",
14
+ "readme",
15
+ "license"
16
+ ]
17
+
18
+ [tool.ruff]
19
+ target-version = "py39"
20
+ line-length = 119
21
+ indent-width = 4
22
+
23
+ [tool.ruff.lint]
24
+ ignore = ["C901", "E501", "E741", "W605", "C408"]
25
+ select = ["C", "E", "F", "I", "W", "RUF022"]
26
+
27
+ [tool.ruff.lint.per-file-ignores]
28
+ "__init__.py" = ["E402", "F401", "F403", "F811"]
29
+
30
+ [tool.ruff.lint.isort]
31
+ lines-after-imports = 2
32
+ known-first-party = ["verl"]
33
+ known-third-party = ["torch", "transformers", "wandb"]
34
+
35
+ [tool.ruff.format]
36
+ quote-style = "double"
37
+ indent-style = "space"
38
+ skip-magic-trailing-comma = false
39
+ line-ending = "auto"
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/requirements.txt ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate
2
+ codetiming
3
+ datasets
4
+ liger-kernel
5
+ mathruler
6
+ numpy
7
+ omegaconf
8
+ pandas
9
+ peft
10
+ pillow
11
+ pyarrow>=15.0.0
12
+ pylatexenc
13
+ qwen-vl-utils
14
+ ray[default]
15
+ tensordict
16
+ torchdata
17
+ transformers>=4.51.0
18
+ vllm>=0.7.3
19
+ wandb
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/scripts/model_merger.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import argparse
16
+ import os
17
+ import re
18
+ from concurrent.futures import ThreadPoolExecutor
19
+ from typing import Dict, List, Tuple
20
+
21
+ import numpy as np
22
+ import torch
23
+ from torch.distributed._tensor import DTensor, Placement, Shard
24
+ from transformers import (
25
+ AutoConfig,
26
+ AutoModelForCausalLM,
27
+ AutoModelForTokenClassification,
28
+ AutoModelForVision2Seq,
29
+ PretrainedConfig,
30
+ PreTrainedModel,
31
+ )
32
+
33
+
34
+ def merge_by_placement(tensors: List[torch.Tensor], placement: Placement):
35
+ if placement.is_replicate():
36
+ return tensors[0]
37
+ elif placement.is_partial():
38
+ raise NotImplementedError("Partial placement is not supported yet")
39
+ elif placement.is_shard():
40
+ return torch.cat(tensors, dim=placement.dim).contiguous()
41
+ else:
42
+ raise ValueError(f"Unsupported placement: {placement}")
43
+
44
+
45
+ def upload_model_to_huggingface(local_path: str, remote_path: str):
46
+ # Push to hugging face
47
+ from huggingface_hub import HfApi
48
+
49
+ api = HfApi()
50
+ api.create_repo(repo_id=remote_path, private=False, exist_ok=True)
51
+ api.upload_folder(repo_id=remote_path, folder_path=local_path, repo_type="model")
52
+
53
+
54
+ if __name__ == "__main__":
55
+ parser = argparse.ArgumentParser()
56
+ parser.add_argument("--local_dir", required=True, type=str, help="The path for your saved model")
57
+ parser.add_argument("--hf_upload_path", default=False, type=str, help="The path of the huggingface repo to upload")
58
+ args = parser.parse_args()
59
+ local_dir: str = args.local_dir
60
+
61
+ assert not local_dir.endswith("huggingface"), "The local_dir should not end with huggingface."
62
+
63
+ # copy rank zero to find the shape of (dp, fsdp)
64
+ rank = 0
65
+ world_size = 0
66
+ for filename in os.listdir(local_dir):
67
+ match = re.match(r"model_world_size_(\d+)_rank_0\.pt", filename)
68
+ if match:
69
+ world_size = match.group(1)
70
+ break
71
+
72
+ assert world_size, "No model file with the proper format."
73
+
74
+ rank0_weight_path = os.path.join(local_dir, f"model_world_size_{world_size}_rank_{rank}.pt")
75
+ state_dict = torch.load(rank0_weight_path, map_location="cpu", weights_only=False)
76
+ pivot_key = sorted(state_dict.keys())[0]
77
+ weight = state_dict[pivot_key]
78
+ if isinstance(weight, DTensor):
79
+ # get sharding info
80
+ device_mesh = weight.device_mesh
81
+ mesh = device_mesh.mesh
82
+ mesh_dim_names = device_mesh.mesh_dim_names
83
+ else:
84
+ # for non-DTensor
85
+ mesh = np.array([int(world_size)], dtype=np.int64)
86
+ mesh_dim_names = ("fsdp",)
87
+
88
+ print(f"Got device mesh {mesh}, mesh_dim_names {mesh_dim_names}")
89
+
90
+ assert mesh_dim_names in (("fsdp",), ("ddp", "fsdp")), f"Unsupported mesh_dim_names {mesh_dim_names}."
91
+
92
+ if "tp" in mesh_dim_names:
93
+ # fsdp * tp
94
+ total_shards = mesh.shape[-1] * mesh.shape[-2]
95
+ mesh_shape = (mesh.shape[-2], mesh.shape[-1])
96
+ else:
97
+ # fsdp
98
+ total_shards = mesh.shape[-1]
99
+ mesh_shape = (mesh.shape[-1],)
100
+
101
+ print(f"Processing {total_shards} model shards in total.")
102
+ model_state_dict_lst = []
103
+ model_state_dict_lst.append(state_dict)
104
+ model_state_dict_lst.extend([""] * (total_shards - 1))
105
+
106
+ def process_one_shard(rank, model_state_dict_lst):
107
+ model_path = os.path.join(local_dir, f"model_world_size_{world_size}_rank_{rank}.pt")
108
+ state_dict = torch.load(model_path, map_location="cpu", weights_only=False)
109
+ model_state_dict_lst[rank] = state_dict
110
+ return state_dict
111
+
112
+ with ThreadPoolExecutor(max_workers=min(32, os.cpu_count())) as executor:
113
+ for rank in range(1, total_shards):
114
+ executor.submit(process_one_shard, rank, model_state_dict_lst)
115
+
116
+ state_dict: Dict[str, List[torch.Tensor]] = {}
117
+ param_placements: Dict[str, List[Placement]] = {}
118
+ keys = set(model_state_dict_lst[0].keys())
119
+ for key in keys:
120
+ state_dict[key] = []
121
+ for model_state_dict in model_state_dict_lst:
122
+ try:
123
+ tensor = model_state_dict.pop(key)
124
+ except Exception:
125
+ print(f"Cannot find key {key} in rank {rank}.")
126
+
127
+ if isinstance(tensor, DTensor):
128
+ state_dict[key].append(tensor._local_tensor.bfloat16())
129
+ placements = tuple(tensor.placements)
130
+ # replicated placement at ddp dimension can be discarded
131
+ if mesh_dim_names[0] == "ddp":
132
+ placements = placements[1:]
133
+
134
+ if key not in param_placements:
135
+ param_placements[key] = placements
136
+ else:
137
+ assert param_placements[key] == placements
138
+ else:
139
+ state_dict[key].append(tensor.bfloat16())
140
+
141
+ del model_state_dict_lst
142
+
143
+ for key in sorted(state_dict):
144
+ if not isinstance(state_dict[key], list):
145
+ print(f"No need to merge key {key}")
146
+ continue
147
+
148
+ if key in param_placements:
149
+ # merge shards
150
+ placements: Tuple[Shard] = param_placements[key]
151
+ if len(mesh_shape) == 1:
152
+ # 1-D list, FSDP without TP
153
+ assert len(placements) == 1
154
+ shards = state_dict[key]
155
+ state_dict[key] = merge_by_placement(shards, placements[0])
156
+ else:
157
+ # 2-D list, FSDP + TP
158
+ raise NotImplementedError("FSDP + TP is not supported yet.")
159
+ else:
160
+ state_dict[key] = torch.cat(state_dict[key], dim=0)
161
+
162
+ print("Merge completed.")
163
+ hf_path = os.path.join(local_dir, "huggingface")
164
+ config: PretrainedConfig = AutoConfig.from_pretrained(hf_path)
165
+ architectures: List[str] = getattr(config, "architectures", ["Unknown"])
166
+
167
+ if "ForTokenClassification" in architectures[0]:
168
+ AutoClass = AutoModelForTokenClassification
169
+ elif "ForCausalLM" in architectures[0]:
170
+ AutoClass = AutoModelForCausalLM
171
+ elif "ForConditionalGeneration" in architectures[0]:
172
+ AutoClass = AutoModelForVision2Seq
173
+ else:
174
+ raise NotImplementedError(f"Unknown architecture {architectures}.")
175
+
176
+ with torch.device("meta"):
177
+ model: PreTrainedModel = AutoClass.from_config(config, torch_dtype=torch.bfloat16)
178
+
179
+ assert isinstance(model, PreTrainedModel)
180
+ model.to_empty(device="cpu")
181
+
182
+ print(f"Saving model to {hf_path}...")
183
+ model.save_pretrained(hf_path, state_dict=state_dict)
184
+ del state_dict, model
185
+
186
+ if args.hf_upload_path:
187
+ upload_model_to_huggingface(hf_path, args.hf_upload_path)
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/setup.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Bytedance Ltd. and/or its affiliates
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import os
16
+ import re
17
+
18
+ from setuptools import find_packages, setup
19
+
20
+
21
+ def get_version() -> str:
22
+ with open(os.path.join("verl", "__init__.py"), encoding="utf-8") as f:
23
+ file_content = f.read()
24
+ pattern = r"__version__\W*=\W*\"([^\"]+)\""
25
+ (version,) = re.findall(pattern, file_content)
26
+ return version
27
+
28
+
29
+ def get_requires() -> list[str]:
30
+ with open("requirements.txt", encoding="utf-8") as f:
31
+ file_content = f.read()
32
+ lines = [line.strip() for line in file_content.strip().split("\n") if not line.startswith("#")]
33
+ return lines
34
+
35
+
36
+ extra_require = {
37
+ "dev": ["pre-commit", "ruff"],
38
+ }
39
+
40
+
41
+ def main():
42
+ setup(
43
+ name="verl",
44
+ version=get_version(),
45
+ description="An Efficient, Scalable, Multi-Modality RL Training Framework based on veRL",
46
+ long_description=open("README.md", encoding="utf-8").read(),
47
+ long_description_content_type="text/markdown",
48
+ author="verl",
49
+ author_email="zhangchi.usc1992@bytedance.com, gmsheng@connect.hku.hk, hiyouga@buaa.edu.cn",
50
+ license="Apache 2.0 License",
51
+ url="https://github.com/volcengine/verl",
52
+ package_dir={"": "."},
53
+ packages=find_packages(where="."),
54
+ python_requires=">=3.9.0",
55
+ install_requires=get_requires(),
56
+ extras_require=extra_require,
57
+ )
58
+
59
+
60
+ if __name__ == "__main__":
61
+ main()
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/PKG-INFO ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: verl
3
+ Version: 0.3.1.dev0
4
+ Summary: An Efficient, Scalable, Multi-Modality RL Training Framework based on veRL
5
+ Home-page: https://github.com/volcengine/verl
6
+ Author: verl
7
+ Author-email: zhangchi.usc1992@bytedance.com, gmsheng@connect.hku.hk, hiyouga@buaa.edu.cn
8
+ License: Apache 2.0 License
9
+ Requires-Python: >=3.9.0
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: accelerate
13
+ Requires-Dist: codetiming
14
+ Requires-Dist: datasets
15
+ Requires-Dist: liger-kernel
16
+ Requires-Dist: mathruler
17
+ Requires-Dist: numpy
18
+ Requires-Dist: omegaconf
19
+ Requires-Dist: pandas
20
+ Requires-Dist: peft
21
+ Requires-Dist: pillow
22
+ Requires-Dist: pyarrow>=15.0.0
23
+ Requires-Dist: pylatexenc
24
+ Requires-Dist: qwen-vl-utils
25
+ Requires-Dist: ray[default]
26
+ Requires-Dist: tensordict
27
+ Requires-Dist: torchdata
28
+ Requires-Dist: transformers>=4.51.0
29
+ Requires-Dist: vllm>=0.7.3
30
+ Requires-Dist: wandb
31
+ Provides-Extra: dev
32
+ Requires-Dist: pre-commit; extra == "dev"
33
+ Requires-Dist: ruff; extra == "dev"
34
+ Dynamic: author
35
+ Dynamic: author-email
36
+ Dynamic: description
37
+ Dynamic: description-content-type
38
+ Dynamic: home-page
39
+ Dynamic: license
40
+ Dynamic: license-file
41
+ Dynamic: provides-extra
42
+ Dynamic: requires-dist
43
+ Dynamic: requires-python
44
+ Dynamic: summary
45
+
46
+ # EasyR1: An Efficient, Scalable, Multi-Modality RL Training Framework
47
+
48
+ [![GitHub Repo stars](https://img.shields.io/github/stars/hiyouga/EasyR1)](https://github.com/hiyouga/EasyR1/stargazers)
49
+ [![Twitter](https://img.shields.io/twitter/follow/llamafactory_ai)](https://twitter.com/llamafactory_ai)
50
+
51
+ This project is a clean fork of the original [veRL](https://github.com/volcengine/verl) project to support vision language models, we thank all the authors for providing such a high-performance RL training framework.
52
+
53
+ EasyR1 is efficient and scalable due to the design of **[HybirdEngine](https://arxiv.org/abs/2409.19256)** and the latest release of **[vLLM](https://github.com/vllm-project/vllm)**'s SPMD mode.
54
+
55
+ ## Features
56
+
57
+ - Supported models
58
+ - Llama3/Qwen2/Qwen2.5/Qwen3 language models
59
+ - Qwen2/Qwen2.5-VL vision language models
60
+ - DeepSeek-R1 distill models
61
+
62
+ - Supported algorithms
63
+ - GRPO
64
+ - Reinforce++
65
+ - ReMax
66
+ - RLOO
67
+
68
+ - Supported datasets
69
+ - Any text, vision-text dataset in a [specific format](#custom-dataset)
70
+
71
+ - Supported tricks
72
+ - Padding-free training
73
+ - Resuming from checkpoint
74
+ - Wandb & SwanLab & Mlflow & Tensorboard tracking
75
+
76
+ ## Requirements
77
+
78
+ ### Software Requirements
79
+
80
+ - Python 3.9+
81
+ - transformers>=4.51.0
82
+ - flash-attn>=2.4.3
83
+ - vllm>=0.8.3
84
+
85
+ We provide a [Dockerfile](./Dockerfile) to easily build environments.
86
+
87
+ We recommend using the [pre-built docker image](https://hub.docker.com/r/hiyouga/verl) in EasyR1.
88
+
89
+ ```bash
90
+ docker pull hiyouga/verl:ngc-th2.6.0-cu126-vllm0.8.4-flashinfer0.2.2-cxx11abi0
91
+ ```
92
+
93
+ ### Hardware Requirements
94
+
95
+ \* *estimated*
96
+
97
+ | Method | Bits | 1.5B | 3B | 7B | 32B |
98
+ | ------------------------ | ---- | ------ | ------ | ------ | ------- |
99
+ | GRPO Full Fine-Tuning | AMP | 2*24GB | 4*40GB | 8*40GB | 16*80GB |
100
+ | GRPO Full Fine-Tuning | BF16 | 1*24GB | 1*40GB | 4*40GB | 8*80GB |
101
+
102
+ > [!NOTE]
103
+ > Use `worker.actor.fsdp.torch_dtype=bf16` and `worker.actor.optim.strategy=adamw_bf16` to enable bf16 training.
104
+ >
105
+ > We are working hard to reduce the VRAM in RL training, LoRA support will be integrated in next updates.
106
+
107
+ ## Tutorial: Run Qwen2.5-VL GRPO on [Geometry3K](https://huggingface.co/datasets/hiyouga/geometry3k) Dataset in Just 3 Steps
108
+
109
+ ![image](assets/qwen2_5_vl_7b_geo.png)
110
+
111
+ ### Installation
112
+
113
+ ```bash
114
+ git clone https://github.com/hiyouga/EasyR1.git
115
+ cd EasyR1
116
+ pip install -e .
117
+ ```
118
+
119
+ ### GRPO Training
120
+
121
+ ```bash
122
+ bash examples/qwen2_5_vl_7b_geo3k_grpo.sh
123
+ ```
124
+
125
+ ### Merge Checkpoint in Hugging Face Format
126
+
127
+ ```bash
128
+ python3 scripts/model_merger.py --local_dir checkpoints/easy_r1/exp_name/global_step_1/actor
129
+ ```
130
+
131
+ > [!TIP]
132
+ > If you encounter issues with connecting to Hugging Face, consider using `export HF_ENDPOINT=https://hf-mirror.com`.
133
+ >
134
+ > If you want to use SwanLab logger, consider using `bash examples/qwen2_5_vl_7b_geo3k_swanlab.sh`.
135
+
136
+ ## Custom Dataset
137
+
138
+ Please refer to the example datasets to prepare your own dataset.
139
+
140
+ - Text dataset: https://huggingface.co/datasets/hiyouga/math12k
141
+ - Image-text dataset: https://huggingface.co/datasets/hiyouga/geometry3k
142
+ - Multi-image-text dataset: https://huggingface.co/datasets/hiyouga/journeybench-multi-image-vqa
143
+
144
+ ## How to Understand GRPO in EasyR1
145
+
146
+ ![image](assets/easyr1_grpo.png)
147
+
148
+ - To learn about the GRPO algorithm, you can refer to [Hugging Face's blog](https://huggingface.co/docs/trl/v0.16.1/en/grpo_trainer).
149
+
150
+ ## How to Run 70B+ Model in Multi-node Environment
151
+
152
+ 1. Start the Ray head node.
153
+
154
+ ```bash
155
+ ray start --head --port=6379 --dashboard-host=0.0.0.0
156
+ ```
157
+
158
+ 2. Start the Ray worker node and connect to the head node.
159
+
160
+ ```bash
161
+ ray start --address=<head_node_ip>:6379
162
+ ```
163
+
164
+ 3. Check the Ray resource pool.
165
+
166
+ ```bash
167
+ ray status
168
+ ```
169
+
170
+ 4. Run training script on the Ray head node only.
171
+
172
+ ```bash
173
+ bash examples/qwen2_5_vl_7b_geo3k_grpo.sh
174
+ ```
175
+
176
+ See the **[veRL's official doc](https://verl.readthedocs.io/en/latest/start/multinode.html)** for more details about multi-node training and Ray debugger.
177
+
178
+ ## Other Baselines
179
+
180
+ We also reproduced the following two baselines of the [R1-V](https://github.com/deep-agent/R1-V) project.
181
+ - [CLEVR-70k-Counting](examples/baselines/qwen2_5_vl_3b_clevr.sh): Train the Qwen2.5-VL-3B-Instruct model on counting problem.
182
+ - [GeoQA-8k](examples/baselines/qwen2_5_vl_3b_geoqa8k.sh): Train the Qwen2.5-VL-3B-Instruct model on GeoQA problem.
183
+
184
+ ## Performance Baselines
185
+
186
+ See [baselines.md](assets/baselines.md).
187
+
188
+ ## Awesome Work using EasyR1
189
+
190
+ - **MMR1**: Advancing the Frontiers of Multimodal Reasoning. [![[code]](https://img.shields.io/github/stars/LengSicong/MMR1)](https://github.com/LengSicong/MMR1)
191
+ - **Vision-R1**: Incentivizing Reasoning Capability in Multimodal Large Language Models. [![[code]](https://img.shields.io/github/stars/Osilly/Vision-R1)](https://github.com/Osilly/Vision-R1) [![[arxiv]](https://img.shields.io/badge/arxiv-2503.06749-blue)](https://arxiv.org/abs/2503.06749)
192
+ - **Seg-Zero**: Reasoning-Chain Guided Segmentation via Cognitive Reinforcement. [![[code]](https://img.shields.io/github/stars/dvlab-research/Seg-Zero)](https://github.com/dvlab-research/Seg-Zero) [![[arxiv]](https://img.shields.io/badge/arxiv-2503.06520-blue)](https://arxiv.org/abs/2503.06520)
193
+ - **MetaSpatial**: Reinforcing 3D Spatial Reasoning in VLMs for the Metaverse. [![[code]](https://img.shields.io/github/stars/PzySeere/MetaSpatial)](https://github.com/PzySeere/MetaSpatial) [![[arxiv]](https://img.shields.io/badge/arxiv-2503.18470-blue)](https://arxiv.org/abs/2503.18470)
194
+ - **Temporal-R1**: Envolving Temporal Reasoning Capability into LMMs via Temporal Consistent Reward. [![[code]](https://img.shields.io/github/stars/appletea233/Temporal-R1)](https://github.com/appletea233/Temporal-R1)
195
+ - **NoisyRollout**: Reinforcing Visual Reasoning with Data Augmentation. [![[code]](https://img.shields.io/github/stars/John-AI-Lab/NoisyRollout)](https://github.com/John-AI-Lab/NoisyRollout) [![[arxiv]](https://img.shields.io/badge/arxiv-2504.13055-blue)](https://arxiv.org/pdf/2504.13055)
196
+ - **GUI-R1**: A Generalist R1-Style Vision-Language Action Model For GUI Agents. [![[code]](https://img.shields.io/github/stars/ritzz-ai/GUI-R1)](https://github.com/ritzz-ai/GUI-R1) [![[arxiv]](https://img.shields.io/badge/arxiv-2504.10458-blue)](https://arxiv.org/abs/2504.10458)
197
+ - **R1-Track**: Direct Application of MLLMs to Visual Object Tracking via Reinforcement Learning. [![[code]](https://img.shields.io/github/stars/Wangbiao2/R1-Track)](https://github.com/Wangbiao2/R1-Track)
198
+ - **VisionReasoner**: Unified Visual Perception and Reasoning via Reinforcement Learning. [![[code]](https://img.shields.io/github/stars/dvlab-research/VisionReasoner)](https://github.com/dvlab-research/VisionReasoner) [![[arxiv]](https://img.shields.io/badge/arxiv-2505.12081-blue)](https://arxiv.org/abs/2505.12081)
199
+ - **MM-UPT**: Unsupervised Post-Training for Multi-Modal LLM Reasoning via GRPO. [![[code]](https://img.shields.io/github/stars/waltonfuture/MM-UPT)](https://github.com/waltonfuture/MM-UPT) [![[arxiv]](https://img.shields.io/badge/arxiv-2505.22453-blue)](https://arxiv.org/pdf/2505.22453)
200
+ - **RL-with-Cold-Start**: Advancing Multimodal Reasoning via Reinforcement Learning with Cold Start. [![[code]](https://img.shields.io/github/stars/waltonfuture/RL-with-Cold-Start)](https://github.com/waltonfuture/RL-with-Cold-Start) [![[arxiv]](https://img.shields.io/badge/arxiv-2505.22334-blue)](https://arxiv.org/pdf/2505.22334)
201
+ - **ViGoRL**: Grounded Reinforcement Learning for Visual Reasoning. [![[code]](https://img.shields.io/github/stars/Gabesarch/grounded-rl)](https://github.com/Gabesarch/grounded-rl) [![[arxiv]](https://img.shields.io/badge/arxiv-2505.22334-blue)](https://arxiv.org/abs/2505.23678)
202
+ - **Revisual-R1**: Advancing Multimodal Reasoning: From Optimized Cold Start to Staged Reinforcement Learning. [![[code]](https://img.shields.io/github/stars/CSfufu/Revisual-R1)](https://github.com/CSfufu/Revisual-R1) [![[arxiv]](https://img.shields.io/badge/arxiv-2506.04207-blue)](https://arxiv.org/abs/2506.04207)
203
+ - **SophiaVL-R1**: Reinforcing MLLMs Reasoning with Thinking Reward. [![[code]](https://img.shields.io/github/stars/kxfan2002/SophiaVL-R1)](https://github.com/kxfan2002/SophiaVL-R1) [![[arxiv]](https://img.shields.io/badge/arxiv-2505.17018-blue)](https://arxiv.org/abs/2505.17018)
204
+
205
+ ## TODO
206
+
207
+ - Support LoRA (high priority).
208
+ - Support ulysses parallelism for VLMs (middle priority).
209
+ - Support more VLM architectures.
210
+
211
+ > [!NOTE]
212
+ > We will not provide scripts for supervised fine-tuning and inference in this project. If you have such requirements, we recommend using [LLaMA-Factory](https://github.com/hiyouga/LLaMA-Factory).
213
+
214
+ ### Known bugs
215
+
216
+ These features are temporarily disabled for now, we plan to fix them one-by-one in the future updates.
217
+
218
+ - Vision language models are not compatible with ulysses parallelism yet.
219
+
220
+ ## Discussion Group
221
+
222
+ 👋 Join our [WeChat group](assets/wechat.jpg).
223
+
224
+ ## FAQs
225
+
226
+ > ValueError: Image features and image tokens do not match: tokens: 8192, features 9800
227
+
228
+ Increase the `data.max_prompt_length` or reduce the `data.max_pixels`.
229
+
230
+ > RuntimeError: CUDA Error: out of memory at /workspace/csrc/cumem_allocator.cpp:62
231
+
232
+ Reduce the `worker.rollout.gpu_memory_utilization` and enable `worker.actor.offload.offload_params`.
233
+
234
+ > RuntimeError: 0 active drivers ([]). There should only be one.
235
+
236
+ Uninstall `deepspeed` from the current python environment.
237
+
238
+ ## Citation
239
+
240
+ Core contributors: [Yaowei Zheng](https://github.com/hiyouga), [Junting Lu](https://github.com/AL-377), [Shenzhi Wang](https://github.com/Shenzhi-Wang), [Zhangchi Feng](https://github.com/BUAADreamer), [Dongdong Kuang](https://github.com/Kuangdd01) and Yuwen Xiong
241
+
242
+ We also thank Guangming Sheng and Chi Zhang for helpful discussions.
243
+
244
+ ```bibtex
245
+ @misc{zheng2025easyr1,
246
+ title = {EasyR1: An Efficient, Scalable, Multi-Modality RL Training Framework},
247
+ author = {Yaowei Zheng, Junting Lu, Shenzhi Wang, Zhangchi Feng, Dongdong Kuang, Yuwen Xiong},
248
+ howpublished = {\url{https://github.com/hiyouga/EasyR1}},
249
+ year = {2025}
250
+ }
251
+ ```
252
+
253
+ We recommend to also cite the original work.
254
+
255
+ ```bibtex
256
+ @article{sheng2024hybridflow,
257
+ title = {HybridFlow: A Flexible and Efficient RLHF Framework},
258
+ author = {Guangming Sheng and Chi Zhang and Zilingfeng Ye and Xibin Wu and Wang Zhang and Ru Zhang and Yanghua Peng and Haibin Lin and Chuan Wu},
259
+ year = {2024},
260
+ journal = {arXiv preprint arXiv: 2409.19256}
261
+ }
262
+ ```
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/SOURCES.txt ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ ./verl/__init__.py
6
+ ./verl/protocol.py
7
+ ./verl/models/__init__.py
8
+ ./verl/models/monkey_patch.py
9
+ ./verl/models/transformers/__init__.py
10
+ ./verl/models/transformers/flash_attention_utils.py
11
+ ./verl/models/transformers/qwen2_vl.py
12
+ ./verl/single_controller/__init__.py
13
+ ./verl/single_controller/base/__init__.py
14
+ ./verl/single_controller/base/decorator.py
15
+ ./verl/single_controller/base/worker.py
16
+ ./verl/single_controller/base/worker_group.py
17
+ ./verl/single_controller/base/register_center/__init__.py
18
+ ./verl/single_controller/base/register_center/ray.py
19
+ ./verl/single_controller/ray/__init__.py
20
+ ./verl/single_controller/ray/base.py
21
+ ./verl/trainer/__init__.py
22
+ ./verl/trainer/config.py
23
+ ./verl/trainer/core_algos.py
24
+ ./verl/trainer/data_loader.py
25
+ ./verl/trainer/main.py
26
+ ./verl/trainer/metrics.py
27
+ ./verl/trainer/ray_trainer.py
28
+ ./verl/utils/__init__.py
29
+ ./verl/utils/dataset.py
30
+ ./verl/utils/flops_counter.py
31
+ ./verl/utils/fsdp_utils.py
32
+ ./verl/utils/model_utils.py
33
+ ./verl/utils/py_functional.py
34
+ ./verl/utils/seqlen_balancing.py
35
+ ./verl/utils/tokenizer.py
36
+ ./verl/utils/torch_dtypes.py
37
+ ./verl/utils/torch_functional.py
38
+ ./verl/utils/ulysses.py
39
+ ./verl/utils/checkpoint/__init__.py
40
+ ./verl/utils/checkpoint/checkpoint_manager.py
41
+ ./verl/utils/checkpoint/fsdp_checkpoint_manager.py
42
+ ./verl/utils/logger/__init__.py
43
+ ./verl/utils/logger/gen_logger.py
44
+ ./verl/utils/logger/logger.py
45
+ ./verl/workers/__init__.py
46
+ ./verl/workers/config.py
47
+ ./verl/workers/fsdp_workers.py
48
+ ./verl/workers/actor/__init__.py
49
+ ./verl/workers/actor/base.py
50
+ ./verl/workers/actor/config.py
51
+ ./verl/workers/actor/dp_actor.py
52
+ ./verl/workers/critic/__init__.py
53
+ ./verl/workers/critic/base.py
54
+ ./verl/workers/critic/config.py
55
+ ./verl/workers/critic/dp_critic.py
56
+ ./verl/workers/reward/__init__.py
57
+ ./verl/workers/reward/config.py
58
+ ./verl/workers/reward/function.py
59
+ ./verl/workers/rollout/__init__.py
60
+ ./verl/workers/rollout/base.py
61
+ ./verl/workers/rollout/config.py
62
+ ./verl/workers/rollout/vllm_rollout_spmd.py
63
+ ./verl/workers/sharding_manager/__init__.py
64
+ ./verl/workers/sharding_manager/base.py
65
+ ./verl/workers/sharding_manager/fsdp_ulysses.py
66
+ ./verl/workers/sharding_manager/fsdp_vllm.py
67
+ verl/__init__.py
68
+ verl/protocol.py
69
+ verl.egg-info/PKG-INFO
70
+ verl.egg-info/SOURCES.txt
71
+ verl.egg-info/dependency_links.txt
72
+ verl.egg-info/requires.txt
73
+ verl.egg-info/top_level.txt
74
+ verl/models/__init__.py
75
+ verl/models/monkey_patch.py
76
+ verl/models/transformers/__init__.py
77
+ verl/models/transformers/flash_attention_utils.py
78
+ verl/models/transformers/qwen2_vl.py
79
+ verl/single_controller/__init__.py
80
+ verl/single_controller/base/__init__.py
81
+ verl/single_controller/base/decorator.py
82
+ verl/single_controller/base/worker.py
83
+ verl/single_controller/base/worker_group.py
84
+ verl/single_controller/base/register_center/__init__.py
85
+ verl/single_controller/base/register_center/ray.py
86
+ verl/single_controller/ray/__init__.py
87
+ verl/single_controller/ray/base.py
88
+ verl/trainer/__init__.py
89
+ verl/trainer/config.py
90
+ verl/trainer/core_algos.py
91
+ verl/trainer/data_loader.py
92
+ verl/trainer/main.py
93
+ verl/trainer/metrics.py
94
+ verl/trainer/ray_trainer.py
95
+ verl/utils/__init__.py
96
+ verl/utils/dataset.py
97
+ verl/utils/flops_counter.py
98
+ verl/utils/fsdp_utils.py
99
+ verl/utils/model_utils.py
100
+ verl/utils/py_functional.py
101
+ verl/utils/seqlen_balancing.py
102
+ verl/utils/tokenizer.py
103
+ verl/utils/torch_dtypes.py
104
+ verl/utils/torch_functional.py
105
+ verl/utils/ulysses.py
106
+ verl/utils/checkpoint/__init__.py
107
+ verl/utils/checkpoint/checkpoint_manager.py
108
+ verl/utils/checkpoint/fsdp_checkpoint_manager.py
109
+ verl/utils/logger/__init__.py
110
+ verl/utils/logger/gen_logger.py
111
+ verl/utils/logger/logger.py
112
+ verl/workers/__init__.py
113
+ verl/workers/config.py
114
+ verl/workers/fsdp_workers.py
115
+ verl/workers/actor/__init__.py
116
+ verl/workers/actor/base.py
117
+ verl/workers/actor/config.py
118
+ verl/workers/actor/dp_actor.py
119
+ verl/workers/critic/__init__.py
120
+ verl/workers/critic/base.py
121
+ verl/workers/critic/config.py
122
+ verl/workers/critic/dp_critic.py
123
+ verl/workers/reward/__init__.py
124
+ verl/workers/reward/config.py
125
+ verl/workers/reward/function.py
126
+ verl/workers/rollout/__init__.py
127
+ verl/workers/rollout/base.py
128
+ verl/workers/rollout/config.py
129
+ verl/workers/rollout/vllm_rollout_spmd.py
130
+ verl/workers/sharding_manager/__init__.py
131
+ verl/workers/sharding_manager/base.py
132
+ verl/workers/sharding_manager/fsdp_ulysses.py
133
+ verl/workers/sharding_manager/fsdp_vllm.py
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/dependency_links.txt ADDED
@@ -0,0 +1 @@
 
 
1
+
MedEvalKit/LLaVA-NeXT/llava-critic-r1/EasyR1/verl.egg-info/requires.txt ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate
2
+ codetiming
3
+ datasets
4
+ liger-kernel
5
+ mathruler
6
+ numpy
7
+ omegaconf
8
+ pandas
9
+ peft
10
+ pillow
11
+ pyarrow>=15.0.0
12
+ pylatexenc
13
+ qwen-vl-utils
14
+ ray[default]
15
+ tensordict
16
+ torchdata
17
+ transformers>=4.51.0
18
+ vllm>=0.7.3
19
+ wandb
20
+
21
+ [dev]
22
+ pre-commit
23
+ ruff