Utility functions to interact with the Hugging Face Hub ()
Hub
Utility functions to interact with the Hugging Face Hub ()
Type Definitions
ExternalData
Specifies whether to load the model using the external data format.
false: Do not use external data formattrue: Use external data format with 1 chunknumber: 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 tonull— If specified, this function is called during model construction with progress updates.config(PretrainedConfig) optional — defaults tonull— 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_pathand a configuration JSON file named config.json is found in the directory.
cache_dir(string) optional — defaults tonull— 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 tofalse— 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,revisioncan 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 tonull— Override the base ONNX model file name, excluding dtype and.onnxsuffixes. This is most useful for single-session models.device(DeviceType|Record<string,DeviceType>) optional — defaults tonull— 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 tonull— 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 tonull— Whether to load external data files.nulluses the model configuration;falsedisables external data;trueuses 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
Source and license
Source: Transformers.js documentation, adapted for this site. Licensing and attribution follow the terms of the upstream project.