当前位置:   article > 正文

Peft库使用技巧(一):合并基座模型与Lora模型【使用Peft库微调基座模型(比如LLaMA-7B)后会得到Lora参数模块,将基座模型与Lora参数合并后才能得到完整的微调后的大模型】_peft库如何将adapt和模型合并

peft库如何将adapt和模型合并

使用Peft库微调基座模型(比如LLaMA-7B)后会得到Lora参数模块,将基座模型与Lora参数合并后才能得到完整的微调后的大模型

  1. # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import Optional
  15. from peft import PeftModel
  16. import fire
  17. import torch
  18. import tqdm
  19. import transformers
  20. @torch.inference_mode()
  21. def merge(
  22. path_zhixi,
  23. path_lora,
  24. p
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/空白诗007/article/detail/960764
推荐阅读
相关标签
  

闽ICP备14008679号