MCPcopy
hub / github.com/huggingface/transformers / create_model_card

Method create_model_card

src/transformers/trainer.py:3948–4020  ·  view source on GitHub ↗

Creates a draft of a model card using the information available to the `Trainer`. Args: language (`str`, *optional*): The language of the model (if applicable) license (`str`, *optional*): The license of the model. Will defaul

(
        self,
        language: str | None = None,
        license: str | None = None,
        tags: str | list[str] | None = None,
        model_name: str | None = None,
        finetuned_from: str | None = None,
        tasks: str | list[str] | None = None,
        dataset_tags: str | list[str] | None = None,
        dataset: str | list[str] | None = None,
        dataset_args: str | list[str] | None = None,
    )

Source from the content-addressed store, hash-verified

3946 self.push_in_progress = None
3947
3948 def create_model_card(
3949 self,
3950 language: str | None = None,
3951 license: str | None = None,
3952 tags: str | list[str] | None = None,
3953 model_name: str | None = None,
3954 finetuned_from: str | None = None,
3955 tasks: str | list[str] | None = None,
3956 dataset_tags: str | list[str] | None = None,
3957 dataset: str | list[str] | None = None,
3958 dataset_args: str | list[str] | None = None,
3959 ) -> None:
3960 """
3961 Creates a draft of a model card using the information available to the `Trainer`.
3962
3963 Args:
3964 language (`str`, *optional*):
3965 The language of the model (if applicable)
3966 license (`str`, *optional*):
3967 The license of the model. Will default to the license of the pretrained model used, if the original
3968 model given to the `Trainer` comes from a repo on the Hub.
3969 tags (`str` or `list[str]`, *optional*):
3970 Some tags to be included in the metadata of the model card.
3971 model_name (`str`, *optional*):
3972 The name of the model.
3973 finetuned_from (`str`, *optional*):
3974 The name of the model used to fine-tune this one (if applicable). Will default to the name of the repo
3975 of the original model given to the `Trainer` (if it comes from the Hub).
3976 tasks (`str` or `list[str]`, *optional*):
3977 One or several task identifiers, to be included in the metadata of the model card.
3978 dataset_tags (`str` or `list[str]`, *optional*):
3979 One or several dataset tags, to be included in the metadata of the model card.
3980 dataset (`str` or `list[str]`, *optional*):
3981 One or several dataset identifiers, to be included in the metadata of the model card.
3982 dataset_args (`str` or `list[str]`, *optional*):
3983 One or several dataset arguments, to be included in the metadata of the model card.
3984 """
3985 if not self.is_world_process_zero():
3986 return
3987
3988 model_card_filepath = os.path.join(self.args.output_dir, "README.md")
3989 is_peft_library = False
3990 if os.path.exists(model_card_filepath):
3991 library_name = ModelCard.load(model_card_filepath).data.get("library_name")
3992 is_peft_library = library_name == "peft"
3993
3994 # Append existing tags in `tags`
3995 existing_tags = ModelCard.load(model_card_filepath).data.tags
3996 if tags is not None and existing_tags is not None:
3997 if isinstance(tags, str):
3998 tags = [tags]
3999 for tag in existing_tags:
4000 if tag not in tags:
4001 tags.append(tag)
4002
4003 training_summary = TrainingSummary.from_trainer(
4004 self,
4005 language=language,

Callers 15

push_to_hubMethod · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 5

is_world_process_zeroMethod · 0.95
joinMethod · 0.80
from_trainerMethod · 0.80
to_model_cardMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected