Transformers.js documentation

configs

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

configs

Helper module for using model configs. For more information, see the corresponding Python documentation.

Example: Load an AutoConfig.

import { AutoConfig } from '@xenova/transformers';
let config = await AutoConfig.from_pretrained('bert-base-uncased');
console.log(config);
// PretrainedConfig {
//   "model_type": "bert",
//   "is_encoder_decoder": false,
//   "architectures": [
//       "BertForMaskedLM"
//   ],
//   "vocab_size": 30522
//   "num_attention_heads": 12,
//   "num_hidden_layers": 12,
//   "hidden_size": 768,
//   "max_position_embeddings": 512,
//   ...
// }

configs.PretrainedConfig

Base class for all configuration classes. For more information, see the corresponding Python documentation.

Kind: static class of configs


new PretrainedConfig(configJSON)

Create a new PreTrainedTokenizer instance.

ParamTypeDescription
configJSONObject

The JSON of the config.


PretrainedConfig.from_pretrained(pretrained_model_name_or_path, options) β‡’ <code> Promise. < PretrainedConfig > </code>

Loads a pre-trained config from the given pretrained_model_name_or_path.

Kind: static method of PretrainedConfig
Returns: Promise.<PretrainedConfig> - A new instance of the PretrainedConfig class.
Throws:

  • Error Throws an error if the config.json is not found in the `pretrained_model_name_or_path`.
ParamTypeDescription
pretrained_model_name_or_pathstring

The path to the pre-trained config.

optionsPretrainedOptions

Additional options for loading the config.


configs.AutoConfig

Helper class which is used to instantiate pretrained configs with the from_pretrained function.

Kind: static class of configs


AutoConfig.from_pretrained() : <code> PretrainedConfig.from_pretrained </code>

Kind: static method of AutoConfig


configs~loadConfig(pretrained_model_name_or_path, options) β‡’ <code> Promise. < Array > </code>

Loads a config from the specified path.

Kind: inner method of configs
Returns: Promise.<Array> - A promise that resolves with information about the loaded config.

ParamTypeDescription
pretrained_model_name_or_pathstring

The path to the config directory.

optionsPretrainedOptions

Additional options for loading the config.


configs~PretrainedOptions : <code> * </code>

Kind: inner typedef of configs


< > Update on GitHub