当前位置:   article > 正文

Peft库使用技巧(二):删除、合并微调参数【从全参数微调后的模型参数中剔除基座模型参数(冻结),然后发布自己训练的这部分参数模块】_peft使用

peft使用

从全参数微调后的模型参数中剔除基座模型参数(冻结),然后发布自己训练的这部分参数模块

  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. # from train import smart_tokenizer_and_embedding_resize
  21. @torch.inference_mode()
  22. def make_diff(
本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/479221
推荐阅读
相关标签
  

闽ICP备14008679号