すべてのプロダクト
Search
ドキュメントセンター

OpenSearch:カスタムソートモデル

最終更新日:Jun 22, 2026

このドキュメントでは、OpenSearch Industry Algorithm Edition のカスタムソートモデル機能の使用方法を説明します。

手順

  1. [特徴量管理] で、必要なフィールド特徴量を作成します。この例では、system_item テーブルを使用します。必要な特徴量がこのテーブルにない場合は、それらを含む外部 MaxCompute テーブルを先に登録する必要があります。title フィールドについては、生の値 (custom_title)、トークン化後のルックアップ特徴量 (custom_title_match)、トークン化後のトークン数 (custom_title_len) の特徴量を作成します。ビジネス要件に基づいて、他の特徴量を追加できます。このセクションで説明する特徴量は、クリック率 (CTR) モデルを構築するための例です。

同様に、description フィールドには custom_descriptioncustom_desc_matchcustom_desc_len を、brand_name フィールドには custom_tagscustom_tags_match を、category_name フィールドには custom_category を作成します。

  1. system_internal テーブルの組み込みの特徴量を、前のステップで作成したフィールド特徴量と組み合わせます。このプロセスは特徴量エンジニアリングと呼ばれます。

一般的な CTR モデル向けの特徴量を一括登録するには、CreateFunctionResource API を使用します:

リクエストでは、ResourceType パラメーターを feature_generator に設定し、Data パラメーターを次の JSON オブジェクトに設定します。注:ステップ 1 の説明どおり、custom_ で始まるすべての入力特徴量が作成されていることを確認してください。

