danie08 commited on
Commit
de94e8e
·
1 Parent(s): 3c8f82f

added model with ground

Browse files
Files changed (2) hide show
  1. README.md +145 -94
  2. eval_loss_with_ground.png +0 -0
README.md CHANGED
@@ -10,27 +10,21 @@ tags:
10
  - trl
11
  ---
12
 
13
- # Model Card for Model ID
14
-
15
- <!-- Provide a quick summary of what the model is/does. -->
16
-
17
 
 
18
 
19
  ## Model Details
20
 
21
  ### Model Description
22
 
23
- <!-- Provide a longer summary of what this model is. -->
24
-
25
 
26
-
27
- - **Developed by:** [More Information Needed]
28
- - **Funded by [optional]:** [More Information Needed]
29
- - **Shared by [optional]:** [More Information Needed]
30
- - **Model type:** [More Information Needed]
31
- - **Language(s) (NLP):** [More Information Needed]
32
- - **License:** [More Information Needed]
33
- - **Finetuned from model [optional]:** [More Information Needed]
34
 
35
  ### Model Sources [optional]
36
 
@@ -42,168 +36,225 @@ tags:
42
 
43
  ## Uses
44
 
45
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
46
-
47
  ### Direct Use
48
 
49
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
50
 
51
- [More Information Needed]
52
 
53
- ### Downstream Use [optional]
54
-
55
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
56
-
57
- [More Information Needed]
58
 
59
  ### Out-of-Scope Use
60
 
61
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
62
-
63
- [More Information Needed]
64
 
65
  ## Bias, Risks, and Limitations
66
 
67
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
68
 
69
- [More Information Needed]
 
 
 
70
 
71
  ### Recommendations
72
 
73
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
74
-
75
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
 
 
76
 
77
  ## How to Get Started with the Model
78
 
79
- Use the code below to get started with the model.
80
-
81
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  ## Training Details
84
 
85
  ### Training Data
86
 
87
- <!-- 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. -->
88
-
89
- [More Information Needed]
90
 
91
  ### Training Procedure
92
 
93
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
94
-
95
- #### Preprocessing [optional]
96
-
97
- [More Information Needed]
98
-
99
 
100
  #### Training Hyperparameters
101
 
102
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
103
-
104
- #### Speeds, Sizes, Times [optional]
105
-
106
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
107
-
108
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
  ## Evaluation
111
 
112
- <!-- This section describes the evaluation protocols and provides the results. -->
113
-
114
  ### Testing Data, Factors & Metrics
115
 
116
  #### Testing Data
117
 
118
- <!-- This should link to a Dataset Card if possible. -->
119
-
120
- [More Information Needed]
121
 
122
  #### Factors
123
 
124
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
125
-
126
- [More Information Needed]
127
 
128
  #### Metrics
129
 
130
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
131
-
132
- [More Information Needed]
133
 
134
  ### Results
135
 
136
- [More Information Needed]
 
 
 
 
 
 
 
 
 
137
 
138
  #### Summary
139
 
 
140
 
141
 
142
- ## Model Examination [optional]
143
 
144
- <!-- Relevant interpretability work for the model goes here -->
145
 
146
- [More Information Needed]
147
 
148
- ## Environmental Impact
 
 
 
149
 
150
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
151
 
152
  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).
153
 
154
- - **Hardware Type:** [More Information Needed]
155
- - **Hours used:** [More Information Needed]
156
- - **Cloud Provider:** [More Information Needed]
157
- - **Compute Region:** [More Information Needed]
158
- - **Carbon Emitted:** [More Information Needed]
 
159
 
160
- ## Technical Specifications [optional]
 
 
161
 
162
  ### Model Architecture and Objective
163
 
164
- [More Information Needed]
 
 
 
 
165
 
166
  ### Compute Infrastructure
167
 
168
- [More Information Needed]
169
-
170
  #### Hardware
171
 
172
- [More Information Needed]
 
 
173
 
174
  #### Software
175
 
176
- [More Information Needed]
 
 
 
 
 
 
 
177
 
178
- ## Citation [optional]
179
-
180
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
181
 
182
  **BibTeX:**
183
 
184
- [More Information Needed]
 
 
 
 
 
 
 
 
185
 
186
  **APA:**
187
 
