Model Studio

更新时间:
复制 MD 格式

Connect to models from Model Studio and call model services in Elasticsearch using the Inference API.

Billing

This service is pay-as-you-go. You are charged only for the API calls you make.

Create a model

  1. Log on to the Alibaba Cloud Elasticsearch console.

  2. In the left navigation menu, choose Elasticsearch Clusters.

  3. Navigate to the target cluster.

    1. In the top navigation bar, select the resource group to which the cluster belongs and the region where the cluster resides.

    2. On the Elasticsearch Clusters page, find the cluster and click its ID.

  4. In the left-side navigation pane, choose AI Service Center > Model Management.

  5. Go to the Model Studio Model tab, click Create, and in the Create Model Studio Model dialog box, select Automatic Creation or Create Manually.

    • Automatic Creation: Enter a valid API Key for Model Studio. This method integrates all Model Studio models that Elasticsearch supports in a single operation.

    • Create Manually: Select the model to integrate, and then enter a valid API Key and the API Host. The API Host is the dedicated domain name for the model's workspace.

      To obtain these parameters, see Obtain an API Key.

      Important

      The API Key and API Host are region-specific. Ensure the region is correct.

  6. Click OK. Once the model is created, it appears in the model list. You can then call the model service.

Usage examples

Text embedding

# text_embedding must match the model category ID; bailian_embeddings must match the model ID in the console.
POST _inference/text_embedding/bailian_embeddings 
{
  "input":[
        "风急天高猿啸哀",
        "渚清沙白鸟飞回", 
        "无边落木萧萧下", 
        "不尽长江滚滚来"
        ]
}

Sample response:

{
  "text_embedding": [
    {
      "embedding": [
        0.049183346,
        -0.068886764,
        0.047604065,
        -0.06778378,
        -0.009488225,
        -0.0791145,
        -0.006082115,
        0.057004552,
        ...
        ]
    }
  ]
}

Sparse vector

# sparse_embedding must match the model category ID; bailian_sparse_emb must match the model ID in the console.
POST _inference/sparse_embedding/bailian_sparse_emb
{
  "input": [
    "风急天高猿啸哀",
    "渚清沙白鸟飞回",
    "无边落木萧萧下",
    "不尽长江滚滚来"
  ]
}

Sample response:

{
  "sparse_embedding": [
    {
      "is_truncated": false,
      "embedding": {
        "35727": 0.897,
        "44636": 1.3828,
        "99208": 1.998,
        "99508": 2.1836,
        "103000": 1.96,
        "111758": 1.9805,
        "115272": 1.7686
      }
    },
    {
      "is_truncated": false,
      "embedding": {
        "18397": 1.4033,
        "79766": 2.0566,
        "99243": 1.2812,
        "99617": 1.3809,
        "99723": 1.1973,
        "100462": 1.4648,
        "119294": 1.9326
      }
    },
   {
      ...
      }
    }
  ]
}

Text ranking

# rerank must match the model category ID; bailian_rerank must match the model ID in the console.
POST _inference/rerank/bailian_rerank
{
  "input": [
    "文本排序模型广泛用于搜索引擎和推荐系统中,它们根据文本相关性对候选文本进行排序",
    "量子计算是计算科学的一个前沿领域",
    "预训练语言模型的发展给文本排序模型带来了新的进展"
  ],
  "query": "什么是文本排序模型"
}

Sample response:

{
  "rerank": [
    {
      "index": 0,
      "relevance_score": 0.9290283
    },
    {
      "index": 2,
      "relevance_score": 0.7562483
    },
    {
      "index": 1,
      "relevance_score": 0.31665403
    }
  ]
}

Multi-modal embedding

# multi_modal_embedding must match the model category ID; bailian_mm must match the model ID in the console.
POST _inference/multi_modal_embedding/bailian_mm
{
  "input":"""
    {"text":"多模态向量模型"},
    {"image":"https://img.alicdn.com/imgextra/i3/O1CN01rdstgY1uiZWt8gqSL_!!6000000006071-0-tps-1970-356.jpg"},
    {"video":"https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250107/lbcemt/new+video.mp4"},
    {"multi_images":[
      "https://img.alicdn.com/imgextra/i2/O1CN019eO00F1HDdlU4Syj5_!!6000000000724-2-tps-2476-1158.png",
      "https://img.alicdn.com/imgextra/i2/O1CN01dSYhpw1nSoamp31CD_!!6000000005089-2-tps-1765-1639.png"
    ]}
    """
}

Sample response:

{
  "multi_modal_embedding": [
    {
      "embedding": [
        -0.014518738,
        -0.014297485,
        -0.056121826,
        0.043823242,
        0.01889038,
        0.04547119,
        ...
        ]
    }
  ]
}

Chat (completion)

# completion must match the model category ID; bailian_deepseek must match the model ID in the console.
POST _inference/completion/bailian_deepseek
{
  "input":"你是谁"
}

Sample response:

{
  "completion": [
    {
      "result": "Hello! I am Qwen, a large language model from Alibaba Group. I can answer questions, create text such as stories, official documents, emails, and scripts, perform logical reasoning, write code, express opinions, and play games. If you have any questions or need help, feel free to ask me anytime!"
    }
  ]
}