Upload folder using huggingface_hub
Browse files- README.md +4 -0
- modeling_internvl_chat.py +2 -1
README.md
CHANGED
@@ -144,6 +144,7 @@ model = AutoModel.from_pretrained(
|
|
144 |
path,
|
145 |
torch_dtype=torch.bfloat16,
|
146 |
low_cpu_mem_usage=True,
|
|
|
147 |
trust_remote_code=True).eval().cuda()
|
148 |
```
|
149 |
|
@@ -158,6 +159,7 @@ model = AutoModel.from_pretrained(
|
|
158 |
torch_dtype=torch.bfloat16,
|
159 |
load_in_8bit=True,
|
160 |
low_cpu_mem_usage=True,
|
|
|
161 |
trust_remote_code=True).eval()
|
162 |
```
|
163 |
|
@@ -206,6 +208,7 @@ model = AutoModel.from_pretrained(
|
|
206 |
path,
|
207 |
torch_dtype=torch.bfloat16,
|
208 |
low_cpu_mem_usage=True,
|
|
|
209 |
trust_remote_code=True,
|
210 |
device_map=device_map).eval()
|
211 |
```
|
@@ -331,6 +334,7 @@ model = AutoModel.from_pretrained(
|
|
331 |
torch_dtype=torch.bfloat16,
|
332 |
load_in_8bit=True,
|
333 |
low_cpu_mem_usage=True,
|
|
|
334 |
trust_remote_code=True,
|
335 |
device_map=device_map).eval()
|
336 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
|
|
|
144 |
path,
|
145 |
torch_dtype=torch.bfloat16,
|
146 |
low_cpu_mem_usage=True,
|
147 |
+
use_flash_attn=True,
|
148 |
trust_remote_code=True).eval().cuda()
|
149 |
```
|
150 |
|
|
|
159 |
torch_dtype=torch.bfloat16,
|
160 |
load_in_8bit=True,
|
161 |
low_cpu_mem_usage=True,
|
162 |
+
use_flash_attn=True,
|
163 |
trust_remote_code=True).eval()
|
164 |
```
|
165 |
|
|
|
208 |
path,
|
209 |
torch_dtype=torch.bfloat16,
|
210 |
low_cpu_mem_usage=True,
|
211 |
+
use_flash_attn=True,
|
212 |
trust_remote_code=True,
|
213 |
device_map=device_map).eval()
|
214 |
```
|
|
|
334 |
torch_dtype=torch.bfloat16,
|
335 |
load_in_8bit=True,
|
336 |
low_cpu_mem_usage=True,
|
337 |
+
use_flash_attn=True,
|
338 |
trust_remote_code=True,
|
339 |
device_map=device_map).eval()
|
340 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
|
modeling_internvl_chat.py
CHANGED
@@ -17,7 +17,7 @@ from transformers.utils import ModelOutput, logging
|
|
17 |
|
18 |
from .configuration_internvl_chat import InternVLChatConfig
|
19 |
from .conversation import get_conv_template
|
20 |
-
from .modeling_intern_vit import InternVisionModel
|
21 |
|
22 |
logger = logging.get_logger(__name__)
|
23 |
|
@@ -48,6 +48,7 @@ class InternVLChatModel(PreTrainedModel):
|
|
48 |
self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
|
49 |
self.downsample_ratio = config.downsample_ratio
|
50 |
self.ps_version = config.ps_version
|
|
|
51 |
config.vision_config.use_flash_attn = True if use_flash_attn else False
|
52 |
config.llm_config._attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
53 |
|
|
|
17 |
|
18 |
from .configuration_internvl_chat import InternVLChatConfig
|
19 |
from .conversation import get_conv_template
|
20 |
+
from .modeling_intern_vit import InternVisionModel, has_flash_attn
|
21 |
|
22 |
logger = logging.get_logger(__name__)
|
23 |
|
|
|
48 |
self.num_image_token = int((image_size // patch_size) ** 2 * (config.downsample_ratio ** 2))
|
49 |
self.downsample_ratio = config.downsample_ratio
|
50 |
self.ps_version = config.ps_version
|
51 |
+
use_flash_attn = use_flash_attn if has_flash_attn else False
|
52 |
config.vision_config.use_flash_attn = True if use_flash_attn else False
|
53 |
config.llm_config._attn_implementation = 'flash_attention_2' if use_flash_attn else 'eager'
|
54 |
|