# Inspect AI

> Write and run LLM evaluations with built-in prompting, tools, and model-graded scoring

- Category: Evaluation & Production Ops / Evaluation & Red-Teaming
- Language: Python
- Licence: MIT
- Repository: https://github.com/UKGovernmentBEIS/inspect_ai
- Website: https://inspect.aisi.org.uk
- Canonical page: https://ai-tldr.dev/tools/inspect-ai/

## In short

Inspect AI is Write and run LLM evaluations with built-in prompting, tools, and model-graded scoring. It sits in the Evaluation & Red-Teaming category of the Evaluation & Production Ops tools and is open-source, written in Python and licensed MIT. To get started: install Inspect.

## Overview

Inspect is a Python framework for evaluating large language models, built by the UK AI Security Institute (AISI). You define an evaluation as a task that pairs a dataset with a solver (how the model is prompted or run) and a scorer (how its answers are judged), then run it against any supported model from the command line or Python.

It is aimed at researchers and engineers who need repeatable, structured evals rather than one-off prompt tests. The framework ships built-in components for prompt engineering, tool use, multi-turn dialog, and model-graded scoring, and can be extended by other Python packages to add new elicitation or scoring techniques.

As an eval framework, Inspect gives you a common harness for measuring model behavior across providers. It also includes a collection of over 200 pre-built evaluations you can run on any model, so you can start from existing benchmarks instead of writing everything from scratch.

## What it does

- Tasks composed of a dataset, a solver, and a scorer, defined in plain Python with the @task decorator
- Built-in support for prompt engineering, tool usage, and multi-turn dialog
- Model-graded scoring (for example model_graded_fact) for judging open-ended answers
- Over 200 pre-built evaluations ready to run on any supported model
- Run evals from the CLI with inspect eval against models from different providers
- Extensible through other Python packages for new scoring and elicitation techniques

## Getting started

Install the package, define a task that pairs a dataset, solver, and scorer, then run it from the command line against your chosen model.

1. Install Inspect

   Install the package from PyPI into your Python environment (Python 3.10 or newer).

```bash
pip install inspect-ai
```

2. Define an evaluation task

   Create a task that combines a dataset, a solver that generates model responses, and a scorer that grades them. Save this as security_guide.py.

```python
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

@task
def security_guide():
    return Task(
        dataset=example_dataset("security_guide"),
        solver=generate(),
        scorer=model_graded_fact()
    )
```

3. Run the eval

   Run the task from the command line against a model, passing the provider-prefixed model name. Set the relevant provider API key in your environment first.

```bash
inspect eval security_guide.py --model openai/gpt-4o
```

## When to use it

- Measuring how a model performs on a benchmark by running one of the 200+ pre-built evaluations
- Building a custom eval for your own task with a dataset, solver, and model-graded scorer
- Comparing models across providers on the same task using a single harness
- Testing tool use and multi-turn agent behavior in a structured, repeatable way
