Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -92,16 +92,20 @@ def load_model(model_path, progress=gr.Progress()):
|
|
92 |
|
93 |
try:
|
94 |
progress(0.3, desc="Loading tokenizer...")
|
95 |
-
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True
|
96 |
-
|
|
|
|
|
|
|
|
|
97 |
|
98 |
progress(0.5, desc="Loading model...")
|
99 |
current_model = AutoModelForCausalLM.from_pretrained(
|
100 |
model_path,
|
101 |
device_map="auto",
|
102 |
torch_dtype=torch.float16,
|
103 |
-
config=config,
|
104 |
-
trust_remote_code=True
|
105 |
)
|
106 |
|
107 |
current_model_path = model_path
|
|
|
92 |
|
93 |
try:
|
94 |
progress(0.3, desc="Loading tokenizer...")
|
95 |
+
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
|
96 |
+
if 'MoE' in model_path:
|
97 |
+
config_moe = config
|
98 |
+
config_moe["auto_map"]["AutoConfig"] = "./configuration_upcycling_qwen2_moe.UpcyclingQwen2MoeConfig"
|
99 |
+
config_moe["auto_map"]["AutoModelForCausalLM"] = "./modeling_upcycling_qwen2_moe.UpcyclingQwen2MoeForCausalLM"
|
100 |
+
current_tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False,trust_remote_code=True)
|
101 |
|
102 |
progress(0.5, desc="Loading model...")
|
103 |
current_model = AutoModelForCausalLM.from_pretrained(
|
104 |
model_path,
|
105 |
device_map="auto",
|
106 |
torch_dtype=torch.float16,
|
107 |
+
config=config_moe if 'MoE' in model_path else config,
|
108 |
+
trust_remote_code=True
|
109 |
)
|
110 |
|
111 |
current_model_path = model_path
|