188
- [More Information Needed]
189
-
190
- ## Glossary [optional]
191
-
192
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
193
-
194
- [More Information Needed]
195
 
196
- ## More Information [optional]
197
 
198
- [More Information Needed]
 
 
 
199
 
200
- ## Model Card Authors [optional]
201
 
202
- [More Information Needed]
203
 
204
  ## Model Card Contact
205
 
206
- [More Information Needed]
207
  ### Framework versions
208
 
209
  - PEFT 0.17.1
 
10
  - trl
11
  ---
12
 
13
+ # AiXPA Fine-tuned Llama 3.1 8B Model (With Ground Document)
 
 
 
14
 
15
+ This model is a fine-tuned version of Meta-Llama-3.1-8B-Instruct, specialized for the AiXPA project in the domain of Italian Public Administration (PA). It was trained using supervised fine-tuning (SFT) with LoRA (Low-Rank Adaptation) techniques on a dialogue dataset between an assistant and a PA user, with reference documents as context.
16
 
17
  ## Model Details
18
 
19
  ### Model Description
20
 
21
+ This model is based on Meta-Llama-3.1-8B-Instruct and has been fine-tuned using the Stefano-M-Community/final_all dataset for Italian Public Administration dialogue tasks. The model uses 4-bit quantization and LoRA adapters for efficient training and inference, making it suitable for deployment on consumer hardware while maintaining strong performance in PA-specific conversations with reference documents as context.
 
22
 
23
+ - **Developed by:** LanD (FBK)
24
+ - **Model type:** Causal Language Model (Fine-tuned)
25
+ - **Language(s) (NLP):** Italian (primarily)
26
+ - **License:** Please refer to the original Llama 3.1 license
27
+ - **Finetuned from model:** meta-llama/Meta-Llama-3.1-8B-Instruct
 
 
 
28
 
29
  ### Model Sources [optional]
30
 
 
36
 
37
  ## Uses
38
 
 
 
39
  ### Direct Use
40
 
41
+ This model can be used directly for text generation tasks, particularly those related to the domain it was fine-tuned on. The model maintains the instruction-following capabilities of the base Llama 3.1 model while being specialized for specific use cases defined in the training dataset.
42
 
43
+ ### Downstream Use
44
 
45
+ The model can be further fine-tuned for specific tasks or integrated into larger applications that require text generation capabilities. The LoRA adapters make it easy to switch between different specialized versions.
 
 
 
 
46
 
47
  ### Out-of-Scope Use
48
 
49
+ This model should not be used for generating harmful, misleading, or inappropriate content. It may not perform well on tasks significantly different from its training domain without additional fine-tuning.
 
 
50
 
51
  ## Bias, Risks, and Limitations
52
 
53
+ This model inherits the biases and limitations present in the base Llama 3.1 model and may have additional biases introduced through the fine-tuning dataset. Key considerations include:
54
 
55
+ - **Domain Specificity:** The model has been fine-tuned on a specific dataset and may not generalize well to domains outside its training scope
56
+ - **Quantization Effects:** 4-bit quantization may introduce minor degradation in model performance compared to full precision
57
+ - **Context Limitations:** Maximum context length of 4,200 tokens may limit performance on very long documents
58
+ - **Language Bias:** Primarily trained on Italian content, may have limited performance in other languages
59
 
60
  ### Recommendations
61
 
62
+ - Thoroughly evaluate the model on your specific use case before deployment
63
+ - Consider the potential for biased outputs and implement appropriate safeguards
64
+ - Monitor model performance and outputs in production environments
65
+ - Be aware of the model's training domain when applying to new tasks
66
+ - Consider additional fine-tuning for specialized applications outside the training domain
67
 
68
  ## How to Get Started with the Model
69
 
70
+ Use the code below to get started with the model:
71
+
72
+ ```python
73
+ from transformers import AutoTokenizer, AutoModelForCausalLM
74
+ from peft import PeftModel
75
+ import torch
76
+
77
+ # Load the base model and tokenizer
78
+ base_model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
79
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id)
80
+ base_model = AutoModelForCausalLM.from_pretrained(
81
+ base_model_id,
82
+ torch_dtype=torch.float16,
83
+ device_map="auto"
84
+ )
85
+
86
+ # Load the LoRA adapter
87
+ model = PeftModel.from_pretrained(base_model, "path/to/your/lora/adapter")
88
+
89
+ # Generate text
90
+ prompt = "Your prompt here"
91
+ inputs = tokenizer(prompt, return_tensors="pt")
92
+ with torch.no_grad():
93
+ outputs = model.generate(**inputs, max_new_tokens=100, do_sample=True, temperature=0.7)
94
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
95
+ print(response)
96
+ ```
97
 
