vlmrun-hub

vlm-runApache-2.0更新放缓

提供各行业专用的 Pydantic schema 集合,让视觉语言模型按统一结构输出 JSON,省去手写解析和字段对齐的麻烦。

A hub for various industry-specific schemas to be used with VLMs.

暂无版本554star25fork同步于 2026-11-07 07:31 UTC

怎么上手

由 README 提炼,执行前请确认
pip install vlmrun-hub
硬件要求按 README 说明

README 未说明,schema 本身不依赖本地 GPU,实际推理算力取决于所选 VLM 提供商或自托管模型

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

预置行业 Pydantic schema 库,让 VLM 从图像视频文档中稳定抽取结构化数据

提供各行业专用的 Pydantic schema 集合,让视觉语言模型按统一结构输出 JSON,省去手写解析和字段对齐的麻烦。

核心能力

  • 提供发票、驾照、银行流水等行业预定义 Pydantic schema
  • 用 Pydantic 校验保证抽取结果类型安全、可直接下游使用
  • 同一 schema 可跨多个 VLM 提供商复用,无需重写提示词
  • 按 catalog.yaml 组织并自动校验 schema 目录完整性
  • 面向视觉 ETL,覆盖图像、视频、文档三类非结构化输入

容易踩的坑

使用 VLM Run SDK 示例需另装 vlmrun 客户端并配置 VLMRUN_API_KEY;Instructor/OpenAI 示例需自备 OpenAI API Key 且模型需支持结构化输出;README 未给出本地模型推理方式,自托管需自行对接 VLM

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Welcome to VLM Run Hub, a comprehensive repository of pre-defined Pydantic schemas for extracting structured data from unstructured visual domains such as images, videos, and documents. Designed for Vision Language Models (VLMs) and optimized for real-world use cases, VLM Run Hub simplifies the integration of visual ETL into your workflows.

    {
      "issuing_state": "MT",
      "license_number": "0812319684104",
      "first_name": "Brenda",
      "middle_name": "Lynn",
      "last_name": "Sample",
      "address": {
        "street": "123 MAIN STREET",
        "city": "HELENA",
        "state": "MT",
        "zip_code": "59601"
      },
      "date_of_birth": "1968-08-04",
      "gender": "F",
      "height": "5'06\"",
      "weight": 150.0,
      "eye_color": "BRO",
      "issue_date": "2015-02-15",
      "expiration_date": "2023-08-04",
      "license_class": "D"
    }
    

    💡 Motivation

    While vision models like OpenAI's GPT-4o and Anthropic's Claude Vision excel in exploratory tasks like "chat with images," they often lack practicality for automation and integration, where strongly-typed, validated outputs are crucial.

    The Structured Outputs API (popularized by GPT-4o, Gemini) addresses this by constraining LLMs to return data in precise, strongly-typed formats such as Pydantic models. This eliminates complex parsing and validation, ensuring outputs conform to expected types and structures. These schemas can be nested and include complex types like lists and dictionaries, enabling seamless integration with existing systems while leveraging the full capabilities of the model.

    🧰 Why use this hub of pre-defined Pydantic schemas?

    • 📚 Easy to use: Pydantic is a well-understood and battle-tested data model for structured data.
    • 🔋 Batteries included: Each schema in this repo has been validated across real-world industry use cases—from healthcare to finance to media—saving you weeks of development effort.
    • 🔍 Automatic Data-validation: Built-in Pydantic validation ensures your extracted data is clean, accurate, and reliable, reducing errors and simplifying downstream workflows.
    • 🔌 Type-safety: With Pydantic's type-safety and compatibility with tools like mypy and pyright, you can build composable, modular systems that are robust and maintainable.
    • 🧰 Model-agnostic: Use the same schema with multiple VLM providers, no need to rewrite prompts for different VLMs.
    • 🚀 Optimized for Visual ETL: Purpose-built for extracting structured data from images, videos, and documents, this repo bridges the gap between unstructured data and actionable insights.

    📖 Schema Catalog

    The VLM Run Hub maintains a comprehensive catalog of all available schemas in the vlmrun/hub/catalog.yaml file. The catalog is automatically validated to ensure consistency and completeness of schema documentation. We refer the developer to the catalog-spec.yaml for the full YAML specification.

    If you have a new schema you want to add to the catalog, please refer to the SCHEMA-GUIDELINES.md for the full guidelines.

    🚀 Getting Started

    Let's say we want to extract invoice metadata from an invoice image. You can readily use our Invoice schema we have defined under vlmrun.hub.schemas.document.invoice and use it with any VLM of your choosing.

    For a comprehensive walkthrough of available schemas and their usage, check out our Schema Showcase Notebook.

    💾 Installation

    pip install vlmrun-hub
    
    With VLM Run Python SDK
    import os
    from PIL import Image
    from vlmrun.client import VLMRun
    from vlmrun.client.types import PredictionResponse
    from vlmrun.common.utils import download_image
    
    VLMRUN_BASE_URL = os.getenv("VLMRUN_BASE_URL", "https://api.vlm.run/v1")
    VLMRUN_API_KEY = os.getenv("VLMRUN_API_KEY", None)
    
    client = VLMRun(base_url=VLMRUN_BASE_URL, api_key=VLMRUN_API_KEY)
    
    IMAGE_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg"
    image: Image.Image = download_image(IMAGE_URL)
    
    response: PredictionResponse = client.image.generate(
        images=[image],
        domain="document.invoice",
    )
    
    With Instructor / OpenAI
    import instructor
    from openai import OpenAI
    
    from vlmrun.hub.schemas.document.invoice import Invoice
    
    IMAGE_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg"
    
    client = instructor.from_openai(
        OpenAI(), mode=instructor.Mode.MD_JSON
    )
    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[
            { "role": "user", "content": [
                {"type": "text", "text": "Extract the invoice in JSON."},
                {"type": "image_url", "image_url": {"url": IMAGE_URL}, "detail": "auto"}
            ]}
        ],
        response_model=Invoice,
        temperature=0,
    )
    
    {
      "invoice_id": "9999999",
      "period_start": null,
      "period_end": null,
      "invoice_issue_date": "2023-11-11",
      "invoice_due_date": null,
      "order_id": null,
      "customer_id": null,
      "issuer": "Anytown, USA",
      "issuer_address": {
        "street": "123 Main Street",
        "city": "Anytown",
        "state": "USA",
        "postal_code": "01234",
        "country": null
      },
      "customer": "Fred Davis",
      "customer_email": "[email protected]",
      "customer_phone": "(800) 123-4567",
      "customer_billing_address": {
        "street": "1335 Martin Luther King Jr Ave",
        "city": "Dunedin",
        "state": "FL",
        "postal_code": "34698",
        "country": null
      },
      "customer_shipping_address": {
        "street": "249 Windward Passage",
        "city": "Clearwater",
        "state": "FL",
        "postal_code": "33767",
        "country": null
      },
      "items": [
        {
          "description": "Service",
          "quantity": 1,
          "currency": null,
          "unit_price": 200.0,
          "total_price": 200.0
        },
        {
          "description": "Parts AAA",
          "quantity": 1,
          "currency": null,
          "unit_price": 100.0,
          "total_price": 100.0
        },
        {
          "description": "Parts BBB",
          "quantity": 2,
          "currency": null,
          "unit_price": 50.0,
          "total_price": 100.0
        }
      ],
      "subtotal": 400.0,
      "tax": null,
      "total": 400.0,
      "currency": null,
      "notes": "",
      "others": null
    }
    
    With OpenAI Structured Outputs API
    import instructor
    from openai import OpenAI
    
    from vlmrun.hub.schemas.document.invoice import Invoice
    
    IMAGE_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg"
    
    client = OpenAI()
    completion = client.beta.chat.completions.parse(
        model="gpt-4o-mini",
        messages=[
            {"role": "user", "content": [
                {"type": "text", "text": "Extract the invoice in JSON."},
                {"type": "image_url", "image_url": {"url": IMAGE_URL}, "detail": "auto"}
            ]},
        ],
        response_format=Invoice,
        temperature=0,
    )
    

    When working with the OpenAI Structured Outputs API, you need to ensure that the response_format is a valid Pydantic model with the supported types.

    Locally with Ollama

    Note: For certain vlmrun.common utilities, you will need to install our main Python SDK via pip install vlmrun.

    from ollama import chat
    
    from vlmrun.common.image import encode_image
    from vlmrun.common.utils import remote_image
    from vlmrun.hub.schemas.document.invoice import Invoice
    
    
    IMAGE_URL = "https://storage.googleapis.com/vlm-data-public-prod/hub/examples/document.invoice/invoice_1.jpg"
    
    img = remote_image(IMAGE_URL)
    chat_response = chat(
        model="llama3.2-vision:11b",
        format=Invoice.model_json_schema(),
        messages=[
            {
                "role": "user",
                "content": "Extract the invoice in JSON.",
                "images": [encode_image(img, format="JPEG").split(",")[1]],
            },
        ],
        options={
            "temperature": 0
        },
    )
    response = Invoice.model_validate_json(
        chat_response.message.content
    )
    

    📖 Qualitative Results

    We periodically run popular VLMs on each of the examples & schemas in the catalog.yaml file and publish the results in the benchmarks directory.

    ProviderModelDateResults
    OpenAIgpt-4o-2024-11-202025-01-09link
    OpenAIgpt-4o-mini-2024-07-182025-01-09link
    Geminigemini-2.0-flash-exp2025-01-10link
    Ollamallama3.2-vision:11b2025-01-10link
    OllamaQwen2.5-VL-7B-Instruct:Q4_K_M_benxh2025-02-20link
    Ollama + InstructorQwen2.5-VL-7B-Instruct:Q4_K_M_benxh2025-02-20link
    Microsoftphi-42025-01-10link

    📂 Directory Structure

    Schemas are organized by industry for easy navigation:

    vlmrun
    └── hub
        ├── schemas
        |   ├── <industry>
        |   |   ├── <use-case-1>.py
        |   |   ├── <use-case-2>.py
        |   |   └── ...
        │   ├── aerospace
        │   │   └── remote_sensing.py
        │   ├── document  # all document schemas are here
        |   |   ├── invoice.py
        |   |   ├── us_drivers_license.py
        |   |   └── ...
        │   ├── healthcare
        │   │   └── medical_insurance_card.py
        │   └── retail
        │   │   └── ecommerce_product_caption.py
        │   └── contrib  # all contributions are welcome here!
        │       └── <schema-name>.py
        └── version.py
    

    ✨ How to Contribute

    We're building this hub for the community, and contributions are always welcome! Follow the CONTRIBUTING and SCHEMA-GUIDELINES.md to get started.

    🔗 Quick Links