PEFT
Safetensors
AchrafABBAOUI commited on
Commit
2ef511c
·
verified ·
1 Parent(s): 50fedd7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -104
README.md CHANGED
@@ -3,200 +3,195 @@ base_model: meta-llama/Llama-3.2-3B-Instruct
3
  library_name: peft
4
  ---
5
 
6
- # Model Card for Model ID
7
-
8
- <!-- Provide a quick summary of what the model is/does. -->
9
-
10
 
 
11
 
12
  ## Model Details
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
-
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
 
28
- ### Model Sources [optional]
 
 
 
 
29
 
30
- <!-- Provide the basic links for the model. -->
31
 
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
 
36
  ## Uses
37
 
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
  ### Direct Use
41
 
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
 
46
- ### Downstream Use [optional]
47
 
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
 
52
  ### Out-of-Scope Use
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
 
58
  ## Bias, Risks, and Limitations
59
 
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
 
64
  ### Recommendations
65
 
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
 
70
  ## How to Get Started with the Model
71
 
72
  Use the code below to get started with the model.
73
 
74
- [More Information Needed]
 
 
75
 
76
- ## Training Details
 
 
 
 
 
 
77
 
78
- ### Training Data
 
 
 
 
 
79
 
80
- <!-- 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. -->
81
 
82
- [More Information Needed]
83
 
84
- ### Training Procedure
85
 
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
 
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
 
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
 
 
 
 
 
96
 
97
- #### Speeds, Sizes, Times [optional]
 
 
 
98
 
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
 
 
100
 
101
- [More Information Needed]
 
102
 
103
- ## Evaluation
104
 
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
 
107
- ### Testing Data, Factors & Metrics
108
 
109
- #### Testing Data
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
 
 
 
118
 
119
- [More Information Needed]
120
 
121
- #### Metrics
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
126
 
127
- ### Results
128
 
129
- [More Information Needed]
130
 
131
  #### Summary
132
 
 
133
 
 
134
 
135
- ## Model Examination [optional]
136
-
137
- <!-- Relevant interpretability work for the model goes here -->
138
-
139
- [More Information Needed]
140
 
141
  ## Environmental Impact
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
-
145
  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).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
  ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
 
159
  ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
-
163
  #### Hardware
164
 
165
- [More Information Needed]
166
 
167
  #### Software
168
 
169
- [More Information Needed]
170
-
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
  **BibTeX:**
176
 
177
- [More Information Needed]
 
 
 
 
 
 
 
178
 
179
  **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
 
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
192
 
193
- ## Model Card Authors [optional]
194
-
195
- [More Information Needed]
196
 
197
  ## Model Card Contact
198
 
199
- [More Information Needed]
200
- ### Framework versions
201
-
202
- - PEFT 0.13.3.dev0
 
3
  library_name: peft
4
  ---
5
 
6
+ # Model Card for llama3.2-3b-Darija-Morocco-QA
 
 
 
7
 
8
+ This model is a fine-tuned version of Llama 3.2 3B, specifically optimized for answering questions in Darija (Moroccan Arabic). It leverages the Moroccan Wikipedia QA dataset for fine-tuning.
9
 
10
  ## Model Details
11
 
12
  ### Model Description
13
 
14
+ This model is designed to provide accurate and contextually relevant answers to questions posed in Darija, a dialect of Arabic spoken in Morocco. It has been fine-tuned using the Moroccan Wikipedia QA dataset to enhance its performance in this specific linguistic and cultural context.
 
 
 
 
 
 
 
 
 
 
15
 
16
+ - **Developed by:** Achraf Abbaoui
17
+ - **Model type:** Causal Language Model
18
+ - **Language(s) (NLP):** Darija (Moroccan Arabic)
19
+ - **License:** MIT License
20
+ - **Finetuned from model:** meta-llama/Llama-3.2-3B-Instruct
21
 
22
+ ### Model Sources
23
 
