Peft ライブラリを使用するためのヒント (1): ベース モデルと Lora モデルのマージ [Peft ライブラリを使用してベース モデル (LLaMA-7B など) を微調整すると、Lora パラメータ モジュールと完全なパラメータ モジュールが取得されます。微調整は、基本モデルと Lora パラメータをマージした後にのみ取得できます。大規模モデルの後]

Peft ライブラリを使用してベース モデル (LLaMA-7B など) を微調整した後、Lora パラメータ モジュールが取得されます。完全な微調整された大規模モデルは、ベース モデルと Lora パラメータを組み合わせた後にのみ取得できます。

#    Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from typing import Optional
from peft import PeftModel
import fire
import torch
import tqdm
import transformers


@torch.inference_mode()
def merge(
    path_zhixi,
    path_lora,
    p

おすすめ

転載: blog.csdn.net/u013250861/article/details/131489135