Reconstructing Handwritten Notes and Geometric Diagrams with Multimodal Models

    Handwritten note digitization is a common need in education, research, and office work, yet there is still a gap between "recognizing text" and "reconstructing an entire page." This article breaks the problem into three verifiable sub-tasks—text and formula recognition, layout element preservation, and geometric diagram reconstruction—and presents a five-stage pipeline from image to compilable document. It covers the design of a tool-agnostic intermediate representation for geometry, a layered evaluation methodology, token cost control strategies, and engineering practices including human review and regression testing, concluding with limitations around handwriting quality, 3D inference uncertainty, and privacy.

    1. Background and Problem Definition

    Digitizing handwritten notes is a common requirement in education, research, and office scenarios. Notes typically contain a mix of handwritten text, mathematical formulas, highlighter marks, tables, and geometric diagrams. The traditional approach—manual transcription—is time-consuming and error-prone. In the past two years, large models with visual understanding capabilities have begun to take on this type of task, but there remains a clear gap between “being able to recognize text” and “being able to reconstruct an entire page.”

    This article decomposes the requirement into three verifiable sub-problems:

    1. Whether text and formulas are recognized accurately and in the correct reading order.
    2. Whether layout elements (highlights, columns, indentation, annotations) are preserved.
    3. Whether geometric diagrams can be reconstructed as structured descriptions and further converted into renderable drawing code.

    The difficulty increases across these three items. The third problem best reflects a model’s visual understanding level, because it requires spatial reasoning, not just character transcription.

    2. Task Decomposition: From Image to Compilable Document

    The full pipeline can be divided into five stages:

    • Layout analysis: Segment text blocks, formula blocks, highlighted regions, and graphic regions, and record the reading order.
    • Content recognition: Recognize text and formulas separately, preserving original symbols and line breaks.
    • Graphic understanding: Extract points, lines, surfaces, annotations, and occlusion relationships into a structured description.
    • Code generation: Convert the structured description into typesetting code and vector drawing instructions.
    • Compilation and comparison: Generate the document and compare it region by region against the original image, logging discrepancies.

    The advantage of this decomposition is that each stage has an independent output, making errors easy to localize. For example, if the final figure is offset, you can check whether the graphic understanding stage missed a point or whether the drawing stage made a coordinate conversion error.

    2.1 Handwritten Text and Formulas

    Key concerns in handwriting recognition include character ambiguity, ligatures, and strike-throughs. Formula recognition must preserve subscripts, superscripts, fraction hierarchies, and the mathematical meaning of symbols. In practice, it is advisable to require the model to output the original symbols without “beautification.” For example, handwritten Greek letters should be kept as their corresponding symbols, and crossed-out content should be annotated separately rather than silently deleted.

    2.2 Highlights and Layout Elements

    Highlight and color information is easily overlooked. The prompt should explicitly require the model to record the color, coverage, and owning paragraph of each highlighted region. On output, highlights can be mapped to background-color markers in the document. If the target format cannot precisely express a particular highlight, the result should be marked as an “approximate reconstruction” rather than silently substituted.

    2.3 Geometric Diagrams

    Reconstructing geometric figures requires the model to understand the following:

    • Vertices and axes: Point positions, labels, and the direction and scale of coordinate axes.
    • Segment types: Solid lines, dashed lines, rays, and auxiliary lines. The solid-versus-dashed distinction directly affects meaning.
    • Layering and occlusion: Front-to-back relationships determine which segments should be occluded and which regions should be filled.
    • Perspective: Three-dimensional structures in a 2D image must be inferred from parallel lines, vanishing points, and proportional relationships.

    Perspective and occlusion are the most error-prone parts. A model may draw an occluded segment as a complete line, or reverse the direction of a ray. Such errors may not be visually obvious, but they change the geometric meaning and must therefore be counted separately in evaluation.

    3. Intermediate Representation Design

    Having the model output drawing code directly makes errors hard to trace. A more robust approach is to first produce an intermediate structure that is independent of any specific drawing tool, and then convert it programmatically into target code. Here is an example:

    1. {
    2. "points": [
    3. {"id": "A", "x": 0.0, "y": 0.0, "label": "A"},
    4. {"id": "B", "x": 4.0, "y": 0.0, "label": "B"},
    5. {"id": "C", "x": 2.0, "y": 3.0, "label": "C"}
    6. ],
    7. "segments": [
    8. {"from": "A", "to": "B", "style": "solid"},
    9. {"from": "B", "to": "C", "style": "solid"},
    10. {"from": "A", "to": "C", "style": "dashed"}
    11. ],
    12. "regions": [
    13. {"vertices": ["A", "B", "C"], "fill": "light_gray", "z_order": 1}
    14. ],
    15. "draw_order": ["region_1", "segment_1", "segment_2", "segment_3"]
    16. }

    This design has three advantages:

    1. Validatable: A program can check for duplicate points, verify that segment endpoints exist, and confirm the draw order covers all elements.
    2. Reusable: The same structure can be converted into different drawing instruction sets, keeping migration costs low.
    3. Easy to correct manually: When a segment is wrong, you only need to edit the corresponding entry instead of regenerating the entire code block.

    The core logic of the conversion program can be expressed as the following pseudocode:

    1. function convert(structure):
    2. validate(structure) # Check endpoints, IDs, and draw order
    3. emit_header() # Emit document and canvas settings
    4. for item in structure.draw_order:
    5. if item is region:
    6. emit_fill(item.vertices, item.fill)
    7. if item is segment:
    8. emit_line(item.from, item.to, item.style)
    9. emit_labels(structure.points)
    10. return document

    Validation should happen as early as possible. If the structured data is invalid, return an error directly rather than generating a document that looks normal but has incorrect semantics.

    4. Evaluation Methodology

    Judging reconstruction quality by eye alone is unreliable. A layered evaluation framework is recommended.

    4.1 Text-Level Metrics

    • Character-level accuracy: Compare recognition results against human annotations character by character.
    • Formula equivalence: Parse formulas into structures and compare them, rather than comparing raw strings.
    • Reading order: Check whether the sequence of paragraphs and formulas is correct.

    4.2 Layout-Level Metrics

    • Highlight coverage: Measure the proportion of highlighted regions correctly reproduced.
    • Layout consistency: Check columns, indentation, and heading hierarchy.

    4.3 Graphic-Level Metrics

    • Element recall: How many of the points, lines, and surfaces in the original image are reconstructed.
    • Relationship correctness: Whether occlusion, layering, and line styles (solid vs. dashed) are correct.
    • Geometric error: The relative deviation between reconstructed coordinates and annotated coordinates.

    Evaluation should record error types, not just overall scores. Common error types include missing elements, spurious elements, wrong directions, and incorrect occlusion. The distribution of error types can guide prompt optimization and the design of post-processing rules.

    5. Cost and Token Consumption Control

    The cost of multimodal tasks comes mainly from three sources: the encoding tokens for input images, the structured content the model outputs, and retries after failures. Higher image resolution means greater input consumption; more complex figures mean longer outputs.

    Common cost-control practices include:

    • Region-based cropping: Split a full page into text regions and graphic regions and process them separately, avoiding repeated encoding of irrelevant areas.
    • Constrained output format: Require the model to output only structured data, with no explanatory prose.
    • Caching intermediate results: Layout analysis results can be reused; after modifying a figure, there is no need to re-recognize all the text.
    • Retry limits: When validation fails, retry only the failed region, and log the reason for each retry.

    Cost evaluation should be broken down by task type rather than averaged. Pages of pure text and pages with complex figures usually differ significantly in cost.

    6. Engineering Recommendations

    6.1 Minimize Model Switching

    Many systems deploy text models and vision models separately: the image is first converted into a textual description by a vision model, then handed to a text model for processing. This approach introduces context shuttling and information loss. If a single multimodal model can directly perform layout analysis, recognition, and structured output, the pipeline becomes much simpler. That said, before making a selection, you should still compare the accuracy and cost of both approaches on the same sample set.

    6.2 Human Review

    For accuracy-sensitive scenarios such as teaching materials and research notes, a human review step is recommended. Review should focus on formulas and geometric figures, because errors in these two categories have the greatest impact and are the hardest for ordinary readers to notice.

    6.3 Versioning and Regression Testing

    After a model version update, run regression tests on a fixed test set. The test set should cover different handwriting styles, different highlight colors, and geometric figures of varying complexity. Compare metric changes after each update to avoid regressions in one capability while another improves.

    7. Limitations and Considerations

    • Handwriting quality varies widely: Sloppy or incomplete handwriting significantly reduces recognition accuracy, so image quality detection should be built into the pipeline.
    • 3D inference is uncertain: Depth relationships in perspective drawings may have multiple plausible interpretations, so model outputs should carry confidence scores or provide an entry point for human confirmation.
    • Reconstruction is not the original: A reconstructed document is a rebuild of the original content; when academic or copyrighted material is involved, usage authorization must be confirmed.
    • Privacy protection: Handwritten notes may contain personal information. Data should be de-identified before processing, and retention periods should be limited.

    8. Conclusion

    Handwritten note reconstruction is an excellent scenario for testing multimodal capabilities, as it simultaneously exercises character recognition, layout understanding, and spatial reasoning. For production deployment, it is advisable to decompose the task into verifiable stages, constrain outputs with an intermediate structure, evaluate quality with layered metrics, and control costs through batching and caching. As long as the evaluation methodology is rigorous enough, teams can objectively judge a model’s real-world capability in their specific scenario and choose the technical approach accordingly.