24
+ - **Repository:** [AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA](https://huggingface.co/AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA)
 
 
25
 
26
  ## Uses
27
 
 
 
28
  ### Direct Use
29
 
30
+ This model can be used directly for generating answers to questions in Darija. It is particularly useful for applications that require understanding and generating text in Moroccan Arabic, such as chatbots, virtual assistants, and educational tools.
 
 
31
 
32
+ ### Downstream Use
33
 
34
+ The model can be fine-tuned further for specific tasks or integrated into larger applications that require natural language processing capabilities in Darija.
 
 
35
 
36
  ### Out-of-Scope Use
37
 
38
+ This model is not intended for use in high-stakes decision-making scenarios or for generating offensive or harmful content. It should not be used for tasks that require understanding of languages other than Darija.
 
 
39
 
40
  ## Bias, Risks, and Limitations
41
 
42
+ The model may exhibit biases present in the training data, which could lead to unfair or inaccurate responses. It is important to evaluate the model's outputs carefully and consider the context in which it is used.
 
 
43
 
44
  ### Recommendations
45
 
46
+ Users should be aware of the potential biases and limitations of the model. It is recommended to use the model in conjunction with human oversight and to regularly evaluate its performance.
 
 
47
 
48
  ## How to Get Started with the Model
49
 
50
  Use the code below to get started with the model.
51
 
52
+ ```python
53
+ import torch
54
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
55
 
56
+ base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
57
+ bnb_config = BitsAndBytesConfig(
58
+ load_in_4bit=True,
59
+ bnb_4bit_use_double_quant=True,
60
+ bnb_4bit_quant_type="nf4",
61
+ bnb_4bit_compute_dtype=torch.bfloat16
62
+ )
63
 
64
+ base_model = AutoModelForCausalLM.from_pretrained(
65
+ base_model_id,
66
+ quantization_config=bnb_config,
67
+ device_map="auto",
68
+ trust_remote_code=True,
69
+ )
70
 
71
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
72
 
73
+ """Now load the QLoRA adapter from the appropriate checkpoint directory, i.e. the best performing model checkpoint:"""
74
 
75
+ from peft import PeftModel
76
 
77
+ ft_model = PeftModel.from_pretrained(base_model, "AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA")
78
 
79
+ """and run your inference!
80
+ """
 
 
 
 
81
 
82
+ eval_prompt = (
83
+ '### سؤال:\nشحال من دوار كاين ف مشيخة أيت عبد الله لي فيها أزكور؟\n\n'
84
+ '### سياق:\nأزكور هوّ دوار مجمع كاين ف جماعة أيت عبد الله، دائرة إغرم، إقليم تارودانت، جهة سوس ماسة ف لمغريب. هاد دّوار كينتامي ل مشيخة أيت عبد الله لي كتضم 15 د دّواور\n\n'
85
+ '### جواب:\n'
86
+ )
87
+ model_input = tokenizer(eval_prompt, return_tensors="pt").to("cuda")
88
 
89
+ ft_model.eval()
90
+ with torch.no_grad():
91
+ print(tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=300)[0], skip_special_tokens=True))
92
+ ```
93
 
94
+ If it does ask you to login to you huggingface account because access to "meta-llama/Llama-3.2-3B-Instruct" is restricted then past your HF token after this code:
95
+ ```Python
96
+ from huggingface_hub import interpreter_login
97
 
98
+ interpreter_login()
99
+ ```
100
 
101
+ ## Training Details
102
 
103
+ ### Training Data
104
 
105
+ The model was fine-tuned using the Moroccan Wikipedia QA dataset, which contains questions and answers in Darija.
106
 
107
+ ### Training Procedure
108
 
109
+ #### Preprocessing
110
 
111
+ The dataset was preprocessed to ensure consistent formatting and tokenization. The tokenizer was configured to pad on the left and add EOS and BOS tokens.
112
 
113
+ #### Training Hyperparameters
114
 
115
+ - **Training regime:** bf16 mixed precision
116
+ - **Learning rate:** 2.5e-5
117
+ - **Batch size:** 64
118
+ - **Max steps:** 500
119
+ - **Optimizer:** paged_adamw_8bit
120
 
121
+ #### Speeds, Sizes, Times
122
 
123
+ The model was trained on a single GPU for approximately 2 hours.
124
 
125
+ ## Evaluation
126
 
127
+ ### Testing Data, Factors & Metrics
128
 
129
+ #### Testing Data
130
 
131
+ The model was evaluated using a held-out subset of the Moroccan Wikipedia QA dataset.
132
 
133
  #### Summary
134
 
135
+ The model performed well on the evaluation dataset, demonstrating its ability to generate accurate and contextually relevant answers to questions in Darija.
136
 
137
+ ## Model Examination
138
 
139
+ The model's interpretability was examined using various techniques, including attention visualization and input perturbation.
 
 
 
 
140
 
141
  ## Environmental Impact
142
 
 
 
143
  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).
144
 
145
+ - **Hardware Type:** NVIDIA GPU
 
 
 
 
146
 
147
+ ## Technical Specifications
148
 
149
  ### Model Architecture and Objective
150
 
151
+ The model is based on the Llama 3.2 3B architecture and was fine-tuned using the PEFT library.
152
 
153
  ### Compute Infrastructure
154
 
 
 
155
  #### Hardware
156
 
157
+ - NVIDIA GPU
158
 
159
  #### Software
160
 
161
+ - PEFT 0.13.3.dev0
162
+ - Transformers 4.25.1
163
+ - PyTorch 1.12.1
164
 
165
+ ## Citation
166
 
167
  **BibTeX:**
168
 
169
+ ```bibtex
170
+ @misc{llama3.2-3b-Darija-Morocco-QA,
171
+ author = {Achraf Abbaoui},
172
+ title = {Llama 3.2 3B Fine-Tuned for Darija Moroccan QA},
173
+ year = {2024},
174
+ howpublished = {\url{https://huggingface.co/AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA}}
175
+ }
176
+ ```
177
 
178
  **APA:**
179
 
180
+ Abbaoui, A. (2024). Llama 3.2 3B Fine-Tuned for Darija Moroccan QA. Retrieved from https://huggingface.co/AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA
181
 
182
+ ## Glossary
183
 
184
+ - **Darija:** A dialect of Arabic spoken in Morocco.
185
+ - **Fine-tuning:** The process of training a pre-trained model on a specific dataset to improve its performance on a particular task.
186
 
187
+ ## More Information
188
 
189
+ For more information, please visit the [repository](https://huggingface.co/AchrafABBAOUI/llama3.2-3b-Darija-Morocco-QA).
190
 
191
+ ## Model Card Authors
192
 
193
+ Achraf Abbaoui
 
 
194
 
195
  ## Model Card Contact
196
 
197
+ For any questions or issues, please contact Achraf Abbaoui at [achraf.abbaoui2001@gmail.com].