セマンティック検索のための検索ブループリントの作成
変更通知を受け取る(購読する)
モデルが選択され、テキスト埋め込みがインデックス化されたら、検索時に埋め込みを考慮するようにLiferayを設定する必要があります。 概念的には、2つの選択肢があります。
- Liferayのデフォルトの検索リクエストを完全に上書きするブループリントを作成します。 純粋な意味検索クエリを実行するためにゼロから構築することで、クエリはテキスト埋め込みのみを使用します。
- テキスト埋め込みによる再スコアリング要素 を使用して、標準のキーワードベースのクエリを実行し、インデックス付き
dense_vectorフィールドのテキスト埋め込みと検索フレーズの埋め込みの間の類似度関数を使用して結果を再スコアリングするブループリントを作成します。
テキスト埋め込みによる再スコアリング要素は、埋め込みプロバイダーと連携するように設定することで、一部のデータセットに対してより的を絞った検索結果を生成できます。 しかし、多くのセマンティック検索ソリューションは、堅牢な検索ソリューションを実現するために、手動での微調整や場合によっては新しい要素の導入が必要となる。

この要素は、埋め込みプロバイダが有効になっており、特定のコンテンツタイプと言語に対応するように設定されている場合にのみ有効です。 テキスト埋め込みプロバイダの設定 を参照してください。
テキスト埋め込み要素による再スコアの追加
構成済みの埋め込みプロバイダによって作成されたテキスト埋め込みを活用してセマンティック検索エクスペリエンスを構築するには、 テキスト埋め込みによる再スコア 要素を使用して、 検索ブループリント を構築できます。 この要素とブループリントのビジュアルクエリビルダーを使用することで、検索クエリを設定およびテストし、適切なセマンティック検索ソリューションを構築できます。
-
Liferay では、 グローバルメニュー (
) を開き、 アプリケーション → ブループリント をクリックします。 -
要素をクリックし、次に 新規 (
をクリックします。 -
タイトル テキスト埋め込みによる再スコア を入力し、 作成 をクリックします。
-
要素のJSONをコピーし、デフォルトの要素コンテンツを置き換えます。
{ "description_i18n": { "en_US": "rescore-by-text-embedding-description" }, "elementDefinition": { "category": "semantic search", "configuration": { "queryConfiguration": { "queryEntries": [ { "condition": { "exists": { "parameterName": "keywords" } }, "rescores": [ { "query": { "script_score": { "boost": "${configuration.boost}", "min_score": "${configuration.min_score}", "query": { "bool": { "filter": [ { "exists": { "field": "text_embedding_${ml.text_embeddings.vector_dimensions}_${context.language_id}" } } ], "must": [ { "match_all": { } } ] } }, "script": { "params": { "query_vector": "${ml.text_embeddings.keywords_embedding}" }, "source": "${configuration.vector_field_function}(params.query_vector, 'text_embedding_${ml.text_embeddings.vector_dimensions}_${context.language_id}') + 1" } } }, "queryWeight": "${configuration.query_weight}", "rescoreQueryWeight": "${configuration.rescore_query_weight}", "scoreMode": "${configuration.score_mode}", "windowSize": "${configuration.window_size}" } ] } ] } }, "icon": "custom-field", "uiConfiguration": { "fieldSets": [ { "fields": [ { "defaultValue": 10, "label": "boost", "name": "boost", "type": "number", "typeOptions": { "min": 0 } }, { "defaultValue": "cosineSimilarity", "helpText": "vector-field-function-field-help", "label": "vector-field-function", "name": "vector_field_function", "type": "select", "typeOptions": { "nullable": false, "options": [ { "label": "Cosine Similarity", "value": "cosineSimilarity" }, { "label": "Dot Product", "value": "dotProduct" } ] } }, { "defaultValue": 1, "helpText": "min-score-field-help", "label": "min-score", "name": "min_score", "type": "number", "typeOptions": { "min": 0 } }, { "defaultValue": 0.01, "helpText": "query-weight-field-help", "label": "query-weight", "name": "query_weight", "type": "slider", "typeOptions": { "min": 0.01, "step": 0.1 } }, { "defaultValue": 10, "helpText": "rescore-query-weight-field-help", "label": "rescore-query-weight", "name": "rescore_query_weight", "type": "slider", "typeOptions": { "min": 0.01, "step": 0.1 } }, { "defaultValue": "avg", "helpText": "score-mode-field-help", "label": "score-mode", "name": "score_mode", "type": "select", "typeOptions": { "nullable": false, "options": [ { "label": "Average", "value": "avg" }, { "label": "Max", "value": "max" }, { "label": "Min", "value": "min" }, { "label": "Multiply", "value": "multiply" }, { "label": "Total", "value": "total" } ] } }, { "defaultValue": 50, "helpText": "rescore-window-size-field-help", "label": "rescore-window-size", "name": "window_size", "type": "number", "typeOptions": { "min": 1 } } ] } ] } }, "externalReferenceCode": "RESCORE_BY_TEXT_EMBEDDING", "title_i18n": { "en_US": "rescore-by-text-embedding" }, "type": 0 }
1. Overwrite the default JSON with the JSON you copied from below.
1. Save the element.

## Configuring the Rescore by Text Embedding Element
Several configurable options are provided in the Rescore by Text Embedding element:
**Boost:** Defaulting to 10, this setting determines by how much to boost re-scored results.
**Vector Field Function:** Choose from the Cosine Similarity or Dot Product functions. Defaulting to use the Cosine Similarity function, the selected function measures similarity between the searched keywords and the target document text embeddings. Check the model's documentation to determine which function is most suitable.
**Min Score:** Defaulting to 1, this setting's integer (or 0) sets the minimum score a returned document must have to be included in the re-score query.
**Query Weight:** Defaulting to 0.01, this setting controls the weight of the original query in the final score calculation.
**Rescore Query Weight:** Defaulting to 10, this sets the weight of the re-score query in the final score calculation.
**Score Mode:** Defaulting to Average, this setting dictates the strategy to use when combining the original query scores with the results of the re-score. Choose from Average, Max, Min, Multiply, or Total.
**Rescorer Window Size:** Defaulting to 50, you can choose the number of results to re-score at a time. Choosing a very high window size can impact performance negatively.