Automatic configuration

This part automatically selects and loads the correct configuration and tokenizer based on the model.

Columns are parts of the code, grouped by process. Read top to bottom. Solid arrow: hands work over. Dashed: the reply. Purple: crosses between processes. Hook: work inside one part. Dashed boxes repeat. Hover a column name or a step for its full text.

MAIN PROCESSModel type mapping in parallelBegin resolving pipelineLoad configurationSelect configuration classResolve repository revisionConvert revision to commitLoad configuration dictionaryDownload and read c…Check trust settingResolve trust remot…Load custom classRetrieve class from…Register custom classRegister with auto…Instantiate configurationCreate config objectLoad assistant modelLoad assistant configFinalize configurationBegin tokenizer selectionSel…Resolve model type mappingGenerate options listResolve tokenizer revisionConvert to commit hashRes…Convert model type keyMap to module nameCreate Mistral backendInitialize tokenize…Select tokenizer assetsResolve asset paths
Pipeline setup
Auto config
Revision fix
Config loader
Auto tokenizer
1Begin resolving pipeline components — The pipeline resolver starts resolving the model, configuration, and task for the pipeline. It sets defaults like fast tokenizer enabled and automatic data type, validates that a model is provided, and prepares to load the configuration. If a PEFT adapter is detected, it may switch to the base model repository.
2Select configuration from mapping — Automatic configuration selects the correct configuration class based on the model type, checking for remote code and registered mappings. It sets internal flags indicating the configuration comes from an auto class and prepares to resolve the repository revision.
3Resolve mutable revision to commit — The commit resolver converts the requested revision, like a branch name, into an immutable commit hash. This ensures all files loaded during this pipeline creation come from the same repository snapshot, even if the repository is updated mid-load.
4Load configuration dictionary — Configuration instantiation downloads or reads the configuration file, following any redirect file if present. It returns the configuration dictionary and any remaining keyword arguments that were not consumed.
5Resolve trust remote code setting — Configuration instantiation checks whether the user has opted in to loading remote code. If remote code exists and the user has not explicitly trusted it, an error is raised requiring user consent.
6Load class from cached module — Configuration instantiation loads a custom configuration class from a cached Python module in the local directory or repository. It splits the class reference, requests the module file, and retrieves the class for use.
7Register custom configuration class — Configuration instantiation registers the loaded custom class with the auto configuration system. This allows the auto system to recognize and use the custom configuration for subsequent operations.
8Instantiate configuration object — Configuration instantiation creates the final configuration object from the pretrained model settings. It applies any user-provided overrides to the loaded values and returns the instantiated configuration.
9Load assistant model if needed — The pipeline resolver checks if an assistant model is needed for speculative decoding. If provided as a string identifier, it loads the assistant model and tokenizer, moving them to the correct device and comparing vocabulary settings.
10Finalize configuration selection — Automatic configuration completes its selection process, having resolved the repository, loaded the configuration dictionary, handled remote code trust, and instantiated the configuration object. It prepares to return the final configuration.
11Begin tokenizer selection process — Automatic tokenizer starts selecting the appropriate tokenizer through explicit choices, model metadata, and compatibility checks. It sets internal flags and determines whether to use a specialized backend for Mistral models.
12Resolve tokenizer repository revision — The commit resolver converts the tokenizer's requested revision into an immutable commit hash. This ensures the tokenizer files come from the same repository state as the model configuration.
13Resolve tokenizer class name — Configuration instantiation resolves the tokenizer class name to an actual class or backend, trying multiple lookup paths including registered aliases and module imports. It may install fast tokenizer aliases for successful lookups.
14Select and resolve tokenizer assets — Configuration instantiation selects tokenizer assets and resolves their paths from a local source or model repository. It discovers vocabulary files, tokenizer configuration, and chat templates, handling both local directories and remote downloads.
15Complete tokenizer selection — Automatic tokenizer completes its selection process, having resolved the tokenizer class, repository revision, and asset paths. It prepares to return the final tokenizer for use in the pipeline.
STEP · hover for full text