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.
StructuredVLMExtractor (Recommended)
TheStructuredVLMExtractor 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. Thevalue_format parameter controls how values are returned:
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:- VLM extracts strings - Ask the model to read values as text (e.g.,
"14:46:38") - Python converts - Reliable code does the math (e.g.,
14 + 46/60 + 38/3600 = 14.777)
value_format parameter controls whether conversion happens.
Low-Level VLMClient
For custom prompts or direct VLM access, useVLMClient:
StructuredVLMExtractor uses VLMClient internally. Use VLMClient directly only when you need full control over the prompt.VLM in an Agent
Related Topics
- Agent System - Building agents with VLM tools
- Complete Examples - Receipt and document processing examples
- LLM Integration - Working with language models
- CLI Reference -
gaia init --profile vlmsetup