Woziii commited on
Commit
984dc97
1 Parent(s): 41a1911

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -22
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
- # Configurations spécifiques par modèle
61
- if "mixtral" in model_name.lower():
62
- model = AutoModelForCausalLM.from_pretrained(
63
- model_name,
64
- torch_dtype=torch.float16,
65
- device_map="auto",
66
- attn_implementation="flash_attention_2",
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