_compute_score() — langchain Function Reference
Architecture documentation for the _compute_score() function in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD af8d1584_7461_17c4_1dc0_409b11712821["_compute_score()"] dc2d52f5_736c_0ec2_ad57_0e2fdaa94e04["_EmbeddingDistanceChainMixin"] af8d1584_7461_17c4_1dc0_409b11712821 -->|defined in| dc2d52f5_736c_0ec2_ad57_0e2fdaa94e04 b87deb74_80b9_1b59_d7bb_3ea345fa69b3["_call()"] b87deb74_80b9_1b59_d7bb_3ea345fa69b3 -->|calls| af8d1584_7461_17c4_1dc0_409b11712821 0aaa55c8_a3a2_76b1_2dcd_56a0d3853e7e["_acall()"] 0aaa55c8_a3a2_76b1_2dcd_56a0d3853e7e -->|calls| af8d1584_7461_17c4_1dc0_409b11712821 55bba962_c474_7d72_fad4_2419ad83c3a7["_call()"] 55bba962_c474_7d72_fad4_2419ad83c3a7 -->|calls| af8d1584_7461_17c4_1dc0_409b11712821 5cbc8187_38d5_da15_88a2_96912b92daeb["_acall()"] 5cbc8187_38d5_da15_88a2_96912b92daeb -->|calls| af8d1584_7461_17c4_1dc0_409b11712821 ce394d48_537e_9c2f_6235_1e3ee8acabb5["_get_metric()"] af8d1584_7461_17c4_1dc0_409b11712821 -->|calls| ce394d48_537e_9c2f_6235_1e3ee8acabb5 91b8ba41_75bf_8afd_e893_d85d055226da["_check_numpy()"] af8d1584_7461_17c4_1dc0_409b11712821 -->|calls| 91b8ba41_75bf_8afd_e893_d85d055226da caa53c2b_01ef_7204_a5e6_ad683c86dbd2["_import_numpy()"] af8d1584_7461_17c4_1dc0_409b11712821 -->|calls| caa53c2b_01ef_7204_a5e6_ad683c86dbd2 style af8d1584_7461_17c4_1dc0_409b11712821 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/evaluation/embedding_distance/base.py lines 329–343
def _compute_score(self, vectors: Any) -> float:
"""Compute the score based on the distance metric.
Args:
vectors (np.ndarray): The input vectors.
Returns:
The computed score.
"""
metric = self._get_metric(self.distance_metric)
if _check_numpy() and isinstance(vectors, _import_numpy().ndarray):
score = metric(vectors[0].reshape(1, -1), vectors[1].reshape(1, -1)).item()
else:
score = metric(vectors[0], vectors[1])
return float(score)
Domain
Subdomains
Source
Frequently Asked Questions
What does _compute_score() do?
_compute_score() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py.
Where is _compute_score() defined?
_compute_score() is defined in libs/langchain/langchain_classic/evaluation/embedding_distance/base.py at line 329.
What does _compute_score() call?
_compute_score() calls 3 function(s): _check_numpy, _get_metric, _import_numpy.
What calls _compute_score()?
_compute_score() is called by 4 function(s): _acall, _acall, _call, _call.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free