combine_embeddings() — langchain Function Reference
Architecture documentation for the combine_embeddings() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 28b658bd_49a9_57f4_afd1_c492036ca171["combine_embeddings()"] 4ca44101_1e0d_43e9_f420_35c5afe4173a["HypotheticalDocumentEmbedder"] 28b658bd_49a9_57f4_afd1_c492036ca171 -->|defined in| 4ca44101_1e0d_43e9_f420_35c5afe4173a dcdba7e0_a4e9_895f_80dd_67dcdcbaa922["embed_query()"] dcdba7e0_a4e9_895f_80dd_67dcdcbaa922 -->|calls| 28b658bd_49a9_57f4_afd1_c492036ca171 style 28b658bd_49a9_57f4_afd1_c492036ca171 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/chains/hyde/base.py lines 56–76
def combine_embeddings(self, embeddings: list[list[float]]) -> list[float]:
"""Combine embeddings into final embeddings."""
try:
import numpy as np
return list(np.array(embeddings).mean(axis=0))
except ImportError:
logger.warning(
"NumPy not found in the current Python environment. "
"HypotheticalDocumentEmbedder will use a pure Python implementation "
"for internal calculations, which may significantly impact "
"performance, especially for large datasets. For optimal speed and "
"efficiency, consider installing NumPy: pip install numpy",
)
if not embeddings:
return []
num_vectors = len(embeddings)
return [
sum(dim_values) / num_vectors
for dim_values in zip(*embeddings, strict=False)
]
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does combine_embeddings() do?
combine_embeddings() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/chains/hyde/base.py.
Where is combine_embeddings() defined?
combine_embeddings() is defined in libs/langchain/langchain_classic/chains/hyde/base.py at line 56.
What calls combine_embeddings()?
combine_embeddings() 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