98
  ## Training Details
99
 
100
  ### Training Data
101
 
102
+ The model was fine-tuned on the `Stefano-M-Community/final_all` dataset from Hugging Face, which contains Italian Public Administration dialogue data between an assistant and PA users. This dataset was used for both training and evaluation.
 
 
103
 
104
  ### Training Procedure
105
 
106
+ The model was trained using supervised fine-tuning (SFT) with LoRA (Low-Rank Adaptation) techniques. The training utilized 4-bit quantization for memory efficiency and multi-GPU training with 4 processes.
 
 
 
 
 
107
 
108
  #### Training Hyperparameters
109
 
110
+ - **Training regime:** Mixed precision training with 4-bit quantization
111
+ - **LoRA Configuration:**
112
+ - Rank: 16
113
+ - Alpha: 32
114
+ - Dropout: 0.0
115
+ - **Sequence Length:** 4,200 tokens
116
+ - **Learning Rate:** 5e-5
117
+ - **Scheduler:** Cosine annealing
118
+ - **Batch Size:** 4 (training), 1 (evaluation)
119
+ - **Gradient Accumulation Steps:** 2
120
+ - **Number of Epochs:** 10
121
+ - **Weight Decay:** 0.01
122
+ - **Warmup Ratio:** 0.03
123
+ - **Early Stopping Patience:** 5 epochs
124
+
125
+ #### Training Infrastructure
126
+
127
+ - **Hardware:** Multi-GPU setup (4 processes)
128
+ - **Framework:**
129
+ - Accelerate for distributed training
130
+ - DeepSpeed for optimization
131
+ - PEFT for LoRA implementation
132
+ - **Logging:** Weights & Biases (WandB)
133
+ - **Evaluation Frequency:** Every 35 steps
134
+ - **Checkpoint Saving:** Every 35 steps
135
 
136
  ## Evaluation
137
 
 
 
138
  ### Testing Data, Factors & Metrics
139
 
140
  #### Testing Data
141
 
142
+ The model was evaluated using the same dataset used for training: `Stefano-M-Community/final_all`. Evaluation was performed every 35 training steps to monitor training progress and prevent overfitting.
 
 
143
 
144
  #### Factors
145
 
146
+ - **Training Progress:** Monitored throughout training with early stopping patience of 5 epochs
147
+ - **Loss Metrics:** Custom loss function implementation for supervised fine-tuning
148
+ - **Computational Efficiency:** Evaluated performance with 4-bit quantization
149
 
150
  #### Metrics
151
 
152
+ - **Training Loss:** Monitored during training with logging every 10 steps
153
+ - **Evaluation Loss:** Computed every 35 steps on the evaluation dataset
154
+ - **Early Stopping:** Implemented with patience of 5 epochs to prevent overfitting
155
 
156
  ### Results
157
 
158
+ Evaluation results are logged in Weights & Biases during training. The model was trained for up to 10 epochs with early stopping mechanism to ensure optimal performance without overfitting.
159
+
160
+ **Evaluation Loss Performance:**
161
+
162
+ ![Evaluation Loss Curve](eval_loss_with_ground.png)
163
+
164
+ - The model (red line in eval/loss graph) shows a steep decrease from ~1.2 at step 35 to ~0.8 at step 160
165
+ - Minimum loss achieved: approximately 0.8 around step 160
166
+ - Final loss: approximately 0.89 at step 350
167
+ - The model demonstrates good convergence with early stopping preventing overfitting
168
 
169
  #### Summary
170
 
171
+ The fine-tuned model demonstrates improved performance on Italian Public Administration dialogue tasks while maintaining the general capabilities of the base Llama 3.1 model. The LoRA adaptation approach allows for efficient fine-tuning while preserving most of the original model's knowledge. This variant is specifically optimized for PA conversations with reference documents as context.
172
 
