Local Multimodal Inference Benchmark: Adding Vision with --mmproj and Comparing Four Models

    This article reports a hands-on local benchmark of multimodal inference using an open-source inference framework. It explains how the --mmproj parameter loads a vision projector and turns a text model into a vision-language model, then compares four models on two practical tasks: OCR table recognition and webpage-screenshot-to-HTML generation. It also covers the internal request flow, VRAM budgeting, launch configuration, client-side image requests, and the trade-offs between local and cloud deployment.

    Local Multimodal Inference Benchmark: Adding Vision with —mmproj and Comparing Four Models

    1. An Overlooked Parameter That Enables Vision

    For the past six months, my main daily tools have been open-source large language models loaded through local inference frameworks. Whether writing business code, reading source code, or organizing technical documents, text generation and reasoning have been smooth enough. The only strange thing was this: the local service clearly supported image input, but I had never actually fed it an image.

    The turning point came during a routine configuration check. While reading through the startup parameter documentation, I noticed a small, easy-to-miss flag:

    1. --mmproj ./vision-projector-f16.gguf

    Its role is to load an additional set of “vision projector” weights. Once this flag is added, a text-only model becomes a vision-language model, or VLM, and can directly “look at” images.

    This matched my recent experience very well. When I needed to describe an interface error, I often had to take a screenshot first and then manually transcribe the text. When I wanted to turn a prototype image into a webpage, I had to handwrite the page step by step based on the image. In essence, I had bought a phone with a camera, but for several months I had only used it to make calls.

    Once the parameter was found, it was hard not to test it. I brought together all four local models that were capable of multimodal inference and tested them on two high-frequency tasks:

    1. OCR, especially “understanding tables.”
    2. “Viewing an image and writing a webpage.”

    2. How Multimodal Inference Works

    2.1 The Three-Part Structure of a Vision-Language Model

    Most mainstream open-source VLMs can be divided into three parts:

    1. Vision encoder: Usually based on the Vision Transformer, or ViT, architecture. It splits an image into small patches and encodes them into visual features. This is similar to how text is tokenized and represented as token embeddings.
    2. Projector: Some implementations use adapters such as cross-attention. Regardless of the exact structure, the projector maps visual features into the embedding space of the language model. This allows image information to participate in later reasoning as “visual tokens.”
    3. Language model backbone: This part handles context understanding, reasoning, and text generation.

    In one sentence: the vision encoder sees, the projector translates, and the language model thinks.

    2.2 The Journey of a Request Inside the Process

    A typical multimodal request usually goes through the following steps:

    1. Raw image
    2. │ Decode, resize, normalize, and other preprocessing
    3. ▼
    4. Image patches
    5. │ Vision encoder forward pass
    6. ▼
    7. Visual feature sequence
    8. │ Projector maps features into the language model embedding space
    9. ▼
    10. Visual tokens ──concatenated with── Text tokens from the prompt
    11. │
    12. ▼
    13. Language model backbone: generate the answer token by token

    This also explains the common “two-stage weight” design in the open-source ecosystem:

    • Main model weights are responsible for language understanding and generation. They are usually released as quantized weight files such as GGUF.
    • Projector weights are packaged separately in a much smaller file. At startup, they are loaded together with the main model through a parameter like --mmproj.

    The benefit is direct: the same text model can be paired with different projectors to support different vision encoders or training recipes, without republishing a large complete model.

    2.3 Key Requirement: The Projector Must Match the Backbone

    The projector is jointly trained with a specific vision encoder and a specific language model. They must be compatible with each other. If mismatched, the result may be a loading error or garbled output.

    When deploying, the main model and projector should always be obtained from the same release source. Their version correspondence should be fixed and documented.

    3. Test Design: Two Scenarios, Four Models, One GPU

    3.1 Candidate Models

    The four tested models represent four typical approaches:

    • Model A: An open-source model of roughly 30B parameters, originally strong in text capabilities. When paired with a projector from the same series, it gains image-text understanding. It is also my main coding model.
    • Model B: An open-source VLM in the ten-billion-parameter range. Its official documentation explicitly mentions support for converting UI screenshots into code.
    • Model C: A small OCR-focused model designed for document parsing. Its goal is to extract text from images and PDFs and output structured Markdown.
    • Model D: A small specialized model for screenshot-to-code scenarios.

    The metrics mentioned below come from local testing and publicly available materials. They do not represent a universal conclusion about any specific product.

    3.2 Test Scenarios

    Test group Task Test material Target output
    Group 1 Pure text recognition, or OCR Screenshot of a comparison table from a public OCR benchmark Restored Markdown table
    Group 2 Webpage screenshot → HTML code Screenshot of a self-designed web application HTML page that preserves structure and visual appearance as much as possible

    3.3 Unified Test Conditions

    To make the comparison fair, all models followed the same rules:

    • Hardware: A single GPU with 24GB VRAM. All models were fully loaded into VRAM.
    • Quantization: The main models used quantization versions of around 4-bit. The projectors retained higher precision.
    • Decoding: The temperature was set to around 0.2 to reduce randomness in the output.
    • Evaluation:
      • For OCR, the focus was on text accuracy and table structure restoration.
      • For webpage generation, the focus was on visual fidelity, code completeness, and whether the code could run.

    4. OCR Test: Specialized Models Lead for Now

    4.1 Public Benchmarks: Two Different Tracks

    Before looking at a single image, it is useful to review the overall pattern from public benchmarks.

    In document parsing and information extraction benchmarks, OCR-specialized models generally perform well. Tasks such as table recognition, formula recognition, and reading order often score above 90. Comprehensive OCR benchmark results for these specialized methods are also usually near the top of their category.

    By contrast, general-purpose VLMs show strong task dependence:

    • Document parsing tasks are often around 85 to 92.
    • On some comprehensive OCR benchmarks, results can drop to the 30s.
    • Formula recognition can be surprisingly strong, with many general models exceeding 90.

    A useful takeaway is this: the visual capabilities of general models are not evenly distributed. Recognizing text may be a different capability from understanding formulas and layout.

    4.2 Real-World Scenarios: The Gap Becomes Clearer in Long-Tail Cases

    When the focus shifts to handwritten text, stamps, multilingual content, and invoices, the gap becomes more pronounced:

    • Document parsing: Specialized models dominate. The image used in this test was itself a comparison table from a public benchmark. It had a regular layout and small font size, which is exactly the kind of case where specialized models feel most comfortable.
    • Multilingual content: Specialized models have a clear advantage. Some general models score poorly, indicating large differences in training coverage for low-resource languages.
    • Formula recognition: General models can perform better.
    • Handwritten text and stamps: Results vary widely. Some general models score above 90 on handwritten text but only around 40 on stamps. Specialized models are more balanced. In real business documents, printed text, handwritten annotations, and stamps often appear together, so being strong in only one area is not enough.

    It should be noted that benchmark scores are based on fixed test sets and standardized workflows. They are only references for average performance.

    4.3 Local Results: Four Typical Problems

    Back to my own image, the four models behaved roughly in line with the benchmark trends.

    Model C produced a table with complete headers and clean alignment. It passed on the first attempt. The other three general-purpose models exposed four common problems:

    1. Row and column misalignment: The table header contained a method name plus multiple task columns plus an average score. Because there were many task columns, the general models often mistook the average score for one of the task columns, causing entire rows to shift.
    2. Number rewriting: The models sometimes rounded numbers, added trailing zeros, or changed “94.6” to “94.60” without being asked.
    3. Header hallucination: Column names that did not exist in the image were sometimes generated anyway.
    4. Slower pace: Both time-to-first-token and output speed were clearly worse than those of the specialized small model.

    4.4 Conclusions from This Round

    • For tables with regular structure: Specialized OCR models are faster and more accurate.
    • For documents with formulas or complex layouts: General VLMs may have an advantage because of broader comprehension.
    • Prompt engineering matters: A good prompt can significantly narrow the gap.
    1. Convert the table in the image strictly according to the image content into a Markdown table:
    2. 1. Output only the table itself and do not add any explanation.
    3. 2. Keep the original headers and row/column order. Leave missing content blank.
    4. 3. Numbers must be exactly the same as in the image. Do not round or add zeros.

    After improving the prompt, some general models produced noticeably better tables. However, alignment errors were still difficult to eliminate completely. For scenarios that require high stability, specialized models are still the safer choice.

    5. Screenshot-to-HTML: Different Strengths

    5.1 Local Comparison

    Converting a webpage screenshot into code tests the combination of layout understanding and code generation.

    Model Restoration speed Layout structure Style details Main issue
    Model A (general large model) Slow Good Good Took longer and occasionally included redundant elements
    Model B (open-source VLM) Relatively fast Medium Medium The result could run, but the style was fairly plain
    Model C (OCR specialized model) — — — Not good at code generation
    Model D (screenshot-to-code small model) Fast Excellent Excellent Component names occasionally repeated

    Model D deserves a closer look. Its HTML output had the following characteristics:

    • Layout regions corresponded clearly to the screenshot.
    • Components such as the navigation bar, cards, and buttons had clear structure.
    • Spacing, rounded corners, shadows, and colors were restored with high fidelity.

    The overall result was even better than Model A, which has stronger general code capabilities but took one or two minutes longer. This is not hard to understand: converting a screenshot into a webpage tests a specialized “see and speak” ability rather than general reasoning alone.

    5.2 Three Key Lessons

    First, image clarity determines the upper limit of restoration. Webpage screenshots contain dense information. Small text can easily disappear after resizing or compression. Keeping the original resolution, or slicing the image into chunks of roughly 512 to 1024 pixels and feeding them into the model, can noticeably improve detail restoration.

    Second, constraints are more important than descriptions. Clearly limiting the output scope can greatly reduce rework:

    1. Analyze this webpage screenshot and generate complete, directly runnable HTML (CSS inline inside style tags):
    2. 1. Use semantic tags to restore the page structure.
    3. 2. Make colors, font sizes, spacing, and rounded corners as close to the screenshot as possible.
    4. 3. Do not introduce content that does not exist in the image.
    5. 4. Do not use ellipses to replace any code.

    Third, component naming needs self-checking. Code generated by specialized models occasionally contains duplicate class names or IDs. Passing the code to a large model for a “code review,” checking tag closure, style conflicts, and accessibility, is often more worthwhile than repeatedly regenerating the page.

    6. Engineering Practice: VRAM Budget and Performance Tuning

    6.1 VRAM Usage: Understand It Before Tuning It

    After enabling multimodal support, VRAM usage can be roughly divided into five parts:

    1. VRAM usage ≈ main model weights after quantization
    2. + vision encoder weights
    3. + projector weights
    4. + KV cache, which grows with context length and concurrency
    5. + runtime overhead

    The key points are as follows:

    • Resolution and number of slices do not have a huge impact: Mainstream implementations usually limit the number of tiles per image. A screenshot often corresponds to only a few hundred visual tokens.
    • The main VRAM consumers are the quantization precision and context length of the main model.
    • Slicing does not significantly increase VRAM usage, but it can increase prefill time.
    • Projectors are very small: Even at 16-bit precision, they are usually only a few hundred MB to around 1GB. Quantizing the projector to save VRAM is usually not worth it. Keeping higher precision is fine.

    On a single 24GB GPU, even a roughly 30B-parameter model with 4-bit quantization can leave sufficient headroom. For larger models, prioritize adjusting the quantization level and context length.

    6.2 A Failed Startup: Only Loading the Projector

    On the first startup, I passed only the projector path and forgot to specify the main model. The service exited immediately and reported that it could not recognize the model architecture.

    As explained in Section 2.2, the reason is simple: the projector is only a “translator.” The content it translates must be thought about by the main model. Both are required.

    The final working launch command is shown below. Parameter names may vary across frameworks.

    1. # Load the text backbone and vision projector together
    2. ./main \
    3. -m ./text-model-q4km.gguf \
    4. --mmproj ./vision-projector-f16.gguf \
    5. --ctx-size 8192 \
    6. -ngl 99 \
    7. --host 0.0.0.0 --port 8080

    6.3 Client Request: How to Send an Image

    Most local inference services expose an HTTP API. Clients can construct requests using a multimodal message format with both text and images. The image is base64-encoded and embedded in the request body. Example code:

    1. import base64
    2. import requests
    3. # Read the image and encode it as a base64 string
    4. with open("screenshot.png", "rb") as f:
    5. img_b64 = base64.b64encode(f.read()).decode()
    6. payload = {
    7. "messages": [{
    8. "role": "user",
    9. "content": [
    10. {"type": "text", "text": "Extract the table in the image and output it in Markdown format"},
    11. {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{img_b64}"}},
    12. ],
    13. }],
    14. "temperature": 0.2,
    15. "max_tokens": 2048,
    16. }
    17. resp = requests.post(
    18. "http://127.0.0.1:8080/v1/chat/completions",
    19. json=payload,
    20. timeout=300,
    21. )
    22. resp.raise_for_status()
    23. print(resp.json()["choices"][0]["message"]["content"])

    6.4 Local or Cloud?

    The advantages of local deployment are clear: data stays inside the internal network, there is no pay-as-you-go billing, and offline use is possible. Local deployment is suitable for small- and medium-scale scenarios such as development assistance and internal knowledge bases.

    However, workloads such as document batch processing and consumer-facing image question answering often face large traffic fluctuations, expensive GPU resources, and difficult peak prediction. These scenarios may be better suited to the cloud:

    • Use elastic GPU resources from cloud platforms such as Baidu AI Cloud to scale with business load and avoid idle capacity.
    • Use container platforms to package inference services consistently and use load balancing to support multiple instances.
    • Use logging, monitoring, and alerting to continuously observe latency, throughput, and error rates, so performance degradation can be detected early.
    • Store original images and parsing results in object storage to create traceable data assets.

    7. From Testing to Production: A Reusable Methodology

    1. Choose models by task, not only by parameter size. Prioritize specialized models for OCR. Consider general VLMs for formulas and complex layouts. For screenshot-to-webpage generation, prioritize code-specialized models.
    2. Make “same-source matching” part of the deployment checklist. Manage the main model and projector as a pair, with a one-to-one version correspondence.
    3. Build a small regression set. Prepare 10 to 20 images covering typical scenarios. Run them every time a model or parameter changes.
    4. Let prompts handle format constraints. Requirements such as output format, number fidelity, and no fabrication should be written into prompt templates and reused.
    5. Adjust quantization first, context length second. If VRAM is insufficient, first lower the quantization level, then reduce context length. Only consider lowering projector precision as a last resort.

    8. Conclusion

    An overlooked projection-layer parameter is enough to teach a local model that can only “read text” how to “see images.” But the tests also show that multimodal capability is not a single unified strength:

    • OCR scenarios: Specialized models currently lead in structure and speed.
    • Webpage generation scenarios: Specialized models perform better in speed and detail restoration.
    • General large models: They win on coverage and open-ended dialogue, and are suitable for tasks requiring additional understanding and analysis.

    What truly determines the result is the match between the task and the model, prompt design, and the budget for VRAM and performance. If you also have a “camera phone that has only been used for calls,” start by loading a projector and giving your local model a pair of eyes.