Home / Function/ _embed_query() — langchain Function Reference

_embed_query() — langchain Function Reference

Architecture documentation for the _embed_query() function in vectorstores.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  ce92a056_502f_c4a0_9d88_124ae4b56bb5["_embed_query()"]
  bf62db79_4217_463c_798f_6f8528ed0d6e["Qdrant"]
  ce92a056_502f_c4a0_9d88_124ae4b56bb5 -->|defined in| bf62db79_4217_463c_798f_6f8528ed0d6e
  39b56a94_734a_4e6b_c1e1_da8cc30168e8["similarity_search_with_score()"]
  39b56a94_734a_4e6b_c1e1_da8cc30168e8 -->|calls| ce92a056_502f_c4a0_9d88_124ae4b56bb5
  c17a2c48_ebf6_0c5a_fc95_55ab8d53b4a8["max_marginal_relevance_search()"]
  c17a2c48_ebf6_0c5a_fc95_55ab8d53b4a8 -->|calls| ce92a056_502f_c4a0_9d88_124ae4b56bb5
  style ce92a056_502f_c4a0_9d88_124ae4b56bb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/qdrant/langchain_qdrant/vectorstores.py lines 2097–2116

    def _embed_query(self, query: str) -> list[float]:
        """Embed query text.

        Used to provide backward compatibility with `embedding_function` argument.

        Args:
            query: Query text.

        Returns:
            List of floats representing the query embedding.

        """
        if self.embeddings is not None:
            embedding = self.embeddings.embed_query(query)
        elif self._embeddings_function is not None:
            embedding = self._embeddings_function(query)
        else:
            msg = "Neither of embeddings or embedding_function is set"
            raise ValueError(msg)
        return embedding.tolist() if hasattr(embedding, "tolist") else embedding

Subdomains

Frequently Asked Questions

What does _embed_query() do?
_embed_query() is a function in the langchain codebase, defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py.
Where is _embed_query() defined?
_embed_query() is defined in libs/partners/qdrant/langchain_qdrant/vectorstores.py at line 2097.
What calls _embed_query()?
_embed_query() is called by 2 function(s): max_marginal_relevance_search, similarity_search_with_score.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free