The traditional approach for candidate generation using k-NN search (k-nearest
neighbors) is accurate but very slow, especially for large scale systems where very low latency
is required.
ANN (approximate nearest neighbor) search uses tools that restructure indexes more
efficiently and reduce the dimensionality of searchable vectors. Using this approach is a
tradeoff between accuracy and low latency. By leveraging ANN with k-NN, search engines can
approximate the nearest neighbors of specific query documents and retrieve relevant candidates
with very low latency, improving search latency for large datasets. OpenSearch 2.11 supports
the NMSLIB, FAISS, and LUCENE search engines, which all implement ANN. For more information,
see k-NN search with filters.
To use an ingestion pipeline on the index, add the pipeline in the API call, ensuring that
the model deployed on the ingestion pipeline has the same dimensionality of the KNN vector
specified in the API call, as follows:
For the Faiss engine, you can use the HNSW algorithm or the IVF algorithm to implement
the ANN filter. See Faiss k-NN filter implementation for details about
the Faiss configuration parameters.
The following examples shows how to create an index using the Faiss engine.
Each of the supported engines use some heuristic to compare document embedding and
retrieve the most relevant documents by measuring the similarity. You have the choice of
several objective metrics to use. The metrics you choose depends on the custom use case,
model, and data. For more information, including a table showing the available options to
choose from, see Spaces.