Customizing the loading from foundation model
Check This First!
This article refers to BaseModel accessed via Docker container. Please refer to Snowflake Native App section if you are using BaseModel as SF GUI application.
The arguments of the load_from_foundation_model
are required to instantiate the scenario model trainer and specify the location of the foundation model for the scenario, the modelling task and expected output, and the target function. Optionally, they let you also e.g. use a customized logger, adapt the data source loading configuration, and modify majority of parameters described in Data configuration section of the foundation model.
Scenario Model Parameters |
---|
-
checkpoint_path : str
No default, required.
Directory where all the checkpoint artifacts of the selected foundation model are stored.
-
downstream_task : Task
No default, required
One of machine learning tasks defined in BaseModel.
Possible values areRegressionTask()
,RecommendationTask()
,BinaryClassificationTask(),
MultilabelClassificationTask(),
MulticlassClassificationTask()`.
-
target_fn : Callable[[Events, Events, Attributes, Dict], Union[Tensor, ndarray, Sketch]]
No default, required
Target function for the specified task. Needs definition in the script and return type aligned with the task.
-
num_outputs : int
No default, optional
The number of outputs of the network, required for all tasks exceptRecommendationTask()
.
Equal to number of predicted classes or to 1 in case ofBinaryClassificationTask()
andRegressionTask()
.
-
pl_logger : Logger
Default: None, optional
Instance of PytorchLightning logger.
-
loading_config : Task
Default: None, optional
A dictionary containing a mapping from datasource name (or from datasource name and mode) to the fields ofDataSourceLoadingConfig
. If provided, the listed parameters will be overwritten. Fielddatasource_cfg
cannot be changed.
Example:loading_config={ "product.buy": {"cache_dir": cache_dir}, "page.visit": {"cache_dir": cache_dir}, }
Additionally, as part of load_from_foundation_model
input you can overwrite MonadDataParams
configured before at Foundation Model training stage as part of data_params
and query_optimization
blocks.
Modifiable Data Parameters |
---|
- data_start_date : datetime
No default, required.
Events before this date will not be used in the training process; events after this date will be considered for training.
- check_target_for_next_N_days : int
default: None
The number of days, after the split point, considered for the model's target function period. Not applicable for recommendation tasks as these predict next basket regardless of time interval.
- validation_start_date : datetime
default: None
Initial date of the validation period.
- validation_end_date : datetime
default: None
The last date of the validation period.
- test_start_date : datetime
default: None
Initial date of the test period. It will be used for downstream models' predictions, but it can be set later, as part of prediction script.
- test_end_date : datetime
default: None
The last date of the test period.
- features_path : str
default: None
The path to the folder with features created during the foundation model training.
- timebased_encoding : Literal["two-hot", "fourier"]
default: "two-hot"
Controls the encoding of time-based features.
- target_sampling_strategy : Literal["valid", "random"]
default: "random"
Controls the data sampling for each entity; settingvalid
usually improves recommendation models.
- maximum_splitpoints_per_entity : int
default: 1
The maximum number of splits into input and target events per entity. In case of smaller data sets or highly imbalanced classes setting to more than 1 may improve performance, as it increases number of training examples. However, it will result with slower training.
- use_recency_sketches : boolean
default: True
If true then recency sketches are used in training.
- extra_columns : list['Extra_Column']
default: None
Columns discarded during foundation model fit stage, that should be then made available in the data_source e.g. for the definition of downstream model's target function.
- dynamic_events_sampling : boolean
default: True
A flag indicating whether to dynamically sample events from the input data. This is useful to avoid overfitting.
- [BETA] apply_event_count_weighting : boolean
default: False
If set to True, enables weighting based on the count of events. This means that the influence of each example in the dataset is adjusted according to the number of events it represents, typically to balance the contribution of examples with varying event counts.
- [BETA] apply_recency_based_weighting : boolean
default: False
If set to True, enables weighting based on the age of examples. This strategy assigns weights to examples based on their temporal proximity to a specific end date, giving preference to more recent examples under the assumption that they may be more relevant or indicative of current trends.
- [BETA] window_shuffling_buffer_size : int
default: 5_000_000
Buffer size used by random window shuffling.
- num_query_chunks : int
default: 1
This parameter represents the number of segments a query should be divided into. Splitting the query into smaller pieces can help reduce memory consumption on the database end.
Updated 8 days ago