mirror of
https://github.com/hwchase17/langchain
synced 2024-11-06 03:20:49 +00:00
parent
79ed66f870
commit
cac849ae86
@ -160,7 +160,7 @@ class PairwiseStringEvalChain(PairwiseStringEvaluator, LLMEvalChain, LLMChain):
|
|||||||
Example:
|
Example:
|
||||||
>>> from langchain.chat_models import ChatOpenAI
|
>>> from langchain.chat_models import ChatOpenAI
|
||||||
>>> from langchain.evaluation.comparison import PairwiseStringEvalChain
|
>>> from langchain.evaluation.comparison import PairwiseStringEvalChain
|
||||||
>>> llm = ChatOpenAI(temperature=0, model_name="gpt-4")
|
>>> llm = ChatOpenAI(temperature=0, model_name="gpt-4", model_kwargs={"random_seed": 42})
|
||||||
>>> chain = PairwiseStringEvalChain.from_llm(llm=llm)
|
>>> chain = PairwiseStringEvalChain.from_llm(llm=llm)
|
||||||
>>> result = chain.evaluate_string_pairs(
|
>>> result = chain.evaluate_string_pairs(
|
||||||
... input = "What is the chemical formula for water?",
|
... input = "What is the chemical formula for water?",
|
||||||
@ -179,7 +179,7 @@ class PairwiseStringEvalChain(PairwiseStringEvaluator, LLMEvalChain, LLMChain):
|
|||||||
# . " by explaining what the formula means.\\n[[B]]"
|
# . " by explaining what the formula means.\\n[[B]]"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
"""
|
""" # noqa: E501
|
||||||
|
|
||||||
output_key: str = "results" #: :meta private:
|
output_key: str = "results" #: :meta private:
|
||||||
output_parser: BaseOutputParser = Field(
|
output_parser: BaseOutputParser = Field(
|
||||||
|
@ -130,7 +130,9 @@ def load_evaluator(
|
|||||||
evaluator_cls = _EVALUATOR_MAP[evaluator]
|
evaluator_cls = _EVALUATOR_MAP[evaluator]
|
||||||
if issubclass(evaluator_cls, LLMEvalChain):
|
if issubclass(evaluator_cls, LLMEvalChain):
|
||||||
try:
|
try:
|
||||||
llm = llm or ChatOpenAI(model="gpt-4", temperature=0)
|
llm = llm or ChatOpenAI(
|
||||||
|
model="gpt-4", model_kwargs={"seed": 42}, temperature=0
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Evaluation with the {evaluator_cls} requires a "
|
f"Evaluation with the {evaluator_cls} requires a "
|
||||||
|
Loading…
Reference in New Issue
Block a user