使用 LoRA 微调
用低秩适配器在单张 GPU 上适配大模型。
使用 LoRA 微调
低秩适配器让你无需更新全部权重即可微调大模型。
from peft import LoraConfig, get_peft_model
config = LoraConfig(r=8, lora_alpha=16, target_modules=['q_proj', 'v_proj'])
model = get_peft_model(base_model, config)
model.print_trainable_parameters()
适配器只有几兆,因此可以在同一基座模型旁挂载多个。