fdastak commited on
Commit
568d35d
·
verified ·
1 Parent(s): 5cce459

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +279 -98
README.md CHANGED
@@ -1,11 +1,21 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
  # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
10
 
11
 
@@ -13,187 +23,358 @@ tags: []
13
 
14
  ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
 
18
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
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]
 
 
1
  ---
2
+ tags:
3
+ - pet_Health
4
+ - veterinary
5
+ license: mit
6
+ language:
7
+ - en
8
+ metrics:
9
+ - accuracy
10
+ - f1
11
+ base_model:
12
+ - havocy28/VetBERTDx
13
+ pipeline_tag: text-classification
14
  ---
15
 
16
  # Model Card for Model ID
17
 
18
+ This model classifies pet health symptoms from text descriptions into predefined health conditions, fine-tuned on VetBERTDx.
19
 
20
 
21
 
 
23
 
24
  ### Model Description
25
 
26
+ Fine-tuned VetBERTDx for sequence classification.
27
 
28
  This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
29
 
30
+ - **Developed by:** Fatemeh Dastak
31
  - **Funded by [optional]:** [More Information Needed]
32
  - **Shared by [optional]:** [More Information Needed]
33
+ - **Model type:** Fine-tuned VetBERTDx for sequence classification
34
+ - **Language(s) (NLP):** English
35
+ - **License:** MIT
36
+ - **Finetuned from model [optional]:** havocy28/VetBERTDx
37
 
38
  ### Model Sources [optional]
39
 
