onnx_diagnostic.torch_models.hghub.hub_api

onnx_diagnostic.torch_models.hghub.hub_api.enumerate_model_list(n: int = 50, task: str | None = None, library: str | None = None, tags: str | List[str] | None = None, search: str | None = None, dump: str | None = None, filter: str | None = None, verbose: int = 0)[source][source]

Enumerates models coming from huggingface_hub.

Parameters:
  • n – number of models to retrieve (-1 for all)

  • task – see huggingface_hub.HfApi.list_models()

  • tags – see huggingface_hub.HfApi.list_models()

  • library – see huggingface_hub.HfApi.list_models()

  • search – see huggingface_hub.HfApi.list_models()

  • filter – see huggingface_hub.HfApi.list_models()

  • dump – dumps the result in this csv file

  • verbose – show progress

onnx_diagnostic.torch_models.hghub.hub_api.get_architecture_default_values(architecture: str)[source][source]

The configuration may miss information to build the dummy inputs. This information returns the missing pieces.

onnx_diagnostic.torch_models.hghub.hub_api.get_cached_configuration(name: str, exc: bool = False, **kwargs) PretrainedConfig | None[source][source]

Returns cached configuration to avoid having to many accesses to internet. It returns None if not Cache. The list of cached models follows. If exc is True or if environment variable NOHTTP is defined, the function raises an exception if name is not found.

    ['HuggingFaceM4/tiny-random-idefics',
     'Intel/bert-base-uncased-mrpc',
     'Xenova/tiny-random-Phi3ForCausalLM',
     'arnir0/Tiny-LLM',
     'echarlaix/tiny-random-PhiForCausalLM',
     'echarlaix/tiny-random-mistral',
     'facebook/bart-base',
     'facebook/bart-large-cnn',
     'fxmarty/pix2struct-tiny-random',
     'fxmarty/tiny-dummy-qwen2',
     'fxmarty/tiny-llama-fast-tokenizer',
     'fxmarty/tiny-random-GemmaForCausalLM',
     'google-bert/bert-base-multilingual-cased',
     'hf-internal-testing/tiny-random-BeitForImageClassification',
     'hf-internal-testing/tiny-random-GPTNeoXForCausalLM',
     'hf-internal-testing/tiny-random-GraniteForCausalLM',
     'hf-internal-testing/tiny-random-HieraForImageClassification',
     'hf-internal-testing/tiny-random-MaskFormerForInstanceSegmentation',
     'hf-internal-testing/tiny-random-MoonshineForConditionalGeneration',
     'hf-internal-testing/tiny-random-Olmo2ForCausalLM',
     'hf-internal-testing/tiny-random-OlmoForCausalLM',
     'hf-internal-testing/tiny-random-ViTMSNForImageClassification',
     'hf-internal-testing/tiny-random-YolosModel',
     'hf-internal-testing/tiny-random-convnext',
     'hf-internal-testing/tiny-random-mobilevit',
     'hf-internal-testing/tiny-xlm-roberta',
     'hf-tiny-model-private/tiny-random-PLBartForConditionalGeneration',
     'hustvl/yolos-tiny',
     'microsoft/Phi-3-mini-4k-instruct',
     'microsoft/Phi-3.5-mini-instruct',
     'microsoft/Phi-4-mini-reasoning',
     'microsoft/phi-2',
     'openai/clip-vit-base-patch16',
     'openai/whisper-tiny',
     'sentence-transformers/all-MiniLM-L6-v1',
     'sshleifer/tiny-marian-en-de',
     'tiiuae/falcon-mamba-tiny-dev',
     'ydshieh/tiny-random-ViTForImageClassification']
onnx_diagnostic.torch_models.hghub.hub_api.get_model_info(model_id) Any[source][source]

Returns the model info for a model_id.

onnx_diagnostic.torch_models.hghub.hub_api.get_pretrained_config(model_id: str, trust_remote_code: bool = True, use_preinstalled: bool = True, subfolder: str | None = None, use_only_preinstalled: bool = False, **kwargs) Any[source][source]

Returns the config for a model_id.

Parameters:
  • model_id – model id

  • trust_remote_code – trust_remote_code, see transformers.AutoConfig.from_pretrained()

  • use_preinstalled – if use_preinstalled, uses this version to avoid accessing the network, if available, it is returned by get_cached_configuration(), the cached list is mostly for unit tests

  • subfolder – subfolder for the given model id

  • use_only_preinstalled – if True, raises an exception if not preinstalled

  • kwargs – additional kwargs

Returns:

a configuration

onnx_diagnostic.torch_models.hghub.hub_api.task_from_arch(arch: str, default_value: str | None = None) str[source][source]

This function relies on stored information. That information needs to be refresh.

Parameters:
  • arch – architecture name

  • default_value – default value in case the task cannot be determined

Returns:

task

    last refresh 2025-03-26

List of supported architectures, see load_architecture_task.

onnx_diagnostic.torch_models.hghub.hub_api.task_from_id(model_id: str, default_value: str | None = None, pretrained: bool = False, fall_back_to_pretrained: bool = True) str[source][source]

Returns the task attached to a model id.

Parameters:
  • model_id – model id

  • default_value – if specified, the function returns this value if the task cannot be determined

  • pretrained – uses the config

  • fall_back_to_pretrained – falls back to pretrained config

Returns:

task

onnx_diagnostic.torch_models.hghub.hub_api.task_from_tags(tags: str | List[str]) str[source][source]

Guesses the task from the list of tags. If given by a string, | should be the separator.