evaluate() function is the single entrypoint for all evaluations in the ai-evaluation SDK. It automatically routes to the right engine based on what you pass.
Installation
Quick Start
How Engine Routing Works
You don’t need to think about engines —evaluate() figures it out:
You can also force an engine with
engine="local", engine="turing", or engine="llm".
Function Signature
EvalResult
Every evaluation returns anEvalResult:
BatchResult
When you pass a list of eval names, you get aBatchResult:
Local Metrics (No API Key)
These run instantly on your machine. No network calls, no API keys.String Checks
Similarity Metrics
Scores are continuous 0.0–1.0:Hallucination Detection
Uses NLI model when available (pip install ai-evaluation[nli]), falls back to heuristics:
RAG Metrics
For evaluating Retrieval-Augmented Generation pipelines:Guardrails (Security)
Block attacks in <10ms:Complete Metrics Reference
Every metric below works throughevaluate(). Scores are 0.0—1.0 unless noted otherwise. Binary metrics return exactly 0 or 1.
String Checks (16 metrics)
String Checks (16 metrics)
Deterministic, regex-based checks. All scores are binary (0 or 1). No API key or model required.
Examples:
JSON Metrics (5 metrics)
JSON Metrics (5 metrics)
Validate JSON structure, schema compliance, and syntax. All scores are binary.
Examples:
Similarity Metrics (7 metrics)
Similarity Metrics (7 metrics)
Continuous scores from 0.0 to 1.0 measuring textual or semantic similarity. No API key required.Examples:
embedding_similarity and semantic_list_contains use sentence-transformers. Install with pip install ai-evaluation[nli].Hallucination Detection (5 metrics)
Hallucination Detection (5 metrics)
Detect fabricated, unsupported, or contradictory claims. Uses a DeBERTa NLI model when available, falls back to heuristics. All support Examples:
augment=True for LLM refinement.For best accuracy, install the NLI model:
pip install ai-evaluation[nli]. Without it, a keyword-based heuristic is used with a warning.Function Calling (4 metrics)
Function Calling (4 metrics)
Evaluate LLM function/tool calling accuracy. Output and expected_output should be JSON strings representing function calls.
Examples:
Agent Trajectory (7 metrics)
Agent Trajectory (7 metrics)
Evaluate autonomous agent behavior across multi-step trajectories. Output should be a trajectory JSON (list of steps), and expected_output should describe the goal/task.
Examples:
RAG Retrieval (8 metrics)
RAG Retrieval (8 metrics)
Evaluate the retrieval step of RAG pipelines. Measures how well retrieved context matches the query and ground truth.
Examples:
RAG Generation (6 metrics)
RAG Generation (6 metrics)
Evaluate the generation step of RAG pipelines. Measures how well the LLM answer uses and stays faithful to the retrieved context.
Examples:
RAG Advanced (3 metrics)
RAG Advanced (3 metrics)
Advanced RAG capabilities: multi-hop reasoning, source attribution, and citation checking.
Examples:
RAG Composite (2 metrics)
RAG Composite (2 metrics)
Aggregate scores that combine multiple RAG sub-metrics into a single number.
Examples:
Structured Output (9 metrics)
Structured Output (9 metrics)
Evaluate JSON, YAML, and other structured outputs for correctness, completeness, and schema compliance.
Examples:
Guardrails (4+ metrics via evaluate)
Guardrails (4+ metrics via evaluate)
Fast security scanners accessible through For advanced guardrails (scanner pipelines, model-based screening, ensembles), use the scanner API directly. See the Guardrails Guide for full details.
evaluate(). All run locally in <10ms. For the full scanner pipeline API, see the Guardrails Guide.Examples:
Cloud Evaluations (Turing Models)
Use Future AGI’s purpose-built evaluation models for production-grade accuracy.Requires
FI_API_KEY and FI_SECRET_KEY. Get them from Admin Settings.turing_flash, turing_small.
LLM-as-Judge (Custom Criteria)
Write your own evaluation criteria and use any LLM as the judge. Works with Gemini, GPT-4, Claude, Llama, or any model supported by LiteLLM.Supported Models
Any LiteLLM model string works:GOOGLE_API_KEY, OPENAI_API_KEY, etc.).
Using Placeholders
Your prompt can reference any input field with{field_name}:
Multimodal Evaluation (Images & Audio)
Pass image or audio URLs directly to the LLM judge. The model sees the actual media, not just the URL text.Requires a vision/audio-capable model like
gemini/gemini-2.5-flash or gpt-4o.Image Evaluation
Comparing Two Images
Audio Evaluation
Supported Media Keys
Auto-Generate Grading Criteria
Don’t want to write a detailed rubric? Describe what you want to evaluate in plain English, and the LLM generates the criteria for you.LLM Augmentation
Run a fast local heuristic first, then have an LLM refine the judgment. Best of both worlds: speed of local metrics + accuracy of LLM judges.How It Works
- Local metric runs first (faithfulness heuristic) → produces initial score + reasoning
- LLM receives the original inputs + the heuristic’s analysis
- LLM produces a refined score with better nuance
Which Metrics Support Augmentation?
Metrics withsupports_llm_judge = True:
faithfulnesshallucination_scoretask_completionaction_safetyreasoning_qualityclaim_supportfactual_consistency
Feedback Loop
Submit corrections when the judge gets it wrong. Future evaluations use your corrections as few-shot examples, improving accuracy over time.Feedback Stores
Two stores are available:Correcting Results
ChromaFeedbackStore requires the feedback extra: pip install ai-evaluation[feedback]. InMemoryFeedbackStore works with the base install.