Home / Function/ _aevaluate_strings() — langchain Function Reference

_aevaluate_strings() — langchain Function Reference

Architecture documentation for the _aevaluate_strings() function in eval_chain.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  375de358_d0b8_d70d_d3fd_da353f95ec25["_aevaluate_strings()"]
  e476a8f9_5ced_15c1_3631_8a65948b94ed["CriteriaEvalChain"]
  375de358_d0b8_d70d_d3fd_da353f95ec25 -->|defined in| e476a8f9_5ced_15c1_3631_8a65948b94ed
  3f59ee2b_7d21_2ac1_4ecc_388e84a8c655["_get_eval_input()"]
  375de358_d0b8_d70d_d3fd_da353f95ec25 -->|calls| 3f59ee2b_7d21_2ac1_4ecc_388e84a8c655
  73dd8c35_4316_e427_8b9a_2f20c324d6b0["_prepare_output()"]
  375de358_d0b8_d70d_d3fd_da353f95ec25 -->|calls| 73dd8c35_4316_e427_8b9a_2f20c324d6b0
  a41998df_2f6e_21cb_6927_203388623323["from_llm()"]
  375de358_d0b8_d70d_d3fd_da353f95ec25 -->|calls| a41998df_2f6e_21cb_6927_203388623323
  style 375de358_d0b8_d70d_d3fd_da353f95ec25 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py lines 456–505

    async def _aevaluate_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:
        """Asynchronously 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)
            >>> await chain.aevaluate_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 = await self.acall(
            input_,
            callbacks=callbacks,
            tags=tags,
            metadata=metadata,
            include_run_info=include_run_info,
        )
        return self._prepare_output(result)

Domain

Subdomains

Frequently Asked Questions

What does _aevaluate_strings() do?
_aevaluate_strings() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py.
Where is _aevaluate_strings() defined?
_aevaluate_strings() is defined in libs/langchain/langchain_classic/evaluation/criteria/eval_chain.py at line 456.
What does _aevaluate_strings() call?
_aevaluate_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