HenryHHHH commited on
Commit
67c47f1
·
verified ·
1 Parent(s): 1a6a8c3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +83 -186
README.md CHANGED
@@ -1,211 +1,108 @@
1
  ---
2
- license: mit
3
- datasets:
4
- - Skylion007/openwebtext
5
- - Salesforce/wikitext
6
- language:
7
- - en
8
- metrics:
9
- - accuracy
10
- base_model:
11
- - meta-llama/Llama-2-7b
12
- pipeline_tag: text-generation
13
- tags:
14
- - Web Text
15
- - University of Melbourne
16
- - Knowledge Distillation
17
- ---
18
- # Model Card for Model ID
19
-
20
- <!-- Provide a quick summary of what the model is/does. -->
21
-
22
- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
23
-
24
- ## Model Details
25
-
26
- ### Model Description
27
-
28
- <!-- Provide a longer summary of what this model is. -->
29
-
30
-
31
-
32
- - **Developed by:** [More Information Needed]
33
- - **Funded by [optional]:** [More Information Needed]
34
- - **Shared by [optional]:** [More Information Needed]
35
- - **Model type:** [More Information Needed]
36
- - **Language(s) (NLP):** [More Information Needed]
37
- - **License:** [More Information Needed]
38
- - **Finetuned from model [optional]:** [More Information Needed]
39
-
40
- ### Model Sources [optional]
41
-
42
- <!-- Provide the basic links for the model. -->
43
-
44
- - **Repository:** [More Information Needed]
45
- - **Paper [optional]:** [More Information Needed]
46
- - **Demo [optional]:** [More Information Needed]
47
-
48
- ## Uses
49
-
50
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
51
-
52
- ### Direct Use
53
-
54
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
55
-
56
- [More Information Needed]
57
-
58
- ### Downstream Use [optional]
59
-
60
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
61
-
62
- [More Information Needed]
63
-
64
- ### Out-of-Scope Use
65
-
66
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
67
-
68
- [More Information Needed]
69
-
70
- ## Bias, Risks, and Limitations
71
-
72
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
73
-
74
- [More Information Needed]
75
-
76
- ### Recommendations
77
-
78
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
79
-
80
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
81
-
82
- ## How to Get Started with the Model
83
-
84
- Use the code below to get started with the model.
85
-
86
- [More Information Needed]
87
-
88
- ## Training Details
89
-
90
- ### Training Data
91
-
92
- <!-- 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. -->
93
-
94
- [More Information Needed]
95
-
96
- ### Training Procedure
97
-
98
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
99
-
100
- #### Preprocessing [optional]
101
-
102
- [More Information Needed]
103
-
104
-
105
- #### Training Hyperparameters
106
-
107
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
108
-
109
- #### Speeds, Sizes, Times [optional]
110
-
111
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
112
-
113
- [More Information Needed]
114
-
115
- ## Evaluation
116
-
117
- <!-- This section describes the evaluation protocols and provides the results. -->
118
-
119
- ### Testing Data, Factors & Metrics
120
-
121
- #### Testing Data
122
-
123
- <!-- This should link to a Dataset Card if possible. -->
124
-
125
- [More Information Needed]
126
-
127
- #### Factors
128
-
129
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
130
-
131
- [More Information Needed]
132
-
133
- #### Metrics
134
-
135
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
136
-
137
- [More Information Needed]
138
-
139
- ### Results
140
-
141
- [More Information Needed]
142
-
143
- #### Summary
144
-
145
-
146
-
147
- ## Model Examination [optional]
148
-
149
- <!-- Relevant interpretability work for the model goes here -->
150
-
151
- [More Information Needed]
152
-
153
- ## Environmental Impact
154
-
155
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
156
-
157
- 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).
158
-
159
- - **Hardware Type:** [More Information Needed]
160
- - **Hours used:** [More Information Needed]
161
- - **Cloud Provider:** [More Information Needed]
162
- - **Compute Region:** [More Information Needed]
163
- - **Carbon Emitted:** [More Information Needed]
164
 
165
- ## Technical Specifications [optional]
166
 
167
- ### Model Architecture and Objective
 
 
168
 
169
- [More Information Needed]
170
 
171
- ### Compute Infrastructure
 
 
 
 
 
 
172
 
173
- [More Information Needed]
 
 
174
 
175
- #### Hardware
176
 
177
- [More Information Needed]
 
 
 
 
 
 
 
 
 
178
 
179
- #### Software
180
 
181
- [More Information Needed]
182
 
183
- ## Citation [optional]
184
 
185
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
 
 
 
 
 
 
 
 
 
 
 
186
 
187
- **BibTeX:**
188
 
189
- [More Information Needed]
 
190
 
191
- **APA:**
 
192
 
193
- [More Information Needed]
194
 
195
- ## Glossary [optional]
 
 
 
196
 
197
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
 
 
 
198
 
199
- [More Information Needed]
 
 
 
 
200
 
201
- ## More Information [optional]
202
 
