Downloads · 30 days
0
ShAIkespear/Phi-2_DPO_M3_Quantized_Alt
Phi-2_DPO_M3_Quantized_Alt is a machine learning model from ShAIkespear. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
A 4-bit (NF4), LoRA-finetuned, DPO-aligned variant of microsoft/phi-2 specialized for multiple-choice question answering (MCQA) in STEM and general knowledge. This Alt checkpoint is the memory-efficient counterpart to…
Downloads · 30 days
0
Access
Public
Updated Nov 1, 2025
Repo size
52.4 MB
Likes
0
Public
Click a slice to open those files.
.safetensors52.4 MB · 94%
From the Hugging Face model README
A 4-bit (NF4), LoRA-finetuned, DPO-aligned variant of microsoft/phi-2 specialized for multiple-choice question answering (MCQA) in STEM and general knowledge. This Alt checkpoint is the memory-efficient counterpart to the unquantized M3 Base Alt model: same SFT → DPO training, then post-training 4-bit quantization for fast, low-VRAM inference.
Use the structured prompt format:
### Question ...
### Explanation ...
### Answer:
Keep a human in the loop for teaching/grading.
Prefer the M3 Base Alt (full precision) for further fine-tuning; use this 4-bit Alt for deployment.
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
model_id = "ShAIkespear/Phi-2_DPO_M3_Quantized_Alt"
bnb_cfg = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True, # often improves stability
bnb_4bit_compute_dtype="bfloat16" # or "float16" depending on your GPU
)
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(
model_id, device_map="auto", quantization_config=bnb_cfg
)
prompt = "### Question: Which planet is known as the Red Planet?\n### Explanation: Identify the planet with the reddish appearance.\n### Answer:"
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=15)
print(tok.decode(out[0], skip_special_tokens=True))