embed_query() — langchain Function Reference
Architecture documentation for the embed_query() function in cache.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1bc8c67b_9021_d0d6_ca62_9ccab3ca8d7e["embed_query()"] b3be4e54_ae5f_c527_4e99_0843e3d30f72["CacheBackedEmbeddings"] 1bc8c67b_9021_d0d6_ca62_9ccab3ca8d7e -->|defined in| b3be4e54_ae5f_c527_4e99_0843e3d30f72 style 1bc8c67b_9021_d0d6_ca62_9ccab3ca8d7e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/embeddings/cache.py lines 241–262
def embed_query(self, text: str) -> list[float]:
"""Embed query text.
By default, this method does not cache queries. To enable caching, set the
`cache_query` parameter to `True` when initializing the embedder.
Args:
text: The text to embed.
Returns:
The embedding for the given text.
"""
if not self.query_embedding_store:
return self.underlying_embeddings.embed_query(text)
(cached,) = self.query_embedding_store.mget([text])
if cached is not None:
return cached
vector = self.underlying_embeddings.embed_query(text)
self.query_embedding_store.mset([(text, vector)])
return vector
Domain
Subdomains
Source
Frequently Asked Questions
What does embed_query() do?
embed_query() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/embeddings/cache.py.
Where is embed_query() defined?
embed_query() is defined in libs/langchain/langchain_classic/embeddings/cache.py at line 241.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free