SentenceTransformerModel.save_as_onnx
- opensearch_py_ml.ml_models.SentenceTransformerModel.save_as_onnx(self, model_id='sentence-transformers/msmarco-distilbert-base-tas-b', model_name: str | None = None, save_json_folder_path: str | None = None, model_output_path: str | None = None, zip_file_name: str | None = None, add_apache_license: bool = False) str
Download sentence transformer model directly from huggingface, convert model to onnx format, zip the model file and its tokenizer.json file to prepare to upload to the Open Search cluster
- Parameters:
model_id (string) – sentence transformer model id to download model from sentence transformers. default model_id = “sentence-transformers/msmarco-distilbert-base-tas-b”
model_name (string) – Optional, model name to name the model file, e.g, “sample_model.pt”. If None, default takes the model_id and add the extension with “.pt”
save_json_folder_path (string) – Optional, path to save model json file, e.g, “home/save_pre_trained_model_json/”). If None, default as default_folder_path from the constructor
model_output_path (string) – Optional, path to save traced model zip file. If None, default as default_folder_path from the constructor
zip_file_name (string) – Optional, file name for zip file. e.g, “sample_model.zip”. If None, default takes the model_id and add the extension with “.zip”
add_apache_license (string) – Optional, whether to add a Apache-2.0 license file to model zip file
- Returns:
model zip file path. The file path where the zip file is being saved
- Return type:
string