Spaces:
Running
Running
improves model card
Browse files
docs/ENHANCED_MODEL_CARD_METADATA.md
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Enhanced Model Card Metadata System
|
2 |
+
|
3 |
+
## Overview
|
4 |
+
|
5 |
+
The enhanced model card system now includes comprehensive YAML metadata that follows the [Hugging Face Model Cards specification](https://huggingface.co/docs/hub/en/model-cards). This ensures maximum compatibility with the Hugging Face Hub and provides rich metadata for model discovery and usage.
|
6 |
+
|
7 |
+
## Metadata Structure
|
8 |
+
|
9 |
+
### Core Metadata Fields
|
10 |
+
|
11 |
+
The model card template now includes the following metadata fields:
|
12 |
+
|
13 |
+
```yaml
|
14 |
+
---
|
15 |
+
language:
|
16 |
+
- en
|
17 |
+
- fr
|
18 |
+
license: apache-2.0
|
19 |
+
library_name: transformers
|
20 |
+
tags:
|
21 |
+
- smollm3
|
22 |
+
- fine-tuned
|
23 |
+
- causal-lm
|
24 |
+
- text-generation
|
25 |
+
- quantized
|
26 |
+
- dataset:OpenHermes-FR
|
27 |
+
- config:H100 Lightweight
|
28 |
+
pipeline_tag: text-generation
|
29 |
+
base_model: HuggingFaceTB/SmolLM3-3B
|
30 |
+
datasets:
|
31 |
+
- OpenHermes-FR
|
32 |
+
---
|
33 |
+
```
|
34 |
+
|
35 |
+
### Conditional Metadata
|
36 |
+
|
37 |
+
The system supports conditional metadata based on model configuration:
|
38 |
+
|
39 |
+
#### Quantized Models
|
40 |
+
When quantized models are available, additional metadata is included:
|
41 |
+
|
42 |
+
```yaml
|
43 |
+
quantization_types:
|
44 |
+
- int8_weight_only
|
45 |
+
- int4_weight_only
|
46 |
+
```
|
47 |
+
|
48 |
+
#### Model Index (Evaluation Results)
|
49 |
+
The system automatically generates structured evaluation results:
|
50 |
+
|
51 |
+
```yaml
|
52 |
+
model-index:
|
53 |
+
- name: Model Name
|
54 |
+
results:
|
55 |
+
- task:
|
56 |
+
type: text-generation
|
57 |
+
dataset:
|
58 |
+
name: OpenHermes-FR
|
59 |
+
type: OpenHermes-FR
|
60 |
+
metrics:
|
61 |
+
- name: Training Loss
|
62 |
+
type: loss
|
63 |
+
value: "2.1"
|
64 |
+
- name: Validation Loss
|
65 |
+
type: loss
|
66 |
+
value: "2.3"
|
67 |
+
- name: Perplexity
|
68 |
+
type: perplexity
|
69 |
+
value: "9.8"
|
70 |
+
```
|
71 |
+
|
72 |
+
For quantized models, additional entries are included:
|
73 |
+
|
74 |
+
```yaml
|
75 |
+
- name: Model Name (int8 quantized)
|
76 |
+
results:
|
77 |
+
- task:
|
78 |
+
type: text-generation
|
79 |
+
dataset:
|
80 |
+
name: OpenHermes-FR
|
81 |
+
type: OpenHermes-FR
|
82 |
+
metrics:
|
83 |
+
- name: Memory Reduction
|
84 |
+
type: memory_efficiency
|
85 |
+
value: "~50%"
|
86 |
+
- name: Inference Speed
|
87 |
+
type: speed
|
88 |
+
value: "Faster"
|
89 |
+
```
|
90 |
+
|
91 |
+
## Metadata Fields Explained
|
92 |
+
|
93 |
+
### Required Fields
|
94 |
+
|
95 |
+
| Field | Description | Example |
|
96 |
+
|-------|-------------|---------|
|
97 |
+
| `language` | Supported languages | `["en", "fr"]` |
|
98 |
+
| `license` | Model license | `"apache-2.0"` |
|
99 |
+
| `library_name` | Primary library | `"transformers"` |
|
100 |
+
| `tags` | Model tags for discovery | `["smollm3", "fine-tuned"]` |
|
101 |
+
| `pipeline_tag` | Task type | `"text-generation"` |
|
102 |
+
| `base_model` | Original model | `"HuggingFaceTB/SmolLM3-3B"` |
|
103 |
+
|
104 |
+
### Optional Fields
|
105 |
+
|
106 |
+
| Field | Description | Example |
|
107 |
+
|-------|-------------|---------|
|
108 |
+
| `datasets` | Training datasets | `["OpenHermes-FR"]` |
|
109 |
+
| `author` | Model author | `"Your Name"` |
|
110 |
+
| `experiment_name` | Experiment tracking | `"smollm3-experiment"` |
|
111 |
+
| `trackio_url` | Monitoring URL | `"https://trackio.space/exp"` |
|
112 |
+
| `hardware` | Training hardware | `"GPU (H100/A100)"` |
|
113 |
+
| `training_config` | Configuration type | `"H100 Lightweight"` |
|
114 |
+
| `trainer_type` | Trainer used | `"SFTTrainer"` |
|
115 |
+
| `batch_size` | Training batch size | `"8"` |
|
116 |
+
| `learning_rate` | Learning rate | `"5e-6"` |
|
117 |
+
| `max_epochs` | Number of epochs | `"3"` |
|
118 |
+
| `max_seq_length` | Sequence length | `"2048"` |
|
119 |
+
| `gradient_accumulation_steps` | Gradient accumulation | `"16"` |
|
120 |
+
|
121 |
+
### Training Results
|
122 |
+
|
123 |
+
| Field | Description | Example |
|
124 |
+
|-------|-------------|---------|
|
125 |
+
| `training_loss` | Final training loss | `"2.1"` |
|
126 |
+
| `validation_loss` | Final validation loss | `"2.3"` |
|
127 |
+
| `perplexity` | Model perplexity | `"9.8"` |
|
128 |
+
|
129 |
+
## Benefits of Enhanced Metadata
|
130 |
+
|
131 |
+
### 1. Improved Discovery
|
132 |
+
- **Filtering**: Users can filter models by dataset, configuration, or hardware
|
133 |
+
- **Search**: Enhanced search capabilities on the Hugging Face Hub
|
134 |
+
- **Tags**: Automatic tag generation for better categorization
|
135 |
+
|
136 |
+
### 2. Better Model Cards
|
137 |
+
- **Structured Data**: Evaluation results are displayed in widgets
|
138 |
+
- **Consistent Format**: Follows Hugging Face standards
|
139 |
+
- **Rich Information**: Comprehensive model information
|
140 |
+
|
141 |
+
### 3. Integration Benefits
|
142 |
+
- **Papers with Code**: Model index data can be indexed in leaderboards
|
143 |
+
- **API Compatibility**: Better integration with Hugging Face APIs
|
144 |
+
- **Automated Tools**: Support for automated model analysis
|
145 |
+
|
146 |
+
## Usage Examples
|
147 |
+
|
148 |
+
### Basic Model Card Generation
|
149 |
+
|
150 |
+
```bash
|
151 |
+
python scripts/model_tonic/generate_model_card.py \
|
152 |
+
--repo-name "username/model-name" \
|
153 |
+
--model-name "My Fine-tuned Model" \
|
154 |
+
--dataset-name "OpenHermes-FR" \
|
155 |
+
--training-config "H100 Lightweight" \
|
156 |
+
--batch-size "8" \
|
157 |
+
--learning-rate "5e-6" \
|
158 |
+
--max-epochs "3" \
|
159 |
+
--training-loss "2.1" \
|
160 |
+
--validation-loss "2.3" \
|
161 |
+
--perplexity "9.8" \
|
162 |
+
--output "README.md"
|
163 |
+
```
|
164 |
+
|
165 |
+
### With Quantized Models
|
166 |
+
|
167 |
+
```bash
|
168 |
+
python scripts/model_tonic/generate_model_card.py \
|
169 |
+
--repo-name "username/model-name" \
|
170 |
+
--model-name "My Fine-tuned Model" \
|
171 |
+
--dataset-name "OpenHermes-FR" \
|
172 |
+
--training-config "H100 Lightweight" \
|
173 |
+
--batch-size "8" \
|
174 |
+
--learning-rate "5e-6" \
|
175 |
+
--max-epochs "3" \
|
176 |
+
--training-loss "2.1" \
|
177 |
+
--validation-loss "2.3" \
|
178 |
+
--perplexity "9.8" \
|
179 |
+
--quantized-models \
|
180 |
+
--output "README.md"
|
181 |
+
```
|
182 |
+
|
183 |
+
## Template Variables
|
184 |
+
|
185 |
+
The enhanced template supports all the original variables plus new metadata fields:
|
186 |
+
|
187 |
+
### New Variables
|
188 |
+
|
189 |
+
| Variable | Description | Default |
|
190 |
+
|----------|-------------|---------|
|
191 |
+
| `training_loss` | Training loss value | `"N/A"` |
|
192 |
+
| `validation_loss` | Validation loss value | `"N/A"` |
|
193 |
+
| `perplexity` | Model perplexity | `"N/A"` |
|
194 |
+
|
195 |
+
### Conditional Metadata
|
196 |
+
|
197 |
+
The template automatically includes:
|
198 |
+
|
199 |
+
- **Dataset Information**: When `dataset_name` is provided
|
200 |
+
- **Quantization Types**: When `quantized_models` is `true`
|
201 |
+
- **Evaluation Results**: When training metrics are available
|
202 |
+
- **Hardware Information**: When `hardware_info` is provided
|
203 |
+
|
204 |
+
## Integration with Training Pipeline
|
205 |
+
|
206 |
+
### Automatic Metadata Generation
|
207 |
+
|
208 |
+
The push script automatically extracts metadata from:
|
209 |
+
|
210 |
+
1. **Training Configuration**: Batch size, learning rate, epochs, etc.
|
211 |
+
2. **Training Results**: Loss values, perplexity, etc.
|
212 |
+
3. **Model Information**: Base model, hardware, etc.
|
213 |
+
4. **Experiment Tracking**: Trackio URLs, experiment names
|
214 |
+
|
215 |
+
### Example Integration
|
216 |
+
|
217 |
+
```python
|
218 |
+
# In push_to_huggingface.py
|
219 |
+
variables = {
|
220 |
+
"model_name": f"{self.repo_name.split('/')[-1]} - Fine-tuned SmolLM3",
|
221 |
+
"repo_name": self.repo_name,
|
222 |
+
"base_model": "HuggingFaceTB/SmolLM3-3B",
|
223 |
+
"dataset_name": training_config.get('dataset_name', 'OpenHermes-FR'),
|
224 |
+
"training_config_type": training_config.get('training_config_type', 'Custom Configuration'),
|
225 |
+
"trainer_type": training_config.get('trainer_type', 'SFTTrainer'),
|
226 |
+
"batch_size": str(training_config.get('per_device_train_batch_size', 8)),
|
227 |
+
"learning_rate": str(training_config.get('learning_rate', '5e-6')),
|
228 |
+
"max_epochs": str(training_config.get('num_train_epochs', 3)),
|
229 |
+
"hardware_info": self._get_hardware_info(),
|
230 |
+
"training_loss": results.get('train_loss', 'N/A'),
|
231 |
+
"validation_loss": results.get('eval_loss', 'N/A'),
|
232 |
+
"perplexity": results.get('perplexity', 'N/A'),
|
233 |
+
"quantized_models": False # Updated if quantized models are added
|
234 |
+
}
|
235 |
+
```
|
236 |
+
|
237 |
+
## Validation and Testing
|
238 |
+
|
239 |
+
### Metadata Validation
|
240 |
+
|
241 |
+
The system includes validation for:
|
242 |
+
|
243 |
+
- **Required Fields**: Ensures all required metadata is present
|
244 |
+
- **Format Validation**: Validates YAML syntax and structure
|
245 |
+
- **Value Ranges**: Checks for reasonable values in numeric fields
|
246 |
+
- **Conditional Logic**: Verifies conditional metadata is properly included
|
247 |
+
|
248 |
+
### Test Coverage
|
249 |
+
|
250 |
+
The test suite verifies:
|
251 |
+
|
252 |
+
- **Basic Metadata**: All required fields are present
|
253 |
+
- **Conditional Metadata**: Quantized model metadata is included when appropriate
|
254 |
+
- **Evaluation Results**: Model index data is properly structured
|
255 |
+
- **Template Processing**: Variable substitution works correctly
|
256 |
+
|
257 |
+
## Best Practices
|
258 |
+
|
259 |
+
### 1. Metadata Completeness
|
260 |
+
- Include all available training information
|
261 |
+
- Provide accurate evaluation metrics
|
262 |
+
- Use consistent naming conventions
|
263 |
+
|
264 |
+
### 2. Conditional Logic
|
265 |
+
- Only include relevant metadata
|
266 |
+
- Use conditional sections appropriately
|
267 |
+
- Provide fallback values for missing data
|
268 |
+
|
269 |
+
### 3. Validation
|
270 |
+
- Test metadata generation with various configurations
|
271 |
+
- Verify YAML syntax is correct
|
272 |
+
- Check that all variables are properly substituted
|
273 |
+
|
274 |
+
### 4. Documentation
|
275 |
+
- Document all available metadata fields
|
276 |
+
- Provide examples for each field type
|
277 |
+
- Include troubleshooting information
|
278 |
+
|
279 |
+
## Future Enhancements
|
280 |
+
|
281 |
+
### Planned Features
|
282 |
+
|
283 |
+
1. **Additional Metrics**: Support for more evaluation metrics
|
284 |
+
2. **Custom Metadata**: User-defined metadata fields
|
285 |
+
3. **Validation Rules**: Configurable validation rules
|
286 |
+
4. **Auto-Detection**: Automatic detection of model features
|
287 |
+
5. **Integration APIs**: Better integration with external tools
|
288 |
+
|
289 |
+
### Extensibility
|
290 |
+
|
291 |
+
The system is designed to be easily extensible:
|
292 |
+
|
293 |
+
- **New Fields**: Easy to add new metadata fields
|
294 |
+
- **Custom Validators**: Support for custom validation logic
|
295 |
+
- **Template Extensions**: Support for template inheritance
|
296 |
+
- **API Integration**: Easy integration with external APIs
|
297 |
+
|
298 |
+
## Conclusion
|
299 |
+
|
300 |
+
The enhanced model card metadata system provides comprehensive, standards-compliant metadata that maximizes compatibility with the Hugging Face Hub while providing rich information for model discovery and usage. The system automatically generates appropriate metadata based on model configuration and training results, ensuring consistency and completeness across all model repositories.
|
scripts/model_tonic/generate_model_card.py
CHANGED
@@ -105,7 +105,10 @@ def create_default_variables() -> Dict[str, Any]:
|
|
105 |
"author_name": "Your Name",
|
106 |
"model_name_slug": "smollm3-fine-tuned",
|
107 |
"quantized_models": False,
|
108 |
-
"dataset_sample_size": None
|
|
|
|
|
|
|
109 |
}
|
110 |
|
111 |
def parse_args():
|
@@ -133,6 +136,9 @@ def parse_args():
|
|
133 |
parser.add_argument("--quantized-models", action="store_true",
|
134 |
help="Include quantized models")
|
135 |
parser.add_argument("--dataset-sample-size", help="Dataset sample size")
|
|
|
|
|
|
|
136 |
|
137 |
return parser.parse_args()
|
138 |
|
@@ -186,6 +192,12 @@ def main():
|
|
186 |
variables["quantized_models"] = True
|
187 |
if args.dataset_sample_size:
|
188 |
variables["dataset_sample_size"] = args.dataset_sample_size
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
# Generate model card
|
191 |
print("π Generating model card...")
|
|
|
105 |
"author_name": "Your Name",
|
106 |
"model_name_slug": "smollm3-fine-tuned",
|
107 |
"quantized_models": False,
|
108 |
+
"dataset_sample_size": None,
|
109 |
+
"training_loss": "N/A",
|
110 |
+
"validation_loss": "N/A",
|
111 |
+
"perplexity": "N/A"
|
112 |
}
|
113 |
|
114 |
def parse_args():
|
|
|
136 |
parser.add_argument("--quantized-models", action="store_true",
|
137 |
help="Include quantized models")
|
138 |
parser.add_argument("--dataset-sample-size", help="Dataset sample size")
|
139 |
+
parser.add_argument("--training-loss", help="Training loss value")
|
140 |
+
parser.add_argument("--validation-loss", help="Validation loss value")
|
141 |
+
parser.add_argument("--perplexity", help="Perplexity value")
|
142 |
|
143 |
return parser.parse_args()
|
144 |
|
|
|
192 |
variables["quantized_models"] = True
|
193 |
if args.dataset_sample_size:
|
194 |
variables["dataset_sample_size"] = args.dataset_sample_size
|
195 |
+
if args.training_loss:
|
196 |
+
variables["training_loss"] = args.training_loss
|
197 |
+
if args.validation_loss:
|
198 |
+
variables["validation_loss"] = args.validation_loss
|
199 |
+
if args.perplexity:
|
200 |
+
variables["perplexity"] = args.perplexity
|
201 |
|
202 |
# Generate model card
|
203 |
print("π Generating model card...")
|
scripts/model_tonic/push_to_huggingface.py
CHANGED
@@ -151,7 +151,10 @@ class HuggingFacePusher:
|
|
151 |
"author_name": training_config.get('author_name', 'Your Name'),
|
152 |
"model_name_slug": self.repo_name.split('/')[-1].lower().replace('-', '_'),
|
153 |
"quantized_models": False, # Will be updated if quantized models are added
|
154 |
-
"dataset_sample_size": training_config.get('dataset_sample_size')
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
# Create generator and generate model card
|
|
|
151 |
"author_name": training_config.get('author_name', 'Your Name'),
|
152 |
"model_name_slug": self.repo_name.split('/')[-1].lower().replace('-', '_'),
|
153 |
"quantized_models": False, # Will be updated if quantized models are added
|
154 |
+
"dataset_sample_size": training_config.get('dataset_sample_size'),
|
155 |
+
"training_loss": results.get('train_loss', 'N/A'),
|
156 |
+
"validation_loss": results.get('eval_loss', 'N/A'),
|
157 |
+
"perplexity": results.get('perplexity', 'N/A')
|
158 |
}
|
159 |
|
160 |
# Create generator and generate model card
|
templates/model_card.md
CHANGED
@@ -3,12 +3,138 @@ language:
|
|
3 |
- en
|
4 |
- fr
|
5 |
license: apache-2.0
|
|
|
6 |
tags:
|
7 |
- smollm3
|
8 |
- fine-tuned
|
9 |
- causal-lm
|
10 |
- text-generation
|
11 |
- {{#if quantized_models}}quantized{{/if}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
---
|
13 |
|
14 |
# {{model_name}}
|
|
|
3 |
- en
|
4 |
- fr
|
5 |
license: apache-2.0
|
6 |
+
library_name: transformers
|
7 |
tags:
|
8 |
- smollm3
|
9 |
- fine-tuned
|
10 |
- causal-lm
|
11 |
- text-generation
|
12 |
- {{#if quantized_models}}quantized{{/if}}
|
13 |
+
- {{#if dataset_name}}dataset:{{dataset_name}}{{/if}}
|
14 |
+
- {{#if training_config_type}}config:{{training_config_type}}{{/if}}
|
15 |
+
pipeline_tag: text-generation
|
16 |
+
base_model: {{base_model}}
|
17 |
+
{{#if dataset_name}}
|
18 |
+
datasets:
|
19 |
+
- {{dataset_name}}
|
20 |
+
{{/if}}
|
21 |
+
{{#if quantized_models}}
|
22 |
+
model-index:
|
23 |
+
- name: {{model_name}}
|
24 |
+
results:
|
25 |
+
- task:
|
26 |
+
type: text-generation
|
27 |
+
dataset:
|
28 |
+
name: {{dataset_name}}
|
29 |
+
type: {{dataset_name}}
|
30 |
+
metrics:
|
31 |
+
- name: Training Loss
|
32 |
+
type: loss
|
33 |
+
value: "{{training_loss|default:'N/A'}}"
|
34 |
+
- name: Validation Loss
|
35 |
+
type: loss
|
36 |
+
value: "{{validation_loss|default:'N/A'}}"
|
37 |
+
- name: Perplexity
|
38 |
+
type: perplexity
|
39 |
+
value: "{{perplexity|default:'N/A'}}"
|
40 |
+
- name: {{model_name}} (int8 quantized)
|
41 |
+
results:
|
42 |
+
- task:
|
43 |
+
type: text-generation
|
44 |
+
dataset:
|
45 |
+
name: {{dataset_name}}
|
46 |
+
type: {{dataset_name}}
|
47 |
+
metrics:
|
48 |
+
- name: Memory Reduction
|
49 |
+
type: memory_efficiency
|
50 |
+
value: "~50%"
|
51 |
+
- name: Inference Speed
|
52 |
+
type: speed
|
53 |
+
value: "Faster"
|
54 |
+
- name: {{model_name}} (int4 quantized)
|
55 |
+
results:
|
56 |
+
- task:
|
57 |
+
type: text-generation
|
58 |
+
dataset:
|
59 |
+
name: {{dataset_name}}
|
60 |
+
type: {{dataset_name}}
|
61 |
+
metrics:
|
62 |
+
- name: Memory Reduction
|
63 |
+
type: memory_efficiency
|
64 |
+
value: "~75%"
|
65 |
+
- name: Inference Speed
|
66 |
+
type: speed
|
67 |
+
value: "Significantly Faster"
|
68 |
+
{{else}}
|
69 |
+
model-index:
|
70 |
+
- name: {{model_name}}
|
71 |
+
results:
|
72 |
+
- task:
|
73 |
+
type: text-generation
|
74 |
+
dataset:
|
75 |
+
name: {{dataset_name}}
|
76 |
+
type: {{dataset_name}}
|
77 |
+
metrics:
|
78 |
+
- name: Training Loss
|
79 |
+
type: loss
|
80 |
+
value: "{{training_loss|default:'N/A'}}"
|
81 |
+
- name: Validation Loss
|
82 |
+
type: loss
|
83 |
+
value: "{{validation_loss|default:'N/A'}}"
|
84 |
+
- name: Perplexity
|
85 |
+
type: perplexity
|
86 |
+
value: "{{perplexity|default:'N/A'}}"
|
87 |
+
{{/if}}
|
88 |
+
{{#if author_name}}
|
89 |
+
author: {{author_name}}
|
90 |
+
{{/if}}
|
91 |
+
{{#if experiment_name}}
|
92 |
+
experiment_name: {{experiment_name}}
|
93 |
+
{{/if}}
|
94 |
+
{{#if trackio_url}}
|
95 |
+
trackio_url: {{trackio_url}}
|
96 |
+
{{/if}}
|
97 |
+
{{#if dataset_repo}}
|
98 |
+
dataset_repo: {{dataset_repo}}
|
99 |
+
{{/if}}
|
100 |
+
{{#if hardware_info}}
|
101 |
+
hardware: {{hardware_info}}
|
102 |
+
{{/if}}
|
103 |
+
{{#if training_config_type}}
|
104 |
+
training_config: {{training_config_type}}
|
105 |
+
{{/if}}
|
106 |
+
{{#if trainer_type}}
|
107 |
+
trainer_type: {{trainer_type}}
|
108 |
+
{{/if}}
|
109 |
+
{{#if batch_size}}
|
110 |
+
batch_size: {{batch_size}}
|
111 |
+
{{/if}}
|
112 |
+
{{#if learning_rate}}
|
113 |
+
learning_rate: {{learning_rate}}
|
114 |
+
{{/if}}
|
115 |
+
{{#if max_epochs}}
|
116 |
+
max_epochs: {{max_epochs}}
|
117 |
+
{{/if}}
|
118 |
+
{{#if max_seq_length}}
|
119 |
+
max_seq_length: {{max_seq_length}}
|
120 |
+
{{/if}}
|
121 |
+
{{#if dataset_sample_size}}
|
122 |
+
dataset_sample_size: {{dataset_sample_size}}
|
123 |
+
{{/if}}
|
124 |
+
{{#if dataset_size}}
|
125 |
+
dataset_size: {{dataset_size}}
|
126 |
+
{{/if}}
|
127 |
+
{{#if dataset_format}}
|
128 |
+
dataset_format: {{dataset_format}}
|
129 |
+
{{/if}}
|
130 |
+
{{#if gradient_accumulation_steps}}
|
131 |
+
gradient_accumulation_steps: {{gradient_accumulation_steps}}
|
132 |
+
{{/if}}
|
133 |
+
{{#if quantized_models}}
|
134 |
+
quantization_types:
|
135 |
+
- int8_weight_only
|
136 |
+
- int4_weight_only
|
137 |
+
{{/if}}
|
138 |
---
|
139 |
|
140 |
# {{model_name}}
|
quick_test_training.py β tests/quick_test_training.py
RENAMED
File without changes
|
tests/test_unified_model_card.py
CHANGED
@@ -42,7 +42,10 @@ def test_basic_model_card():
|
|
42 |
"author_name": "Test User",
|
43 |
"model_name_slug": "test_smollm3_model",
|
44 |
"quantized_models": False,
|
45 |
-
"dataset_sample_size": "
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
try:
|
@@ -66,6 +69,13 @@ def test_basic_model_card():
|
|
66 |
assert "int8" not in content
|
67 |
assert "int4" not in content
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
print("β
Basic model card generation test passed")
|
70 |
return True
|
71 |
|
@@ -100,7 +110,10 @@ def test_quantized_model_card():
|
|
100 |
"author_name": "Test User",
|
101 |
"model_name_slug": "test_smollm3_model",
|
102 |
"quantized_models": True,
|
103 |
-
"dataset_sample_size": "
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
try:
|
@@ -125,6 +138,14 @@ def test_quantized_model_card():
|
|
125 |
assert "test-user/test-model/int8" in content
|
126 |
assert "test-user/test-model/int4" in content
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
print("β
Quantized model card generation test passed")
|
129 |
return True
|
130 |
|
@@ -198,8 +219,11 @@ def test_file_saving():
|
|
198 |
"dataset_format": "Chat format",
|
199 |
"author_name": "Test User",
|
200 |
"model_name_slug": "test_model",
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
# Generate and save
|
|
|
42 |
"author_name": "Test User",
|
43 |
"model_name_slug": "test_smollm3_model",
|
44 |
"quantized_models": False,
|
45 |
+
"dataset_sample_size": "800000",
|
46 |
+
"training_loss": "2.1",
|
47 |
+
"validation_loss": "2.3",
|
48 |
+
"perplexity": "9.8"
|
49 |
}
|
50 |
|
51 |
try:
|
|
|
69 |
assert "int8" not in content
|
70 |
assert "int4" not in content
|
71 |
|
72 |
+
# Check that metadata fields are present
|
73 |
+
assert "library_name: transformers" in content
|
74 |
+
assert "pipeline_tag: text-generation" in content
|
75 |
+
assert "base_model: HuggingFaceTB/SmolLM3-3B" in content
|
76 |
+
assert "datasets:" in content
|
77 |
+
assert "model-index:" in content
|
78 |
+
|
79 |
print("β
Basic model card generation test passed")
|
80 |
return True
|
81 |
|
|
|
110 |
"author_name": "Test User",
|
111 |
"model_name_slug": "test_smollm3_model",
|
112 |
"quantized_models": True,
|
113 |
+
"dataset_sample_size": "800000",
|
114 |
+
"training_loss": "2.1",
|
115 |
+
"validation_loss": "2.3",
|
116 |
+
"perplexity": "9.8"
|
117 |
}
|
118 |
|
119 |
try:
|
|
|
138 |
assert "test-user/test-model/int8" in content
|
139 |
assert "test-user/test-model/int4" in content
|
140 |
|
141 |
+
# Check that metadata fields are present
|
142 |
+
assert "library_name: transformers" in content
|
143 |
+
assert "pipeline_tag: text-generation" in content
|
144 |
+
assert "base_model: HuggingFaceTB/SmolLM3-3B" in content
|
145 |
+
assert "datasets:" in content
|
146 |
+
assert "model-index:" in content
|
147 |
+
assert "quantization_types:" in content
|
148 |
+
|
149 |
print("β
Quantized model card generation test passed")
|
150 |
return True
|
151 |
|
|
|
219 |
"dataset_format": "Chat format",
|
220 |
"author_name": "Test User",
|
221 |
"model_name_slug": "test_model",
|
222 |
+
"quantized_models": False,
|
223 |
+
"dataset_sample_size": None,
|
224 |
+
"training_loss": "N/A",
|
225 |
+
"validation_loss": "N/A",
|
226 |
+
"perplexity": "N/A"
|
227 |
}
|
228 |
|
229 |
# Generate and save
|