Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,18 +45,19 @@ def load_model():
|
|
| 45 |
if tokenizer.pad_token is None:
|
| 46 |
tokenizer.pad_token = tokenizer.eos_token
|
| 47 |
|
| 48 |
-
# 3. Load and fix the PeftConfig (
|
| 49 |
-
# We
|
| 50 |
-
#
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
# to 'text-generation', which is disallowed by newer PEFT versions.
|
| 56 |
-
peft_config.task_type = "CAUSAL_LM"
|
| 57 |
|
| 58 |
# 4. Load the LoRA adapter weights using the corrected config object
|
| 59 |
-
# The 'config' argument now correctly receives a PeftConfig object.
|
| 60 |
model = PeftModel.from_pretrained(
|
| 61 |
base_model,
|
| 62 |
LORA_MODEL_ID,
|
|
|
|
| 45 |
if tokenizer.pad_token is None:
|
| 46 |
tokenizer.pad_token = tokenizer.eos_token
|
| 47 |
|
| 48 |
+
# 3. Load and fix the PeftConfig (FINAL FIX)
|
| 49 |
+
# We pass the desired task_type directly as a keyword argument to PeftConfig.from_pretrained.
|
| 50 |
+
# This overrides the invalid 'text-generation' value in the remote config file,
|
| 51 |
+
# ensuring the configuration object is created successfully before validation fails.
|
| 52 |
+
print("Loading and fixing PeftConfig with direct override...")
|
| 53 |
+
peft_config = PeftConfig.from_pretrained(
|
| 54 |
+
LORA_MODEL_ID,
|
| 55 |
+
task_type="CAUSAL_LM" # <-- CRITICAL OVERRIDE HERE
|
| 56 |
+
)
|
| 57 |
|
| 58 |
+
# We no longer need the explicit line: peft_config.task_type = "CAUSAL_LM"
|
|
|
|
|
|
|
| 59 |
|
| 60 |
# 4. Load the LoRA adapter weights using the corrected config object
|
|
|
|
| 61 |
model = PeftModel.from_pretrained(
|
| 62 |
base_model,
|
| 63 |
LORA_MODEL_ID,
|