cli.utils.load

cli.utils.load

Utilities for model, tokenizer, etc. loading.

Functions

Name Description
load_model_and_tokenizer Helper function for loading a model, tokenizer, and processor specified in the
resolve_chat_template_str Resolves the chat template string for inference from the axolotl config,

load_model_and_tokenizer

cli.utils.load.load_model_and_tokenizer(cfg, inference=False)

Helper function for loading a model, tokenizer, and processor specified in the given axolotl config.

Parameters

Name Type Description Default
cfg DictDefault Dictionary mapping axolotl config keys to values. required
inference bool Boolean denoting inference mode. False

Returns

Name Type Description
tuple[PreTrainedModel, PreTrainedTokenizer | PreTrainedTokenizerFast | Any, ProcessorMixin | None] Tuple of (PreTrainedModel, PreTrainedTokenizer, ProcessorMixin).

resolve_chat_template_str

cli.utils.load.resolve_chat_template_str(cfg, tokenizer)

Resolves the chat template string for inference from the axolotl config, mirroring how it would be resolved at training time: an explicit chat_template config takes precedence, then the first dataset’s chat_template if that dataset is of type chat_template.

Parameters

Name Type Description Default
cfg DictDefault Dictionary mapping axolotl config keys to values. required
tokenizer PreTrainedTokenizer | PreTrainedTokenizerFast | Any Tokenizer to fall back to for tokenizer-default templates. required

Returns

Name Type Description
str | None Chat template string, or None if the config does not specify one.