Argument Correctness
The argument correctness metric is an agentic LLM metric that assesses your LLM agent's ability to generate the correct arguments for the tools it calls. It is calculated by determining whether the arguments for each tool call is correct based on the input.
The ArgumentCorrectnessMetric
uses an LLM to determine argument correctness, and is also referenceless. If you're looking to determistically evaluate argument correctness, refer to the tool correctness metric instead.
Required Arguments
To use the ArgumentCorrectnessMetric
, you'll have to provide the following arguments when creating an LLMTestCase
:
input
actual_output
tools_called
Read the How Is It Calculated section below to learn how test case parameters are used for metric calculation.
Usage
The ArgumentCorrectnessMetric()
can be used for end-to-end evaluation:
from deepeval import evaluate
from deepeval.metrics import ArgumentCorrectnessMetric
from deepeval.test_case import LLMTestCase, ToolCall
metric = ArgumentCorrectnessMetric(
threshold=0.7,
model="gpt-4",
include_reason=True
)
test_case = LLMTestCase(
input="When did Trump first raise tariffs?",
actual_output="Trump first raised tariffs in 2018 during the U.S.-China trade war.",
tools_called=[
ToolCall(
name="WebSearch Tool",
description="Tool to search for information on the web.",
input={"search_query": "Trump first raised tariffs year"}
),
ToolCall(
name="History FunFact Tool",
description="Tool to provide a fun fact about the topic.",
input={"topic": "Trump tariffs"}
)
]
)
# To run metric as a standalone
# metric.measure(test_case)
# print(metric.score, metric.reason)
evaluate(test_cases=[test_case], metrics=[metric])
There are SIX optional parameters when creating an ArgumentCorrectnessMetric
:
- [Optional]
threshold
: a float representing the minimum passing threshold, defaulted to 0.5. - [Optional]
model
: a string specifying which of OpenAI's GPT models to use, OR any custom LLM model of typeDeepEvalBaseLLM
. Defaulted to 'gpt-4.1'. - [Optional]
include_reason
: a boolean which when set toTrue
, will include a reason for its evaluation score. Defaulted toTrue
. - [Optional]
strict_mode
: a boolean which when set toTrue
, enforces a binary metric score: 1 for perfection, 0 otherwise. It also overrides the current threshold and sets it to 1. Defaulted toFalse
. - [Optional]
async_mode
: a boolean which when set toTrue
, enables concurrent execution within themeasure()
method. Defaulted toTrue
. - [Optional]
verbose_mode
: a boolean which when set toTrue
, prints the intermediate steps used to calculate said metric to the console, as outlined in the How Is It Calculated section. Defaulted toFalse
.
Within components
You can also run the ArgumentCorrectnessMetric
within nested components for component-level evaluation.
from deepeval.dataset import Golden
from deepeval.tracing import observe, update_current_span
...
@observe(metrics=[metric])
def inner_component():
# Set test case at runtime
test_case = LLMTestCase(input="...", actual_output="...", tools_called=[...])
update_current_span(test_case=test_case)
return
@observe
def llm_app(input: str):
# Component can be anything from an LLM call, retrieval, agent, tool use, etc.
inner_component()
return
evaluate(observed_callback=llm_app, goldens=[Golden(input="Hi!")])
As a standalone
You can also run the ArgumentCorrectnessMetric
on a single test case as a standalone, one-off execution.
...
metric.measure(test_case)
print(metric.score, metric.reason)
This is great for debugging or if you wish to build your own evaluation pipeline, but you will NOT get the benefits (testing reports, Confident AI platform) and all the optimizations (speed, caching, computation) the evaluate()
function or deepeval test run
offers.
How Is It Calculated?
The ArgumentCorrectnessMetric
score is calculated according to the following equation:
The ArgumentCorrectnessMetric
assesses the correctness of the arguments (input parameters) for each tool call, based on the task outlined in the input.
You can set the verbose_mode
of ANY deepeval
metric to True
to debug the measure()
method:
...
metric = ArgumentCorrectnessMetric(verbose_mode=True)
metric.measure(test_case)