Configure Neural Hybrid Search
Neural Hybrid Search combines lexical-semantic search with dense vector search.
This feature is currently only available to clients who have contracted with Lucidworks for features related to Neural Hybrid Search and Lucidworks AI. |
This feature is only available in Fusion 5.9.5 and later versions of Fusion 5.9. |
Lucidworks recommends setting up Neural Hybrid Search with Lucidworks AI vector search, however you can instead use Seldon vector search. If using Lucidworks AI, you may use the default LWAI Neural Hybrid Search pipeline.
Configure vector search
-
If using Seldon, refer to Configure Seldon vector search
-
If using Lucidworks AI, refer to Configure Lucidworks AI vector search
Modify Solr managed-schema
This step is required if you’re migrating a collection from a version of Fusion that does not support Neural Hybrid Search. If creating a new collection in Fusion 5.9.5, you can continue to Configure Hybrid Query stage.
-
Go to System > Solr Config then click managed-schema to edit it.
-
Comment out
<copyField dest="_text_" source="*"/>
and add<copyField dest="text" source="*_t"/>
below it. This will concatenate and index all*_t fields
. -
Add the following code block to the managed-schema file:
<fieldType class="solr.DenseVectorField" hnswBeamWidth=“200" hnswMaxConnections="45” name="knn_DIM_vector" similarityFunction="cosine" vectorDimension="DIM"/> <dynamicField docValues="false" indexed="true" multiValued="false" name="*_512v" required="false" stored="true" type="knn_DIM_vector"/>
This example uses 512 vector dimension. If your model uses a different dimension, modify the code block to match your model. For example, _1024v
. There is no limitation on supported vector dimensions.
Configure Hybrid Query stage
-
In the same query pipeline where you configured vector search, click Add a new pipeline stage, then select Hybrid Query.
-
In the Label field, enter a unique identifier for this stage or leave blank to use the default value.
-
In the Condition field, enter a script that results in true or false, which determines if the stage should process, or leave blank.
-
In the Lexical Query Input field, enter the location from which the lexical query is retrieved. For example, <request.params.q>. Template expressions are supported.
-
In the Lexical Query Weight field, enter the relative weight of the lexical query. For example, 0.3. If this value is 0, no re-ranking will be applied using the lexical query scores.
-
In the Number of Lexical Results field, enter the number of lexical search results to include in re-ranking. For example, 1000. A value is 0 is ignored.
-
In the Vector Query Field, enter the name of the Solr field for k-nearest neighbor (KNN) vector search.
-
In the Vector Input field, enter the location from which the vector is retrieved. Template expressions are supported. For example, a value of
<ctx.vector>
evaluates the context variable resulting from a previous stage, such as the LWAI Vectorize Query stage. -
In the Vector Query Weight field, enter the relative weight of the vector query. For example, 0.7.
-
Select the Use KNN Query checkbox to use the knn query parser and configure its options. This option cannot be selected if Use VecSim Query checkbox is selected. In addition, Use KNN Query is used if neither Use KNN Query or Use VecSim Query is selected.
-
If the Use KNN Query checkbox is selected, enter a value in the Number of Vector Results field. For example, 1000.
-
-
Select the Use VecSim Query checkbox to use the vecSim query parser and configure its options. This option cannot be selected if Use KNN Query checkbox is selected.
If the Use VecSim Query checkbox is selected, enter values in the following fields:
-
Min Return Vector Similarity. Enter the minimum vector similarity value to qualify as a match from the Vector portion of the hybrid query.
-
Min Traversal Vector Similarity. Enter the minimum vector similarity value to use when walking through the graph during the Vector portion of the hybrid query. The value must be lower than, or equal to, the value in the Min Return Vector Similarity field.
-
-
In the Minimum Vector Similarity Filter, enter the value for a minimum similarity threshold for filtering documents. This option applies to all documents, regardless of other score boosting such as rules or signals.
-
Click Save.
Make sure the Hybrid Query stage is ordered before the Solr Query stage. See Reorder Query Pipeline Stages.
Perform hybrid searches
After setting up the stages, you can perform hybrid searches via the knn
query parser as you would with Solr. Specify the search vector and include it in the query. For example, change the q
parameter to a knn
query parser string.
The Hybrid Query stage will encode user queries using the specified model and modify the q
parameter to use the knn
query parser, turning the query into a vector search.
XDenseVectorField is not supported in Fusion 5.9.5. Instead, use DenseVectorField .
|
Known issues
Neural Hybrid Search is not recommended for high availability (HA) deployments because it may cause errors. A workaround for HA deployments is to add an Additional Query Parameters stage with the following settings:
Parameter Name | Parameter Value | Update Policy |
---|---|---|
|
|
|
|
|
|
Save the stage and order it after the Hybrid Query stage but before the Solr Query stage.