slicktune.models

Model and tokenizer loading helpers.

Functions

load_model(→ Any)

Load a causal LM configured for strategy.

load_tokenizer(→ transformers.PreTrainedTokenizerBase)

Load a tokenizer and ensure a pad token exists.

resolve_dtype(→ torch.dtype)

Pick a default compute dtype for the current device.

Package Contents

slicktune.models.load_model(*, model_id: str, strategy: slicktune.types.Strategy) Any[source]

Load a causal LM configured for strategy.

Parameters:
  • model_id (str) – Hugging Face model id or local path.

  • strategy (Strategy) – Parameter-update strategy providing load kwargs.

Returns:

Any – Hugging Face causal LM (not yet PEFT-wrapped unless strategy does so during apply).

slicktune.models.load_tokenizer(model_id: str) transformers.PreTrainedTokenizerBase[source]

Load a tokenizer and ensure a pad token exists.

Parameters:

model_id (str) – Hugging Face model id or local path.

Returns:

PreTrainedTokenizerBase – Tokenizer with pad_token set when missing.

slicktune.models.resolve_dtype() torch.dtype[source]

Pick a default compute dtype for the current device.

Returns:

torch.dtypebfloat16 on CUDA when supported, else float32 (including MPS, which is more stable for small SFT smoke tests than float16).