Upload folder using huggingface_hub
Browse files
modeling_internvl_chat.py
CHANGED
@@ -18,7 +18,7 @@ from transformers.utils import ModelOutput, logging
|
|
18 |
|
19 |
from .configuration_internvl_chat import InternVLChatConfig
|
20 |
from .conversation import get_conv_template
|
21 |
-
from .modeling_intern_vit import InternVisionModel
|
22 |
from .modeling_internlm2 import InternLM2ForCausalLM
|
23 |
|
24 |
logger = logging.get_logger(__name__)
|
@@ -50,6 +50,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
50 |
self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
|
51 |
self.downsample_ratio = config.downsample_ratio
|
52 |
self.ps_version = config.ps_version
|
|
|
53 |
config.vision_config.use_flash_attn = True if use_flash_attn else False
|
54 |
config.llm_config.attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
55 |
|
|
|
18 |
|
19 |
from .configuration_internvl_chat import InternVLChatConfig
|
20 |
from .conversation import get_conv_template
|
21 |
+
from .modeling_intern_vit import InternVisionModel, has_flash_attn
|
22 |
from .modeling_internlm2 import InternLM2ForCausalLM
|
23 |
|
24 |
logger = logging.get_logger(__name__)
|
|
|
50 |
self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
|
51 |
self.downsample_ratio = config.downsample_ratio
|
52 |
self.ps_version = config.ps_version
|
53 |
+
use_flash_attn = use_flash_attn if has_flash_attn else False
|
54 |
config.vision_config.use_flash_attn = True if use_flash_attn else False
|
55 |
config.llm_config.attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
56 |
|