Skip to main content
TrustTest provides a flexible framework for evaluating any LLM target. The core of this flexibility lies in the Target base class, which you can inherit from to create your own custom model implementations.

Creating a Custom Target

To create your own model evaluator, you simply need to inherit from the Target class and implement the required abstract methods. The base class provides the foundation for both synchronous and asynchronous operations.

Basic Implementation

Here’s a simple example of how to create a custom model:

Using Your Custom Target

Once you’ve created your custom model, you can use it in any TrustTest scenario:

Conversation Targets

For models that need to handle multi-turn conversations, TrustTest provides the ConversationTarget class. This class extends the base Target class and adds support for conversation history.

Creating a Conversation Target

Here’s an example of how to create a custom Conversation Target:

Using Conversation Targets

Conversation Targets can be used in the same way as regular targets. Pass your DummyConversationTarget to any probe:
The ConversationTarget class provides both synchronous and asynchronous methods for handling conversations:
  • respond_conversation(): Synchronous method for getting responses
  • async_respond_conversation(): Asynchronous method that must be implemented by subclasses
This makes it easy to evaluate models that need to maintain context across multiple turns of conversation, such as chatbots or dialogue systems. The Target base class handles all the necessary infrastructure, allowing you to focus on implementing the core model logic in the async_respond method. This makes it easy to evaluate any LLM model, whether it’s a local model, an API-based service, or any other implementation. Remember that your custom model must implement the async_respond method, which is the core method responsible for generating responses to input messages. The base class will handle the conversion between synchronous and asynchronous calls automatically.