chore: update model card
Browse files
README.md
CHANGED
|
@@ -1,199 +1,136 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model Card for Model ID
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
### Model Sources
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
|
| 36 |
## Uses
|
| 37 |
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 39 |
-
|
| 40 |
### Direct Use
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
[More Information Needed]
|
| 45 |
-
|
| 46 |
-
### Downstream Use [optional]
|
| 47 |
-
|
| 48 |
-
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
|
| 49 |
-
|
| 50 |
-
[More Information Needed]
|
| 51 |
|
| 52 |
### Out-of-Scope Use
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
## Bias, Risks, and Limitations
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
### Recommendations
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
| 69 |
-
|
| 70 |
-
## How to Get Started with the Model
|
| 71 |
-
|
| 72 |
-
Use the code below to get started with the model.
|
| 73 |
-
|
| 74 |
-
[More Information Needed]
|
| 75 |
-
|
| 76 |
-
## Training Details
|
| 77 |
-
|
| 78 |
-
### Training Data
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
|
| 159 |
-
|
| 160 |
|
| 161 |
-
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
|
|
|
| 178 |
|
| 179 |
-
|
| 180 |
|
| 181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
-
|
| 184 |
|
| 185 |
-
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
| 188 |
|
| 189 |
-
|
| 190 |
|
| 191 |
-
|
| 192 |
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
-
|
| 196 |
|
| 197 |
-
##
|
| 198 |
|
| 199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
license: mit
|
| 4 |
+
language:
|
| 5 |
+
- en
|
| 6 |
+
base_model:
|
| 7 |
+
- microsoft/phi-2
|
| 8 |
---
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
+
# Model Card for ShAIkespear/Phi-2_DPO_M3_Quantized_Alt
|
| 12 |
|
| 13 |
+
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**.
|
| 14 |
+
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.
|
| 15 |
|
| 16 |
+
---
|
| 17 |
|
| 18 |
## Model Details
|
| 19 |
|
| 20 |
+
* **Developed by:** ShAIkespear team
|
| 21 |
+
* **Shared by:** ShAIkespear team
|
| 22 |
+
* **Model type:** Causal LM (Phi-2) with LoRA adapters; DPO-aligned; **4-bit NF4** quantized
|
| 23 |
+
* **Languages:** English
|
| 24 |
+
* **License:** MIT
|
| 25 |
+
* **Finetuned from:** microsoft/phi-2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
### Model Sources
|
| 28 |
|
| 29 |
+
* **Repository:** [2.8B-Phi-2-LLM-QA](https://github.com/EricSaikali/2.8B-Phi-2-LLM-QA)
|
| 30 |
+
* **Report:** *“ShAIkespear – How to replace TAs: A comprehensive study on letting LLMs answer your questions”*
|
| 31 |
|
| 32 |
+
---
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## Uses
|
| 35 |
|
|
|
|
|
|
|
| 36 |
### Direct Use
|
| 37 |
|
| 38 |
+
* MCQA inference for STEM & general knowledge (MMLU/ScienceQA style).
|
| 39 |
+
* Educational assistants and lightweight evaluation tools on **low-VRAM GPUs**.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
### Out-of-Scope Use
|
| 42 |
|
| 43 |
+
* Safety-critical domains (medical/legal/financial) without human oversight.
|
| 44 |
+
* Long-form creative writing or tasks far from MCQA.
|
| 45 |
+
* Any misuse involving exam integrity or confidential assessments.
|
| 46 |
|
| 47 |
+
---
|
| 48 |
|
| 49 |
## Bias, Risks, and Limitations
|
| 50 |
|
| 51 |
+
* **Quantization trade-offs:** Small accuracy drop vs. full-precision; bigger memory savings than 8-bit.
|
| 52 |
+
* **STEM difficulty:** Multi-step reasoning can remain challenging.
|
| 53 |
+
* **Alignment bias:** DPO style preferences may influence verbosity/format.
|
| 54 |
|
| 55 |
### Recommendations
|
| 56 |
|
| 57 |
+
* Use the structured prompt format:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
```
|
| 60 |
+
### Question ...
|
| 61 |
+
### Explanation ...
|
| 62 |
+
### Answer:
|
| 63 |
+
```
|
| 64 |
+
* Keep a human in the loop for teaching/grading.
|
| 65 |
+
* Prefer the **M3 Base Alt** (full precision) for further fine-tuning; use this **4-bit Alt** for deployment.
|
| 66 |
|
| 67 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
## How to Get Started
|
| 70 |
|
| 71 |
+
```python
|
| 72 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 73 |
|
| 74 |
+
model_id = "ShAIkespear/Phi-2_DPO_M3_Quantized_Alt"
|
| 75 |
|
| 76 |
+
bnb_cfg = BitsAndBytesConfig(
|
| 77 |
+
load_in_4bit=True,
|
| 78 |
+
bnb_4bit_quant_type="nf4",
|
| 79 |
+
bnb_4bit_use_double_quant=True, # often improves stability
|
| 80 |
+
bnb_4bit_compute_dtype="bfloat16" # or "float16" depending on your GPU
|
| 81 |
+
)
|
| 82 |
|
| 83 |
+
tok = AutoTokenizer.from_pretrained(model_id, use_fast=True)
|
| 84 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 85 |
+
model_id, device_map="auto", quantization_config=bnb_cfg
|
| 86 |
+
)
|
| 87 |
|
| 88 |
+
prompt = "### Question: Which planet is known as the Red Planet?\n### Explanation: Identify the planet with the reddish appearance.\n### Answer:"
|
| 89 |
+
inputs = tok(prompt, return_tensors="pt").to(model.device)
|
| 90 |
+
out = model.generate(**inputs, max_new_tokens=15)
|
| 91 |
+
print(tok.decode(out[0], skip_special_tokens=True))
|
| 92 |
+
```
|
| 93 |
|
| 94 |
+
---
|
| 95 |
|
| 96 |
+
## Training Details
|
| 97 |
|
| 98 |
+
### Data (SFT → DPO)
|
| 99 |
|
| 100 |
+
* **SFT:** Mixed MCQA (MathQA, OpenBookQA, ScienceQA, TAL-SCQ5K) + EPFL MCQA; unified schema; ≤512 tokens; per-dataset caps.
|
| 101 |
+
* **DPO:** EPFL preference pairs + public preference data (chosen vs. rejected responses).
|
| 102 |
|
| 103 |
+
### Procedure & Hyperparameters
|
| 104 |
|
| 105 |
+
* **Pipeline:** SFT → DPO → **4-bit (NF4) quantization**.
|
| 106 |
+
* **LoRA:** rank=16, α=16, dropout=0.05.
|
| 107 |
+
* **Batch sizes:** 4 (SFT), 1 (DPO).
|
| 108 |
+
* **LR:** 1e-5 (public), 1e-4 (EPFL); cosine schedule w/ warmup.
|
| 109 |
+
* **Frameworks:** HF Transformers, TRL, PEFT (LoRA), bitsandbytes.
|
| 110 |
|
| 111 |
+
---
|
| 112 |
|
| 113 |
+
## Evaluation Summary
|
| 114 |
|
| 115 |
+
* **Configuration:** Balanced-then-DPO (**M3 Alt**).
|
| 116 |
+
* **Efficiency:** Fits comfortably on mid-range GPUs thanks to **4-bit** weights; faster/lighter than 8-bit with a modest accuracy trade-off vs. full precision.
|
| 117 |
+
* **Use case:** Best when **VRAM is tight** and you want DPO-aligned behavior with structured MCQA prompts.
|
| 118 |
|
| 119 |
+
---
|
| 120 |
|
| 121 |
+
## Technical Specifications
|
| 122 |
|
| 123 |
+
* **Architecture:** Phi-2 (~2.78B params), decoder-only transformer.
|
| 124 |
+
* **Objective:** SFT next-token prediction + DPO preference alignment.
|
| 125 |
+
* **Quantization:** **4-bit NF4** (bitsandbytes) with optional double quantization; compute in bf16/fp16.
|
| 126 |
+
* **Precision:** Quantized 4-bit runtime.
|
| 127 |
|
| 128 |
+
---
|
| 129 |
|
| 130 |
+
## Glossary
|
| 131 |
|
| 132 |
+
* **MCQA:** Multiple-Choice Question Answering
|
| 133 |
+
* **SFT:** Supervised Finetuning
|
| 134 |
+
* **DPO:** Direct Preference Optimization
|
| 135 |
+
* **LoRA:** Low-Rank Adaptation
|
| 136 |
+
* **NF4:** NormalFloat-4 quantization format (bnb) for 4-bit weight quantization
|