Generate Embedding

opensearch_py_ml.ml_commons.MLCommonClient.generate_embedding(self, model_id: str, sentences: List[str]) object

This method return embedding for given sentences (using ml commons _predict api)

Parameters:
  • model_id (string) – unique id of the nlp model

  • sentences (list of string) – List of sentences

Returns:

returns a json object inference_results which is a list of embedding results of given sentences every item has 4 properties: name, data_type, shape, data (embedding value)

Return type:

object