feat: Add datasets information in the model card

This commit is contained in:
Vinay Umrethe 2026-11-15 03:10:36 +00:00
parent a14b854353
commit 2ab2c628b4
No known key found for this signature in database
GPG Key ID: D5491E9AAB6A7424
1 changed files with 24 additions and 0 deletions

View File

@ -86,6 +86,7 @@ from .config import (
DatasetSpecification,
ExportStrategy,
QuantizationMethod,
SingleDatasetSpecification,
)
from .evaluator import Evaluator
from .model import Model, get_model_class
@ -1301,6 +1302,29 @@ def run():
if is_hf_path(settings.model):
card.data.base_model = settings.model
# Add the datasets that were used, in the
# `datasets` field of the model card.
flat_specifications: list[
SingleDatasetSpecification
] = []
for specification in dataset_specifications:
if isinstance(
specification, SingleDatasetSpecification
):
flat_specifications.append(specification)
else:
flat_specifications.extend(specification)
datasets: list[str] = list(
dict.fromkeys(
specification.dataset
for specification in flat_specifications
if is_hf_path(specification.dataset)
)
)
if datasets:
card.data.datasets = datasets
card.text = (
get_readme_intro(
settings,