Milvus
Milvus is an open-source vector similarity search engine, integrated into Fusion to streamline its deep learning capabilities and reduce the workload on Solr. See Milvus v0.10.2 documentation.
Milvus collections
Milvus stores the vectors produced by machine learning models in one or more Milvus collections.
For each collection, the following parameters need to be set:
-
Collection Name
. A name for the Milvus collection you are creating. Milvus requires that collection names only include alphanumeric characters and the underscore_
. -
Dimension
. The dimension size of the vectors to store in this Milvus collection. The Dimension should match the size of the vectors returned by the encoding model. For example, theSmart Answers Pre-trained Coldstart
models output vectors of 512 dimension size. Dimensionality of encoders trained bySmart Answers Supervised Training
job depends on the provided parameters and printed in the training job logs. See Smart Answers Supervised model training for more details. -
Index file size
. Vectors are added to the raw data files and then indexed. Files larger than this will trigger index building for raw data files. -
Metric
. The type of metric used to determine how close the search vector is to the vectors in the collection. It is used to calculate the vector similarity scores. In most cases we suggest to use Cosine Similarity which can be obtained by using theInner Product
metric over normalized vectors. It produces values between -1 and 1, where a higher value means higher similarity.
The Metric options for Milvus collections are: Euclidean, Inner Product, Hamming, Jaccard, Tanimoto, Substructure, and Superstructure. The following metrics all require that the Dimension is a multiple of 8: Hamming, Jaccard, Tanimoto, Substructure, and Superstructure. Otherwise the Create Milvus Collection job will fail. See Milvus metrics documentation for more details.
Milvus can be configured to pre-load one or more collections via the Milvus parameter preload_collection
. Fusion does not currently ship with a method to manage this parameter, but the Milvus API can be used directly (after first setting up port forwarding via kubectl port-forward milvus-writeable-<hash>-<random> 19121:19121
).
For an example of how to create and utilize a Milvus collection, see Configure The Smart Answers Pipelines.
Milvus indexes
When a Milvus collection is large, creating an index can speed up the similarities search. If you do not create an index on a collection then a FLAT index is used. See Milvus index documentation for more details.
When you create an index on a collection, in addition to the collection name
you will need to specify:
-
Index Type
. The index type must be one of [ANNOY
,FLAT
,HNSW
,IVF_PQ
,IVF_SQ8
,IVF_SQ8H
,IVFLAT
,RNSG
]. We recommend you use the Fusion job default value ofHNSW
. -
Index Parameters
. Parameters used to create an index in Milvus. These required parameters are specific to the chosenIndex Type
. For example,nlist=4096
for IVF indexes orM=36
andefConstruction=500
for HNSW indexes.
If you create an index for the collection different from FLAT, index specific query parameters have to be added as Search Parameters in the Milvus Query stage. Refer to the Milvus supported indexes for query parameters for each index type. |
Milvus management jobs
Fusion ships with several jobs for managing collections and indexes in Milvus:
Pipeline stages
For more information about using these stages see Configure the Smart Answers Pipeline (5.3 and later).
-
The Encode into Milvus index pipeline stage invokes a machine learning model to encode a field and store it into Milvus.
-
Query pipeline stages:
-
Milvus Query performs vectors similarity search in Milvus.
-
Milvus Ensemble Query performs ensemble of different search results to retrieve metadata from Solr.
-
Milvus Response Update updates response documents with vectors similarity and ensemble scores.
-
Troubleshooting
Milvus Vector Search Issue
Issue: Create, Read, Update, and Delete (CRUD) operations for indexing and query objects save current user permissions in thread local variables. Permissions are saved only once, and are never updated for that thread. Calls to a pipeline with a REST call or to Milvus stages use the saved permissions, not the calling user permissions. And the saved permissions are then used to check authorization for Milvus or external http:
and https:
calls.
If a thread does not have saved permissions, the call to Milvus is authorized for any user. |
Workaround for Milvus stages:
-
Add the following permissions to all existing non-admin users:
GET,POST,PUT:/http-call/milvus/**
-
Restart all instances of query and indexing services.
Update a Milvus collection
Update and delete semantics are not supported on individual items in a Milvus collection. We recommend that you use a blue/green set of collections: reindex to apply updates to an empty Milvus collection, then swap between collections to apply the updates.