Skip to main content
AgentScope provides the tuner module to enhance your agents’ performance on specific tasks. The tuner module currently supports three different methods to tune your agents: This tutorial will guide you through how to leverage the tuner module, including:
  • Introducing the core components of the tuner module
  • Demonstrating the key code required for the tuning workflow
  • Showing how to configure and run the tuning process

Core Components

The tuner module introduces three core components essential for all three tuning methods:
  • Task Dataset: A collection of tasks for tuning and evaluating the agent.
  • Workflow Function: Encapsulates the agent’s logic to be tuned.
  • Judge Function: Evaluates the agent’s performance on tasks and provides reward signals for tuning.
The following sections demonstrates how to use tuner to tune a simple math agent.

Task Dataset

A collection of tasks that the agent will be tuned and evaluated on during the tuning process. Each task typically includes input data and expected outputs. In math agent tuning, the task dataset may consist of various math problems along with their correct solutions. tuner requires the task dataset follows the Huggingface Datasets format, and can be loaded directly through the datasets.load_dataset API. A simple example of satisfying this requirement is shown below:
Each line in the jsonl files represents a single task sample in JSON format, for example:
Before using the dataset in the tuning process, you can verify its structure and content as follows:

Workflow Function

The workflow function defines how the agent processes each task. It encapsulates the logic of the agent, including how it interprets the input data and generates responses.
In most cases, the workflow function requires no code changes compared to your original agent implementation — you simply wrap the agent logic into a function with a specific signature. Different tuning methods require different input parameters, but the core idea remains the same.
Below is an example of a simple math agent workflow function:
Before tuning, you can run the workflow function locally to ensure it works as expected, here we use model weights tuning as an example:

Judge Function

The judge function evaluates the agent’s performance on each task and provides reward signals that guide the tuning process. Here is an example of a judge function for the math agent:
You can also test the judge function locally to ensure it behaves as expected:
In practice, you may want to implement a more sophisticated judge function that can better evaluate the agent’s performance on complex tasks.
You can leverage AgentScope’s evaluation metrics or OpenJudge to build a more advanced judge function for complex tasks.