Update README.md
Browse files- LICENSE +51 -0
- README.md +7 -11
- config.json +1 -57
- configuration_internvl_chat.py +2 -2
- modeling_internvl_chat.py +1 -1
- vocab.json +0 -0
LICENSE
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Qwen LICENSE AGREEMENT
|
2 |
+
|
3 |
+
Qwen LICENSE AGREEMENT Release Date: September 19, 2024
|
4 |
+
|
5 |
+
By clicking to agree or by using or distributing any portion or element of the Qwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
6 |
+
|
7 |
+
1. Definitions
|
8 |
+
a. This Qwen LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
9 |
+
b. "We" (or "Us") shall mean Alibaba Cloud.
|
10 |
+
c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
|
11 |
+
d. "Third Parties" shall mean individuals or legal entities that are not under common control with us or you.
|
12 |
+
e. "Qwen" shall mean the large language models, and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by us.
|
13 |
+
f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Qwen and Documentation (and any portion thereof) made available under this Agreement.
|
14 |
+
g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
|
15 |
+
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
16 |
+
|
17 |
+
2. Grant of Rights
|
18 |
+
You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Alibaba Cloud's intellectual property or other rights owned by us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials.
|
19 |
+
|
20 |
+
3. Redistribution
|
21 |
+
You may distribute copies or make the Materials, or derivative works thereof, available as part of a product or service that contains any of them, with or without modifications, and in Source or Object form, provided that you meet the following conditions:
|
22 |
+
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
23 |
+
b. You shall cause any modified files to carry prominent notices stating that you changed the files;
|
24 |
+
c. You shall retain in all copies of the Materials that you distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Qwen is licensed under the Qwen LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."; and
|
25 |
+
d. You may add your own copyright statement to your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of your modifications, or for any such derivative works as a whole, provided your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
26 |
+
|
27 |
+
4. Restrictions
|
28 |
+
If you are commercially using the Materials, and your product or service has more than 100 million monthly active users, you shall request a license from us. You cannot exercise your rights under this Agreement without our express authorization.
|
29 |
+
|
30 |
+
5. Rules of use
|
31 |
+
a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
|
32 |
+
b. If you use the Materials or any outputs or results therefrom to create, train, fine-tune, or improve an AI model that is distributed or made available, you shall prominently display “Built with Qwen” or “Improved using Qwen” in the related product documentation.
|
33 |
+
|
34 |
+
6. Intellectual Property
|
35 |
+
a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
|
36 |
+
b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
|
37 |
+
c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licenses granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
|
38 |
+
|
39 |
+
7. Disclaimer of Warranty and Limitation of Liability
|
40 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Qwen Materials or to grant any license thereto.
|
41 |
+
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
42 |
+
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
43 |
+
d. You will defend, indemnify and hold harmless us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
|
44 |
+
|
45 |
+
8. Survival and Termination.
|
46 |
+
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
47 |
+
b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 7 and 9 shall survive the termination of this Agreement.
|
48 |
+
|
49 |
+
9. Governing Law and Jurisdiction.
|
50 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
51 |
+
b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
|
README.md
CHANGED
@@ -4,10 +4,8 @@ license_name: qwen
|
|
4 |
license_link: https://huggingface.co/Qwen/Qwen2.5-72B-Instruct/blob/main/LICENSE
|
5 |
pipeline_tag: image-text-to-text
|
6 |
library_name: transformers
|
7 |
-
base_model:
|
8 |
-
|
9 |
-
- Qwen/Qwen2.5-72B-Instruct
|
10 |
-
base_model_relation: merge
|
11 |
language:
|
12 |
- multilingual
|
13 |
tags:
|
@@ -83,7 +81,7 @@ The training pipeline for a single model in InternVL 2.5 is structured across th
|
|
83 |
|
84 |
We introduce a progressive scaling strategy to align the vision encoder with LLMs efficiently. This approach trains with smaller LLMs first (e.g., 20B) to optimize foundational visual capabilities and cross-modal alignment before transferring the vision encoder to larger LLMs (e.g., 72B) without retraining. This reuse skips intermediate stages for larger models.
|
85 |
|
86 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/
|
87 |
|
88 |
Compared to Qwen2-VL's 1.4 trillion tokens, InternVL2.5-78B uses only 120 billion tokens—less than one-tenth. This strategy minimizes redundancy, maximizes pre-trained component reuse, and enables efficient training for complex vision-language tasks.
|
89 |
|
@@ -166,7 +164,7 @@ As shown in the following figure, from InternVL 1.5 to 2.0 and then to 2.5, the
|
|
166 |
|
167 |
### Video Understanding
|
168 |
|
169 |
-
![image/png](https://cdn-uploads.huggingface.co/production/uploads/
|
170 |
|
171 |
## Evaluation on Language Capability
|
172 |
|
@@ -178,10 +176,10 @@ Training InternVL 2.0 models led to a decline in pure language capabilities. Int
|
|
178 |
|
179 |
### LMDeploy
|
180 |
|
181 |
-
LMDeploy is a toolkit for compressing, deploying, and serving
|
182 |
|
183 |
```sh
|
184 |
-
pip install lmdeploy>=0.
|
185 |
```
|
186 |
|
187 |
LMDeploy abstracts the complex inference process of multi-modal Vision-Language Models (VLM) into an easy-to-use pipeline, similar to the Large Language Model (LLM) inference pipeline.
|
@@ -205,8 +203,6 @@ If `ImportError` occurs while executing this case, please install the required d
|
|
205 |
|
206 |
When dealing with multiple images, you can put them all in one list. Keep in mind that multiple images will lead to a higher number of input tokens, and as a result, the size of the context window typically needs to be increased.
|
207 |
|
208 |
-
question = 'Describe this video in detail.'
|
209 |
-
|
210 |
```python
|
211 |
from lmdeploy import pipeline, TurbomindEngineConfig
|
212 |
from lmdeploy.vl import load_image
|
@@ -270,7 +266,7 @@ print(sess.response.text)
|
|
270 |
LMDeploy's `api_server` enables models to be easily packed into services with a single command. The provided RESTful APIs are compatible with OpenAI's interfaces. Below are an example of service startup:
|
271 |
|
272 |
```shell
|
273 |
-
lmdeploy serve api_server OpenGVLab/InternVL2_5-78B-AWQ --
|
274 |
```
|
275 |
|
276 |
To use the OpenAI-style interface, you need to install OpenAI:
|
|
|
4 |
license_link: https://huggingface.co/Qwen/Qwen2.5-72B-Instruct/blob/main/LICENSE
|
5 |
pipeline_tag: image-text-to-text
|
6 |
library_name: transformers
|
7 |
+
base_model: OpenGVLab/InternVL2_5-78B
|
8 |
+
base_model_relation: quantized
|
|
|
|
|
9 |
language:
|
10 |
- multilingual
|
11 |
tags:
|
|
|
81 |
|
82 |
We introduce a progressive scaling strategy to align the vision encoder with LLMs efficiently. This approach trains with smaller LLMs first (e.g., 20B) to optimize foundational visual capabilities and cross-modal alignment before transferring the vision encoder to larger LLMs (e.g., 72B) without retraining. This reuse skips intermediate stages for larger models.
|
83 |
|
84 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/UoNUyS7ctN5pBxNv9KnzH.png)
|
85 |
|
86 |
Compared to Qwen2-VL's 1.4 trillion tokens, InternVL2.5-78B uses only 120 billion tokens—less than one-tenth. This strategy minimizes redundancy, maximizes pre-trained component reuse, and enables efficient training for complex vision-language tasks.
|
87 |
|
|
|
164 |
|
165 |
### Video Understanding
|
166 |
|
167 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/tcwH-i1qc8H16En-7AZ5M.png)
|
168 |
|
169 |
## Evaluation on Language Capability
|
170 |
|
|
|
176 |
|
177 |
### LMDeploy
|
178 |
|
179 |
+
LMDeploy is a toolkit for compressing, deploying, and serving LLMs & VLMs.
|
180 |
|
181 |
```sh
|
182 |
+
pip install lmdeploy>=0.6.4
|
183 |
```
|
184 |
|
185 |
LMDeploy abstracts the complex inference process of multi-modal Vision-Language Models (VLM) into an easy-to-use pipeline, similar to the Large Language Model (LLM) inference pipeline.
|
|
|
203 |
|
204 |
When dealing with multiple images, you can put them all in one list. Keep in mind that multiple images will lead to a higher number of input tokens, and as a result, the size of the context window typically needs to be increased.
|
205 |
|
|
|
|
|
206 |
```python
|
207 |
from lmdeploy import pipeline, TurbomindEngineConfig
|
208 |
from lmdeploy.vl import load_image
|
|
|
266 |
LMDeploy's `api_server` enables models to be easily packed into services with a single command. The provided RESTful APIs are compatible with OpenAI's interfaces. Below are an example of service startup:
|
267 |
|
268 |
```shell
|
269 |
+
lmdeploy serve api_server OpenGVLab/InternVL2_5-78B-AWQ --server-port 23333 --tp 4
|
270 |
```
|
271 |
|
272 |
To use the OpenAI-style interface, you need to install OpenAI:
|
config.json
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
{
|
2 |
"_commit_hash": null,
|
3 |
-
"_name_or_path": "/mnt/bigdisk/InternVL2_5-78B/InternVL2_5-78B",
|
4 |
"architectures": [
|
5 |
"InternVLChatModel"
|
6 |
],
|
@@ -18,8 +17,8 @@
|
|
18 |
"architectures": [
|
19 |
"Qwen2ForCausalLM"
|
20 |
],
|
21 |
-
"attention_dropout": 0.0,
|
22 |
"attn_implementation": "eager",
|
|
|
23 |
"bad_words_ids": null,
|
24 |
"begin_suppress_tokens": null,
|
25 |
"bos_token_id": 151643,
|
@@ -110,91 +109,36 @@
|
|
110 |
"select_layer": -1,
|
111 |
"template": "internvl2_5",
|
112 |
"torch_dtype": "float16",
|
113 |
-
"transformers_version": null,
|
114 |
"use_backbone_lora": 0,
|
115 |
"use_llm_lora": 0,
|
116 |
"use_thumbnail": true,
|
117 |
"vision_config": {
|
118 |
-
"_name_or_path": "",
|
119 |
-
"add_cross_attention": false,
|
120 |
"architectures": [
|
121 |
"InternVisionModel"
|
122 |
],
|
123 |
"attention_dropout": 0.0,
|
124 |
-
"bad_words_ids": null,
|
125 |
-
"begin_suppress_tokens": null,
|
126 |
-
"bos_token_id": null,
|
127 |
-
"chunk_size_feed_forward": 0,
|
128 |
-
"cross_attention_hidden_size": null,
|
129 |
-
"decoder_start_token_id": null,
|
130 |
-
"diversity_penalty": 0.0,
|
131 |
-
"do_sample": false,
|
132 |
"drop_path_rate": 0.0,
|
133 |
"dropout": 0.0,
|
134 |
-
"early_stopping": false,
|
135 |
-
"encoder_no_repeat_ngram_size": 0,
|
136 |
-
"eos_token_id": null,
|
137 |
-
"exponential_decay_length_penalty": null,
|
138 |
-
"finetuning_task": null,
|
139 |
-
"forced_bos_token_id": null,
|
140 |
-
"forced_eos_token_id": null,
|
141 |
"hidden_act": "gelu",
|
142 |
"hidden_size": 3200,
|
143 |
-
"id2label": {
|
144 |
-
"0": "LABEL_0",
|
145 |
-
"1": "LABEL_1"
|
146 |
-
},
|
147 |
"image_size": 448,
|
148 |
"initializer_factor": 0.1,
|
149 |
"initializer_range": 1e-10,
|
150 |
"intermediate_size": 12800,
|
151 |
-
"is_decoder": false,
|
152 |
-
"is_encoder_decoder": false,
|
153 |
-
"label2id": {
|
154 |
-
"LABEL_0": 0,
|
155 |
-
"LABEL_1": 1
|
156 |
-
},
|
157 |
"layer_norm_eps": 1e-06,
|
158 |
-
"length_penalty": 1.0,
|
159 |
-
"max_length": 20,
|
160 |
-
"min_length": 0,
|
161 |
"model_type": "intern_vit_6b",
|
162 |
-
"no_repeat_ngram_size": 0,
|
163 |
"norm_type": "rms_norm",
|
164 |
"num_attention_heads": 25,
|
165 |
-
"num_beam_groups": 1,
|
166 |
-
"num_beams": 1,
|
167 |
"num_channels": 3,
|
168 |
"num_hidden_layers": 45,
|
169 |
-
"num_return_sequences": 1,
|
170 |
"output_attentions": false,
|
171 |
"output_hidden_states": false,
|
172 |
-
"output_scores": false,
|
173 |
-
"pad_token_id": null,
|
174 |
"patch_size": 14,
|
175 |
-
"prefix": null,
|
176 |
-
"problem_type": null,
|
177 |
-
"pruned_heads": {},
|
178 |
"qk_normalization": true,
|
179 |
"qkv_bias": false,
|
180 |
-
"remove_invalid_values": false,
|
181 |
-
"repetition_penalty": 1.0,
|
182 |
"return_dict": true,
|
183 |
-
"return_dict_in_generate": false,
|
184 |
-
"sep_token_id": null,
|
185 |
-
"suppress_tokens": null,
|
186 |
-
"task_specific_params": null,
|
187 |
-
"temperature": 1.0,
|
188 |
-
"tf_legacy_loss": false,
|
189 |
-
"tie_encoder_decoder": false,
|
190 |
-
"tie_word_embeddings": true,
|
191 |
-
"tokenizer_class": null,
|
192 |
-
"top_k": 50,
|
193 |
-
"top_p": 1.0,
|
194 |
"torch_dtype": "bfloat16",
|
195 |
-
"torchscript": false,
|
196 |
"transformers_version": "4.46.0.dev0",
|
197 |
-
"typical_p": 1.0,
|
198 |
"use_bfloat16": true,
|
199 |
"use_flash_attn": true
|
200 |
}
|
|
|
1 |
{
|
2 |
"_commit_hash": null,
|
|
|
3 |
"architectures": [
|
4 |
"InternVLChatModel"
|
5 |
],
|
|
|
17 |
"architectures": [
|
18 |
"Qwen2ForCausalLM"
|
19 |
],
|
|
|
20 |
"attn_implementation": "eager",
|
21 |
+
"attention_dropout": 0.0,
|
22 |
"bad_words_ids": null,
|
23 |
"begin_suppress_tokens": null,
|
24 |
"bos_token_id": 151643,
|
|
|
109 |
"select_layer": -1,
|
110 |
"template": "internvl2_5",
|
111 |
"torch_dtype": "float16",
|
|
|
112 |
"use_backbone_lora": 0,
|
113 |
"use_llm_lora": 0,
|
114 |
"use_thumbnail": true,
|
115 |
"vision_config": {
|
|
|
|
|
116 |
"architectures": [
|
117 |
"InternVisionModel"
|
118 |
],
|
119 |
"attention_dropout": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
"drop_path_rate": 0.0,
|
121 |
"dropout": 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
"hidden_act": "gelu",
|
123 |
"hidden_size": 3200,
|
|
|
|
|
|
|
|
|
124 |
"image_size": 448,
|
125 |
"initializer_factor": 0.1,
|
126 |
"initializer_range": 1e-10,
|
127 |
"intermediate_size": 12800,
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
"layer_norm_eps": 1e-06,
|
|
|
|
|
|
|
129 |
"model_type": "intern_vit_6b",
|
|
|
130 |
"norm_type": "rms_norm",
|
131 |
"num_attention_heads": 25,
|
|
|
|
|
132 |
"num_channels": 3,
|
133 |
"num_hidden_layers": 45,
|
|
|
134 |
"output_attentions": false,
|
135 |
"output_hidden_states": false,
|
|
|
|
|
136 |
"patch_size": 14,
|
|
|
|
|
|
|
137 |
"qk_normalization": true,
|
138 |
"qkv_bias": false,
|
|
|
|
|
139 |
"return_dict": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
"torch_dtype": "bfloat16",
|
|
|
141 |
"transformers_version": "4.46.0.dev0",
|
|
|
142 |
"use_bfloat16": true,
|
143 |
"use_flash_attn": true
|
144 |
}
|
configuration_internvl_chat.py
CHANGED
@@ -38,11 +38,11 @@ class InternVLChatConfig(PretrainedConfig):
|
|
38 |
super().__init__(**kwargs)
|
39 |
|
40 |
if vision_config is None:
|
41 |
-
vision_config = {}
|
42 |
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')
|
43 |
|
44 |
if llm_config is None:
|
45 |
-
llm_config = {}
|
46 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
47 |
|
48 |
self.vision_config = InternVisionConfig(**vision_config)
|
|
|
38 |
super().__init__(**kwargs)
|
39 |
|
40 |
if vision_config is None:
|
41 |
+
vision_config = {'architectures': ['InternVisionModel']}
|
42 |
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')
|
43 |
|
44 |
if llm_config is None:
|
45 |
+
llm_config = {'architectures': ['Qwen2ForCausalLM']}
|
46 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
47 |
|
48 |
self.vision_config = InternVisionConfig(**vision_config)
|
modeling_internvl_chat.py
CHANGED
@@ -111,7 +111,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
111 |
B, N, C = input_embeds.shape
|
112 |
input_embeds = input_embeds.reshape(B * N, C)
|
113 |
|
114 |
-
if torch.distributed.get_rank() == 0:
|
115 |
print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
|
116 |
|
117 |
input_ids = input_ids.reshape(B * N)
|
|
|
111 |
B, N, C = input_embeds.shape
|
112 |
input_embeds = input_embeds.reshape(B * N, C)
|
113 |
|
114 |
+
if torch.distributed.is_initialized() and torch.distributed.get_rank() == 0:
|
115 |
print(f'dynamic ViT batch size: {vit_batch_size}, images per sample: {vit_batch_size / B}, dynamic token length: {N}')
|
116 |
|
117 |
input_ids = input_ids.reshape(B * N)
|
vocab.json
CHANGED
The diff for this file is too large to render.
See raw diff
|
|