Sentence Transformer¶
The Snowflake Model Registry supports models that use Sentence Transformers (sentence_transformers.SentenceTransformer).
For more information, see the Sentence Transformers documentation.
For the registry to know the signatures of the target methods, you must specify either sample input data or the signatures that define the input and output schema for the model’s methods.
For sample input data, specify a Snowpark DataFrame as the value for the sample_input_data parameter. For example you can specify a value such as sample_input = pd.DataFrame(["This is a sample sentence."], columns=["TEXT"]).
If you’re using the signatures parameter, specify a dictionary as the value for the signatures parameter. The dictionary defines the input and output methods for the model. For example, the following code defines the input and output schema for the model’s encode method:
When you call log_model, you can use the following additional options in the options dictionary:
Option |
Description |
|---|---|
|
A list of the names of the methods available on the model object. Sentence Transformer models have the following target method by default, assuming the method exists:
|
|
The version of the CUDA runtime to be used when deploying to a platform with a GPU; defaults to 11.8. If manually set
to |
The following example:
Loads a pre-trained Sentence Transformer model.
Logs it to the Snowflake ML Model Registry
Uses the logged model for inference.
Note
In the example, reg is an instance of snowflake.ml.registry.Registry. For information on
creating a registry object, see Snowflake Model Registry.