PairwiseStringDistanceEvalChain Class — langchain Architecture
Architecture documentation for the PairwiseStringDistanceEvalChain class in base.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 673d639d_36b0_87dd_ead9_5b65d00daaca["PairwiseStringDistanceEvalChain"] 910b9203_afa5_b8ca_1a1e_3933f70c340f["PairwiseStringEvaluator"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|extends| 910b9203_afa5_b8ca_1a1e_3933f70c340f 5c42d4f5_4dcc_bdad_cf78_f643b26ab2eb["_RapidFuzzChainMixin"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|extends| 5c42d4f5_4dcc_bdad_cf78_f643b26ab2eb e8a12ac8_a98d_9b97_548e_a57588a0d3dc["base.py"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|defined in| e8a12ac8_a98d_9b97_548e_a57588a0d3dc d7f8913c_9231_a53d_478d_90fc1499618e["input_keys()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| d7f8913c_9231_a53d_478d_90fc1499618e 991c603e_8000_ae16_c631_7b59ee13fdfa["evaluation_name()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| 991c603e_8000_ae16_c631_7b59ee13fdfa cf6188b8_533c_de49_feb5_b7617d9319ea["_call()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| cf6188b8_533c_de49_feb5_b7617d9319ea 26aeaa7f_8a64_e9f8_b6bf_e561c2708a27["_acall()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| 26aeaa7f_8a64_e9f8_b6bf_e561c2708a27 1fe1bfd8_c0e2_e992_88ac_e0bbb569d592["_evaluate_string_pairs()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| 1fe1bfd8_c0e2_e992_88ac_e0bbb569d592 7ae8c4c6_d065_6bd6_7b3a_d805a0a31ecc["_aevaluate_string_pairs()"] 673d639d_36b0_87dd_ead9_5b65d00daaca -->|method| 7ae8c4c6_d065_6bd6_7b3a_d805a0a31ecc
Relationship Graph
Source Code
libs/langchain/langchain_classic/evaluation/string_distance/base.py lines 325–452
class PairwiseStringDistanceEvalChain(PairwiseStringEvaluator, _RapidFuzzChainMixin):
"""Compute string edit distances between two predictions."""
@property
def input_keys(self) -> list[str]:
"""Get the input keys.
Returns:
The input keys.
"""
return ["prediction", "prediction_b"]
@property
def evaluation_name(self) -> str:
"""Get the evaluation name.
Returns:
The evaluation name.
"""
return f"pairwise_{self.distance.value}_distance"
@override
def _call(
self,
inputs: dict[str, Any],
run_manager: CallbackManagerForChainRun | None = None,
) -> dict[str, Any]:
"""Compute the string distance between two predictions.
Args:
inputs: The input values.
run_manager: The callback manager.
Returns:
The evaluation results containing the score.
"""
return {
"score": self.compute_metric(inputs["prediction"], inputs["prediction_b"]),
}
@override
async def _acall(
self,
inputs: dict[str, Any],
run_manager: AsyncCallbackManagerForChainRun | None = None,
) -> dict[str, Any]:
"""Asynchronously compute the string distance between two predictions.
Args:
inputs: The input values.
run_manager: The callback manager.
Returns:
The evaluation results containing the score.
"""
return {
"score": self.compute_metric(inputs["prediction"], inputs["prediction_b"]),
}
@override
def _evaluate_string_pairs(
self,
*,
prediction: str,
prediction_b: str,
callbacks: Callbacks = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
include_run_info: bool = False,
**kwargs: Any,
) -> dict:
"""Evaluate the string distance between two predictions.
Args:
prediction: The first prediction string.
prediction_b: The second prediction string.
callbacks: The callbacks to use.
tags: The tags to apply.
metadata: The metadata to use.
include_run_info: Whether to include run info in the output.
**kwargs: Additional keyword arguments.
Source
Frequently Asked Questions
What is the PairwiseStringDistanceEvalChain class?
PairwiseStringDistanceEvalChain is a class in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/string_distance/base.py.
Where is PairwiseStringDistanceEvalChain defined?
PairwiseStringDistanceEvalChain is defined in libs/langchain/langchain_classic/evaluation/string_distance/base.py at line 325.
What does PairwiseStringDistanceEvalChain extend?
PairwiseStringDistanceEvalChain extends PairwiseStringEvaluator, _RapidFuzzChainMixin.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free