LoftQ Phi
Collection
LoftQ initialization of Phi-2 and Phi-3
•
3 items
•
Updated
•
1
| Paper | Code | PEFT Example |
LoftQ (LoRA-fine-tuning-aware Quantization) provides a quantized backbone Q and LoRA adapters A and B, given a full-precision pre-trained weight W.
This model, LoftQ/Phi-3-mini-4k-instruct-4bit-64rank
, is obtained from Phi-3-mini-4k-instruct.
The backbone is under LoftQ/Phi-3-mini-4k-instruct-4bit-64rank
and LoRA adapters are under the subfolder='loftq_init'
.
Training Here's an example of loading this model and preparing for the LoRA fine-tuning.
import torch
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
MODEL_ID = "LoftQ/Phi-3-mini-4k-instruct-4bit-64rank"
base_model = AutoModelForCausalLM.from_pretrained(MODEL_ID, trust_remote_code=True)
peft_model = PeftModel.from_pretrained(
base_model,
MODEL_ID,
subfolder="loftq_init",
is_trainable=True,
)
# Do training with peft_model ...
See the full code at our Github Repo
@article{li2023loftq,
title={Loftq: Lora-fine-tuning-aware quantization for large language models},
author={Li, Yixiao and Yu, Yifan and Liang, Chen and He, Pengcheng and Karampatziakis, Nikos and Chen, Weizhu and Zhao, Tuo},
journal={arXiv preprint arXiv:2310.08659},
year={2023}
}