Skip to main content
Testkube 2.15.0 is out! AI Governance, GitLab in AI Test Creation, an executions timeline, and much more! Read More

AI Testing Metrics

AI evaluation tools such as Promptfoo, DeepEval, Inspect AI, Ragas and the LM Evaluation Harness measure the quality of LLM applications and models. Each of them writes its results in its own format, so Testkube needs a common format to chart them. This page explains what these tools measure, how Testkube ingests and charts their metrics, and how the testkube-ai-metrics-parser converts the output of each tool for you.

What AI Evaluation Tools Measure​

A traditional functional test either passes or fails. The output of an LLM is not deterministic, and its quality is a matter of degree, so AI evaluation tools report scores alongside pass/fail results. Most of what they produce falls into a few groups:

Kind of metricWhat it tells youExamples
Assertion resultsHow many test cases met their assertions or thresholds, and the resulting pass rate.Promptfoo successes, failures and pass rate; DeepEval passed and failed test cases
LLM-as-a-judge quality scoresA score, usually between 0 and 1, that a second model assigns to an answer for a quality such as relevancy, correctness, or the absence of hallucination.DeepEval answer relevancy, G-Eval and hallucination metrics
RAG metricsHow well a retrieval-augmented generation (RAG) pipeline grounds its answers in the retrieved context, and how relevant that context is.Ragas faithfulness, answer relevancy, context precision, and context recall
Benchmark scoresHow a model performs on a standardized dataset of tasks, often with the standard error of the score.LM Evaluation Harness exact match on gsm8k; Inspect AI accuracy and standard error
Cost and efficiencyWhat a run costs and how long it takes.Token counts, cost of the judge model calls, evaluation duration

A single run of an evaluation tells you little on its own. The value comes from following these metrics over time, so you can:

  • Catch a regression when a prompt, a retrieval step, or the application code changes.
  • Compare models, or model versions, on the same evaluation before you switch.
  • Notice drift in a hosted model that changes behind the same name.
  • Track the cost and token usage of your evaluations as they grow.

Ingesting AI Metrics in Testkube​

Testkube ingests custom metrics from any Workflow step that writes them in InfluxDB line protocol, a simple text format with one record per line. Each record has a measurement name, optional tags and one or more numeric fields:

measurement[,tag_key=tag_value...] field_key=value[,field_key=value...]

For example, a DeepEval run against gpt-4o can be summarized as:

deepeval,metric=answer_relevancy,model=gpt-4o cost=0.019998,errors=0i,failed=0i,mean_score=1,passed=2i,tests=2i
deepeval,model=gpt-4o errors=0i,failed=0i,passed=2i

To get these metrics into Testkube:

  1. Run the evaluation tool in a Workflow step, so that it writes its results to files in the working directory.
  2. Convert the results to line protocol and write them to a file with an .lp or .influx extension.
  3. Upload that file as an artifact. Testkube detects the line protocol during the upload, registers the file as an influx.line_protocol report and ingests its numeric fields after the execution completes.

Testkube turns each field into a metric key, {measurement}_{field} in lower case, and each tag into an identity field that you can segment and filter by:

Line protocol recordMetric keysIdentity fields
deepeval,metric=answer_relevancy,model=gpt-4o mean_score=1,tests=2ideepeval_mean_score, deepeval_testsmetric=answer_relevancy, model=gpt-4o
ragas_eval,model=gpt-4o-mini answer_relevancy=1,faithfulness=1ragas_eval_answer_relevancy, ragas_eval_faithfulnessmodel=gpt-4o-mini
promptfoo_eval pass_rate=1,total_tokens=125ipromptfoo_eval_pass_rate, promptfoo_eval_total_tokensnone
note

Custom metrics require Testkube Runner and Control Plane version 2.11.0 or later and a Testkube deployment that uses Postgres. See Custom Metrics with Influx Line Protocol for the full line format, the supported field types, and troubleshooting.

Visualizing AI Metrics in Insights​

Once a Workflow has run, its AI metrics appear in Test Insights under the Custom Report Metrics group of granular metrics. To chart them:

  1. Create an Executions Time Series analysis.
  2. Select an AI metric, such as promptfoo_eval_pass_rate or ragas_eval_faithfulness, as the Measure.
  3. Pick an Aggregate. Insights defaults to maximum for rates and to sum for counts; average is usually the most useful aggregate for a quality score when a Workflow runs several times in one time interval.
  4. Set the Segment to an identity field, such as model, to draw one line per model, or filter the analysis to a single Workflow.

Add the analyses you use most to an Insights Board, so that you can follow the quality of your AI application next to its other test results.

tip

Tag each record with the model, prompt version or dataset that the run used, and keep the number of distinct tag values small. Tags such as model=gpt-4o make it easy to compare runs, while unique values, such as a run ID, create a new series for every execution.

The AI Metrics Parser​