203
- [More Information Needed]
 
 
 
 
204
 
205
- ## Model Card Authors [optional]
206
 
207
- [More Information Needed]
 
 
208
 
209
- ## Model Card Contact
210
 
211
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ ### Overview
4
 
5
+ 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.
6
+
7
+ ### Training Process
8
 
9
+ 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:
10
 
11
+ ```python
12
+ def distillation_loss(student_logits, teacher_logits, temperature=2.0):
13
+ return F.kl_div(
14
+ F.log_softmax(student_logits / temperature, dim=-1),
15
+ F.softmax(teacher_logits / temperature, dim=-1),
16
+ reduction='batchmean'
17
+ ) * (temperature ** 2)
18
 
19
+ # Loss Calculation
20
+ loss = (alpha * distill_loss) + ((1 - alpha) * task_loss)
21
+ ```
22
 
23
+ ### Training Configuration
24
 
25
+ - **Batch Size**: 64
26
+ - **Max Sequence Length**: 128
27
+ - **Epochs**: 2
28
+ - **Log Interval**: 3000
29
+ - **Learning Rate**: 3e-4
30
+ - **Warmup Steps**: 4000
31
+ - **Accumulation Steps**: 8
32
+ - **Load Model**: True
33
+ - **Temperature**: 2.0
34
+ - **Alpha**: 0.3
35
 
36
+ ### Performance Comparison
37
 
38
+ 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).
39
 
40
+ #### Example Queries
41
 
42
+ | **Query** | **Keyword** |
43
+ |----------------------------------------------|-------------------|
44
+ | The capital of France is | Paris |
45
+ | The author of *To Kill a Mockingbird* is | Harper Lee |
46
+ | The planet known as the Red Planet is | Mars |
47
+ | The smallest country in the world is | Vatican City |
48
+ | The *Mona Lisa* was painted by | Leonardo da Vinci |
49
+ | The tallest mountain in the world is | Mount Everest |
50
+ | The host country of the 2016 Summer Olympics | Brazil |
51
+ | The currency of Japan is | Yen |
52
+ | The "Father of Computers" is | Charles Babbage |
53
+ | The largest ocean on Earth is | Pacific Ocean |
54
 
55
+ ### Text Generation Examples
56
 
57
+ 1. **Input**: *The capital of France is*
58
+ - **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."
59
 
60
+ 2. **Input**: *The tallest mountain in the world is*
61
+ - **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."
62
 
63
+ ### Evaluation Metrics
64
 
65
+ 1. **Cosine Similarity using Word Embeddings**
66
+ - **Description**: Measures semantic similarity by mapping words/phrases to vectors.
67
+ - **Equation**: Cosine Similarity = \( \frac{\vec{A} \cdot \vec{B}}{||\vec{A}|| \, ||\vec{B}||} \)
68
+ - **Example**: "The dog chased the cat." vs. "A canine pursued a feline." (High similarity)
69
 
70
+ 2. **Exact Match (EM)**
71
+ - **Description**: Checks if critical keywords are present.
72
+ - **Example**:
73
+ - Expected: "Paris"
74
+ - Response: "The capital of France is Paris." (EM = 1)
75
 
76
+ 3. **ROUGE Score**
77
+ - **Description**: Measures the overlap of the longest common subsequences between reference and response texts.
78
+ - **Equation**:
79
+ - Precision = \( \frac{LCS(R, C)}{\text{Length of } C} \)
80
+ - Recall = \( \frac{LCS(R, C)}{\text{Length of } R} \)
81
 
82
+ ### Model Evaluation Summary
83
 
84
+ | Model Name | Duration (s) | Emissions Rate | Avg. EM | Avg. Cosine Similarity | Avg. ROUGE Score |
85
+ |-----------------|--------------|----------------|---------|------------------------|------------------|
86
+ | LLaMA-2-7B-HF | 18215.61 | 1.01e-05 | 0.715 | 0.7257 | 0.0821 |
87
+ | baby-llama-58m | 57.20 | 4.79e-08 | 0.025 | 0.6556 | 0.0097 |
88
+ | DistilLlama | 77.12 | 1.01e-05 | 0.02 | 0.6623 | 0.0115 |
89
 
90
+ ### Acknowledgments
91
 
92
+ - **University of Melbourne**
93
+ - **AGL Energy**
94
+ - **My teammates**: Svarnim and Mohit
95
 
96
+ ### Reference
97
 
98
+ @misc{timiryasov2023babyllamaknowledgedistillation,
99
+ title={Baby Llama: knowledge distillation from an ensemble of teachers trained on a small dataset with no performance penalty},
100
+ author={Inar Timiryasov and Jean-Loup Tastet},
101
+ year={2023},
102
+ eprint={2308.02019},
103
+ archivePrefix={arXiv},
104
+ primaryClass={cs.CL},
105
+ url={https://arxiv.org/abs/2308.02019},
106
+ }
107
+
108
+ *Note: The repository will be updated as training progresses. Last update 2024-10-23*