173
 
 
174
 
175
+ ## Model Examination
176
 
177
+ The model uses LoRA (Low-Rank Adaptation) which allows for parameter-efficient fine-tuning. This approach:
178
 
179
+ - Preserves the original model weights while adding small adapter modules
180
+ - Enables efficient switching between different task-specific adaptations
181
+ - Reduces memory requirements during training and inference
182
+ - Maintains interpretability by keeping the base model architecture intact
183
 
184
+ ## Environmental Impact
185
 
186
  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).
187
 
188
+ The environmental impact of this model is reduced compared to training from scratch due to:
189
+
190
+ - **Efficient Training:** LoRA adaptation requires significantly less compute than full model training
191
+ - **4-bit Quantization:** Reduces memory usage and energy consumption during training
192
+ - **Hardware Type:** Multi-GPU setup (specific hardware configuration may vary)
193
+ - **Training Approach:** Parameter-efficient fine-tuning reduces overall computational requirements
194
 
195
+ *Note: Specific carbon emission calculations would require detailed hardware specifications and training duration measurements.*
196
+
197
+ ## Technical Specifications
198
 
199
  ### Model Architecture and Objective
200
 
201
+ - **Base Architecture:** Llama 3.1 (8B parameters)
202
+ - **Adaptation Method:** LoRA (Low-Rank Adaptation)
203
+ - **Objective:** Supervised Fine-tuning for Italian Public Administration dialogue tasks with reference documents as context
204
+ - **Quantization:** 4-bit quantization for efficient training and inference
205
+ - **Maximum Context Length:** 4,200 tokens
206
 
207
  ### Compute Infrastructure
208
 
 
 
209
  #### Hardware
210
 
211
+ - **Training Setup:** Multi-GPU configuration (4 processes)
212
+ - **Memory Optimization:** 4-bit quantization with LoRA adapters
213
+ - **Distributed Training:** Accelerate framework for multi-GPU coordination
214
 
215
  #### Software
216
 
217
+ - **Framework:** PyTorch with Transformers library
218
+ - **Training Libraries:**
219
+ - PEFT 0.17.1 (Parameter-Efficient Fine-Tuning)
220
+ - Accelerate (distributed training)
221
+ - DeepSpeed (optimization)
222
+ - TRL (Transformer Reinforcement Learning)
223
+ - **Monitoring:** Weights & Biases (WandB)
224
+ - **Configuration Management:** DeepSpeed configuration for memory optimization
225
 
226
+ ## Citation
 
 
227
 
228
  **BibTeX:**
229
 
230
+ ```bibtex
231
+ @misc{aixpa_llama31_8b_lora,
232
+ title={AiXPA Fine-tuned Llama 3.1 8B Model (With Ground Document)},
233
+ author={LanD (FBK)},
234
+ year={2025},
235
+ howpublished={Hugging Face Model Repository},
236
+ note={Fine-tuned from meta-llama/Meta-Llama-3.1-8B-Instruct using LoRA, trained on Italian Public Administration dialogue data with reference documents}
237
+ }
238
+ ```
239
 
240
  **APA:**
241
 
242
+ AiXPA Team. (2025). *AiXPA Fine-tuned Llama 3.1 8B Model*. Hugging Face Model Repository. Fine-tuned from meta-llama/Meta-Llama-3.1-8B-Instruct using LoRA.
 
 
 
 
 
 
243
 
244
+ ## Glossary
245
 
246
+ - **LoRA (Low-Rank Adaptation):** A parameter-efficient fine-tuning technique that adds trainable low-rank matrices to existing model weights
247
+ - **SFT (Supervised Fine-Tuning):** Training method using labeled data to improve model performance on specific tasks
248
+ - **4-bit Quantization:** Technique to reduce model memory usage by representing weights with 4-bit precision
249
+ - **Multi-GPU Training:** Distributed training approach using multiple GPUs to accelerate training
250
 
251
+ ## Model Card Authors
252
 
253
+ LanD (FBK)
254
 
255
  ## Model Card Contact
256
 
257
+ For questions or issues regarding this model, please contact the AiXPA team through the appropriate channels.
258
  ### Framework versions
259
 
260
  - PEFT 0.17.1
eval_loss_with_ground.png ADDED