RichardErkhov commited on
Commit
250bd13
·
verified ·
1 Parent(s): 92f3d0a

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +194 -0
README.md ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ DistilLlama - GGUF
11
+ - Model creator: https://huggingface.co/HenryHHHH/
12
+ - Original model: https://huggingface.co/HenryHHHH/DistilLlama/
13
+
14
+
15
+ | Name | Quant method | Size |
16
+ | ---- | ---- | ---- |
17
+ | [DistilLlama.Q2_K.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q2_K.gguf) | Q2_K | 0.04GB |
18
+ | [DistilLlama.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.IQ3_XS.gguf) | IQ3_XS | 0.04GB |
19
+ | [DistilLlama.IQ3_S.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.IQ3_S.gguf) | IQ3_S | 0.04GB |
20
+ | [DistilLlama.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q3_K_S.gguf) | Q3_K_S | 0.04GB |
21
+ | [DistilLlama.IQ3_M.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.IQ3_M.gguf) | IQ3_M | 0.04GB |
22
+ | [DistilLlama.Q3_K.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q3_K.gguf) | Q3_K | 0.04GB |
23
+ | [DistilLlama.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q3_K_M.gguf) | Q3_K_M | 0.04GB |
24
+ | [DistilLlama.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q3_K_L.gguf) | Q3_K_L | 0.05GB |
25
+ | [DistilLlama.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.IQ4_XS.gguf) | IQ4_XS | 0.05GB |
26
+ | [DistilLlama.Q4_0.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q4_0.gguf) | Q4_0 | 0.05GB |
27
+ | [DistilLlama.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.IQ4_NL.gguf) | IQ4_NL | 0.05GB |
28
+ | [DistilLlama.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q4_K_S.gguf) | Q4_K_S | 0.05GB |
29
+ | [DistilLlama.Q4_K.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q4_K.gguf) | Q4_K | 0.05GB |
30
+ | [DistilLlama.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q4_K_M.gguf) | Q4_K_M | 0.05GB |
31
+ | [DistilLlama.Q4_1.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q4_1.gguf) | Q4_1 | 0.05GB |
32
+ | [DistilLlama.Q5_0.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q5_0.gguf) | Q5_0 | 0.06GB |
33
+ | [DistilLlama.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q5_K_S.gguf) | Q5_K_S | 0.06GB |
34
+ | [DistilLlama.Q5_K.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q5_K.gguf) | Q5_K | 0.06GB |
35
+ | [DistilLlama.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q5_K_M.gguf) | Q5_K_M | 0.06GB |
36
+ | [DistilLlama.Q5_1.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q5_1.gguf) | Q5_1 | 0.06GB |
37
+ | [DistilLlama.Q6_K.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q6_K.gguf) | Q6_K | 0.07GB |
38
+ | [DistilLlama.Q8_0.gguf](https://huggingface.co/RichardErkhov/HenryHHHH_-_DistilLlama-gguf/blob/main/DistilLlama.Q8_0.gguf) | Q8_0 | 0.09GB |
39
+
40
+
41
+
42
+
43
+ Original model description:
44
+ ---
45
+ language: en
46
+ tags:
47
+ - text-generation
48
+ - knowledge-distillation
49
+ - llama
50
+ - causal-lm
51
+ - openwebtext
52
+ - wikitext
53
+ - transfer-learning
54
+ model_name: DistilLLaMA
55
+ license: apache-2.0
56
+ datasets:
57
+ - openwebtext
58
+ - wikitext
59
+ parameter_count: 80M
60
+ metrics:
61
+ - cosine-similarity
62
+ - exact-match
63
+ - rouge
64
+ library_name: transformers
65
+ base_model: meta-llama/LLaMA-2-7B
66
+ ---
67
+
68
+
69
+ ### Overview
70
+
71
+ This model is a distilled version of LLaMA 2, containing approximately 80 million parameters. It was trained using a mix of OpenWebText and WikiText Raw V1 datasets. Knowledge distillation was employed to transfer knowledge from a larger "teacher" model—Meta’s 7B LLaMA 2—to help this smaller model mimic the behavior of the teacher.
72
+
73
+ ### Model Architecture
74
+
75
+ The architecture is based on LLaMA 2, with the following parameters:
76
+ | Parameter | Value |
77
+ |-------------------------|-------|
78
+ | Hidden Dimension | 512 |
79
+ | Intermediate Dimension | 1536 |
80
+ | Max Positional Embeddings | 128 |
81
+ | Attention Heads | 8 |
82
+ | Transformer Layers | 16 |
83
+
84
+
85
+ ### Training Process
86
+
87
+ During each training step, the input data \( X \) is fed to both the teacher and student models. The student model calculates output logits and loss with the true labels, while the teacher model only generates logits. The total loss combines task-specific loss and distillation loss:
88
+
89
+ ```python
90
+ def distillation_loss(student_logits, teacher_logits, temperature=2.0):
91
+ return F.kl_div(
92
+ F.log_softmax(student_logits / temperature, dim=-1),
93
+ F.softmax(teacher_logits / temperature, dim=-1),
94
+ reduction='batchmean'
95
+ ) * (temperature ** 2)
96
+
97
+ # Loss Calculation
98
+ loss = (alpha * distill_loss) + ((1 - alpha) * task_loss)
99
+ ```
100
+
101
+ ### Training Configuration
102
+
103
+ - **Batch Size**: 64
104
+ - **Max Sequence Length**: 128
105
+ - **Epochs**: 2
106
+ - **Log Interval**: 3000
107
+ - **Learning Rate**: 3e-4
108
+ - **Warmup Steps**: 4000
109
+ - **Accumulation Steps**: 8
110
+ - **Load Model**: True
111
+ - **Temperature**: 2.0
112
+ - **Alpha**: 0.3
113
+
114
+ ### Performance Comparison
115
+
116
+ The model’s performance is evaluated on 200 queries created in-house. For more details, visit the [GitHub repository](https://github.com/svarnim1805/Knowledge-Distillation/tree/main).
117
+
118
+ #### Example Queries
119
+
120
+ | **Query** | **Keyword** |
121
+ |----------------------------------------------|-------------------|
122
+ | The capital of France is | Paris |
123
+ | The author of *To Kill a Mockingbird* is | Harper Lee |
124
+ | The planet known as the Red Planet is | Mars |
125
+ | The smallest country in the world is | Vatican City |
126
+ | The *Mona Lisa* was painted by | Leonardo da Vinci |
127
+ | The tallest mountain in the world is | Mount Everest |
128
+ | The host country of the 2016 Summer Olympics | Brazil |
129
+ | The currency of Japan is | Yen |
130
+ | The "Father of Computers" is | Charles Babbage |
131
+ | The largest ocean on Earth is | Pacific Ocean |
132
+
133
+ ### Text Generation Examples
134
+
135
+ 1. **Input**: *The capital of France is*
136
+ - **Output**: "The capital of France is located in the southern province of Lyon, France. The capital is the main hub of the French capital, La Caillion, and the main hub of the French capital. A major part of the French capital is in the southern city of Paris."
137
+
138
+ 2. **Input**: *The tallest mountain in the world is*
139
+ - **Output**: "The tallest mountain in the world is Mount Everest, which is located in the northwest corner of the village of Kahuna. The mountain is about 1,000 feet (3,000 m) above sea level."
140
+
141
+ ### Evaluation Metrics
142
+
143
+ 1. **Cosine Similarity using Word Embeddings**
144
+ - **Description**: Measures semantic similarity by mapping words/phrases to vectors.
145
+ - **Equation**: Cosine Similarity = ( A • B ) / ( ||A|| ||B|| )
146
+ - **Example**: "The dog chased the cat." vs. "A canine pursued a feline." (High similarity)
147
+
148
+ 2. **Exact Match (EM)**
149
+ - **Description**: Checks if critical keywords are present.
150
+ - **Example**:
151
+ - Expected: "Paris"
152
+ - Response: "The capital of France is Paris." (EM = 1)
153
+
154
+ 3. **ROUGE Score**
155
+ - **Description**: Measures the overlap of the longest common subsequences between reference and response texts.
156
+ - **Equation**:
157
+ - Precision = Precision = LCS(R, C) / Length of C
158
+ - Recall = Recall = LCS(R, C) / Length of R
159
+
160
+ ### Model Evaluation Summary
161
+
162
+ | Model Name | Duration (s) | Emissions (kgCO₂e) | Avg. EM | Avg. Cosine Similarity | Avg. ROUGE Score |
163
+ |-----------------|--------------|--------------------|---------|------------------------|------------------|
164
+ | LLaMA-2-7B-HF | 18215.61 | 1.84e-01 | 0.715 | 0.7257 | 0.0821 |
165
+ | baby-llama-58m | 57.20 | 2.73e-06 | 0.025 | 0.6556 | 0.0097 |
166
+ | DistilLlama | 77.12 | 7.79e-04 | 0.02 | 0.6623 | 0.0115 |
167
+
168
+ *Note: CodeCarbon was used to track carbon emission. Allocated 80GB memory, 32 cores, Intel(R) Xeon(R) Gold 6448H for the evaluation*
169
+
170
+ ### Acknowledgments
171
+
172
+ - **University of Melbourne**
173
+ - **AGL Energy**
174
+ - **My teammates**: Svarnim and Mohit
175
+
176
+ ### GitHub Repositories
177
+
178
+ - **Training Repo**: [DistilLlama Training Repository](https://github.com/HenryHuang2/DistilLlama)
179
+ - **Evaluation Repo**: [Knowledge Distillation Evaluation Repository](https://github.com/svarnim1805/Knowledge-Distillation)
180
+
181
+ ### Reference
182
+
183
+ @misc{timiryasov2023babyllamaknowledgedistillation,
184
+ title={Baby Llama: knowledge distillation from an ensemble of teachers trained on a small dataset with no performance penalty},
185
+ author={Inar Timiryasov and Jean-Loup Tastet},
186
+ year={2023},
187
+ eprint={2308.02019},
188
+ archivePrefix={arXiv},
189
+ primaryClass={cs.CL},
190
+ url={https://arxiv.org/abs/2308.02019},
191
+ }
192
+
193
+ *Note: The repository will be updated as training progresses. Last update 2024-10-23*
194
+