Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
@@ -48,14 +48,28 @@ def load_model(model_name):
|
|
48 |
del model
|
49 |
torch.cuda.empty_cache()
|
50 |
|
51 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# Ensure the padding token is set
|
54 |
if tokenizer.pad_token is None:
|
55 |
tokenizer.pad_token = tokenizer.eos_token
|
56 |
tokenizer.add_special_tokens({'pad_token': tokenizer.eos_token})
|
57 |
|
58 |
-
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
selected_model = model_name
|
60 |
except Exception as e:
|
61 |
print(f"Error loading model {model_name}: {e}")
|
|
|
48 |
del model
|
49 |
torch.cuda.empty_cache()
|
50 |
|
51 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
52 |
+
models[model_name],
|
53 |
+
padding_side='left',
|
54 |
+
use_auth_token=hugging_face_token,
|
55 |
+
trust_remote_code=True
|
56 |
+
)
|
57 |
|
58 |
# Ensure the padding token is set
|
59 |
if tokenizer.pad_token is None:
|
60 |
tokenizer.pad_token = tokenizer.eos_token
|
61 |
tokenizer.add_special_tokens({'pad_token': tokenizer.eos_token})
|
62 |
|
63 |
+
model = AutoModelForCausalLM.from_pretrained(
|
64 |
+
models[model_name],
|
65 |
+
use_auth_token=hugging_face_token,
|
66 |
+
trust_remote_code=True
|
67 |
+
)
|
68 |
+
|
69 |
+
# Only move to CUDA if it's not a quantized model
|
70 |
+
if model_name not in quantized_models:
|
71 |
+
model = model.to("cuda")
|
72 |
+
|
73 |
selected_model = model_name
|
74 |
except Exception as e:
|
75 |
print(f"Error loading model {model_name}: {e}")
|