You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求Elasticsearch LTR插件的LightGBM与CatBoost模型及特征示例

Elasticsearch LTR插件:LightGBM、CatBoost模型及特征集示例

一、基础特征集定义示例

先创建一个关联后续模型的小型特征集,包含文本匹配、字段长度、权重调整三类基础特征:

POST _ltr/_featureset/performancetest
{
  "featureset": {
    "name": "performancetest",
    "features": [
      {
        "name": "title_query_match",
        "params": ["query"],
        "template": {
          "match": {
            "title": "{{query}}"
          }
        }
      },
      {
        "name": "content_char_length",
        "template": {
          "script": {
            "source": "doc['content'].value.length()"
          }
        }
      },
      {
        "name": "document_boost",
        "params": ["boost_val"],
        "template": {
          "function_score": {
            "boost_factor": "{{boost_val}}"
          }
        }
      }
    ]
  }
}

二、LightGBM排序模型创建示例

适配LTR插件格式的小型LightGBM LambdaRank模型,关联上述特征集:

POST _ltr/_featureset/performancetest/_createmodel
{
  "model": {
    "name": "lightgbm_ranking_demo",
    "model": {
      "type": "model/lightgbm",
      "definition": """
        {
          "num_leaves": 16,
          "max_depth": 4,
          "objective": "lambdarank",
          "boosting_type": "gbdt",
          "metric": "ndcg",
          "ndcg_eval_at": [3,5],
          "learning_rate": 0.1,
          "num_boost_round": 50
        }
      """,
      "feature_names": ["title_query_match", "content_char_length", "document_boost"]
    }
  }
}

三、CatBoost排序模型创建示例

适配LTR插件格式的小型CatBoost YetiRank模型,同样关联上述特征集:

POST _ltr/_featureset/performancetest/_createmodel
{
  "model": {
    "name": "catboost_ranking_demo",
    "model": {
      "type": "model/catboost",
      "definition": """
        {
          "iterations": 30,
          "learning_rate": 0.15,
          "loss_function": "YetiRank",
          "eval_metric": "NDCG",
          "max_depth": 3,
          "verbose": 0
        }
      """,
      "feature_names": ["title_query_match", "content_char_length", "document_boost"]
    }
  }
}

内容的提问来源于stack exchange,提问作者Yatin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 18:25:22