40
+ - **Repository:** https://huggingface.co/fdastak/model_classification
41
+ - **Dataset:** [Pet Health Symptoms Dataset](https://www.kaggle.com/datasets/yyzz1010/pet-health-symptoms-dataset)
 
 
 
42
 
43
  ## Uses
44
 
 
 
45
  ### Direct Use
46
+ ```python
47
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
48
 
49
+ model = AutoModelForSequenceClassification.from_pretrained("fdastak/model_classification")
50
+ tokenizer = AutoTokenizer.from_pretrained("fdastak/model_classification")
51
+ ```
52
 
53
+ ### Out-of-Scope Use
54
+ - Not for actual medical diagnosis
55
+ - Not a replacement for veterinary consultation
56
+ - Not suitable for emergency medical decisions
57
 
58
  ### Downstream Use [optional]
59
 
60
+ This model can be integrated into:
61
 
62
+ - Veterinary triage systems
63
+ - Pet health monitoring applications
64
+ - Symptom screening tools
65
+ - Educational veterinary platforms
66
 
67
  ### Out-of-Scope Use
68
 
69
+ This model should NOT be used for:
70
 
71
+ - Direct medical diagnosis
72
+ - Emergency medical decisions
73
+ - Replacement of veterinary consultation
74
+ - Legal or insurance decisions
75
+ - Automated treatment recommendation
76
 
77
  ## Bias, Risks, and Limitations
78
 
79
+ ## Technical Limitations
80
 
81
+ - Limited to 512 token input length
82
+ - CPU-only training constraints
83
+ - Early stopping at 301 steps
84
+ - Batch size limitations (8 training, 20 evaluation)
85
+ - Specific to owner-reported symptoms
86
 
87
+ ## Data Biases
88
 
89
+ - Training data from owner observations only
90
+ - English language only
91
+ - Limited to common pet conditions
92
+ - Potential reporting biases in symptoms
93
+ - Class imbalance considerations
94
 
95
+ ### Risk
96
 
97
+ -Misinterpretation of medical conditions
98
+ -Over-reliance on automated classification
99
+ -Delayed professional consultation
100
+ -False confidence in predictions
101
+ -Language and cultural biases
102
 
103
+ ### Recommendations
104
 
105
+ ## Best Practices
106
 
107
+ - Always verify predictions with professionals
108
+ - Use as screening tool only
109
+ - Monitor prediction confidence scores
110
+ - Implement user warnings
111
+ - Regular model evaluation
112
 
113
+ ## How to Get Started with the Model
114
 
115
+ # Load required libraries
116
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
117
+ import torch.nn.functional as F
118
 
119
+ # Load model and tokenizer
120
+ repo_id = "fdastak/model_classification"
121
+ model = AutoModelForSequenceClassification.from_pretrained(repo_id)
122
+ tokenizer = AutoTokenizer.from_pretrained(repo_id)
123
 
124
+ # Example usage
125
 
126
+ def classify_symptoms(text: str):
127
+ # Preprocess and tokenize
128
+ inputs = tokenizer(
129
+ text,
130
+ truncation=True,
131
+ padding=True,
132
+ max_length=512,
133
+ return_tensors="pt"
134
+ )
135
+
136
 
137
+ ## Training Details
138
 
139
+ ### Training Data
140
+ - Source: Pet Health Symptoms Dataset (Kaggle)
141
+ - Split: 80% training, 20% validation
142
+ - Preprocessing: Text lowercasing, label encoding
143
 
144
+ ### Training Procedure
145
 
146
  #### Training Hyperparameters
147
+ - Epochs: 5
148
+ - Train batch size: 8
149
+ - Eval batch size: 20
150
+ - Learning rate: 2e-5
151
+ - Scheduler: Linear with warmup
152
+ - Warmup ratio: 0.1
153
+ - Early stopping: At step 301
154
+ - Maximum sequence length: 512
155
 
156
+ ### Evaluation
 
 
 
 
157
 
158
+ #### Metrics
159
+ - Accuracy
160
+ - Precision (weighted)
161
+ - Recall (weighted)
162
+ - F1-score (weighted)
163
+ -
164
+ #### Speeds, Sizes, Times
165
+ - **Training Duration**: ~1 hour
166
+ - **Steps**: 301 (with early stopping)
167
+ - **Checkpoint Frequency**: Every 50 steps
168
+ - **Batch Processing**:
169
+ - Training: 8 samples/batch
170
+ - Evaluation: 20 samples/batch
171
+ - **Model Storage**: Local checkpoints in './model_classification'
172
 
173
  ## Evaluation
174
 
 
 
175
  ### Testing Data, Factors & Metrics
176
 
177
  #### Testing Data
178
+ - **Source**: [Pet Health Symptoms Dataset](https://www.kaggle.com/datasets/yyzz1010/pet-health-symptoms-dataset)
179
+ - **Split**: 20% of data (validation set)
180
+ - **Format**: Text descriptions with condition labels
181
+ - **Preprocessing**: Text lowercasing, label encoding
182
 
183
  #### Factors
184
+ - **Record Types**: Owner observations
185
+ - **Text Length**: Maximum 512 tokens
186
+ - **Language**: English
187
+ - **Conditions**: Multiple pet health conditions
188
+ - **Data Balance**: Stratified split for class distribution
189
 
190
  #### Metrics
191
+ - **Accuracy**: Overall classification accuracy
192
+ - **Precision (weighted)**: Measure of exactness
193
+ - **Recall (weighted)**: Measure of completeness
194
+ - **F1-score (weighted)**: Harmonic mean of precision and recall
195
+ - **Confusion Matrix**: Class-wise performance visualization
196
 
197
  ### Results
198
 
199
+ #### Performance Summary
200
+ - Overall Accuracy: 89%
201
+ - Average F1-Score: 0.89
202
+ - Class-wise Performance:
203
+ - Class 0: Highest precision (0.97) and F1-score (0.95)
204
+ - Class 1: Perfect recall (1.00)
205
+ - Class 2: Balanced performance (0.93 across metrics)
206
+ - Classes 3 & 4: Similar performance (~0.82-0.83 F1-score)
207
+
208
+ #### Key Metrics
209
+ - **Precision (weighted)**: 0.89
210
+ - **Recall (weighted)**: 0.89
211
+ - **F1-score (weighted)**: 0.89
212
+ - **Support**: 200 validation samples (40 per class)
213
 
214
  #### Summary
215
+ - Model shows balanced performance across classes
216
+ - Early stopping at step 301 prevents overfitting
217
+ - Validation performed every 50 steps
218
+ - Best model selected based on eval_loss
219
+ - Confusion matrix shows class-wise performance
220
+
221
+
222
+ ## Model Examination
223
+
224
+ ### Validation Results
225
+ The model's performance was examined using several evaluation methods:
226
+
227
+ 1. **Classification Metrics**
228
+ - Computed using sklearn's classification_report
229
+ - Includes precision, recall, and F1-score
230
+ - Evaluated on validation dataset
231
+ - Weighted averages to handle class imbalance
232
+
233
+ 2. **Confusion Matrix Analysis**
234
+ ```python
235
+ # Visualization code
236
+ from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
237
+ import matplotlib.pyplot as plt
238
+
239
+ model.eval()
240
+ with torch.no_grad():
241
+ # Prediction collection
242
+ true_labels = []
243
+ pred_labels = []
244
+ pred_scores = []
245
+ # ...evaluation logic
246
+ ```
247
+
248
+ 3. **Prediction Confidence**
249
+ - Softmax probabilities for class predictions
250
+ - Confidence scores tracked for each prediction
251
+ - Score distribution analysis for reliability
252
+
253
+ 4. **Early Stopping Analysis**
254
+ - Training stopped at step 301
255
+ - Monitored eval_loss for best model selection
256
+ - Used custom StopAtStepCallback for controlled training
257
+
258
+ ### Model Interpretability
259
+ - Base model: VetBERTDx (domain-specific veterinary BERT)
260
+ - Fine-tuned for pet symptom classification
261
+ - Uses attention mechanisms for text understanding
262
+ - Maximum sequence length: 512 tokens
263
+
264
+ ### Limitations
265
+ - CPU-only training might affect model capacity
266
+ - Limited to predefined condition categories
267
+ - Performance varies by symptom complexity
268
+ - Early stopping may affect final performance
269
 
270
  ## Environmental Impact
271
 
 
 
272
  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).
273
 
274
+ - **Hardware Type:** CPU (Personal Computer)
275
+ - **Hours used:** ~2 hours (301 steps with early stopping)
276
+ - **Cloud Provider:** None (Local training)
277
+ - **Compute Region:** USA (Colorado)
278
+ - **Power Mix:** Rocky Mountain Power Grid
279
+ - **Training Configuration:**
280
+ - 301 steps with early stopping
281
+ - CPU-based training
282
+ - Batch size: 8 samples
283
+ - Epochs: 5
284
+ - Local machine execution
285
+
286
+ Environmental considerations:
287
+ - Used CPU instead of GPU for lower power consumption
288
+ - Implemented early stopping at step 301
289
+ - Leveraged pre-trained model (VetBERTDx)
290
+ - Local training to minimize data center impact
291
+ - Efficient batch size selection
292
 
293
  ## Technical Specifications [optional]
294
 
295
  ### Model Architecture and Objective
296
 
297
+ - Base model: VetBERTDx
298
+ - Task: Sequence classification
299
+ - Input: Text descriptions of pet symptoms
300
+ - Output: Classification among health conditions
301
 
302
  ### Compute Infrastructure
303
 
304
+ - Framework: PyTorch
305
+ - Training device: GPU
306
+ - Python dependencies:
307
+ - transformers
308
+ - torch
309
+ - numpy
310
+ - scikit-learn
311
 
312
  #### Hardware
313
 
314
+ The model was trained using:
315
+ - Training Device: CPU
316
+ - Batch Configuration:
317
+ - Training batch size: 8
318
+ - Evaluation batch size: 20
319
+ - Training Steps: Limited to 301 (early stopping)
320
+ - Local Storage: Required for model checkpoints in './model_classification'
321
 
322
  #### Software
323
 
324
+ Training environment specifications:
325
+ - Python 3.11
326
+ - Core Libraries:
327
+ ```python
328
+ torch>=2.0.0
329
+ transformers>=4.30.0
330
+ numpy>=1.24.0
331
+ pandas>=1.5.0
332
+ scikit-learn>=1.0.0
333
+ sentence-transformers>=2.2.0
334
+ ```
335
+ - Training Components:
336
+ - Framework: 🤗 Transformers
337
+ - Base Model: havocy28/VetBERTDx
338
+ - Tokenizer: AutoTokenizer
339
+ - Model Class: AutoModelForSequenceClassification
340
+ - Training API: Transformers Trainer with custom callbacks
341
+ - Logging: Python's built-in logging module
342
+
343
  ## Citation [optional]
344
 
345
+ If you use this model in your research, please cite it using the following:
346
 
347
  **BibTeX:**
348
+ ```bibtex
349
+ @misc{dastak2024pethealthclassifier,
350
+ title={Pet Health Symptoms Classification Model},
351
+ author={Dastak, Fatemeh},
352
+ year={2024},
353
+ publisher={Hugging Face},
354
+ howpublished={\url{https://huggingface.co/fdastak/model_classification}},
355
+ note={Based on VetBERTDx by Havocy28},
356
+ keywords={veterinary-nlp, text-classification, pet-health}
357
+ }
358
+ ```
359
 
360
  **APA:**
361
+ ```
362
+ Dastak, F. (2025). Pet Health Symptoms Classification Model [Machine learning model]. Hugging Face Model Hub. https://huggingface.co/fdastak/model_classification
363
+ ```
364
+
365
+ Please also cite the base model:
366
+ ```
367
+ @misc{havocy282023vetbertdx,
368
+ title={VetBERTDx: A Domain-Specific Language Model for Veterinary Medicine},
369
+ author={Havocy28},
370
+ year={2023},
371
+ publisher={Hugging Face},
372
+ howpublished={\url{https://huggingface.co/havocy28/VetBERTDx}}
373
+ }
374
+ ```
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  ## Model Card Contact
378
 
379
+ Author: Fatemeh Dastak
380
+ Repository: https://huggingface.co/fdastak/model_classification