Irfanuruchi commited on
Commit
52cce82
·
verified ·
1 Parent(s): 4ebda79

README file for Large Language Model

Browse files
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - phi2
5
+ - alpaca
6
+ - instruction-tuning
7
+ - causal-lm
8
+ - lora
9
+ datasets:
10
+ - yahma/alpaca-cleaned
11
+ - custom
12
+ base_model: microsoft/phi-2
13
+ ---
14
+
15
+ # Phi‑2‑Alpaca‑LoRA
16
+
17
+ [![GitHub Repo](https://img.shields.io/badge/GitHub-phi--2--alpaca--lora-181717?style=for-the-badge&logo=github)](https://github.com/IrfanUruchi/phi-2-alpaca-lora)
18
+ [![Model Weights](https://img.shields.io/badge/🤗-Model_Weights-FFD21F?style=for-the-badge)](https://huggingface.co/Irfanuruchi/phi-2-alpaca-lora)
19
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](https://huggingface.co/microsoft/phi-2/blob/main/LICENSE)
20
+
21
+ ---
22
+
23
+ ### Overview
24
+
25
+ This repository contains LoRA‑tuned weights for **microsoft/phi‑2 (2.7B)**.
26
+ The adapters were trained on:
27
+
28
+ - [yahma/alpaca-cleaned](https://huggingface.co/datasets/yahma/alpaca-cleaned) (~5k instructions)
29
+ - Custom instruction datasets (collected separately)
30
+
31
+ Targets: `q_proj`, `k_proj`, `v_proj`, `dense` layers within the transformer.
32
+ Adapters were merged after training to produce a standalone Hugging Face checkpoint.
33
+
34
+ ---
35
+
36
+ ### Training setup
37
+
38
+ - **LoRA config**: rank=16, α=32, dropout=0.05
39
+ - **Max seq length**: 256
40
+ - **Optimizer**: AdamW, lr=2e‑4
41
+ - **Precision**: bf16 (fp16 fallback)
42
+
43
+ ---
44
+
45
+ ### Example
46
+
47
+ ```python
48
+ from transformers import AutoModelForCausalLM, AutoTokenizer
49
+ import torch
50
+
51
+ model_id = "<your-hf-username>/phi-2-alpaca-lora"
52
+ tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
53
+
54
+ model = AutoModelForCausalLM.from_pretrained(
55
+ model_id,
56
+ torch_dtype=torch.float16,
57
+ device_map="auto",
58
+ trust_remote_code=True,
59
+ )
60
+
61
+ prompt = "### Instruction: List three advantages of modular code.\n### Response:"
62
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
63
+
64
+ with torch.inference_mode():
65
+ outputs = model.generate(
66
+ **inputs,
67
+ max_new_tokens=200,
68
+ temperature=0.7,
69
+ top_p=0.9,
70
+ )
71
+
72
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Limitations
78
+
79
+ - Context length capped at 256 tokens
80
+ - Can return hallucinated or biased content
81
+ - Output tone/style depends on Alpaca + custom data
82
+
83
+ ---