Skip to main content
Source Code: src/gaia/vlm/
Import: from gaia.vlm import StructuredVLMExtractor (structured extraction) or from gaia.llm import VLMClient (raw VLM)

Detailed Spec: spec/vlm-client Setup: gaia init --profile vlm installs Lemonade Server and downloads the Gemma-4-E4B-it-GGUF vision model (~3 GB). Purpose: Extract structured data (tables, charts, key-value pairs, timelines) from images and documents using vision-language models.
The StructuredVLMExtractor is the high-level API for extracting structured data from images and documents. It handles prompt engineering, JSON parsing, and format conversion automatically.

Extract Key-Value Pairs

Pull specific fields from an image (invoices, forms, receipts):

Extract Tables

Pull tabular data as a list of row dictionaries:

Extract Chart Data

Pull values from bar charts, pie charts, timelines, or any visual data representation. The value_format parameter controls how values are returned:
Supported formats:

Extract with Custom Schema

Define a typed schema for complex documents:

Process Full Documents

Extract from multi-page PDFs with a single call:

How Two-Step Extraction Works

A key design principle: VLMs read text accurately but do math poorly. When extracting numeric data from charts, the extractor uses a two-step approach:
  1. VLM extracts strings - Ask the model to read values as text (e.g., "14:46:38")
  2. Python converts - Reliable code does the math (e.g., 14 + 46/60 + 38/3600 = 14.777)
This achieves 100% accuracy on numeric conversions, compared to ~40% when asking the VLM to convert directly. The value_format parameter controls whether conversion happens.

Low-Level VLMClient

For custom prompts or direct VLM access, use VLMClient:
StructuredVLMExtractor uses VLMClient internally. Use VLMClient directly only when you need full control over the prompt.

VLM in an Agent