PEFT
English
llama
lora
instruction-tuning
dolly
minhchuxuan commited on
Commit
a51bdd9
·
verified ·
1 Parent(s): f8b4ccb

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +127 -0
README.md ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: meta-llama/Llama-2-7b-hf
4
+ tags:
5
+ - llama
6
+ - lora
7
+ - instruction-tuning
8
+ - dolly
9
+ - peft
10
+ datasets:
11
+ - databricks/databricks-dolly-15k
12
+ language:
13
+ - en
14
+ ---
15
+
16
+ # LLaMA 2.7B Fine-tuned on Dolly
17
+
18
+ This is a LoRA adapter for LLaMA-2.7B, fine-tuned on the Databricks Dolly dataset for instruction-following tasks.
19
+
20
+ ## Model Details
21
+
22
+ - **Base Model**: LLaMA-2.7B
23
+ - **Training Method**: LoRA (Low-Rank Adaptation)
24
+ - **Dataset**: Databricks Dolly 15k
25
+ - **Adapter Type**: PEFT LoRA
26
+
27
+ ## LoRA Configuration
28
+
29
+ - **Rank (r)**: 16
30
+ - **Alpha**: 32
31
+ - **Dropout**: 0.05
32
+ - **Target Modules**: Query and Value projection layers
33
+ - **Trainable Parameters**: ~8-16M (adapters only, <1% of base model)
34
+
35
+ ## Training Configuration
36
+
37
+ - **Epochs**: 5
38
+ - **Batch Size**: 4
39
+ - **Learning Rate**: 5e-04
40
+ - **Gradient Accumulation**: 1
41
+ - **GPUs**: 2
42
+ - **Training Steps**: 6810
43
+ - **Optimizer**: AdamW
44
+ - **Weight Decay**: 0.01
45
+
46
+ ## Usage
47
+
48
+ You need to install the required packages:
49
+
50
+ ```bash
51
+ pip install transformers peft torch
52
+ ```
53
+
54
+ Then load and use the model:
55
+
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer
58
+ from peft import PeftModel
59
+ import torch
60
+
61
+ # Load base model (replace with actual 2.7B base model)
62
+ base_model = AutoModelForCausalLM.from_pretrained(
63
+ "meta-llama/Llama-2-7b-hf", # Update to 2.7B base if available
64
+ torch_dtype=torch.float16,
65
+ device_map="auto"
66
+ )
67
+
68
+ # Load LoRA adapter
69
+ model = PeftModel.from_pretrained(
70
+ base_model,
71
+ "YOUR_USERNAME/llama-2.7b-fine-tuned-on-dolly"
72
+ )
73
+
74
+ # Optional: Merge adapter for faster inference
75
+ # model = model.merge_and_unload()
76
+
77
+ tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/llama-2.7b-fine-tuned-on-dolly")
78
+
79
+ # Generate
80
+ prompt = "Instruction: Write a short poem about AI.\n\nResponse:"
81
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
82
+ outputs = model.generate(
83
+ **inputs,
84
+ max_length=256,
85
+ temperature=0.7,
86
+ top_p=0.9,
87
+ do_sample=True
88
+ )
89
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
90
+ ```
91
+
92
+ ## Key Benefits
93
+
94
+ - **Efficiency**: Only ~8-16M trainable parameters (vs billions in full fine-tuning)
95
+ - **Storage**: Small adapter files (~30-60MB vs multi-GB full models)
96
+ - **Modularity**: Can swap adapters on the same base model
97
+ - **Quality**: Maintains competitive performance with full fine-tuning
98
+
99
+ ## Limitations
100
+
101
+ - Requires the base LLaMA model to use
102
+ - Performance depends on base model quality
103
+ - Trained primarily on English instruction-following tasks
104
+ - May generate biased or incorrect responses
105
+
106
+ ## Training Details
107
+
108
+ This model was fine-tuned using:
109
+ - **PEFT/LoRA**: Parameter-efficient fine-tuning
110
+ - **Training Data**: 15k instruction-response pairs from Dolly
111
+ - **Task**: General instruction following and question answering
112
+ - **Learning Rate Schedule**: Cosine decay with warmup
113
+
114
+ ## Citation
115
+
116
+ ```bibtex
117
+ @inproceedings{lora,
118
+ title={LoRA: Low-Rank Adaptation of Large Language Models},
119
+ author={Hu, Edward J and Shen, Yelong and Wallis, Phillip and Allen-Zhu, Zeyuan and Li, Yuanzhi and Wang, Shean and Wang, Lu and Chen, Weizhu},
120
+ booktitle={International Conference on Learning Representations},
121
+ year={2022}
122
+ }
123
+ ```
124
+
125
+ ## License
126
+
127
+ This model is released under Apache 2.0 license. Note that LLaMA models have specific usage terms from Meta.