Example Custom Metrics
Custom metrics are a powerful tool to assess various aspects of your LLM application. From analyzing cost and usage to monitoring application performance, custom metrics offer flexibility to tailor evaluations to your specific needs. Use this page as a guide on how to create custom metrics, though this is not an exhaustive list.Percent of Correct
This example demonstrates how to calculate the percentage of predictions with an incorrectQA_Correctness_Eval. We achieve this using a FILTER (WHERE ...) clause, applying the filter only to the numerator and not the denominator:
FILTER (WHERE) clauses here.
Performance Metrics
Use natively supported performance metrics as functions that can take multiple arguments for enhanced flexibility. Additionally, you can create entirely new metrics using conditionals and other logic, as shown below. Explore the documentation for performance metrics here.Precision
You can calculate the precision of your evaluations using annotations as the ground truth:PRECISION and related functions here. You can also use any of our built-in functions to assess the performance of your evaluations. Feel free to utilize a dimension you have traced for your actual values.
Total Costs
Calculate the total cost by summing up completion and prompt token counts:Average Cost per User Query
Below is an example with the per-input token cost set to0.0000025. Adjust it according to your per-token cost: