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 are RegressionTask(), 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 except RecommendationTask().
    Equal to number of predicted classes or to 1 in case of BinaryClassificationTask() and RegressionTask().

  • 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 of DataSourceLoadingConfig. If provided, the listed parameters will be overwritten. Field datasource_cfg cannot be changed.
    Example:

    loading_config={  
        "product.buy": {"cache_dir": cache_dir},  
        "page.visit": {"cache_dir": cache_dir},  
    }
    

📘

Good to know

Additionally, as part of load_from_foundation_model input, you can expand or overwrite configurations made during the Foundation Model training stage.

  • data_params: dates to separate training, validation and test sets, managing sampling, number of split points, declaring extra columns to be available for target function etc.
  • query_optimization: chunking query, capping sample size or CPUs in case of infrastructure constraints.

To review the list of modifiable parameters refer to: