id
stringlengths
14
15
text
stringlengths
32
2.18k
source
stringclasses
30 values
62decbd06b8a-17
the user to make an informed decision. Therefore, the response is accurate and useful. Final Grade: A", " The API response provided a list of tablets that are under $400. The response accurately answered the user's question. Additionally, the response provided useful information such as the product name, price, and...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-18
included the name, price, and attributes of each skirt. This is a great start, as it provides the user with a variety of options to choose from. However, the response does not provide any images of the skirts, which would have been helpful for the user to make a decision. Additionally, the response does not provide any...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-19
len(metric_scores) if len(metric_scores) > 0 else float("nan") ) row = "{:<20}\t{:<10.2f}\t{:<10.2f}\t{:<10.2f}".format( metric, min(metric_scores), mean_scores, max(metric_scores) ) print(row) Metric Min Mean Max completed 1.00...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-20
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support.# List the paths in the OpenAP...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-21
this value from the language the user asked their question in. Always use the full name of the language (e.g. Spanish, French). */ native_language?: string, /* A description of any additional context in the user's question that could affect the explanation - e.g. setting, scenario, situation, tone, speaking sty...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-22
= parse_list(text)queries ["Can you explain how to say 'hello' in Spanish?", "I need help understanding the French word for 'goodbye'.", "Can you tell me how to say 'thank you' in German?", "I'm trying to learn the Italian word for 'please'.", "Can you help me with the pronunciation of 'yes' in Portu...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-23
word for \'goodbye\'."}', '{"task_description": "say \'thank you\'", "learning_language": "German", "native_language": "English", "full_query": "Can you tell me how to say \'thank you\' in German?"}', '{"task_description": "Learn the Italian word for \'please\'", "learning_language": "Italian", "native_language...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-24
for \'please\'", "learning_language": "Arabic", "native_language": "English", "full_query": "I\'m trying to learn the Arabic word for \'please\'."}']## AI Assisted Correctioncorrection_template = """Correct the following API request based on the user's feedback. If the user indicates no changes are needed, output the o...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-25
for 'goodbye'."} Requested changes: Query: Can you tell me how to say 'thank you' in German? Request: {"task_description": "say 'thank you'", "learning_language": "German", "native_language": "English", "full_query": "Can you tell me how to say 'thank you' in German?"} Requested changes: Query: I'm try...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-26
"Can you explain the meaning of 'hello' in Japanese?"} Requested changes: Query: I need help understanding the Russian word for 'thank you'. Request: {"task_description": "understanding the Russian word for 'thank you'", "learning_language": "Russian", "native_language": "English", "full_query": "I need help ...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-27
'{"task_description": "say \'thank you\'", "learning_language": "German", "native_language": "English", "full_query": "Can you tell me how to say \'thank you\' in German?"}', '{"task_description": "Learn the Italian word for \'please\'", "learning_language": "Italian", "native_language": "English", "full_query": "I...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
62decbd06b8a-28
"Arabic", "native_language": "English", "full_query": "I\'m trying to learn the Arabic word for \'please\'."}']PreviousData Augmented Question AnsweringNextQuestion Answering Benchmarking: Paul Graham EssayLoad the API ChainOptional: Generate Input Questions and Request Ground Truth QueriesRun the API ChainEvaluate the...
https://python.langchain.com/docs/guides/evaluation/examples/openapi_eval
7549d0f4fb0e-0
Question Answering Benchmarking: State of the Union Address | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_sota
7549d0f4fb0e-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsExamplesAgent VectorDB Question Answeri...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_sota
7549d0f4fb0e-2
0%| | 0/1 [00:00<?, ?it/s]Setting up a chain​Now we need to create some pipelines for doing question answering. Step one in that is creating an index over the data in question.from langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")from langchain.indexes im...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_sota
7549d0f4fb0e-3
{'question': 'What is the purpose of the NATO Alliance?', 'answer': 'The purpose of the NATO Alliance is to secure peace and stability in Europe after World War 2.', 'result': ' The purpose of the NATO Alliance is to secure peace and stability in Europe after World War 2.'}Next, we can use a language model to s...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_sota
7549d0f4fb0e-4
Paul Graham EssayNextQA GenerationLoading the dataSetting up a chainMake a predictionMake many predictionsEvaluate performanceCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_sota
8d137bc8f49b-0
Question Answering Benchmarking: Paul Graham Essay | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_pg
8d137bc8f49b-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsExamplesAgent VectorDB Question Answeri...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_pg
8d137bc8f49b-2
?it/s]Setting up a chain​Now we need to create some pipelines for doing question answering. Step one in that is creating an index over the data in question.from langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/paul_graham_essay.txt")from langchain.indexes import VectorstoreIndexCreatorve...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_pg
8d137bc8f49b-3
author worked on before college were writing and programming.', 'result': ' Writing and programming.'}Next, we can use a language model to score them programaticallyfrom langchain.evaluation.qa import QAEvalChainllm = OpenAI(temperature=0)eval_chain = QAEvalChain.from_llm(llm)graded_outputs = eval_chain.evaluate( ...
https://python.langchain.com/docs/guides/evaluation/examples/qa_benchmarking_pg
617ad7d2f504-0
Agent VectorDB Question Answering Benchmarking | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
617ad7d2f504-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsExamplesAgent VectorDB Question Answeri...
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
617ad7d2f504-2
100%|██████████| 1/1 [00:00<00:00, 414.42it/s]dataset[0] {'question': 'What is the purpose of the NATO Alliance?', 'answer': 'The purpose of the NATO Alliance is to secure peace and stability in Europe after World War 2.', 'steps': [{'tool': 'State of Union QA System', 'tool_input': None}...
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
617ad7d2f504-3
create a question answering chain.from langchain.chains import RetrievalQAfrom langchain.llms import OpenAIchain_sota = RetrievalQA.from_chain_type( llm=OpenAI(temperature=0), chain_type="stuff", retriever=vectorstore_sota.as_retriever(), input_key="question",)Now we do the same for the Paul Graham data.loa...
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
617ad7d2f504-4
question.", ),]agent = initialize_agent( tools, OpenAI(temperature=0), agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, max_iterations=4,)Make a prediction​First, we can make predictions one datapoint at a time. Doing it at this level of granularity allows use to explore the outputs in detail, and also is ...
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
617ad7d2f504-5
= eval_chain.evaluate( predicted_dataset, predictions, question_key="input", prediction_key="output")We can add in the graded output to the predictions dict and then get a count of the grades.for i, prediction in enumerate(predictions): prediction["grade"] = graded_outputs[i]["text"]from collections import Counte...
https://python.langchain.com/docs/guides/evaluation/examples/agent_vectordb_sota_pg
ff49425f490f-0
String Evaluators | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/
ff49425f490f-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/
ff49425f490f-2
used alongside approximate/fuzzy matching criteria for very basic unit testing.PreviousEvaluationNextEvaluating Custom CriteriaCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc.
https://python.langchain.com/docs/guides/evaluation/string/
52c4a5752779-0
QA Correctness | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/qa
52c4a5752779-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/qa
52c4a5752779-2
LLM to check the equivalence of a SQL query against a reference SQL query using the sql prompt.from langchain.evaluation.qa.eval_prompt import SQL_PROMPTeval_chain = load_evaluator("qa", eval_llm=llm, prompt=SQL_PROMPT)eval_chain.evaluate_strings( input="What's last quarter's sales numbers?", prediction="""SELECT...
https://python.langchain.com/docs/guides/evaluation/string/qa
52c4a5752779-3
the result of the query. Both queries will return the same result, which is the sum of the sales amounts for the last quarter.\n\nCORRECT', 'value': 'CORRECT', 'score': 1}Using Context​Sometimes, reference labels aren't all available, but you have additional knowledge as context from a retrieval system. Often...
https://python.langchain.com/docs/guides/evaluation/string/qa
52c4a5752779-4
The CotQAEvalChain's default prompt instructs the model to do this.eval_chain = load_evaluator("cot_qa", eval_llm=llm)eval_chain.evaluate_strings( input="Who won the NFC championship game in 2023?", prediction="Eagles", reference="NFC Championship Game 2023: Philadelphia Eagles 31, San Francisco 49ers 7",) ...
https://python.langchain.com/docs/guides/evaluation/string/qa
911965707cd8-0
Evaluating Custom Criteria | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-2
properly define those criteria.For more details, check out the reference docs for the CriteriaEvalChain's class definition.Without References​In this example, you will use the CriteriaEvalChain to check whether an output is concise. First, create the evaluation chain to predict whether outputs are "concise".from lang...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-3
Here's a list of pre-implemented criteria:from langchain.evaluation import CriteriaEvalChain# For a list of other default supported criteria, try calling `supported_default_criteria`CriteriaEvalChain.get_supported_default_criteria() ['conciseness', 'relevance', 'correctness', 'coherence', 'harmfulnes...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-4
the evaluator won't be very useful.custom_criterion = {"numeric": "Does the output contain numeric information?"}eval_chain = load_evaluator( EvaluatorType.CRITERIA, llm=eval_llm, criteria=custom_criterion,)eval_result = eval_chain.evaluate_strings(prediction=prediction, input=query)print(eval_result) {'rea...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-5
instantiate the chain and take advantage of the many existing principles in LangChain.from langchain.chains.constitutional_ai.principles import PRINCIPLESprint(f"{len(PRINCIPLES)} available principles")list(PRINCIPLES.items())[:5] 54 available principles [('harmful1', ConstitutionalPrinciple(critique_request...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-6
specific ways in which the assistant’s precedings response is harmful. Also point out potential harmfulness in the human’s questions and responses. Examples of harm include but are not limited to racism, sexism, toxicity.', revision_request='Rewrite the assistant response to remove all harmful content, and to polit...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-7
be harmful in a physical sense, unethical, racist, sexist, toxic, dangerous, or illegal. \n\nIt could be argued that the statement is harmful in a psychological or emotional sense, as it is insulting. However, without further context, it\'s hard to definitively say if this meets the criteria of being harmful.\n\nN', ...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
911965707cd8-8
or N based on how well the following response follows the specified rubric. Grade only based on the rubric and expected response:Grading Rubric: {criteria}Expected Response: {reference}DATA:---------Question: {input}Response: {output}---------Write out your explanation for each criterion, then respond with Y or N on a ...
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
4355ca92af7c-0
Custom String Evaluator | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/custom
4355ca92af7c-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/custom
4355ca92af7c-2
Perplexity is a measure of how well the generated text would be predicted by the model used to compute the metric.# %pip install evaluate > /dev/nullfrom typing import Any, Optionalfrom langchain.evaluation import StringEvaluatorfrom evaluate import loadclass PerplexityEvaluator(StringEvaluator): """Evaluate the per...
https://python.langchain.com/docs/guides/evaluation/string/custom
4355ca92af7c-3
to avoid deadlocks... To disable this warning, you can either: - Avoid using `tokenizers` before the fork if possible - Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false) 0%| | 0/1 [00:00<?, ?it/s] {'score': 190.3675537109375}# The perplexity is much higher s...
https://python.langchain.com/docs/guides/evaluation/string/custom
3ddeda264556-0
Embedding Distance | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/embedding_distance
3ddeda264556-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/embedding_distance
3ddeda264556-2
'manhattan'>, <EmbeddingDistance.CHEBYSHEV: 'chebyshev'>, <EmbeddingDistance.HAMMING: 'hamming'>]# You can load by enum or by raw python stringevaluator = load_evaluator( "embedding_distance", distance_metric=EmbeddingDistance.EUCLIDEAN)Select Embeddings to Use​The constructor uses OpenAI embeddings by def...
https://python.langchain.com/docs/guides/evaluation/string/embedding_distance
3ddeda264556-3
or [LabeledCriteriaEvalChain](https://api.python.langchain.com/en/latest/evaluation/langchain.evaluation.criteria.eval_chain.LabeledCriteriaEvalChain.html#langchain.evaluation.criteria.eval_chain.LabeledCriteriaEvalChain)) PreviousCustom String EvaluatorNextQA CorrectnessSelect the Distance MetricSelect Embeddings to U...
https://python.langchain.com/docs/guides/evaluation/string/embedding_distance
3e7eebca25e4-0
String Distance | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/string/string_distance
3e7eebca25e4-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsEvaluating Custom CriteriaCustom String EvaluatorEmbedding DistanceQA Correctness...
https://python.langchain.com/docs/guides/evaluation/string/string_distance
3e7eebca25e4-2
using the distance argument.from langchain.evaluation import StringDistancelist(StringDistance) [<StringDistance.DAMERAU_LEVENSHTEIN: 'damerau_levenshtein'>, <StringDistance.LEVENSHTEIN: 'levenshtein'>, <StringDistance.JARO: 'jaro'>, <StringDistance.JARO_WINKLER: 'jaro_winkler'>]jaro_evaluator = load_eva...
https://python.langchain.com/docs/guides/evaluation/string/string_distance
940eb78357f4-0
Trajectory Evaluators | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajector...
https://python.langchain.com/docs/guides/evaluation/trajectory/
d23bed2a30c9-0
Agent Trajectory | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/trajectory/trajectory_eval
d23bed2a30c9-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsCustom Trajectory EvaluatorAgent Trajec...
https://python.langchain.com/docs/guides/evaluation/trajectory/trajectory_eval
d23bed2a30c9-2
["ping", "-c", "1", hostname], capture_output=True, text=True ) output = completed_process.stdout if return_error and completed_process.returncode != 0: return completed_process.stderr return output@tooldef trace_route(url: HttpUrl, return_error: bool) -> str: """Trace the route to the specified u...
https://python.langchain.com/docs/guides/evaluation/trajectory/trajectory_eval
d23bed2a30c9-3
you don't select an LLM to use for evaluation, the load_evaluator function will use gpt-4 to power the evaluation chain. You can select any chat model for the agent trajectory evaluator as below.# %pip install anthropic# ANTHROPIC_API_KEY=<YOUR ANTHROPIC API KEY>from langchain.chat_models import ChatAnthropiceval_llm =...
https://python.langchain.com/docs/guides/evaluation/trajectory/trajectory_eval
090692635e5e-0
Custom Trajectory Evaluator | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/trajectory/custom
090692635e5e-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsCustom Trajectory EvaluatorAgent Trajec...
https://python.langchain.com/docs/guides/evaluation/trajectory/custom
090692635e5e-2
template) def _evaluate_agent_trajectory( self, *, prediction: str, input: str, agent_trajectory: Sequence[Tuple[AgentAction, str]], reference: Optional[str] = None, **kwargs: Any, ) -> dict: vals = [ f"{i}: Action=[{action.tool}] returned observa...
https://python.langchain.com/docs/guides/evaluation/trajectory/custom
090692635e5e-3
AgentAction(tool="ask", tool_input="What is today?", log=""), "tomorrow's yesterday", ), ( AgentAction(tool="check_tv", tool_input="Watch tv for half hour", log=""), "bzzz", ), ],) {'score': 1, 'value': 'Y', 'reasoning': 'Y'}PreviousTrajectory EvaluatorsNextAg...
https://python.langchain.com/docs/guides/evaluation/trajectory/custom
cc868abf9b0f-0
Comparison Evaluators | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsCustom Pa...
https://python.langchain.com/docs/guides/evaluation/comparison/
c4ed184747cf-0
Custom Pairwise Evaluator | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsCustom Pairwise EvaluatorPairwise Embedding DistancePairwise...
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-2
return {"score": score}evaluator = LengthComparisonPairwiseEvalutor()evaluator.evaluate_string_pairs( prediction="The quick brown fox jumped over the lazy dog.", prediction_b="The quick brown fox jumped over the dog.",) {'score': 1}LLM-Based Example​That example was simple to illustrate the API, but it wasn'...
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-3
B: You can use the following code:from pathlib import PathPath(__file__).absolute().parentReasoning: Both options return the same result. However, since option B is more concise and easily understand, it is preferred.
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-4
Preference: BWhich option is preferred? Do not take order into account. Evaluate based on accuracy and helpfulness. If neither is preferred, respond with C. Provide your reasoning, then finish with Preference: A/B/C Input: {input} Option A: {prediction} Option B: {prediction_b} Reasoning:""",
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-5
)@propertydef requires_input(self) -> bool: return True@propertydef requires_reference(self) -> bool: return Falsedef _evaluate_string_pairs( self, *, prediction: str, prediction_b: str, reference: Optional[str] = None, input: Optional[str] = None, **kwargs: Any,) -> dict: result = self.ev...
https://python.langchain.com/docs/guides/evaluation/comparison/custom
c4ed184747cf-6
straightforward and concise.\n\nOption A uses the importlib module, which allows importing a module by specifying the full name as a string. While this works, it is less clear compared to option B.\n\nOption B directly imports from the relative path using dot notation, which clearly shows that it is a relative import. ...
https://python.langchain.com/docs/guides/evaluation/comparison/custom
ac3ff691981a-0
Pairwise Embedding Distance | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_embedding_distance
ac3ff691981a-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsCustom Pairwise EvaluatorPairwise Embedding DistancePairwise...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_embedding_distance
ac3ff691981a-2
<EmbeddingDistance.EUCLIDEAN: 'euclidean'>, <EmbeddingDistance.MANHATTAN: 'manhattan'>, <EmbeddingDistance.CHEBYSHEV: 'chebyshev'>, <EmbeddingDistance.HAMMING: 'hamming'>]evaluator = load_evaluator( "pairwise_embedding_distance", distance_metric=EmbeddingDistance.EUCLIDEAN)Select Embeddings to Use​The ...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_embedding_distance
a857ded138da-0
Pairwise String Comparison | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
a857ded138da-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsCustom Pairwise EvaluatorPairwise Embedding DistancePairwise...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
a857ded138da-2
The results will reflect the evaluation model's preference, which is less reliable and may result
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
a857ded138da-3
in preferences that are factually incorrect.from langchain.evaluation import load_evaluatorevaluator = load_evaluator("pairwise_string")evaluator.evaluate_string_pairs( prediction="Addition is a mathematical operation.", prediction_b="Addition is a mathematical operation that adds two numbers to create a third nu...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
a857ded138da-4
question, despite lacking depth or creativity.\n\n[[B]]\n', 'value': 'B', 'score': 0}Customize the Evaluation Prompt​You can use your own custom evaluation prompt to add more task-specific instructions or to instruct the evaluator to score the output.*Note: If you use a prompt that expects generates a result ...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
a857ded138da-5
prediction_b="The dog's name is spot", input="What is the name of the dog that ate the ice cream?", reference="The dog's name is fido",) {'reasoning': "Option A is most similar to the reference label. Both the reference label and option A state that the dog's name is Fido. Option B, on the other hand, gives a ...
https://python.langchain.com/docs/guides/evaluation/comparison/pairwise_string
016228b75473-0
Model Comparison | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/model_laboratory
016228b75473-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationDebuggingDeploymentLangSmithModel ComparisonEcosystemAdditional resourcesGuidesModel ComparisonMod...
https://python.langchain.com/docs/guides/model_laboratory
016228b75473-2
Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 20, 'temperature': 0.0, 'k': 0, 'p': 1, 'frequency_penalty': 0, 'presence_penalty': 0} Pink HuggingFaceHub Params: {'repo_id': 'google/flan-t5-xl', 'temperature': 1} pink prompt = PromptTemplate( template="What is the cap...
https://python.langchain.com/docs/guides/model_laboratory
016228b75473-3
'temperature': 1} st john s from langchain import SelfAskWithSearchChain, SerpAPIWrapperopen_ai_llm = OpenAI(temperature=0)search = SerpAPIWrapper()self_ask_with_search_openai = SelfAskWithSearchChain( llm=open_ai_llm, search_chain=search, verbose=True)cohere_llm = Cohere(temperature=0, model="command-xlarge-2...
https://python.langchain.com/docs/guides/model_laboratory
016228b75473-4
Follow up: Where is Carlos Alcaraz from? Intermediate answer: El Palmar, Spain. So the final answer is: El Palmar, Spain > Finished chain. So the final answer is: El Palmar, Spain Cohere Params: {'model': 'command-xlarge-20221108', 'max_tokens': 256, 'temperature': 0.0, 'k': 0, 'p': 1, 'freque...
https://python.langchain.com/docs/guides/model_laboratory
385697ef0e6a-0
LangSmith | 🦜�🔗 Langchain Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationDebuggingDeploymentLangSmithLangSmith WalkthroughModel Comp...
https://python.langchain.com/docs/guides/langsmith/
712506381261-0
LangSmith Walkthrough | 🦜�🔗 Langchain
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-1
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationDebuggingDeploymentLangSmithLangSmith WalkthroughModel ComparisonEcosystemAdditional resourcesGuid...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-2
You can tell LangChain which project to log to by setting the LANGCHAIN_PROJECT environment variable (if this isn't set, runs will be logged to the default project). This will automatically create the project for you if it doesn't exist. You must also set the LANGCHAIN_ENDPOINT and LANGCHAIN_API_KEY environment variabl...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-3
LangSmith works regardless of which type of LangChain component you use (LLMs, Chat Models, Tools, Retrievers, Agents are all supported).from langchain.chat_models import ChatOpenAIfrom langchain.agents import AgentType, initialize_agent, load_toolsllm = ChatOpenAI(temperature=0)tools = load_tools(["serpapi", "llm-math...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-4
return await agent.arun(input_example) except Exception as e: # The agent sometimes makes mistakes! These will be captured by the tracing. return efor input_example in inputs: results.append(arun(agent, input_example))results = await asyncio.gather(*results)from langchain.callbacks.tracers.langchain...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-5
to a benchmark dataset to be used for evaluating other agents.For more information on datasets, including how to create them from CSVs or other files or how to create them in the platform, please refer to the LangSmith documentation.dataset_name = f"calculator-example-dataset-{unique_id}"dataset = client.create_dataset...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-6
object directly# to improve runtime performance. For example:# chain_factory = lambda: agent3. Configure evaluation​Manually comparing the results of chains in the UI is effective, but it can be time consuming.
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-7
It can be helpful to use automated metrics and AI-assisted feedback to evaluate your component's performance.Below, we will create some pre-implemented run evaluators that do the following:Compare results against ground truth labels. (You used the debug outputs above for this)Measure semantic (dis)similarity using embe...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-8
custom evaluators, please refer to the LangSmith documentation.from langchain.evaluation import EvaluatorTypefrom langchain.smith import RunEvalConfigevaluation_config = RunEvalConfig( # Evaluators can either be an evaluator type (e.g., "qa", "criteria", "embedding_distance", etc.) or a configuration for that evalua...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-9
be # applied to each prediction. Check out the docs for examples. custom_evaluators=[],)4. Run the agent and evaluators​Use the arun_on_dataset (or synchronous run_on_dataset) function to evaluate your model. This will:Fetch example rows from the specified datasetRun your llm or chain on each example.Apply eval...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-10
** 0.43 ") raised error: 'age_of_Dua_Lipa_boyfriend'. Please try again with a valid numerical expression Processed examples: 4 Chain failed for example 91439261-1c86-4198-868b-a6c1cc8a051b. Error: Too many arguments to single-input tool Calculator. Args: ['height ^ 0.13', {'height': 68}] Processed examples:...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-11
extra={'runtime': {'library': 'langchain', 'runtime': 'python', 'platform': 'macOS-13.4.1-arm64-arm-64bit', 'sdk_version': '0.0.8', 'library_version': '0.0.231', 'runtime_version': '3.11.2'}, 'total_tokens': 512, 'prompt_tokens': 451, 'completion_tokens': 61}, error=None, serialized=None, events=[{'name': 'start', 'tim...
https://python.langchain.com/docs/guides/langsmith/walkthrough
712506381261-12
UUID('a6f92bf5-cfba-4747-9336-370cb00c928a'), UUID('65312576-5a39-4250-b820-4dfae7d73945')], child_runs=None, feedback_stats={'correctness': {'n': 1, 'avg': 1.0, 'mode': 1}, 'helpfulness': {'n': 1, 'avg': 1.0, 'mode': 1}, 'fifth-grader-score': {'n': 1, 'avg': 1.0, 'mode': 1}, 'embedding_cosine_distance': {'n': 1, 'avg'...
https://python.langchain.com/docs/guides/langsmith/walkthrough