Transformers.js documentation

utils/hub

You are viewing main version, which requires installation from source. If you'd like regular npm install, checkout the latest stable version (v3.8.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

utils/hub

Utility functions to interact with the Hugging Face Hub (https://huggingface.co/models)

Type Definitions

ExternalData

Specifies whether to load the model using the external data format.

  • false: Do not use external data format
  • true: Use external data format with 1 chunk
  • number: Use external data format with the specified number of chunks

Type: boolean | number

PretrainedOptions

Options for loading a pretrained model.

Properties

  • progress_callback (ProgressCallback) optional β€” defaults to null β€” If specified, this function is called during model construction with progress updates.
  • config (PretrainedConfig) optional β€” defaults to null β€” Configuration to use for the model instead of an automatically loaded configuration. Configuration can be automatically loaded when:
    • The model is provided by the library and loaded with the model ID string of a pretrained model.
    • The model is loaded by supplying a local directory as pretrained_model_name_or_path and a configuration JSON file named config.json is found in the directory.
  • cache_dir (string) optional β€” defaults to null β€” Path to a directory where downloaded model files should be cached if the standard cache should not be used.
  • local_files_only (boolean) optional β€” defaults to false β€” Whether to only look at local files (e.g., not try downloading the model).
  • revision (string) optional β€” defaults to 'main' β€” The model revision to use. This can be a branch name, tag name, or commit ID. Because the Hub uses Git-based storage, revision can be any identifier accepted by Git. Ignored for local requests.

ModelSpecificPretrainedOptions

Options for loading a pretrained model.

Properties

  • subfolder (string) optional β€” defaults to 'onnx' β€” In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can specify the folder name here.
  • model_file_name (string) optional β€” defaults to null β€” Override the base ONNX model file name, excluding dtype and .onnx suffixes. This is most useful for single-session models.
  • device (DeviceType | Record<string, DeviceType>) optional β€” defaults to null β€” The device to run the model on. If not specified, the device will be chosen from the environment settings.
  • dtype (DataType | Record<string, DataType>) optional β€” defaults to null β€” The data type to use for the model. If not specified, the data type will be chosen from the environment settings.
  • use_external_data_format (ExternalData | Record<string, ExternalData>) optional β€” defaults to null β€” Whether to load external data files. null uses the model configuration; false disables external data; true uses one chunk; a number selects the chunk count.
  • session_options (InferenceSession.SessionOptions) optional β€” defaults to {} β€” User-specified ONNX Runtime session options. Suitable defaults are filled in when omitted.

PretrainedModelOptions

Options for loading a pretrained model.

Type: PretrainedOptions & ModelSpecificPretrainedOptions

Update on GitHub