Instructions to use thisisaditichouhan/Phi-2-4bit-Quantized-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use thisisaditichouhan/Phi-2-4bit-Quantized-Model with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("microsoft/phi-2") model = PeftModel.from_pretrained(base_model, "thisisaditichouhan/Phi-2-4bit-Quantized-Model") - Notebooks
- Google Colab
- Kaggle
Phi-2 4-bit Quantized Model (with LoRA Adapter)
This repository contains a 4-bit quantized version of Microsoft's Phi-2 model, prepared using bitsandbytes and wrapped with a LoRA adapter via the PEFT library.
Model Description
The original Phi-2 model runs on 16-bit precision (Float16) and consumes a lot of memory. To make it highly efficient and runnable on free-tier cloud GPUs (like Google Colab T4) or local machines with limited VRAM, this model has been compressed to 4-bit using NormalFloat4 (NF4) quantization.
Key Highlights & Comparison:
- Base Model:
microsoft/phi-2 - Quantization Tech: 4-bit NF4 (
bitsandbytes) - PEFT Framework: LoRA Adapter added for efficient fine-tuning/saving configuration.
- Memory Footprint Optimization:
- Original Model Size: ~5.56 GB (Float16)
- Quantized Model Size: ~1.78 GB (4-bit)
- Size Reduction: ~68% lower VRAM usage with minimal drop in response quality!
How It Was Made
- Optimization: Loaded the model using
BitsAndBytesConfigwithload_in_4bit=Trueandbnb_4bit_compute_dtype=torch.float16. - LoRA Integration: Prepared the model for k-bit training and attached a
LoraConfigtargeting the standard query/value projection layers (q_proj,v_proj). - Saving: Saved the lightweight PEFT adapter weights (
adapter_model.safetensors) and tokenizer configuration.
Intended Use
This repository is perfect for anyone looking to experiment with lightweight text generation or perform Parameter-Efficient Fine-Tuning (PEFT) on top of a 4-bit quantized version of Phi-2.
- Downloads last month
- 18
Model tree for thisisaditichouhan/Phi-2-4bit-Quantized-Model
Base model
microsoft/phi-2