fix compatibility issue for transformers 4.46+
Browse files- configuration_intern_vit.py +1 -0
- configuration_internvl_chat.py +3 -3
- conversation.py +15 -17
- eval_llm_benchmark.log +53 -0
- modeling_intern_vit.py +1 -0
- modeling_internvl_chat.py +6 -7
configuration_intern_vit.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
|
|
6 |
import os
|
7 |
from typing import Union
|
8 |
|
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
6 |
+
|
7 |
import os
|
8 |
from typing import Union
|
9 |
|
configuration_internvl_chat.py
CHANGED
@@ -47,12 +47,12 @@ class InternVLChatConfig(PretrainedConfig):
|
|
47 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
48 |
|
49 |
self.vision_config = InternVisionConfig(**vision_config)
|
50 |
-
if llm_config['architectures'][0] == 'LlamaForCausalLM':
|
51 |
self.llm_config = LlamaConfig(**llm_config)
|
52 |
-
elif llm_config['architectures'][0] == 'InternLM2ForCausalLM':
|
53 |
self.llm_config = InternLM2Config(**llm_config)
|
54 |
else:
|
55 |
-
raise ValueError('Unsupported architecture: {}'.format(llm_config['architectures'][0]))
|
56 |
self.use_backbone_lora = use_backbone_lora
|
57 |
self.use_llm_lora = use_llm_lora
|
58 |
self.select_layer = select_layer
|
|
|
47 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
48 |
|
49 |
self.vision_config = InternVisionConfig(**vision_config)
|
50 |
+
if llm_config.get(['architectures'])[0] == 'LlamaForCausalLM':
|
51 |
self.llm_config = LlamaConfig(**llm_config)
|
52 |
+
elif llm_config.get(['architectures'])[0] == 'InternLM2ForCausalLM':
|
53 |
self.llm_config = InternLM2Config(**llm_config)
|
54 |
else:
|
55 |
+
raise ValueError('Unsupported architecture: {}'.format(llm_config.get(['architectures'])[0]))
|
56 |
self.use_backbone_lora = use_backbone_lora
|
57 |
self.use_llm_lora = use_llm_lora
|
58 |
self.select_layer = select_layer
|
conversation.py
CHANGED
@@ -3,11 +3,13 @@ Conversation prompt templates.
|
|
3 |
|
4 |
We kindly request that you import fastchat instead of copying this file if you wish to use it.
|
5 |
If you have changes in mind, please contribute back so the community can benefit collectively and continue to maintain these valuable templates.
|
|
|
|
|
6 |
"""
|
7 |
|
8 |
import dataclasses
|
9 |
from enum import IntEnum, auto
|
10 |
-
from typing import
|
11 |
|
12 |
|
13 |
class SeparatorStyle(IntEnum):
|
@@ -344,12 +346,6 @@ register_conv_template(
|
|
344 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
345 |
sep_style=SeparatorStyle.MPT,
|
346 |
sep='<|im_end|>',
|
347 |
-
stop_token_ids=[
|
348 |
-
2,
|
349 |
-
6,
|
350 |
-
7,
|
351 |
-
8,
|
352 |
-
],
|
353 |
stop_str='<|endoftext|>',
|
354 |
)
|
355 |
)
|
@@ -365,11 +361,6 @@ register_conv_template(
|
|
365 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
366 |
sep_style=SeparatorStyle.MPT,
|
367 |
sep='<|im_end|>',
|
368 |
-
stop_token_ids=[
|
369 |
-
2,
|
370 |
-
92543,
|
371 |
-
92542
|
372 |
-
]
|
373 |
)
|
374 |
)
|
375 |
|
@@ -384,10 +375,17 @@ register_conv_template(
|
|
384 |
roles=('<|user|>\n', '<|assistant|>\n'),
|
385 |
sep_style=SeparatorStyle.MPT,
|
386 |
sep='<|end|>',
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
)
|
393 |
)
|
|
|
3 |
|
4 |
We kindly request that you import fastchat instead of copying this file if you wish to use it.
|
5 |
If you have changes in mind, please contribute back so the community can benefit collectively and continue to maintain these valuable templates.
|
6 |
+
|
7 |
+
Modified from https://github.com/lm-sys/FastChat/blob/main/fastchat/conversation.py
|
8 |
"""
|
9 |
|
10 |
import dataclasses
|
11 |
from enum import IntEnum, auto
|
12 |
+
from typing import Dict, List, Tuple, Union
|
13 |
|
14 |
|
15 |
class SeparatorStyle(IntEnum):
|
|
|
346 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
347 |
sep_style=SeparatorStyle.MPT,
|
348 |
sep='<|im_end|>',
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
stop_str='<|endoftext|>',
|
350 |
)
|
351 |
)
|
|
|
361 |
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
362 |
sep_style=SeparatorStyle.MPT,
|
363 |
sep='<|im_end|>',
|
|
|
|
|
|
|
|
|
|
|
364 |
)
|
365 |
)
|
366 |
|
|
|
375 |
roles=('<|user|>\n', '<|assistant|>\n'),
|
376 |
sep_style=SeparatorStyle.MPT,
|
377 |
sep='<|end|>',
|
378 |
+
)
|
379 |
+
)
|
380 |
+
|
381 |
+
|
382 |
+
register_conv_template(
|
383 |
+
Conversation(
|
384 |
+
name='internvl2_5',
|
385 |
+
system_template='<|im_start|>system\n{system_message}',
|
386 |
+
system_message='你是书生·万象,英文名是InternVL,是由上海人工智能实验室、清华大学及多家合作单位联合开发的多模态大语言模型。',
|
387 |
+
roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
|
388 |
+
sep_style=SeparatorStyle.MPT,
|
389 |
+
sep='<|im_end|>\n',
|
390 |
)
|
391 |
)
|
eval_llm_benchmark.log
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/mnt/petrelfs/wangweiyun/miniconda3/envs/internvl_eval/lib/python3.10/site-packages/bitsandbytes/cextension.py:34: UserWarning: The installed version of bitsandbytes was compiled without GPU support. 8-bit optimizers, 8-bit multiplication, and GPU quantization are unavailable.
|
2 |
+
warn("The installed version of bitsandbytes was compiled without GPU support. "
|
3 |
+
/mnt/petrelfs/wangweiyun/miniconda3/envs/internvl_eval/lib/python3.10/site-packages/bitsandbytes/libbitsandbytes_cpu.so: undefined symbol: cadam32bit_grad_fp32
|
4 |
+
model path is /mnt/petrelfs/wangweiyun/workspace_cz/InternVL/internvl_chat_dev/share_internvl/InternVL2-8B
|
5 |
+
09/30 19:08:03 - OpenCompass - WARNING - No previous results to reuse!
|
6 |
+
09/30 19:08:03 - OpenCompass - INFO - Reusing experiements from 20240930_190803
|
7 |
+
09/30 19:08:03 - OpenCompass - INFO - Current exp folder: /mnt/petrelfs/wangweiyun/workspace_cz/InternVL/internvl_chat_dev/share_internvl/InternVL2-8B/20240930_190803
|
8 |
+
09/30 19:08:06 - OpenCompass - INFO - Partitioned into 64 tasks.
|
9 |
+
[ ] 0/64, elapsed: 0s, ETA:
|
10 |
+
09/30 19:52:33 - OpenCompass - INFO - Partitioned into 287 tasks.
|
11 |
+
[ ] 0/287, elapsed: 0s, ETA:
|
12 |
+
dataset version metric mode internvl-chat-20b
|
13 |
+
---------------------------- --------- ---------------------------- ------ -------------------
|
14 |
+
mmlu - naive_average gen 73.17
|
15 |
+
cmmlu - naive_average gen 79.21
|
16 |
+
ceval - naive_average gen 80.14
|
17 |
+
agieval - - - -
|
18 |
+
GaokaoBench - weighted_average gen 74.99
|
19 |
+
triviaqa 2121ce score gen 62.03
|
20 |
+
triviaqa_wiki_1shot - - - -
|
21 |
+
nq 3dcea1 score gen 28.12
|
22 |
+
C3 8c358f accuracy gen 94.19
|
23 |
+
race-high 9a54b6 accuracy gen 90.82
|
24 |
+
flores_100 - - - -
|
25 |
+
winogrande b36770 accuracy gen 85.87
|
26 |
+
hellaswag e42710 accuracy gen 94.91
|
27 |
+
bbh - naive_average gen 72.67
|
28 |
+
gsm8k 1d7fe4 accuracy gen 75.59
|
29 |
+
math 393424 accuracy gen 39.50
|
30 |
+
TheoremQA 6f0af8 score gen 15.62
|
31 |
+
MathBench - - - -
|
32 |
+
openai_humaneval 8e312c humaneval_pass@1 gen 69.51
|
33 |
+
humanevalx - - - -
|
34 |
+
sanitized_mbpp a447ff score gen 58.75
|
35 |
+
mbpp_cn 6fb572 score gen 48.20
|
36 |
+
leval - - - -
|
37 |
+
leval_closed - - - -
|
38 |
+
leval_open - - - -
|
39 |
+
longbench - - - -
|
40 |
+
longbench_single-document-qa - - - -
|
41 |
+
longbench_multi-document-qa - - - -
|
42 |
+
longbench_summarization - - - -
|
43 |
+
longbench_few-shot-learning - - - -
|
44 |
+
longbench_synthetic-tasks - - - -
|
45 |
+
longbench_code-completion - - - -
|
46 |
+
teval - - - -
|
47 |
+
teval_zh - - - -
|
48 |
+
IFEval 3321a3 Prompt-level-strict-accuracy gen 52.31
|
49 |
+
IFEval 3321a3 Inst-level-strict-accuracy gen 62.71
|
50 |
+
IFEval 3321a3 Prompt-level-loose-accuracy gen 54.90
|
51 |
+
IFEval 3321a3 Inst-level-loose-accuracy gen 64.87
|
52 |
+
09/30 19:55:16 - OpenCompass - INFO - write summary to /mnt/petrelfs/wangweiyun/workspace_cz/InternVL/internvl_chat_dev/share_internvl/InternVL2-8B/20240930_190803/summary/summary_20240930_190803.txt
|
53 |
+
09/30 19:55:16 - OpenCompass - INFO - write csv to /mnt/petrelfs/wangweiyun/workspace_cz/InternVL/internvl_chat_dev/share_internvl/InternVL2-8B/20240930_190803/summary/summary_20240930_190803.csv
|
modeling_intern_vit.py
CHANGED
@@ -3,6 +3,7 @@
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
|
|
6 |
from typing import Optional, Tuple, Union
|
7 |
|
8 |
import torch
|
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
6 |
+
|
7 |
from typing import Optional, Tuple, Union
|
8 |
|
9 |
import torch
|
modeling_internvl_chat.py
CHANGED
@@ -3,8 +3,9 @@
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
|
|
6 |
import warnings
|
7 |
-
from typing import
|
8 |
|
9 |
import torch.utils.checkpoint
|
10 |
import transformers
|
@@ -237,7 +238,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
237 |
model_inputs = tokenizer(queries, return_tensors='pt', padding=True)
|
238 |
input_ids = model_inputs['input_ids'].to(self.device)
|
239 |
attention_mask = model_inputs['attention_mask'].to(self.device)
|
240 |
-
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep)
|
241 |
generation_config['eos_token_id'] = eos_token_id
|
242 |
generation_output = self.generate(
|
243 |
pixel_values=pixel_values,
|
@@ -246,7 +247,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
246 |
**generation_config
|
247 |
)
|
248 |
responses = tokenizer.batch_decode(generation_output, skip_special_tokens=True)
|
249 |
-
responses = [response.split(template.sep)[0].strip() for response in responses]
|
250 |
return responses
|
251 |
|
252 |
def chat(self, tokenizer, pixel_values, question, generation_config, history=None, return_history=False,
|
@@ -265,7 +266,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
265 |
|
266 |
template = get_conv_template(self.template)
|
267 |
template.system_message = self.system_message
|
268 |
-
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep)
|
269 |
|
270 |
history = [] if history is None else history
|
271 |
for (old_question, old_answer) in history:
|
@@ -294,7 +295,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
294 |
**generation_config
|
295 |
)
|
296 |
response = tokenizer.batch_decode(generation_output, skip_special_tokens=True)[0]
|
297 |
-
response = response.split(template.sep)[0].strip()
|
298 |
history.append((question, response))
|
299 |
if return_history:
|
300 |
return response, history
|
@@ -314,7 +315,6 @@ class InternVLChatModel(PreTrainedModel):
|
|
314 |
visual_features: Optional[torch.FloatTensor] = None,
|
315 |
generation_config: Optional[GenerationConfig] = None,
|
316 |
output_hidden_states: Optional[bool] = None,
|
317 |
-
return_dict: Optional[bool] = None,
|
318 |
**generate_kwargs,
|
319 |
) -> torch.LongTensor:
|
320 |
|
@@ -342,7 +342,6 @@ class InternVLChatModel(PreTrainedModel):
|
|
342 |
attention_mask=attention_mask,
|
343 |
generation_config=generation_config,
|
344 |
output_hidden_states=output_hidden_states,
|
345 |
-
return_dict=return_dict,
|
346 |
use_cache=True,
|
347 |
**generate_kwargs,
|
348 |
)
|
|
|
3 |
# Copyright (c) 2024 OpenGVLab
|
4 |
# Licensed under The MIT License [see LICENSE for details]
|
5 |
# --------------------------------------------------------
|
6 |
+
|
7 |
import warnings
|
8 |
+
from typing import List, Optional, Tuple, Union
|
9 |
|
10 |
import torch.utils.checkpoint
|
11 |
import transformers
|
|
|
238 |
model_inputs = tokenizer(queries, return_tensors='pt', padding=True)
|
239 |
input_ids = model_inputs['input_ids'].to(self.device)
|
240 |
attention_mask = model_inputs['attention_mask'].to(self.device)
|
241 |
+
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep.strip())
|
242 |
generation_config['eos_token_id'] = eos_token_id
|
243 |
generation_output = self.generate(
|
244 |
pixel_values=pixel_values,
|
|
|
247 |
**generation_config
|
248 |
)
|
249 |
responses = tokenizer.batch_decode(generation_output, skip_special_tokens=True)
|
250 |
+
responses = [response.split(template.sep.strip())[0].strip() for response in responses]
|
251 |
return responses
|
252 |
|
253 |
def chat(self, tokenizer, pixel_values, question, generation_config, history=None, return_history=False,
|
|
|
266 |
|
267 |
template = get_conv_template(self.template)
|
268 |
template.system_message = self.system_message
|
269 |
+
eos_token_id = tokenizer.convert_tokens_to_ids(template.sep.strip())
|
270 |
|
271 |
history = [] if history is None else history
|
272 |
for (old_question, old_answer) in history:
|
|
|
295 |
**generation_config
|
296 |
)
|
297 |
response = tokenizer.batch_decode(generation_output, skip_special_tokens=True)[0]
|
298 |
+
response = response.split(template.sep.strip())[0].strip()
|
299 |
history.append((question, response))
|
300 |
if return_history:
|
301 |
return response, history
|
|
|
315 |
visual_features: Optional[torch.FloatTensor] = None,
|
316 |
generation_config: Optional[GenerationConfig] = None,
|
317 |
output_hidden_states: Optional[bool] = None,
|
|
|
318 |
**generate_kwargs,
|
319 |
) -> torch.LongTensor:
|
320 |
|
|
|
342 |
attention_mask=attention_mask,
|
343 |
generation_config=generation_config,
|
344 |
output_hidden_states=output_hidden_states,
|
|
|
345 |
use_cache=True,
|
346 |
**generate_kwargs,
|
347 |
)
|