Evaluating OCR Capabilities of Multimodal Models: Methods and Best Practices

    This article presents a systematic methodology for evaluating the text recognition (OCR) capabilities of multimodal models. It covers scenario breakdown, test set construction, prompt control, metric computation (including Character Error Rate), error classification, and result verification, applicable to any multimodal model that accepts image inputs.

    1. Why a Systematic Evaluation of Text Recognition Matters

    Image-text understanding is a foundational capability of multimodal models. Text recognition may look intuitive, but it actually depends on visual encoding, layout understanding, and language priors working together. Anecdotal results from a single image are unreliable: the same image with a different prompt, or even a repeated call, can yield different conclusions. Evaluation therefore needs to break “can it read text?” down into repeatable, quantifiable metrics.

    This article provides a general methodology covering scenario breakdown, test set construction, prompt control, metric computation, error classification, and result verification. It applies to any multimodal model that accepts image inputs.

    2. Scenario Breakdown

    The difficulty of text recognition concentrates in several typical scenarios. Dividing them by difficulty and failure mode gives the following table:

    Scenario Typical Challenges Key Metrics
    Vertical text, calligraphy, ancient inscriptions Reading order (right-to-left, top-to-bottom), variant characters, traditional vs. simplified forms, visually similar glyphs Character accuracy, reading-order accuracy
    Occlusion and low resolution Missing strokes that require context-based completion Visible-character accuracy, completion error rate
    Complex poster layouts Text regions, wide font-size ranges, graphics overlapping text Region classification accuracy, miss rate
    Multilingual mixed text Mixed Chinese-English, abbreviations, proper noun capitalization Language-switching accuracy, proper noun accuracy
    Small and corner text Insufficient resolution, easily overlooked Recall rate

    Each scenario should be tested separately so that results from different difficulty sources do not mask one another.

    2.1 Vertical and Classical Text

    The core problem with vertical text is reading order. A model may recognize every character correctly yet scramble the sequence of columns. Evaluation should therefore track two dimensions separately: whether the characters are correct, and whether the order is correct.

    Traditional and variant characters require separate annotation. Legitimate variant forms should not be counted as errors, and confusions between visually similar characters should not be counted as correct just because they “look close enough.”

    2.2 Occlusion and Low Resolution

    Occluded scenes most easily produce results that “look right.” The model may not have actually seen the occluded character; instead, it may have completed it based on context or common word collocations. Such completion is valuable in everyday use, but it must be recorded separately during evaluation because it reflects language priors rather than visual recognition ability. Annotations should distinguish between “visible characters” and “inferred characters.”

    2.3 Complex Layouts

    Poster images contain decorative text, stylized fonts, and zoned layouts. The evaluation focus here is structure: does the model assign text to the correct region, and does it miss small text in corners? It is recommended to build region-level annotations for each image—for example, “top headline,” “left body text,” “small text in the bottom-right corner”—and then compare region by region.

    3. Test Set Construction

    3.1 Sample Sources and Compliance

    Test images should come from licensed sources or be created in-house. Images containing personal information, commercial trademarks, or copyrighted content must be anonymized or replaced before use. Screenshots from public discussions should not be distributed directly as a test set.

    3.2 Annotation Guidelines

    Every image needs a ground-truth answer. It is recommended that two annotators transcribe independently, with a third person arbitrating disagreements. Each annotation should retain at least the following information:

    • The original character sequence
    • The reading order
    • Whether each character is visible
    • Whether variant characters, traditional/simplified differences, or typos present in the original image exist

    Typos in the original image must be preserved rather than silently corrected. Otherwise, annotation errors will be counted as model errors, distorting the evaluation results.

    3.3 Stratified Sampling

    Each scenario should contain at least several dozen images, covering different resolutions, camera angles, and fonts. When the sample size is too small, variance in a single run can mask real differences.

    4. Prompt Design and Call Control

    Prompts significantly affect output. During evaluation, a fixed baseline prompt should be used—the same text for all models or versions—so that prompt differences are not mistaken for capability differences. The baseline prompt can be simple, such as “recognize the text in the image.” The effect of structured requirements (e.g., “output in reading order, preserving line breaks”) can then be tested separately.

    Below is a framework example for unified invocation. run_model is a placeholder function that needs to be replaced with an actual API wrapper:

    1. import json
    2. from pathlib import Path
    3. BASELINE_PROMPT = "识别图片中的文字,按阅读顺序输出,不要添加解释。"
    4. def run_model(image_path: str, prompt: str) -> str:
    5. """Placeholder: call the multimodal model and return the text result."""
    6. raise NotImplementedError
    7. def evaluate_dataset(dataset_dir: str, output_file: str, repeat: int = 3) -> None:
    8. results = []
    9. for image in sorted(Path(dataset_dir).glob("*.png")):
    10. for run_id in range(repeat):
    11. prediction = run_model(str(image), BASELINE_PROMPT)
    12. results.append({
    13. "image": image.name,
    14. "run": run_id,
    15. "prediction": prediction,
    16. })
    17. with open(output_file, "w", encoding="utf-8") as f:
    18. json.dump(results, f, ensure_ascii=False, indent=2)

    Results from repeated calls on the same image form the basis of stability metrics. If outputs vary widely across runs of the same image, that itself is a problem worth recording. When making calls, keep controllable parameters (such as sampling temperature) fixed wherever possible, and save the parameters alongside the results.

    5. Evaluation Metrics

    5.1 Character Error Rate

    Character Error Rate (CER) is the most commonly used metric in text recognition, defined as the ratio of edit distance to the length of the reference text:

    CER = (S + D + I) / N

    where S is the number of substitutions, D is the number of deletions, I is the number of insertions, and N is the number of characters in the reference text. Lower CER is better; 0 means an exact match.

    1. def edit_distance(a: str, b: str) -> int:
    2. prev = list(range(len(b) + 1))
    3. for i, ca in enumerate(a, start=1):
    4. curr = [i]
    5. for j, cb in enumerate(b, start=1):
    6. cost = 0 if ca == cb else 1
    7. curr.append(min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + cost))
    8. prev = curr
    9. return prev[-1]
    10. def cer(reference: str, hypothesis: str) -> float:
    11. if not reference:
    12. raise ValueError("Reference text must not be empty")
    13. return edit_distance(reference, hypothesis) / len(reference)

    Before computing, define normalization rules for punctuation, whitespace, and line breaks, and apply the same rules to all samples. Otherwise, formatting differences will be incorrectly counted as recognition errors.

    5.2 Other Metrics

    • Reading-order accuracy: for vertical and multi-column text, the proportion of lines or paragraphs in the correct order.
    • Region classification accuracy: for poster-type samples, whether text is assigned to the correct region.