mployd-engineering commited on
Commit
692d002
·
verified ·
1 Parent(s): 2aa01b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
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 (NEW FIX)
49
- # We must load the config object first, modify the incompatible field,
50
- # and then pass the corrected object to PeftModel.from_pretrained.
51
- print("Loading and fixing PeftConfig...")
52
- peft_config = PeftConfig.from_pretrained(LORA_MODEL_ID)
 
 
 
 
53
 
54
- # CRITICAL FIX: The pre-trained LoRA adapter config sometimes incorrectly defaults
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,