Views
No views yet
Note: This model was created as a learning project to understand the complete LLM fine-tuning workflow.
microsoft/Phi-3-mini-4k-instruct| Parameter | Value |
|---|---|
| Base Model | Phi-3 Mini 4K Instruct |
| Fine-Tuning Method | QLoRA |
| LoRA Rank (r) | 8 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0.05 |
| Task | Causal Language Modeling |
| Quantization | 4-bit NF4 |
| Compute Type | FP16 |
pip install transformers peft bitsandbytes accelerate torch1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
3from peft import PeftModel
4
5BASE_MODEL = "microsoft/Phi-3-mini-4k-instruct"
6
7bnb_config = BitsAndBytesConfig(
8 load_in_4bit=True,
9 bnb_4bit_quant_type="nf4",
10 bnb_4bit_compute_dtype=torch.float16,
11 bnb_4bit_use_double_quant=True,
12)
13
14tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
15
16base_model = AutoModelForCausalLM.from_pretrained(
17 BASE_MODEL,
18 quantization_config=bnb_config,
19 device_map="auto",
20)
21
22model = PeftModel.from_pretrained(
23 base_model,
24 "YOUR_USERNAME/YOUR_REPOSITORY_NAME"
25)1prompt = """### Instruction:
2Who created Python?
3
4### Response:
5"""
6
7inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
8
9outputs = model.generate(
10 **inputs,
11 max_new_tokens=100,
12)
13
14print(tokenizer.decode(outputs[0], skip_special_tokens=True))adapter_config.json
adapter_model.safetensors
README.md