Skip to content

Inspect AI - LLM Evaluation Framework Cheatsheet

Inspect AI - LLM Evaluation Framework Cheatsheet

Inspect is an open-source framework for large language model evaluations, created by the UK AI Safety Institute. It gives evals a clear structure — a dataset of samples, a solver pipeline that produces answers, and a scorer that grades them — plus a first-class viewer for inspecting exactly what the model saw and did on every sample. It is designed for rigorous, reproducible evaluation, including agentic tasks and tool use, and is widely used for safety and capability testing.

Installation

MethodCommand
pippip install inspect-ai
uvuv add inspect-ai
Model keyexport OPENAI_API_KEY=... / ANTHROPIC_API_KEY=...
VS CodeInstall the Inspect extension for the viewer
Verifyinspect --version

The Three Building Blocks

ComponentRole
DatasetSamples with input and target
SolverSteps that turn input into model output
ScorerGrades output against the target

A Minimal Eval

from inspect_ai import Task, task
from inspect_ai.dataset import example_dataset
from inspect_ai.scorer import model_graded_fact
from inspect_ai.solver import generate, system_message

@task
def security_qa():
    return Task(
        dataset=example_dataset("theory_of_mind"),
        solver=[
            system_message("You are a concise security expert."),
            generate(),
        ],
        scorer=model_graded_fact(),
    )
inspect eval security_qa.py --model openai/gpt-4o

Running Evals

CommandDescription
inspect eval task.py --model openai/gpt-4oRun an eval
inspect eval task.py --limit 20Only the first 20 samples
inspect eval task.py --model-base-url URLCustom/local endpoint
inspect eval task.py -T param=valuePass task parameters
inspect eval-retry <log>Retry failed samples
inspect viewOpen the log viewer

Solvers

SolverDoes
generate()Call the model
system_message(...)Prepend a system prompt
chain_of_thought()Add CoT prompting
self_critique()Model reviews its own answer
use_tools([...])Enable tool calling
basic_agent()A ReAct-style agent loop

Scorers

ScorerGrades by
match()Exact/substring match
includes()Target appears in output
pattern(regex)Regex extraction
model_graded_qa()LLM judge against a rubric
model_graded_fact()LLM judge for factual equivalence
choice()Multiple-choice answer

Agentic Evals & Tools

from inspect_ai.tool import bash, python
from inspect_ai.solver import basic_agent

solver = basic_agent(tools=[bash(), python()], max_attempts=3)
CapabilityNote
Tool useBuilt-in bash, python, web tools
SandboxingRun tools in Docker for isolation
Multi-turnAgent loops with attempt limits
Custom toolsDecorate Python functions as tools

The Viewer

ShowsWhy it matters
Every sampleInput, target, output, score
Full transcriptEach message, tool call, and result
Scoring rationaleWhy the judge graded as it did
MetricsAccuracy and custom metrics

Being able to read the transcript of failures is what turns a score into an actionable finding.

Inspect vs Other Eval Frameworks

AspectInspectDeepEvalRagas
OriginUK AI Safety InstituteConfident AIExploding Gradients
FocusGeneral + agentic evalsUnit-test style app evalsRAG-specific metrics
ViewerRich, first-classReports/dashboardScores
Best forRigorous capability/safety evalsCI test gatingRAG pipeline scoring

Complements DeepEval for CI-style testing and Ragas for RAG-specific metrics.

Resources