Load_adapter vs from_pretrained

Hello, everyone.

when using peft library,

Scenario

model = AutoModel.from_pretrained(“your_model”)
model = get_peft_model(model, lora_config)
model.save_pretrained(“my_dir”)

After executing the code above, let’s discuss the differences in the following approaches:

Approach 1

model = AutoModel.from_pretrained(“your_model”)
model = PeftModel.from_pretrained(model, “my_dir”)

Approach 2

model = AutoModel.from_pretrained(“your_model”)
model.load_adapter(“my_dir”)

what is different between the two approaches??

I think both approaches are equivalent according to the source code:

        if config.task_type not in MODEL_TYPE_TO_PEFT_MODEL_MAPPING.keys():
            model = cls(model, config, adapter_name)
        else:
            model = MODEL_TYPE_TO_PEFT_MODEL_MAPPING[config.task_type](model, config, adapter_name)
        model.load_adapter(model_id, adapter_name, is_trainable=is_trainable, **kwargs)
        return model