configs
Helper module for using model configs. For more information, see the corresponding Python documentation.
Example: Load an AutoConfig
.
import { AutoConfig } from '@huggingface/transformers';
const 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
- static
- .PretrainedConfig
new PretrainedConfig(configJSON)
- instance
.model_type
:string
|null
.is_encoder_decoder
:boolean
.max_position_embeddings
:number
- static
.from_pretrained(pretrained_model_name_or_path, options)
βPromise.<PretrainedConfig>
- .AutoConfig
.getKeyValueShapes(config)
βRecord.<string, Array<number>>
~decoderFeeds
:Record.<string, Array<number>>
- .PretrainedConfig
- inner
~loadConfig(pretrained_model_name_or_path, options)
βPromise.<Object>
~getNormalizedConfig(config)
βObject
~PretrainedOptions
:*
~ProgressCallback
:*
~ProgressInfo
:*
- static
configs.PretrainedConfig
Base class for all configuration classes. For more information, see the corresponding Python documentation.
Kind: static class of configs
- .PretrainedConfig
new PretrainedConfig(configJSON)
- instance
.model_type
:string
|null
.is_encoder_decoder
:boolean
.max_position_embeddings
:number
- static
.from_pretrained(pretrained_model_name_or_path, options)
βPromise.<PretrainedConfig>
new PretrainedConfig(configJSON)
Create a new PreTrainedTokenizer instance.
Param | Type | Description |
---|---|---|
configJSON | Object | The JSON of the config. |
pretrainedConfig.model_type : <code> string </code> | <code> null </code>
Kind: instance property of PretrainedConfig
pretrainedConfig.is_encoder_decoder : <code> boolean </code>
Kind: instance property of PretrainedConfig
pretrainedConfig.max_position_embeddings : <code> number </code>
Kind: instance property of PretrainedConfig
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`.
Param | Type | Description |
---|---|---|
pretrained_model_name_or_path | string | The path to the pre-trained config. |
options | PretrainedOptions | 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> * </code>
Kind: static method of AutoConfig
configs.getKeyValueShapes(config) β <code> Record. < string, Array < number > > </code>
Kind: static method of configs
Param | Type |
---|---|
config | PretrainedConfig |
getKeyValueShapes~decoderFeeds : <code> Record. < string, Array < number > > </code>
Kind: inner constant of getKeyValueShapes
configs~loadConfig(pretrained_model_name_or_path, options) β <code> Promise. < Object > </code>
Loads a config from the specified path.
Kind: inner method of configs
Returns: Promise.<Object>
- A promise that resolves with information about the loaded config.
Param | Type | Description |
---|---|---|
pretrained_model_name_or_path | string | The path to the config directory. |
options | PretrainedOptions | Additional options for loading the config. |
configs~getNormalizedConfig(config) β <code> Object </code>
Kind: inner method of configs
Returns: Object
- The normalized configuration.
Param | Type |
---|---|
config | PretrainedConfig |
configs~PretrainedOptions : <code> * </code>
Kind: inner typedef of configs
configs~ProgressCallback : <code> * </code>
Kind: inner typedef of configs
configs~ProgressInfo : <code> * </code>
Kind: inner typedef of configs
< > Update on GitHub