Skip to main content

Overview

The metrics module provides functions for calculating performance tradeoffs between different model characteristics.

Functions

latency_accuracy_tradeoff

Calculates the tradeoff ratio between accuracy and latency.
def latency_accuracy_tradeoff(accuracy: float, latency_ms: float) -> float
accuracy
float
required
The accuracy value (typically between 0 and 1)
latency_ms
float
required
The latency in milliseconds
return
float
The tradeoff ratio calculated as accuracy divided by latency. A higher value indicates better performance (higher accuracy with lower latency).
Implementation Notes:
  • Uses a minimum latency threshold of 1e-6 to prevent division by zero
  • Returns accuracy / max(latency_ms, 1e-6)
Example:
from evaluation.metrics import latency_accuracy_tradeoff

# Model with 95% accuracy and 100ms latency
tradeoff = latency_accuracy_tradeoff(0.95, 100.0)
print(f"Tradeoff ratio: {tradeoff}")

Build docs developers (and LLMs) love