API Reference

Query Relevant Chunks

Description

Query a knowledge base for text chunks that are most semantically relevant to the query.

Details

Given a query expressed as an embedding, this API runs a similarity search amongst the embeddings indexed in the knowledge base to find the most relevant chunk embeddings. To use this API, specify the knowledge_base_id of the knowledge base you want to query, pass in the natural language query that you want to search for, specify the value top_k, which is the number of similar chunks that will be returned, and specify whether you want the returned chunks to include_embeddings.

Similarity search is used to efficiently find, retrieve, and rank chunks based on their similarity to a given query, which is also expressed as an embedding. Similarity scores ( using the cosine similarity metric) are calculated between each chunk embedding and the embedded query, and the chunks are ranked based on similarity score. The top-ranked chunks are returned as the query results.

We are using the Hierarchical Navigable Small World (HNSW) algorithm to perform a k nearest neighbors search in the vector space. This algorithm returns an estimate of the best k nearest neighbors and is optimized for datasets with hundreds of thousands of vectors. You can read more about the specifics of this algorithm here.

Backwards Compatibility

V2 and V1 Knowledge Bases are entirely separate and not backwards compatible. Users who have existing V1 knowledge bases will need to migrate their data to V2 knowledge bases.

Language
Authorization
Header
Click Try It! to start a request and see the response here!