[
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_raw_q_ultra"
        },
        {
          "type": "item",
          "name": "system_item_id"
        }
      ]
    },
    "generator": "combo",
    "output": "comb_q_nid"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_user_id"
        },
        {
          "type": "item",
          "name": "system_item_id"
        }
      ]
    },
    "generator": "combo",
    "output": "comb_uid_nid"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_user_id"
        },
        {
          "type": "item",
          "name": "custom_tags"
        }
      ]
    },
    "generator": "combo",
    "output": "comb_uid_tags"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_raw_q_ultra"
        },
        {
          "type": "item",
          "name": "custom_tags"
        }
      ]
    },
    "generator": "combo",
    "output": "comb_q_tags"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_exp_time"
        }
      ]
    },
    "generator": "id",
    "output": "exp_time"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "id",
    "output": "terms2"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_raw_q_ultra"
        }
      ]
    },
    "generator": "id",
    "output": "raw_q_ultra"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_user_id"
        }
      ]
    },
    "generator": "id",
    "output": "user_id"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_item_id"
        }
      ]
    },
    "generator": "id",
    "output": "item_id"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_description"
        }
      ]
    },
    "generator": "id",
    "output": "description"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_desc_len"
        }
      ]
    },
    "generator": "id",
    "output": "desc_len"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_title"
        }
      ]
    },
    "generator": "id",
    "output": "title"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_title_len"
        }
      ]
    },
    "generator": "id",
    "output": "title_len"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_category"
        }
      ]
    },
    "generator": "id",
    "output": "category"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "custom_tags"
        }
      ]
    },
    "generator": "id",
    "output": "tags"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ctr_30"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ctr_30"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ctr_7"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ctr_7"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ctr_1"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ctr_1"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_pv_30"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_pv_30"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_pv_7"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_pv_7"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_pv_1"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_pv_1"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ipv_30"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ipv_30"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ipv_7"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ipv_7"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_all_nid_ipv_1"
        }
      ]
    },
    "generator": "id",
    "output": "all_nid_ipv_1"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "custom_title_match"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "term_title_match"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "custom_desc_match"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "term_desc_match"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "custom_tags_match"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "term_tags_match"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "system_qterm_match_decay"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "term_os_kw_match"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_query_cnt"
        }
      ]
    },
    "generator": "id",
    "output": "opensearch_query_cnt"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_qterm_cnt"
        }
      ]
    },
    "generator": "id",
    "output": "opensearch_qterm_cnt"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "system_query_ctr_decay"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_raw_q_ultra"
        }
      ]
    },
    "generator": "lookup",
    "output": "os_q_ctr_decay"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "system_qterm_ctr_decay"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "os_term_ctr_decay"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "system_query_ctr_decay"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_raw_q_ultra"
        }
      ]
    },
    "generator": "lookup",
    "output": "os_q_ctr_decay_nokey"
  },
  {
    "input": {
      "features": [
        {
          "role": "map",
          "type": "item",
          "name": "system_qterm_ctr_decay"
        },
        {
          "role": "key",
          "type": "user",
          "name": "system_terms2"
        }
      ]
    },
    "generator": "lookup",
    "output": "os_term_ctr_decay_nokey"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_query_seq_decay"
        }
      ]
    },
    "generator": "id",
    "output": "os_q_seq_decay"
  },
  {
    "input": {
      "features": [
        {
          "type": "item",
          "name": "system_qterm_seq_decay"
        }
      ]
    },
    "generator": "id",
    "output": "os_term_seq_decay"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "system_qterm_seq_decay"
        }
      ],
      "method": "query_common_ratio"
    },
    "generator": "overlap",
    "output": "os_qterm_q_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "system_qterm_seq_decay"
        }
      ],
      "method": "title_common_ratio"
    },
    "generator": "overlap",
    "output": "os_qterm_title_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "custom_title"
        }
      ],
      "method": "query_common_ratio"
    },
    "generator": "overlap",
    "output": "title_q_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "custom_title"
        }
      ],
      "method": "title_common_ratio"
    },
    "generator": "overlap",
    "output": "title_title_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "custom_description"
        }
      ],
      "method": "query_common_ratio"
    },
    "generator": "overlap",
    "output": "desc_q_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "role": "query",
          "type": "user",
          "name": "system_terms2"
        },
        {
          "role": "title",
          "type": "item",
          "name": "custom_description"
        }
      ],
      "method": "title_common_ratio"
    },
    "generator": "overlap",
    "output": "desc_title_common_ratio"
  },
  {
    "input": {
      "features": [
        {
          "type": "user",
          "name": "system_term_seq_length"
        }
      ],
      "dimension": 1
    },
    "generator": "raw",
    "output": "term_seq_length"
  }
]

作成した特徴量は、[特徴量管理] ページで編集できます。

モデルコードで、これらの特徴量の使用方法を指定する必要があります。

クイックスタートに基づいて、使用する特徴量のリストを変更してください。 通常、これらの特徴量は embedding_columns に指定します。

[カスタムソートモデル] の設定ページで、モデル記述の名前 (例: model1) を指定してください。Python ファイルでは、self.embedding_columns 変数を定義し、特徴量設定の出力フィールド (例: comb_q_nidcomb_uid_nidcomb_uid_tags) を埋め込み特徴量のリストとしてモデルに渡します。

  1. カスタムソートモデルで使用する特徴記述とモデル記述を指定してください。

[ナビゲーションペイン][カスタムソートモデル] を選択します。[モデル作成] ページで、次のパラメーターを設定します:[対象アプリケーション] を選択し、[モデル名] (例: rank_model。長さは 1~30 文字、先頭は英字とし、英大文字、英小文字、数字、アンダースコアが使用できます) を入力し、[モデルタイプ][カスタムソートモデル] に設定し、必要に応じて [定期トレーニング] を有効化し、作成した [特徴記述] (例: fg1) と [モデル記述] (例: model1) を選択します。

  1. モデルのトレーニングが成功したら、CTR モデルと同じ方法で Cava で使用できます。詳細については、「カスタムソートモデル」をご参照ください。モデルをデプロイする前に、A/B テスト を実行してパフォーマンスを検証してください。