Downloads · 30 days
155
4% of all-time downloads
RichardErkhov/LoftQ_-_phi-2-4bit-64rank-gguf
LoftQ_-_phi-2-4bit-64rank-gguf is a machine learning model from RichardErkhov. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
155
4% of all-time downloads
All-time downloads
4K
Public
Repo size
28.5 GB
Likes
0
Public
Click a slice to open those files.
.gguf33.6 GB · 100%
From the Hugging Face model README
Quantization made by Richard Erkhov.
phi-2-4bit-64rank - GGUF
| Name | Quant method | Size |
|---|---|---|
| phi-2-4bit-64rank.Q2_K.gguf | Q2_K | 1.03GB |
| phi-2-4bit-64rank.Q3_K_S.gguf | Q3_K_S | 1.16GB |
| phi-2-4bit-64rank.Q3_K.gguf | Q3_K | 1.33GB |
| phi-2-4bit-64rank.Q3_K_M.gguf | Q3_K_M | 1.33GB |
| phi-2-4bit-64rank.Q3_K_L.gguf | Q3_K_L | 1.47GB |
| phi-2-4bit-64rank.IQ4_XS.gguf | IQ4_XS | 1.43GB |
| phi-2-4bit-64rank.Q4_0.gguf | Q4_0 | 1.49GB |
| phi-2-4bit-64rank.IQ4_NL.gguf | IQ4_NL | 1.5GB |
| phi-2-4bit-64rank.Q4_K_S.gguf | Q4_K_S | 1.51GB |
| phi-2-4bit-64rank.Q4_K.gguf | Q4_K | 1.62GB |
| phi-2-4bit-64rank.Q4_K_M.gguf | Q4_K_M | 1.62GB |
| phi-2-4bit-64rank.Q4_1.gguf | Q4_1 | 1.65GB |
| phi-2-4bit-64rank.Q5_0.gguf | Q5_0 | 1.8GB |
| phi-2-4bit-64rank.Q5_K_S.gguf | Q5_K_S | 1.8GB |
| phi-2-4bit-64rank.Q5_K.gguf | Q5_K | 1.87GB |
| phi-2-4bit-64rank.Q5_K_M.gguf | Q5_K_M | 1.87GB |
| phi-2-4bit-64rank.Q5_1.gguf | Q5_1 | 1.95GB |
| phi-2-4bit-64rank.Q6_K.gguf | Q6_K | 2.13GB |
| phi-2-4bit-64rank.Q8_0.gguf | Q8_0 | 2.75GB |
license: mit language:
| 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, phi-2-4bit-64rank, is obtained from phi-2.
The backbone is under LoftQ/phi-2-4bit-64rank and LoRA adapters are under the subfolder='loftq_init'.
torch.float16Training 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-2-4bit-64rank"
base_model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.float32, # you may change it with different models
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float32, # float32 is tested and veryfied
bnb_4bit_use_double_quant=False,
bnb_4bit_quant_type='nf4',
),
)
peft_model = PeftModel.from_pretrained(
base_model,
MODEL_ID,
subfolder="loftq_init",
is_trainable=True,
)
# Do training with peft_model ...
We have conducted experiments on supervised fine-tuning of GSM8K.
| Model | Bits | Rank | LoRA Initial | GSM8K |
|---|---|---|---|---|
| Phi-2 | 16 | - | Full model fine-tuning | 66.8±1.2 |
| Phi-2 | 16 | 64 | Gaussian + 0 (LoRA) | 64.8±0.5 |
| Phi-2 | 4 | 64 | Gaussian + 0 (QLoRA) | 60.2±0.6 |
| Phi-2 | 4 | 64 | LoftQ | 64.1±0.7 |
Inference Here is an example code for inference after the model has been fine-tuned on GSM8K.
import torch
from transformers import AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
MODEL_ID = "LoftQ/phi-2-4bit-64rank"
base_model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.float32, # you may change it with different models
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float32, # float32 is tested and veryfied
bnb_4bit_use_double_quant=False,
bnb_4bit_quant_type='nf4',
),
)
peft_model = PeftModel.from_pretrained(
base_model,
MODEL_ID,
subfolder="gsm8k",
is_trainable=True,
)
# Do inference 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}
}