-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
Problem Description
I'm experiencing a significant accuracy drop when loading a LoRA adapter for inference. During training evaluation, the model achieves ~70% accuracy, but when I load the saved LoRA weights for inference, accuracy drops to ~2% (essentially random predictions). But inference with full fine-tuned model (non-LoRA): Works correctly ✓
LoRA Configuration
{
"base_model_name_or_path": "Qwen/Qwen2.5-VL-7B-Instruct",
"bias": "none",
"inference_mode": true,
"lora_alpha": 64,
"lora_dropout": 0.05,
"peft_type": "LORA",
"r": 64,
"target_modules": [
"score", // Classification head
"q_proj", "v_proj", "k_proj", "o_proj",
// ... other MLP layers
],
"task_type": "CAUSAL_LM"
}Inference Code Snippet
# Loading base model
model = Qwen2_5_VLForSequenceClassification.from_pretrained(
base_model_path,
config=config,
torch_dtype=torch.bfloat16,
trust_remote_code=True
)
# Loading LoRA adapter
from peft import PeftModel
model = PeftModel.from_pretrained(model, lora_checkpoint_path)
model = model.merge_and_unload() # Also tried without merging
model.eval()
# Inference results in ~2% accuracyWhat I've Tried
- ✓ Verified that
adapter_model.binandadapter_config.jsonare saved correctly - ✓ Confirmed that
non_lora_state_dict.bincontains the classification head weights - ✓ Tried both with and without
merge_and_unload() - ✓ Verified the base model path is correct
- ✓ Checked that CLASS_2_ID mapping is consistent between training and inference
Suspected Issues
- Classification head initialization: The classification head might be getting re-initialized during LoRA loading
- State dict merging: The non-LoRA parameters (including classification head) might not be loaded correctly
- Task type mismatch: Using
task_type="CAUSAL_LM"for a classification task
Thanks a lot for your time and help!
Metadata
Metadata
Assignees
Labels
No labels