Spaces:
Paused
Paused
Hanzo Dev
commited on
Commit
Β·
7d5010c
1
Parent(s):
205f509
Add automatic model card generation with dataset documentation
Browse files
app.py
CHANGED
|
@@ -327,6 +327,111 @@ def train_model(
|
|
| 327 |
yield from log("β
TRAINING COMPLETED!")
|
| 328 |
yield from log("=" * 80)
|
| 329 |
yield from log(f"π Final Loss: {result.training_loss:.4f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
yield from log(f"βοΈ Model uploaded to: {output_repo}")
|
| 331 |
yield from log("")
|
| 332 |
yield from log("π SUCCESS!")
|
|
|
|
| 327 |
yield from log("β
TRAINING COMPLETED!")
|
| 328 |
yield from log("=" * 80)
|
| 329 |
yield from log(f"π Final Loss: {result.training_loss:.4f}")
|
| 330 |
+
|
| 331 |
+
# Generate model card with dataset info
|
| 332 |
+
yield from log("")
|
| 333 |
+
yield from log("π Generating model card...")
|
| 334 |
+
|
| 335 |
+
from datetime import datetime
|
| 336 |
+
|
| 337 |
+
# Build dataset info for model card
|
| 338 |
+
dataset_info = []
|
| 339 |
+
dataset_hf_ids = []
|
| 340 |
+
for dataset_name in selected_datasets:
|
| 341 |
+
if " / " in dataset_name:
|
| 342 |
+
dataset_short_name = dataset_name.split(" / ", 1)[1]
|
| 343 |
+
else:
|
| 344 |
+
dataset_short_name = dataset_name
|
| 345 |
+
|
| 346 |
+
for category in DATASETS.values():
|
| 347 |
+
if dataset_short_name in category:
|
| 348 |
+
ds_config = category[dataset_short_name]
|
| 349 |
+
dataset_info.append(f"- [{dataset_short_name}](https://huggingface.co/datasets/{ds_config['hf_id']}) ({ds_config['size']})")
|
| 350 |
+
dataset_hf_ids.append(ds_config['hf_id'])
|
| 351 |
+
break
|
| 352 |
+
|
| 353 |
+
model_card = f"""---
|
| 354 |
+
language:
|
| 355 |
+
- en
|
| 356 |
+
license: apache-2.0
|
| 357 |
+
tags:
|
| 358 |
+
- zen
|
| 359 |
+
- vision-language
|
| 360 |
+
- function-calling
|
| 361 |
+
- agent
|
| 362 |
+
base_model: {model_config['hf_id']}
|
| 363 |
+
datasets:
|
| 364 |
+
{chr(10).join([f"- {hf_id}" for hf_id in dataset_hf_ids])}
|
| 365 |
+
---
|
| 366 |
+
|
| 367 |
+
# {output_repo.split('/')[-1]}
|
| 368 |
+
|
| 369 |
+
Fine-tuned from [{model_config['hf_id']}](https://huggingface.co/{model_config['hf_id']}) using the Zen Training Space.
|
| 370 |
+
|
| 371 |
+
## Training Details
|
| 372 |
+
|
| 373 |
+
### Base Model
|
| 374 |
+
- **Model**: {model_short_name}
|
| 375 |
+
- **Size**: {model_config['size']} parameters
|
| 376 |
+
- **Type**: {model_config['type']}
|
| 377 |
+
- **Base HF ID**: [{model_config['hf_id']}](https://huggingface.co/{model_config['hf_id']})
|
| 378 |
+
|
| 379 |
+
### Datasets Used
|
| 380 |
+
{chr(10).join(dataset_info)}
|
| 381 |
+
|
| 382 |
+
### Training Configuration
|
| 383 |
+
- **Total Samples**: {len(all_datasets):,}
|
| 384 |
+
- **Epochs**: {epochs}
|
| 385 |
+
- **Batch Size**: {batch_size}
|
| 386 |
+
- **Learning Rate**: {learning_rate}
|
| 387 |
+
- **Precision**: bfloat16
|
| 388 |
+
- **Final Training Loss**: {result.training_loss:.4f}
|
| 389 |
+
- **Training Date**: {datetime.now().strftime('%Y-%m-%d %H:%M:%S UTC')}
|
| 390 |
+
|
| 391 |
+
### Hardware
|
| 392 |
+
- **GPU**: NVIDIA A10G (24GB)
|
| 393 |
+
- **Platform**: HuggingFace Spaces
|
| 394 |
+
|
| 395 |
+
## Usage
|
| 396 |
+
|
| 397 |
+
```python
|
| 398 |
+
from transformers import AutoModel, AutoProcessor
|
| 399 |
+
|
| 400 |
+
model = AutoModel.from_pretrained("{output_repo}", trust_remote_code=True)
|
| 401 |
+
processor = AutoProcessor.from_pretrained("{output_repo}")
|
| 402 |
+
|
| 403 |
+
# Your inference code here
|
| 404 |
+
```
|
| 405 |
+
|
| 406 |
+
## Training Space
|
| 407 |
+
|
| 408 |
+
This model was trained using the [Zen Training Space](https://huggingface.co/spaces/zeekay/zen-training),
|
| 409 |
+
a unified platform for training all Zen AI models.
|
| 410 |
+
|
| 411 |
+
## Citation
|
| 412 |
+
|
| 413 |
+
```bibtex
|
| 414 |
+
@misc{{{output_repo.replace('/', '_').replace('-', '_')},
|
| 415 |
+
author = {{Zen AI}},
|
| 416 |
+
title = {{{output_repo.split('/')[-1]}}},
|
| 417 |
+
year = {{2025}},
|
| 418 |
+
publisher = {{HuggingFace}},
|
| 419 |
+
url = {{https://huggingface.co/{output_repo}}}
|
| 420 |
+
}}
|
| 421 |
+
```
|
| 422 |
+
|
| 423 |
+
---
|
| 424 |
+
|
| 425 |
+
*Trained with β€οΈ using [Zen Training Space](https://huggingface.co/spaces/zeekay/zen-training)*
|
| 426 |
+
"""
|
| 427 |
+
|
| 428 |
+
# Save model card
|
| 429 |
+
import os
|
| 430 |
+
os.makedirs("./training-output", exist_ok=True)
|
| 431 |
+
with open("./training-output/README.md", "w") as f:
|
| 432 |
+
f.write(model_card)
|
| 433 |
+
|
| 434 |
+
yield from log("β
Model card generated")
|
| 435 |
yield from log(f"βοΈ Model uploaded to: {output_repo}")
|
| 436 |
yield from log("")
|
| 437 |
yield from log("π SUCCESS!")
|