Skip to main content
This guide explains how to create custom probes in TrustTest to test your AI models for specific vulnerabilities or behaviors. Whether you want to test for a new type of prompt injection, a domain-specific attack, or a custom evaluation scenario, this guide will walk you through the process.

Understanding Probe Architecture

Core Concepts

In TrustTest, a Probe is a class that generates test cases to evaluate a target model. The probe architecture follows these principles:
  1. Target: The model or endpoint being tested
  2. Test Cases: Individual test scenarios containing questions and expected evaluation contexts
  3. Interactions: Question-response pairs within a test case
  4. Context: Metadata used by evaluators to score responses

Probe Hierarchy


Quick Start: Simple Dataset Probe

The simplest way to create a custom probe is using a YAML dataset:

Step 1: Create a Dataset File

Create a YAML file with your attack prompts:

Step 2: Use the Dataset Probe


Creating a Prompt-Based Probe

For dynamic attack generation, create a probe that uses an LLM to generate attacks:

Step 1: Create the Dataset Builder

The dataset builder defines how attacks are generated:

Step 2: Create the Probe Class

Step 3: Use Your Custom Probe


Creating a Multi-Turn Probe

Multi-turn probes conduct attacks across multiple conversation turns:

Real-World Example: Custom Prompt Injection Probe

Here’s a complete example of a custom prompt injection probe:

Using the Custom Probe


Best Practices

1. Define Clear Evaluation Criteria

Always provide clear true_description and false_description in your context:

2. Use Diverse Examples

Provide multiple examples in your dataset builder to guide LLM generation:

3. Implement Deduplication

Track previous questions to avoid repetition:

4. Handle Errors Gracefully

5. Support Multiple Languages


Testing Your Custom Probe

Unit Testing

Integration Testing


Next Steps

Attack Catalog

Browse all available attack probes

Custom Evaluators

Create custom evaluation logic