Multimodal Evaluation: Images, Audio, and PDF
Run Future AGI's built-in image, audio, and PDF eval metrics from the SDK or the dashboard.
Score image captions, detect AI-generated images, evaluate audio quality and TTS accuracy, and verify OCR output against source PDFs using built-in multimodal eval metrics.
| Time | Difficulty | Package |
|---|---|---|
| 10 min | Intermediate | ai-evaluation |
- Future AGI account → app.futureagi.com
- API keys:
FI_API_KEYandFI_SECRET_KEY(see Get your API keys) - Python 3.11
Install
pip install ai-evaluation
export FI_API_KEY="your-api-key"
export FI_SECRET_KEY="your-secret-key"
Tutorial
Set up the Evaluator
import os
from fi.evals import Evaluator
evaluator = Evaluator(
fi_api_key=os.environ["FI_API_KEY"],
fi_secret_key=os.environ["FI_SECRET_KEY"],
)You should see no output. evaluator is ready to score any of the templates below.
Detect caption hallucination
Check whether a caption accurately describes an image. Pass the image as a URL (or base64) and the caption as text.
result = evaluator.evaluate(
eval_templates="caption_hallucination",
inputs={
"image": "https://raw.githubusercontent.com/future-agi/cookbooks/main/ecom_agent/observe/generated_products/nike_air_max_sneakers.png",
"caption": "A pair of white sneakers with a wavy sole design.",
},
model_name="turing_small",
)
eval_result = result.eval_results[0]
print(f"Passed: {eval_result.output}")
print(f"Reason: {eval_result.reason}")You should see a passing verdict and a reason confirming the caption matches the sneaker image. Now try a caption that describes something else entirely:
result = evaluator.evaluate(
eval_templates="caption_hallucination",
inputs={
"image": "https://raw.githubusercontent.com/future-agi/cookbooks/main/ecom_agent/observe/generated_products/nike_air_max_sneakers.png",
"caption": "A red leather handbag with gold buckles on a wooden table.",
},
model_name="turing_small",
)
eval_result = result.eval_results[0]
print(f"Passed: {eval_result.output}")
print(f"Reason: {eval_result.reason}")This time the verdict flips to failing. The reason explains what the caption claims that the image doesn’t show.
Detect AI-generated images
Score whether an image was generated by AI or is a real photograph.
result = evaluator.evaluate(
eval_templates="synthetic_image_evaluator",
inputs={
"image": "https://raw.githubusercontent.com/future-agi/cookbooks/main/ecom_agent/observe/generated_products/nike_air_max_sneakers.png",
},
model_name="turing_small",
)
eval_result = result.eval_results[0]
print(f"Score: {eval_result.output}")
print(f"Reason: {eval_result.reason}")You should see a numeric score plus a reason describing the visual cues the model used.
Evaluate audio quality
Get a Mean Opinion Score (MOS) assessment of audio quality. Pass the audio file as a URL or base64.
Warning
audio_quality and ocr_evaluation require model_name="turing_large". Calling either with a smaller model returns an unsupported-model error.
result = evaluator.evaluate(
eval_templates="audio_quality",
inputs={
"input_audio": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.flac",
},
model_name="turing_large",
)
eval_result = result.eval_results[0]
print(f"Score: {eval_result.output}")
print(f"Reason: {eval_result.reason}")You should see a MOS-style score and a reason noting artifacts like noise or clipping, if any.
Evaluate text-to-speech accuracy
Check whether a TTS audio output accurately reflects the original text, including pronunciation, emphasis, and tone.
result = evaluator.evaluate(
eval_templates="TTS_accuracy",
inputs={
"text": "Welcome to Future AGI. Our platform helps you evaluate and optimize AI applications.",
"generated_audio": "https://storage.googleapis.com/cloud-samples-data/speech/brooklyn_bridge.flac",
},
model_name="turing_large",
)
eval_result = result.eval_results[0]
print(f"Score: {eval_result.output}")
print(f"Reason: {eval_result.reason}")You should see a score and a reason comparing the spoken audio against the source text.
Evaluate OCR output against a PDF
Score how accurately OCR-extracted content matches the source PDF document. Substitute input_pdf with a publicly reachable URL to your own PDF, and json_content with the fields you expect the OCR pass to have extracted from it.
result = evaluator.evaluate(
eval_templates="ocr_evaluation",
inputs={
"input_pdf": "https://your-public-url.example.com/your-document.pdf",
"json_content": '{"invoice_number": "INV-2024-001", "total": "$1,250.00", "date": "2024-03-15"}',
},
model_name="turing_large",
)
eval_result = result.eval_results[0]
print(f"Score: {eval_result.output}")
print(f"Reason: {eval_result.reason}")You should see a score and a reason listing which fields matched or diverged from the PDF, based on the document and fields you supplied.
Run multimodal evals from the dashboard
You can also run these evals directly from the Future AGI platform without writing any code.
- Go to Datasets and create or open a dataset
- Add columns for your multimodal inputs, for example an
imagecolumn with image URLs, or anaudiocolumn with audio URLs - Click Add Evaluation and select a multimodal eval, for example
caption_hallucinationoraudio_quality - Map the eval’s required keys to your dataset columns, for example
imageto your image column andcaptionto your caption column - Choose a Turing model and click Run
- View scores alongside each row in the dataset
This is the same approach shown in the Dataset SDK cookbook, but with multimodal columns instead of text-only.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Evaluator() raises a missing-credentials error | FI_API_KEY or FI_SECRET_KEY isn’t exported before the script runs | Export both keys, or pass fi_api_key/fi_secret_key directly to Evaluator() |
audio_quality or ocr_evaluation returns an unsupported-model error | Called with model_name="turing_small" instead of turing_large | Use model_name="turing_large" for these evals |
caption_hallucination or synthetic_image_evaluator comes back empty or errors | The image URL isn’t publicly reachable, for example a private bucket or an expired signed URL | Use a publicly accessible URL, or pass the image as base64 |
ocr_evaluation scores low even on a correct extraction | json_content isn’t valid JSON, for example a trailing comma or an unescaped quote | Validate the string with json.loads() before passing it in |
TTS_accuracy or audio_quality times out on a long clip | The input audio runs several minutes and the evaluation model processes it in full | Trim the clip to the relevant segment before scoring |
result.eval_results[0] is None | That row failed to evaluate, usually a bad input URL or an unsupported file type | Check the entry for None before reading .output or .reason, and re-check the input for that row |
Next up
Ready to score plain text next? See Running Your First Eval for text evals and LLM-as-Judge.
Questions & Discussion