Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add transformers tag to the modelcard #32623

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/transformers/modelcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ def create_metadata(self):
metric_mapping = infer_metric_tags_from_eval_results(self.eval_results)

metadata = {}
metadata = _insert_value(metadata, "library_name", "transformers")
metadata = _insert_values_as_list(metadata, "language", self.language)
metadata = _insert_value(metadata, "license", self.license)
if self.finetuned_from is not None and isinstance(self.finetuned_from, str) and len(self.finetuned_from) > 0:
Expand Down
7 changes: 6 additions & 1 deletion tests/utils/test_model_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import tempfile
import unittest

from transformers.modelcard import ModelCard
from transformers.modelcard import ModelCard, TrainingSummary


class ModelCardTester(unittest.TestCase):
Expand Down Expand Up @@ -82,3 +82,8 @@ def test_model_card_from_and_save_pretrained(self):
model_card_second = ModelCard.from_pretrained(tmpdirname)

self.assertEqual(model_card_second.to_dict(), model_card_first.to_dict())

def test_model_summary_modelcard_base_metadata(self):
metadata = TrainingSummary("Model name").create_metadata()
self.assertTrue("library_name" in metadata)
self.assertTrue(metadata["library_name"] == "transformers")
Loading