Skip to main content
Version: 1.9.x

Knowledge Base

A Langflow knowledge base is a vector database that stores embeddings for use in your flows. By default, knowledge bases use Chroma as a local vector store, but you can configure an external vector database provider such as OpenSearch. For more information, see Configure vector database providers.

Because knowledge bases don't re-ingest data with every flow run, they can be more efficient than using a remote vector database. They are a good choice for flows that use custom, domain-specific datasets, like slices of customer and product data.

You can use knowledge base components in much the same way that you use vector store components. However, there are several key differences:

  • Local storage by default: Langflow knowledge bases use Chroma local storage by default. In contrast, only some vector store components support local databases.
  • Built-in embedding models: Langflow knowledge bases include built-in support for several embedding models. Other models aren't supported for use with knowledge bases. To use a different provider or model, you must use a vector store component along with your preferred embedding model component.
  • Basic similarity search: When querying Langflow knowledge bases, only standard similarity search is supported. For more advanced searches, you must use a vector store component for a vector database provider that supports your desired functionality.
  • Structured data: Langflow knowledge bases only support structured data. For unstructured data, you must use a compatible vector store component.

The Knowledge Base component reads from an existing knowledge base using semantic search.

The output is a Table containing the top matching results from the queried knowledge base.

Knowledge Base parameters

Some parameters are hidden by default in the visual editor. You can modify all component parameters through the component inspection panel that appears when you select a component.

NameDisplay NameInfo
knowledge_baseKnowledgeInput parameter. Select the knowledge base to retrieve data from.
api_keyEmbedding Provider API KeyInput parameter. Optional API key for the embedding provider to override a previously-provided key. The embedding provider and model are chosen when you create a knowledge base.
search_querySearch QueryInput parameter. Optional search query to filter knowledge base data using semantic similarity. If omitted, the top results are returned from an arbitrary sort.
top_kTop K ResultsInput parameter. Number of search results to return. Default: 5.
include_metadataInclude MetadataInput parameter. Whether to include all metadata and embeddings in the output. If enabled, each output row includes all metadata, embeddings, and content. If disabled, only the content is returned. Default: Enabled (true).

Use the Knowledge Base component in a flow

After you create and load data to a knowledge base, you can use the Knowledge Base component in any flow to retrieve data from your knowledge base using semantic search:

  1. Add a Knowledge Base component to your flow.

  2. In the Knowledge field, select the knowledge base you want to search, such as the customer sales data knowledge base created in the previous steps.

  3. To view the search results as chat messages, connect the Results output to a Chat Output component.

  4. In Search query, enter a query that relates to your embedded data.

    For the customer sales data example, enter a product name like laptop or wireless devices.

  5. Click Run component on the Knowledge Base component, and then open the Playground to view the output.

See also

Search