Writing line protocol by hand for each evaluation tool is tedious, so Testkube provides the testkube-ai-metrics-parser. It is a small open source Go binary, published as the docker.io/kubeshop/testkube-ai-metrics-parser image, that reads the native output of the supported tools and writes an .lp file with a stable set of measurements, fields, and tags. It has no dependency on Testkube, so you can also run it in other CI or observability pipelines.

Supported Tools and Metrics​

ToolParser argumentDefault inputMeasurementFieldsStructural tags
Promptfoopromptfooresults.jsonpromptfoo_evalsuccesses, failures, errors, pass_rate, total_tokens, duration_msnone
DeepEvaldeepevaltest_run_*.jsondeepevalPer metric: mean_score, tests, passed, failed, errors, cost. Rollup: passed, failed, errorsmetric, on the per-metric records
Inspect AIinspect-ailogs/*.jsoninspect_evalOne field per scorer metric, such as accuracy and stderrnone
Ragasragasresults/ragas_results.jsonragas_evalThe mean of every numeric column of the results, such as faithfulness and answer_relevancynone
LM Evaluation Harnesslm-evalresults/**/*.json, results/*.jsonlm_evalOne field per harness metric, such as exact_match; standard errors are skippedtask, filter

A few details per tool:

  • Promptfoo: the parser reads the results.stats summary of the file that promptfoo eval -o results.json writes, and computes pass_rate from the success and failure counts.
  • DeepEval: set the DEEPEVAL_RESULTS_FOLDER environment variable so that deepeval test run exports its test_run_*.json files. The parser writes one record per DeepEval metric, tagged with the metric name, plus a rollup record without a metric tag for the overall pass/fail count.
  • Inspect AI: run inspect eval with --log-format json, so that it writes JSON logs the parser can read.
  • Ragas: the parser reads a JSON file with the per-sample results of a Ragas evaluation, as the Ragas example writes it, and averages each metric over the samples.
  • LM Evaluation Harness: the parser writes one record per task and filter, so that gsm8k with the strict-match and flexible-extract filters gives two series.

Structural tags are part of the identity of a series and are always added. Any other tag comes from the --tag option.

Usage​

testkube-ai-metrics-parser <framework> [flags]
FlagDescription
-i, --inputInput file or glob; repeatable. Defaults to the tool's default input.
-o, --outputThe .lp file to write. Defaults to metrics.lp.
-m, --measurementOverride the measurement name.
--tag key=valueAdd an identity tag to every record, such as --tag model=gpt-4o; repeatable.
--latestParse only the newest matching file instead of aggregating all of them.
--fail-on-emptyExit with an error if no metrics are found.
--stdoutAlso print the line protocol to the log.

A single evaluation often writes several result files: DeepEval writes one file per test case, the LM Evaluation Harness one per task, and sharded runs one per shard. The parser folds every matching file into one set of metrics for the run. It sums counts such as tests, total_tokens and cost, averages scores over the examples behind them rather than per file, and computes pass_rate again from the summed counts. A file that cannot be parsed is skipped with a warning, so one truncated file does not lose the metrics of the rest.

Adding the Parser to a Workflow​

Run the evaluation on the image of its own tool, then add a step that runs the parser image on its output and a step that uploads the results and the metrics file. Steps share the working directory, so the parser sees the files that the evaluation wrote. The always condition makes sure the metrics are exported and uploaded even when the evaluation fails, which is when you most want to see its scores.

ragas-metrics-steps.yaml
steps:
- name: Run Ragas evaluation
shell: python ragas_eval.py
- name: Export metrics
condition: always
container:
image: docker.io/kubeshop/testkube-ai-metrics-parser:latest
shell: testkube-ai-metrics-parser ragas -i results/ragas_results.json -o results/metrics.lp --tag model={{config.model}} --stdout
- name: Save results
condition: always
artifacts:
paths:
- results/*.json
- results/*.lp

When you run the same evaluation for several models in a parallel step with a matrix, run the parser inside each parallel worker and tag its output with the model, as in --tag model={{matrix.model}}. Each worker has its own file system, so a parser step after the parallel step would not see the results of the workers. The DeepEval example shows this.

tip

The latest tag of the parser image follows the main branch of its repository. To pin a build that does not change, use a main-<commit> tag of the image.

To request support for another tool, or a new metric for a supported one, open an issue in the testkube-ai-metrics-parser repository.

Examples​

Each of these examples runs an evaluation tool in a Workflow and exports its metrics with the parser:

  • Promptfoo - Runs a Promptfoo evaluation and exports its pass rate and token usage.
  • DeepEval - Runs a DeepEval test suite against several models in parallel and tags the metrics with each model.
  • Inspect AI - Runs an Inspect AI evaluation with an accuracy quality gate.
  • Ragas - Evaluates a RAG pipeline with faithfulness and relevancy metrics.
  • LM Evaluation Harness - Runs a slice of the gsm8k benchmark and exports one series per task.