Model adapters are a generalized framework to enable Foundry to interoperate with arbitrary models. Model adapters are one of the two components that make a model:
Model adapters can enable Foundry to interoperate with the following:
Palantir interacts with all models in the same way by interfacing with the model adapter class of that model version.
Since models can be created once, and used in multiple places within the platform, the adapter needs to be aware of how to initialize an instance of models from either the weights or the underlying container.
For weights trained within the platform, users should use the @auto_serialize annotation to leverage built-in serializers that should work with most model types. In advanced cases where serialization / deserialization logic must be explicitly specified, see: load() and _save() methods.
For container and external models, the adapter is initialized using either the init_container()
, or init_external()
method, so that it can be used for inference. For both types of models, the load()
method is also called when the model is initialized, but it then calls init_container()
or init_external()
in the background so that only the context that is relevant to these types of models (for example, ContainerizedApplicationContext or ExternalModelContext) is provided to the model instances. As an alternative to using init_container()
or init_external()
, users can overwrite the load()
method to define how these models should be initialized.
Each adapter is required to declare an API description. The platform relies on this description, which includes the expected inputs, outputs, column names and type, for enabling integrations with other applications for a variety of model consumption patterns.
For supported types and examples of API definitions, review the API reference.
Once initialized, the adapter can be used for inference for either batch or interactive workloads. The inference logic must be defined as part of the predict()
method.
The platform uses the provided API definition to call the predict()
method with the defined names and types so that inference can be performed.
For more information on creating model adapters, refer to the documentation on creating model adapters. You can also consult the full Python API on the model adapter reference page.