Skip to content

Retriever

Retriever

This step conducts a similarity search using your specified distance_metric on the embeddings of your chunks in the vector index.

This step does not embed the query itself and must be preceded by an embedding step.

Valid input steps: SentenceTransformerEmbedder, OpenAIEmbedder

Step Args
Key Value Type Value Description
top_k int The number of results to return1
metadata_json object The metadata filters you wish to apply on the embeddings in your vector DB before doing the similarity search
distance_metric literal 'cosine' or 'dotproduct'
vector_index_name str the name of the vector index to be queried

The metadata_json field accepts OneContext's structured query language, which is documented here:

If your retriever is followed by a "Reranker" step, in general, you should want to retrieve more results (in top_k) than you need, as the Reranker will then "Rerank" your results, and then you can retrieve your desired quantity of final results from the Reranker.


  1. Results will be ordered by distance.