Home / Function/ embed_documents() — langchain Function Reference

embed_documents() — langchain Function Reference

Architecture documentation for the embed_documents() function in huggingface_endpoint.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  bcc591c5_13d4_9230_07fe_b338b9fa9f55["embed_documents()"]
  3e578245_e691_a97e_a094_2b8fa981436a["HuggingFaceEndpointEmbeddings"]
  bcc591c5_13d4_9230_07fe_b338b9fa9f55 -->|defined in| 3e578245_e691_a97e_a094_2b8fa981436a
  4ef55f39_d22f_e607_6c86_d27f1631763f["embed_query()"]
  4ef55f39_d22f_e607_6c86_d27f1631763f -->|calls| bcc591c5_13d4_9230_07fe_b338b9fa9f55
  style bcc591c5_13d4_9230_07fe_b338b9fa9f55 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/partners/huggingface/langchain_huggingface/embeddings/huggingface_endpoint.py lines 115–130

    def embed_documents(self, texts: list[str]) -> list[list[float]]:
        """Call out to HuggingFaceHub's embedding endpoint for embedding search docs.

        Args:
            texts: The list of texts to embed.

        Returns:
            List of embeddings, one for each text.

        """
        # replace newlines, which can negatively affect performance.
        texts = [text.replace("\n", " ") for text in texts]
        _model_kwargs = self.model_kwargs or {}
        #  api doc: https://huggingface.github.io/text-embeddings-inference/#/Text%20Embeddings%20Inference/embed
        responses = self.client.feature_extraction(text=texts, **_model_kwargs)
        return responses.tolist()

Domain

Subdomains

Called By

Frequently Asked Questions

What does embed_documents() do?
embed_documents() is a function in the langchain codebase, defined in libs/partners/huggingface/langchain_huggingface/embeddings/huggingface_endpoint.py.
Where is embed_documents() defined?
embed_documents() is defined in libs/partners/huggingface/langchain_huggingface/embeddings/huggingface_endpoint.py at line 115.
What calls embed_documents()?
embed_documents() is called by 1 function(s): embed_query.

Analyze Your Own Codebase

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

Try Supermodel Free