Spaces:
Configuration error
Configuration error
DoctorSlimm
commited on
Commit
•
9c5835b
1
Parent(s):
da98440
Update app.py
Browse files
app.py
CHANGED
@@ -8,10 +8,14 @@ from huggingface_hub import snapshot_download
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
9 |
|
10 |
|
11 |
-
#
|
12 |
# MODEL_PATH = "THUDM/cogvlm2-llama3-chat-19B"
|
|
|
|
|
13 |
MODEL_PATH = "THUDM/cogvlm2-llama3-chat-19B-int4"
|
14 |
|
|
|
|
|
15 |
os.environ['HF_HUB_ENABLE_HF_TRANSFER'] = '1'
|
16 |
MODEL_PATH = snapshot_download(MODEL_PATH)
|
17 |
move_cache()
|
@@ -19,10 +23,14 @@ move_cache()
|
|
19 |
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
20 |
TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
|
21 |
|
|
|
|
|
22 |
tokenizer = AutoTokenizer.from_pretrained(
|
23 |
MODEL_PATH,
|
24 |
trust_remote_code=True
|
25 |
)
|
|
|
|
|
26 |
model = AutoModelForCausalLM.from_pretrained(
|
27 |
MODEL_PATH,
|
28 |
torch_dtype=TORCH_TYPE,
|
|
|
8 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
9 |
|
10 |
|
11 |
+
# https://huggingface.co/THUDM/cogvlm2-llama3-chat-19B
|
12 |
# MODEL_PATH = "THUDM/cogvlm2-llama3-chat-19B"
|
13 |
+
|
14 |
+
# https://huggingface.co/THUDM/cogvlm2-llama3-chat-19B-int4
|
15 |
MODEL_PATH = "THUDM/cogvlm2-llama3-chat-19B-int4"
|
16 |
|
17 |
+
|
18 |
+
### DOWNLOAD ###
|
19 |
os.environ['HF_HUB_ENABLE_HF_TRANSFER'] = '1'
|
20 |
MODEL_PATH = snapshot_download(MODEL_PATH)
|
21 |
move_cache()
|
|
|
23 |
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
24 |
TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
|
25 |
|
26 |
+
|
27 |
+
## MODEL ##
|
28 |
tokenizer = AutoTokenizer.from_pretrained(
|
29 |
MODEL_PATH,
|
30 |
trust_remote_code=True
|
31 |
)
|
32 |
+
|
33 |
+
## TOKENIZER ##
|
34 |
model = AutoModelForCausalLM.from_pretrained(
|
35 |
MODEL_PATH,
|
36 |
torch_dtype=TORCH_TYPE,
|