Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -57,28 +57,13 @@ def load_model(model_name, progress=gr.Progress()):
|
|
57 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
58 |
progress(0.5, desc="Chargement du modèle")
|
59 |
|
60 |
-
#
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
load_in_8bit=True
|
68 |
-
)
|
69 |
-
elif "llama" in model_name.lower() or "mistral" in model_name.lower():
|
70 |
-
model = AutoModelForCausalLM.from_pretrained(
|
71 |
-
model_name,
|
72 |
-
torch_dtype=torch.float16,
|
73 |
-
device_map="auto",
|
74 |
-
attn_implementation="flash_attention_2"
|
75 |
-
)
|
76 |
-
else:
|
77 |
-
model = AutoModelForCausalLM.from_pretrained(
|
78 |
-
model_name,
|
79 |
-
torch_dtype=torch.float16,
|
80 |
-
device_map="auto"
|
81 |
-
)
|
82 |
|
83 |
if tokenizer.pad_token is None:
|
84 |
tokenizer.pad_token = tokenizer.eos_token
|
|
|
57 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
58 |
progress(0.5, desc="Chargement du modèle")
|
59 |
|
60 |
+
# Configuration générique pour tous les modèles
|
61 |
+
model = AutoModelForCausalLM.from_pretrained(
|
62 |
+
model_name,
|
63 |
+
torch_dtype=torch.float16,
|
64 |
+
device_map="auto",
|
65 |
+
low_cpu_mem_usage=True
|
66 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
if tokenizer.pad_token is None:
|
69 |
tokenizer.pad_token = tokenizer.eos_token
|