Skip to main content

What is Node-Level Evaluation?

As your AI application grows in complexity, it becomes increasingly difficult to understand how it is performing on different flows and components. This granular insight becomes necessary to identify bottlenecks or low quality areas in your application’s or agent’s flow. By targeting the underperforming areas, you can optimize overall performance more effectively than using brute force approaches. This is where Node-Level evaluation can help out. It enables you to evaluate a trace or its component (a span, generation or retrieval) in isolation. This can be done via the Maxim SDK’s logger using a very simple API. Let us see how we can start evaluating our nodes.
Before you startYou need to have your logging set up to capture interactions between your LLM and users before you can evaluate them. To do so, you would need to integrate Maxim SDK into your application.

Understanding How the Maxim SDK Logger Evaluates

Two actions are mainly required to evaluate a node:
  1. Attach Evaluators: This action defines what evaluators to run on the particular node, this needs to be called to start an evaluation on any component.
  2. Attach Variables: Once evaluators are attached on a component, each evaluator waits for all the variables it needs to evaluate to be attached to it. Only after all the variables an evaluator needs are attached, does it start processing.
Once you have attached evaluators and variables to them, we will process the evaluator and display the results in the Evaluation tab under the respective node.
  • The evaluator will not run until all of the variables it needs are attached to it.
  • If we don’t receive all the variables needed for an evaluator for over 5 minutes, we will start displaying a Missing variables message (although we will still process the evaluator even if variables are received after 5 minutes).
  • The variables that an evaluator needs can be found in the evaluator’s page. The evaluator test panel on the right has all the variables that the evalutor needs listed (all of them are required).
Screenshot of evaluator test panel
As per the image above, we can see that the evaluator needs input, context and expectedOutput variables.

Evaluation Framework Architecture

The Maxim SDK provides a robust evaluation framework built on several key components:

Core Evaluation Classes

BaseEvaluator: The foundation class for all evaluators in maxim-py
EvaluateContainer: Manages evaluators for specific entities (traces, spans, generations, retrievals)
PassFailCriteria: Defines success/failure thresholds for evaluations

Evaluation Types

The SDK supports multiple evaluator types:
  • AI Evaluators: Use AI models to evaluate content (e.g., “clarity”, “toxicity”)
  • Programmatic Evaluators: Custom logic-based evaluations
  • Statistical Evaluators: Mathematical/statistical analysis
  • API Evaluators: External API-based evaluations
  • Human Evaluators: Manual human assessment
  • Local Evaluators: Client-side custom evaluators

Attaching Evaluators via Maxim SDK

We use the with_evaluators method to attach evaluators to any component within a trace or the trace itself. It is as easy as just listing the names of the evaluators you want to attach, which are available on the platform.
If you list an evaluator that doesn’t exist in your workspace but is available in the store, we will auto install it for you in the workspace.If the evaluator is not available in the store as well, we will ignore it.

Advanced Evaluator Configuration

You can also attach custom local evaluators with specific pass/fail criteria:

Providing Variables to Evaluators

Once evaluators are attached to a component, variables can be passed to them via the with_variables method. This method accepts a key-value pair of variable names to their values. You also need to specify which evaluators you want these variables to be attached to, which can be done by passing the list of evaluator names as the second argument.
You can directly chain the with_variables method after attaching evaluators to any component. Allowing you to skip mentioning the evaluator names again.

Viewing Evaluation Results on Evaluations Tab

This is very similar to Making sense of evaluations on logs, except that the evaluations for each component appear on their own card as it did for the trace. Screenshot of node level evaluation result

Comprehensive Code Examples

Basic Generation Evaluation

This example shows how to evaluate a simple text generation with multiple evaluators:

Advanced RAG System Evaluation

This example demonstrates evaluation in a Retrieval-Augmented Generation (RAG) system:

Multi-Agent System Evaluation

This example shows evaluation in a multi-agent system with different evaluation strategies:

Custom Local Evaluator Implementation

This example shows how to create and use custom local evaluators:

Best Practices

1. Strategic Evaluator Selection

  • Use evaluators selectively to monitor key performance metrics. Don’t overdo with attaching too many evaluators.
  • Choose evaluators based on your use case:
    • For customer service: helpfulness, clarity, toxicity
    • For content generation: coherence, relevance, creativity
    • For technical documentation: accuracy, completeness, clarity

2. Variable Management

  • Attach variables reliably to ensure no evaluation is left pending due to lack of variables.
  • Use meaningful variable names that clearly indicate their purpose.
  • Provide context when available - many evaluators perform better with additional context.

3. Performance Optimization

  • Setup sampling and filtering according to your needs to ensure accurate evaluation processing without eating up too much cost.
  • Use local evaluators for simple, fast evaluations that don’t require external API calls.
  • Batch evaluations when possible to reduce overhead.

4. Custom Evaluator Development

  • Inherit from BaseEvaluator for consistent behavior.
  • Define clear pass/fail criteria that align with your business objectives.
  • Include detailed reasoning in your evaluation results for better debugging.
  • Test your custom evaluators thoroughly before deploying to production.

5. Error Handling and Monitoring

  • Monitor evaluation results regularly to identify patterns and issues.
  • Set up alerts for evaluations that consistently fail or score poorly.
  • Review evaluation reasoning to understand why certain outputs are scored low.

6. Integration Patterns

  • Use decorators for simple, repetitive evaluation patterns.
  • Use programmatic evaluation for complex, conditional evaluation logic.
  • Combine multiple evaluation strategies for comprehensive assessment.

Troubleshooting Common Issues

Missing Variables

If you see “Missing variables” messages:
  1. Check that all required variables are provided
  2. Verify variable names match exactly what the evaluator expects
  3. Ensure variables are attached to the correct evaluators

Evaluation Not Running

If evaluations aren’t processing:
  1. Verify evaluators are properly attached with with_evaluators()
  2. Check that all required variables are provided
  3. Ensure the component (generation, retrieval, etc.) is properly ended

Custom Evaluator Issues

If custom evaluators aren’t working:
  1. Verify the evaluator inherits from BaseEvaluator
  2. Check that pass_fail_criteria are properly defined
  3. Ensure the evaluate() method returns the correct format
  4. Test the evaluator in isolation before integration

Advanced Use Cases

A/B Testing with Evaluations