# Proper way of saving/loading models for complex workflows

**URL:** <https://discuss.huggingface.co/t/proper-way-of-saving-loading-models-for-complex-workflows/163970>\
**Category:** 🤗Transformers\
**Created:** [July 21, 2025, 2:53pm UTC](https://discuss.huggingface.co/t/proper-way-of-saving-loading-models-for-complex-workflows/163970 "2025-07-21T14:53:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [July 22, 2025, 1:47am UTC](https://discuss.huggingface.co/t/proper-way-of-saving-loading-models-for-complex-workflows/163970/2 "2025-07-22T01:47:24Z")

</div>

I think the base model path in the PEFT adapter configuration may be pointing to the model on the hub. How about like this?

```py
    peft_config = LoraConfig(
        r=4,
        lora_alpha=32,
        task_type=TaskType.SEQ_CLS,
        target_modules="all-linear"
    )
    model = get_peft_model(base_model, peft_config)

    model.save_pretrained(path_to_dir)

    # Overwrite adapter_config to point to local base model
    peft_cfg = PeftConfig.from_pretrained(path_to_dir)
    peft_cfg.base_model_name_or_path = str(path_to_dir)
    peft_cfg.save_pretrained(path_to_dir)

    model.base_model.save_pretrained(path_to_dir)
    tokenizer.save_pretrained(path_to_dir)

```

### References

> [@Correct way to save/load adapters and checkpoints in PEFT](https://discuss.huggingface.co/t/correct-way-to-save-load-adapters-and-checkpoints-in-peft/77836):
>
> Hi, It is not clear to me what is the correct way to save/load a PEFT checkpoint, as well as the final fine-tuned model. There have been reports of trainer.resume\_from\_checkpoint not working as expected [[1]](https://github.com/huggingface/transformers/issues/24330)[[2]](https://github.com/huggingface/transformers/issues/24252)[[3]](https://discuss.huggingface.co/t/retraining-peft-model/43829), each of which have very few replies, or do not seem to have any sort of consensus. Proposed solutions range from trainer.save\_model, to trainer.save\_state to resume\_from\_checkpoint=True to model.save\_pretrained [(PEFT docs)](https://huggingface.co/docs/transformers/main/en/peft) to even a very complicated procedure of merging and saving the…

> **[PEFT](https://huggingface.co/docs/transformers/main/peft)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

_[View the full topic](https://discuss.huggingface.co/t/proper-way-of-saving-loading-models-for-complex-workflows/163970)._
