Key-value stores
Overviewβ
LangChain provides a key-value store interface for storing and retrieving data.
LangChain includes a BaseStore
interface,
which allows for storage of arbitrary data. However, LangChain components that require KV-storage accept a
more specific BaseStore[str, bytes]
instance that stores binary data (referred to as a ByteStore
), and internally take care of
encoding and decoding data for their specific needs.
This means that as a user, you only need to think about one type of store rather than different ones for different types of data.
Usageβ
The key-value store interface in LangChain is used primarily for:
-
Caching embeddings via CachedBackedEmbeddings to avoid recomputing embeddings for repeated queries or when re-indexing content.
-
As a simple Document persistence layer in some retrievers.
Please see these how-to guides for more information: