Skip to main content
Plexe provides a flexible callback system that allows you to monitor and interact with the model building process. This reference documents all built-in callbacks and provides information on creating custom callbacks.

Base Callback Class

All callbacks inherit from the Callback base class:

BuildStateInfo

The BuildStateInfo dataclass provides context about the current state of the build process and is passed to all callback methods:

Built-in Callbacks

ChainOfThoughtModelCallback

This callback logs detailed steps of the agent’s reasoning during the build process:
This callback is automatically added when chain_of_thought=True is set in model.build(). Example:

MLFlowCallback

Integrates with MLflow for experiment tracking:
Example:

Creating Custom Callbacks

You can create custom callbacks by subclassing Callback and implementing the desired methods:

Using Multiple Callbacks

You can use multiple callbacks simultaneously:

Callback Execution Order

When multiple callbacks are provided:
  1. All callbacks’ on_build_start methods are called in the order they appear in the list
  2. For each iteration: a. All callbacks’ on_iteration_start methods are called in order b. The iteration runs c. All callbacks’ on_iteration_end methods are called in order
  3. All callbacks’ on_build_end methods are called in order

Emitters for Chain of Thought

The ChainOfThoughtModelCallback uses a ChainOfThoughtEmitter to output the chain of thought logs. Built-in emitters include:

ConsoleEmitter

Outputs logs to the console (stdout).

LoggingEmitter

Sends logs to the Python logging system.

MultiEmitter

Combines multiple emitters into one.

Creating Custom Emitters

You can create custom emitters by subclassing ChainOfThoughtEmitter:

Best Practices

  • Choose callbacks based on your needs: Use MLflow for experiment tracking, TensorBoard for visualization, or custom callbacks for specialized logging
  • Limit callback overhead: Complex callbacks can slow down the build process
  • Combine callbacks strategically: Multiple callbacks can provide different views of the same process
  • Handle exceptions gracefully: Callbacks should catch their own exceptions to avoid disrupting the build process