Unsloth base library
Unsloth base library with shared helper methods for model loading and training.
This module provides the base class for Unsloth implementations, with reusable helper methods to eliminate code duplication across SFT and GRPO trainers.
Reviewers
-
References
NONE
UnslothBaseLibrary
Bases: ABC
Base class for Unsloth fine-tuning implementations with shared helper methods.
framework_name: str
abstractmethod
property
Get the name of the framework.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The framework name. |
load_model(experiment_args, hyperparameters, **kwargs)
abstractmethod
Load a model based on the provided configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_args |
ExperimentConfig
|
Configuration for the experiment. |
required |
hyperparameters |
FinetunedHyperparameters
|
Configuration for the hyperparameters. |
required |
**kwargs |
Any
|
Additional framework-specific arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
|
A tuple containing the loaded model and tokenizer. |
save_tokenizer(tokenizer, path, **kwargs)
abstractmethod
Save the tokenizer to the specified path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tokenizer |
The tokenizer instance to save. |
required | |
path |
str
|
The directory path to save the tokenizer to. |
required |
**kwargs |
Any
|
Additional framework-specific arguments. |
{}
|