Palantir enables the creation of a model that wrap weights produced outside of the platform. These files can include open-source model weights, models trained in a local development environment, models trained in the Code Workspaces application, and model weights from legacy systems.
Once a Palantir model has been created, Palantir provides the following:
To create a model from model files, you will need the following:
First, upload your model files to an unstructured dataset in the Palantir platform. Create a new dataset by selecting +New > Dataset in a Project.
Then, select Import new data and choose the files from your computer to upload to the model.
If required, you can upload many different files to the same dataset. The dataset will be unstructured, meaning it will not have a tabular schema.
Create a new code repository that will manage the logic for reading the model files from your unstructured dataset. The logic will wrap those files in a model adapter and publish them as a model. In the Code Repositories application, choose to initialize a Model Integration repository with the Model Training language template.
View the full documentation on the Model Training template and the model adapter API for reference.
To publish model files in your unstructured dataset as a Palantir model, you must author a transform that completes the following:
You can place the logic for loading and publishing a model within the model_training
folder in the repository.
For additional information, we recommend reviewing the following documentation:
Once you have defined your model training logic, select Build to execute the logic to read the model files and publish a model.
Copied!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
from transforms.api import transform, Input from palantir_models.transforms import ModelOutput, copy_model_to_driver import palantir_models as pm import palantir_models_serializers as pms @transform( model_files=Input("<Model Files Dataset>"), model_output=ModelOutput("<Your Model Path>") ) def compute(model_files, model_output): model = copy_model_to_driver(model_files.filesystem()) wrapped_model = ExampleModelAdapter(model) model_output.publish( model_adapter=wrapped_model ) class ExampleModelAdapter(pm.ModelAdapter): @pm.auto_serialize( model=pms.DillSerializer() ) def __init__(self, model): self.model = model @classmethod def api(cls): pass # Implement the API of this model def predict(self, df_in): pass # Implement the inference logic
Once you have successfully published a model, you can consume the model for inference. Use the following documentation for guidance: