Downloads · 30 days
0
ShAIkespear/Phi-2_DPO_M3_Base
Phi-2_DPO_M3_Base 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 LoRA-finetuned variant of microsoft/phi-2 targeting STEM multiple-choice question answering (MCQA). The model was first trained with SFT on mixed STEM MCQA datasets, then aligned via DPO using human preference data…
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 LoRA-finetuned variant of microsoft/phi-2 targeting STEM multiple-choice question answering (MCQA). The model was first trained with SFT on mixed STEM MCQA datasets, then aligned via DPO using human preference data (EPFL exam MCQAs). This Base checkpoint is the standard (non-quantized) version intended for highest fidelity before any 4/8-bit compression.
This model adapts Phi-2 (≈2.78B params, 2,048 context length) for MCQA, especially STEM. Training used LoRA adapters (rank=16, α=16, dropout=0.05) with the TRL library for SFT and DPO; checkpoints focus on adapter weights for compactness. This Base release loads in full precision (fp16/bf16 capable) and is recommended for evaluation and further finetuning.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id = "ShAIkespear/Phi-2_DPO_M3_Base" # replace with your Hub ID
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
prompt = "### Question: What is 2+2?\n### Explanation: Add the integers.\n### Answer:"
inputs = tok(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=10)
print(tok.decode(out[0], skip_special_tokens=True))
Mixed SFT on MathQA, OpenBookQA, ScienceQA, TAL-SCQ5K, plus balanced/shuffled merged MCQA sets; DPO on HelpSteer and a student-curated EPFL preference dataset (~20–30k pairs; subsets used for SFT/DPO). Long items (>512 tokens) dropped; large datasets clipped to 20k samples. Example split: train 50%, test_overfit 25%, test_comparison 10%, test_quantization 15% (quant split retained for comparability, though this is the Base model).
Unified MCQA schema.
SFT format: id, subject, question, answer/answer_text, choices.
DPO format: prompt, rejected, chosen.
Prompts used a structured header:
### Question ... ### Explanation ... ### Answer
Per-dataset held-out test sets (per splits), plus MMLU converted to the SFT schema.
Task domain (math vs. general science vs. open-domain), data balancing, and SFT→DPO ordering.
MCQA accuracy; DPO pairwise preference accuracy.
Across ablations, the balanced-then-DPO configuration (M3) performed best overall on the team’s benchmark suite. The Base model serves as the reference for subsequent quantized variants.
Phi-2 transformer decoder LM (≈2.78B params) with next-token prediction objective; LoRA adapters for parameter-efficient finetuning; DPO for preference alignment.
Hugging Face TRL, PEFT/LoRA, Transformers.