_evaluate_strings() — langchain Function Reference
Architecture documentation for the _evaluate_strings() function in eval_chain.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dfe00c3b_61a4_4940_d85c_397366806f14["_evaluate_strings()"] e476a8f9_5ced_15c1_3631_8a65948b94ed["CriteriaEvalChain"] dfe00c3b_61a4_4940_d85c_397366806f14 -->|defined in| e476a8f9_5ced_15c1_3631_8a65948b94ed 3f59ee2b_7d21_2ac1_4ecc_388e84a8c655["_get_eval_input()"] dfe00c3b_61a4_4940_d85c_397366806f14 -->|calls| 3f59ee2b_7d21_2ac1_4ecc_388e84a8c655 73dd8c35_4316_e427_8b9a_2f20c324d6b0["_prepare_output()"] dfe00c3b_61a4_4940_d85c_397366806f14 -->|calls| 73dd8c35_4316_e427_8b9a_2f20c324d6b0 a41998df_2f6e_21cb_6927_203388623323["from_llm()"] dfe00c3b_61a4_4940_d85c_397366806f14 -->|calls| a41998df_2f6e_21cb_6927_203388623323 style dfe00c3b_61a4_4940_d85c_397366806f14 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py lines 404–453
def _evaluate_strings(
self,
*,
prediction: str,
reference: str | None = None,
input: str | None = None,
callbacks: Callbacks = None,
tags: list[str] | None = None,
metadata: dict[str, Any] | None = None,
include_run_info: bool = False,
**kwargs: Any,
) -> dict:
"""Evaluate a prediction against the criteria.
Args:
prediction: The predicted text to evaluate.
reference: The reference text to compare against. This is required if
`requires_reference` is `True`.
input: The input text used to generate the prediction.
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 to pass to the `LLMChain` `__call__`
method.
Returns:
The evaluation results.
Examples:
>>> from langchain_openai import OpenAI
>>> from langchain_classic.evaluation.criteria import CriteriaEvalChain
>>> model = OpenAI()
>>> criteria = "conciseness"
>>> chain = CriteriaEvalChain.from_llm(llm=model, criteria=criteria)
>>> chain.evaluate_strings(
prediction="The answer is 42.",
reference="42",
input="What is the answer to life, the universe, and everything?",
)
"""
input_ = self._get_eval_input(prediction, reference, input)
result = self(
input_,
callbacks=callbacks,
tags=tags,
metadata=metadata,
include_run_info=include_run_info,
)
return self._prepare_output(result)
Domain
Subdomains
Source
Frequently Asked Questions
What does _evaluate_strings() do?
_evaluate_strings() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py.
Where is _evaluate_strings() defined?
_evaluate_strings() is defined in libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py at line 404.
What does _evaluate_strings() call?
_evaluate_strings() calls 3 function(s): _get_eval_input, _prepare_output, from_llm.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free