Local VLM Inference in Practice: Putting Four Vision-Language Models to the Test

    This article walks through running multimodal inference locally, starting with the projector file that many setups leave out and turning a text-only server into a vision-capable one. It then describes a hands-on comparison of four vision-language models on a single 24GB consumer GPU across two tasks: document and table recognition, and screenshot-to-code generation. You will find practical prompt templates, a structured JSON output pattern, guidance on balancing VRAM, context length, and throughput, and a data-driven selection workflow built around a small regression set. The goal is not a leaderboard but a repeatable method for choosing and validating a model in your own environment.

    1. The Overlooked Parameter: From Text-Only to Vision-Capable

    Many developers run local inference services for text chat and code completion for a long time, leaving visual capability idle. The reason is often not insufficient hardware, but a missing “projection” step in the startup command that connects the vision encoder to the main model.

    A standard multimodal model usually has three parts: a vision encoder that splits an image into patches and extracts features; a projection layer that maps those visual features into the language model’s embedding space; and the language model itself, which interprets instructions and generates text. Local inference frameworks package this projection layer as a separate weight file, mounted at startup through a parameter such as --mmproj. A schematic command looks like this (structure only, not a specific product interface):

    1. python -m inference_server \
    2. --model llm-base-q4_k_m.gguf \
    3. --mmproj vision-projector-f16.gguf \
    4. --ctx-size 8192 \
    5. --n-gpu-layers 99

    If you load only the main model without mounting the projector file, the service degrades to a text-only model; image inputs are either rejected or treated as garbage. It is like installing a camera on a device and using it only for phone calls. Once that parameter is in place, the same service can handle image understanding, document parsing, and UI reconstruction.

    2. Experiment Design: Two Scenarios, Four Models, One GPU

    The goal is not a ranking but a reusable selection method. The hardware is a single 24GB consumer GPU. Model sizes are kept between 7B and 30B, and quantization between Q4 and Q8, to keep the comparison fair.

    Scenario one is text recognition from images: the input is a comparison image containing tables and multiple lines of text, evaluated on character accuracy, row and column structure recovery, and recognition of numbers and units. Scenario two is generating frontend code from UI screenshots: the input is screenshots of a self-built web app, evaluated on layout fidelity, component completeness, runnability, and the reasonableness of interaction code.

    Keep in mind that results vary widely across frameworks, quantization levels, and image resolutions. Any specific score is valid only within this configuration, so readers should re-test in their own environments.

    3. Scenario One: Document and Table Recognition

    The hard part of table images is not reading characters but recovering structure. Merged cells, thin divider lines, light background colors, and small digits all degrade results noticeably. In testing, a model specifically optimized for document parsing clearly outperformed on layout recovery, while general vision-language models tended to “flatten” tables into a continuous block of text.

    It helps to standardize output as a structured intermediate format and then convert it to the target format for easier post-processing:

    1. {
    2. "type": "table",
    3. "header": ["Model", "Accuracy", "Speed"],
    4. "rows": [["A", "94.6", "12/s"], ["B", "91.1", "9/s"]]
    5. }

    Three practical lessons: first, increase input resolution and preserve the aspect ratio so small text is not compressed; second, state explicitly in the prompt to “output by rows and columns and do not merge cells”; third, run a second-pass check on key fields by feeding recognition results into rules or program validation rather than trusting a single generation.

    4. Scenario Two: Screenshot to Code

    This task tests the ability to map visuals to structure. Better-performing models usually output an overall grid layout first and then fill in details, while weaker ones pile on styles and lose hierarchy. Evaluation should cover four layers: whether the structure is correct, whether the styling is close, whether the code runs directly, and whether the interaction logic is sound.

    A prompt template that works:

    1. You are a frontend engineer. Generate single-file HTML+CSS from the screenshot.
    2. Requirements: 1) use semantic tags; 2) reproduce the layout with Flex/Grid;
    3. 3) use relative units for sizing; 4) output code only, no explanations.

    The iteration strategy is “skeleton first, details second”: the first pass asks only for the layout skeleton; the second pass feeds the screenshot back together with the skeleton and asks the model to fill in colors, spacing, and component states. Compared with one-shot generation, the two-pass approach is more stable in both fidelity and maintainability.

    5. Balancing VRAM, Context, and Throughput

    On a 24GB budget, roughly half goes to the main model weights, ten to twenty percent to the vision encoder and projection layer, and the rest to the KV cache and image tokens. Token growth from higher image resolution is super-linear, so long contexts can easily trigger VRAM overflow.

    Practical measures include: cap the maximum edge of each image and split it into patches; set the context length to actual needs rather than the maximum; process batch jobs serially through a queue to avoid concurrent contention; and cache and reuse visual features for fixed documents. If VRAM is tight, you can keep the vision part in memory and offload the language model layer by layer, but throughput will drop significantly.

    6. Selection Takeaways and Deployment Advice

    For structured tasks such as document parsing, table recovery, receipts, and handwriting, prefer models specifically optimized for documents. For UI reconstruction and visual question answering, choose general vision-language models with better instruction following. For latency-sensitive scenarios, a smaller model paired with high-resolution preprocessing is often the better deal.

    The recommended path is: first get the projector parameter working with a single command, then build a regression set from ten to twenty fixed samples, and turn three metrics—accuracy, structure recovery rate, and per-image latency—into a script that runs every time you change the model or quantization level. This turns selection from a “feeling” into something data-driven.

    To reduce operational overhead, you can also move this capability to the cloud, hosting the inference service on a container platform, with object storage for samples, and logging and monitoring with alerting to track latency and failure rates—forming a hybrid architecture that validates locally and processes in batches in the cloud.