為以下項目部署模型 InstructLab

選擇部署模型的方式。

將模型部署到 RHEL-AI 上 IBM Cloud

  1. 在 IBM Cloud 上安裝 RHEL-AI。

  2. 使用 IBM Cloud CLI 取得承載令牌。

    ibmcloud iam oauth-tokens
    
  3. 更新此 bash 腳本中的變數,並執行它。

    #!/usr/bin/env bash
    # Replace variable with the bearer token
    BEARER_TOKEN="XXX"
    # Replace variable with the Object Storage bucket name
    CUSTOMER_BUCKET="XXX"
    # Replace variable with the Object Storage endpoint
    COS_ENDPOINT=https://s3.direct.us-east.cloud-object-storage.appdomain.cloud
    # Replace variable with the model ID
    MODEL_PREFIX="trained_models/XXX/model/"
    # Replace variable with the model directory path
    MODEL_DIR=/root/model/modeltest
    curl -v -G "$COS_ENDPOINT/$CUSTOMER_BUCKET" --data-urlencode "list-type=2" --data-urlencode "prefix=$MODEL_PREFIX" -H "Authorization: Bearer $BEARER_TOKEN" >/tmp/rawxml.txt
    cat /tmp/rawxml.txt | awk '{split($0,a,"<Key>"); for (i=1; i<=length(a); i++)  print a[i]}' >/tmp/keysonnewline.txt
    mkdir -p "$MODEL_DIR"
    while read -r line; do
        if [[ "$line" != "trained_models"* ]]; then
            continue
        fi
        KEY_TO_DOWNLOAD=$(echo "$line" | awk -F '<' '{print $1}')
        FILE_NAME=$(basename "$KEY_TO_DOWNLOAD")
        curl -X "GET" "$COS_ENDPOINT/$CUSTOMER_BUCKET/$KEY_TO_DOWNLOAD" -H "Authorization: Bearer $BEARER_TOKEN" >"${MODEL_DIR}/$FILE_NAME"
    done </tmp/keysonnewline.txt
    
  4. 然後使用 ilab 指令來服務和聊天。

    ilab model serve --model-path $MODEL_DIR -- --tensor-parallel-size 1 --host 0.0.0.0 --port 8080
    
    ilab model chat --endpoint-url http://localhost:8080/v1 -m $MODEL_DIR
    

將模型部署到 Watsonx 上 IBM Cloud

  1. 註冊 IBM watsonx as a Service.

  2. 登入並建立 API 金鑰。

  3. 如果您還沒有 項目,請建立一個。

  4. 在 IBM Cloud 中 新增連線 至 Object Storage 資料來源。

  5. 匯入模型。

  6. 部署模型。

  7. 測試部署。

部署模型至 Red Hat OpenShift AI

  1. 如果您還沒有,安裝 Red Hat OpenShift AI 附加元件。 安裝附加元件可能需要 15 分鐘。
  2. 安裝附加元件後,瀏覽 OpenShift AI 面板。
  3. 按一下資料科學專案,然後按一下建立專案。
  4. 按照提示為專案命名和說明,然後按一下建立。
  5. 找到 Serve models(上菜模式 )部分,然後選擇 Single-model serving platform(單一模式上菜平台 )選項。
  6. 按一下部署模型。
  7. 填寫所需的組態屬性。 若要指定您使用 InstructLab 訓練的模型,請找到來源模型位置區段,並選擇 S3 相容的物件儲存 -v1 連線類型。
  8. 在連線詳細資訊下,指定存取金鑰、密碼金鑰、端點和儲存已訓練模型資料的 COS 儲存桶名稱。 指定您的模型路徑,或您的資料桶中包含模型的資料夾。
  9. 填寫其餘組態屬性後,按一下部署。
  10. 若要驗證和檢視模型部署的健康狀況,請按一下 型號 > 機型部署,然後選擇您在其中建立模型的資料科學專案。