Research · Document AI

REPLICA: Visually Faithful Document Reconstruction

Converting a page to text throws information away. REPLICA rebuilds the page as HTML that keeps its words, structure, positions and appearance, checks the result against the original, and turns every rebuilt page into labelled training data.

Document AIDocument reconstructionAgentic systems

Overview

Can a text version of a page keep everything that is on the page? This post is about why the answer is usually no, and how we built a system for which it is yes.

Almost everything we do with documents at scale runs on text, not on pixels. Search indexes text. Retrieval chunks text. Translation rewrites text. Most importantly for our work, generating training data for document models means writing questions and answers about text. So the first step of nearly every document workflow is the same: convert the page to text.

That step is where information disappears. A page holds words, but it also holds a structure (headings, tables, lists), a geometry (where each block sits), and an appearance (size, weight, colour, a strikethrough, a stamp). Common conversions keep the words. Many keep some structure. Almost none keep geometry and appearance. Whatever the conversion drops, every system built on top of it has lost too.

The one-line version of this work: we turn a document into HTML that does not just read like the original. It looks like it. The argument has four steps, and the rest of the post follows them in order.

REPLICA (ICDAR 2026, oral) is our answer. It has three parts, and this post follows them in order:

This post is the second in a series. The hub post tells the whole story in brief: a lossless text form of the page, grounding models that point with masks, and the loop that connects them. Here we go deep on the first idea, and end where it meets the second. A complete reconstruction is labelled by construction, so it can generate grounded training data. A model trained on that data, DocLayout-VL, then replaces REPLICA's own layout detectors.

What a page holds

Start with one concrete page: an invoice. List what it carries, one kind of information at a time.

The REPLICA paper names these four axes Text Extraction, Logical Structure, Physical Structure and Visual Fidelity. They are the spine of everything that follows: the format must carry all four, the system must produce all four, and the benchmark must score all four.

The talk adds two requirements on the format itself. It must be web-native, so it opens anywhere without a special viewer. It must be machine-readable, so a downstream model can read the structure directly. Four axes and two requirements make a six-item checklist. Everything that follows is measured against it.

Now convert the invoice, adding one axis at a time. Figure 1 does this live. The left side is the original. The right side starts as the text a typical OCR system returns and gains one layer per step.

Figure 1 · The same invoice, rebuilt one layer at a time

Swipe the figure sideways to see all of it.

Figure 1 Left: the source invoice. Right: a reconstruction that gains one axis per step. Text only gives a wall of words, and nothing separates the total from the fine print. Adding logical structure recovers headings and the table, but there is still no page. Adding physical position puts every block where it belongs. Only visual fidelity brings back the strikethrough and the stamp, and with them the meaning: the cancelled licence is not owed, and the invoice is overdue.

Read Figure 1 as four fixes, each answering what the previous level left broken. Text only has the right words but no page. You cannot tell the heading from the body, the table is a run of numbers, and the total looks like fine print. Logical structure says which part is the heading and which is the table, with rows and columns. That is a large gain for a machine, but there is still no page shape. Physical position gives the page its dimensions back, and now you can tell which number belongs to which item. Appearance brings back the typography, the weight and the colour. Only at this level does the cancelled line read as cancelled, and only here does the overdue notice exist at all.

The last step is the one most systems skip, and it changes what the document says. With the strikethrough lost, the four line items add up to 6,420.00. The page's own subtotal is 4,020.00, because the licence line was cancelled. A downstream model that reads the flattened text would compute the wrong amount, and nothing in its input would tell it so.

Which uses need which axes

Different downstream uses need different subsets of the four axes. Keyword search needs the words. Retrieval that chunks by section also needs the hierarchy. Retrieval by position ("the figure to the right of the table") needs geometry. Translating a form so it still looks like the same form needs all four. Generating grounded training data needs to know exactly where each element sits, so it needs geometry at least.

A team rarely knows in advance every use its converted documents will serve. So the useful target is a single conversion that keeps all four axes. Then search, retrieval, translation, archiving, accessibility and data generation can all start from the same file. The REPLICA paper lists six such applications: layout-preserving translation, document preservation, indexing and search, grounded document intelligence, semantic chunking for retrieval-augmented generation, and position-aware retrieval.

Two of these uses follow directly from the shape of the format. Chunking for retrieval can follow the logical structure instead of cutting at a fixed character count, because the structure is in the file. Grounded document intelligence gets pixel-level grounding almost for free, because the nested DOM already says which phrase sits inside which line inside which block. That is the same phrase, line and block nesting that M3Grounder predicts as masks.

Why existing formats lose information

Before building a system, it is worth asking where the loss comes from. Is it the models, or something more basic?

Look at what each conversion is asked to write. OCR engines and many document vision-language models write plain text or Markdown. Pipeline tools such as Marker and Docling write Markdown, JSON or HTML. General vision-language models such as GPT-5 and Qwen3-VL, when asked for HTML, write generic HTML. SmolDocling writes DocTags, a markup with location tokens. hOCR, an older HTML-based OCR format, writes word boxes.

Each format has a fixed set of things it can say. Figure 2 shows the same part of the invoice written in five formats. Pick a format, then pick an aspect to see where, if anywhere, that aspect lives in the output.

Figure 2 · The same invoice in five output formats


            

    Figure 2 Outputs written by hand to show what each format can carry; they are illustrative, not the output of a specific system. The panel on the right shows what a reader of that output would see. Click an aspect to highlight where it is written in the code. Plain text and Markdown have no syntax for a coordinate or a colour. DocTags can write boxes but carries little styling. Generic HTML can express position and style, but nothing requires them, so they are usually left out. FID-HTML requires both on every element.

    Picture the four axes of the page as four things that must all pass through one narrow place: the output format. Whatever the format has no slot for is dropped before it reaches the output. Text and hierarchy pass through almost every format. Geometry and style get stuck. The bottleneck is the target, not the model.

    The pattern has three causes, not one.

    The third cause is the subtle one. HTML looks like the right target, and it nearly is. But a format that permits position does not make a system produce it. In practice, systems write the parts the format requires and leave out the parts it merely allows.

    Table 1 reproduces the paper's comparison of representation formats along these lines. Columns are grouped by the four axes.

    Table 1 · Document representation formats (paper Table 1). ✓ full support, P partial, ✗ missing. R.O. reading order; L.H. logical hierarchy.
    FormatContent (text)R.O.L.H.TablesListsFiguresFormulaHierarchy (physical)Boxes (physical)Styling (visual)
    Markdown (md)✓P✓✗✗PPP✗✗
    Markdown (mmd)✓P✓P✗PPP✗✗
    LaTeX✓P✓✓✓✓✓✓P✓
    DocTags✓P✓✓✓✓✓✓✓P
    HTML✓P✓✓✓PPP✗✓
    hOCR✓P✓✓✓PP✓✓✓
    Qwen-HTML✓P✓✓✓PPP✗✓
    Unstructured HTML✓P✓✓✓PP✗✗✓
    FID-HTML✓✓✓✓✓✓✓✓✓✓

    How to read this table: each row is a format, and each column asks whether the format can represent that aspect. Read the last three columns. Every format except FID-HTML is partial or missing on at least one of them. Note that a ✓ here means the format can express the aspect; the HTML rows show that being able to express styling is not the same as producing it.

    What real systems produce

    Figure 3 shows real outputs from the paper's first figure. The input is a magazine letters page with three columns, green headings and italic bylines. Each system's HTML has been rendered in a browser.

    Figure 3 · One page, four systems, rendered

    Input pagesource
    Source page: a three-column magazine letters page with green headings and italic bylines.
    Markerrendered output

    Figure 3 Rendered outputs from the REPLICA paper's Figure 1. Marker turns three columns into one. GPT-5 and Qwen3-VL-30B keep most of the words but drift on placement, font attributes and the number of columns. REPLICA keeps the columns, the green headings, the italic bylines and the font sizes. The chips mark which axes the project page credits each output with.

    Every baseline in the figure passes the text test. Every one of them fails on geometry and appearance. The failure is the same across a pipeline tool, a commercial model and an open model, which points at the target format and the single-pass design rather than at any one model.

    FID-HTML: position and style are required

    So we changed the target. FID-HTML is HTML that a browser renders and a language model can read. It differs from generic HTML in one rule: position and style are required, inline, on every element. Fidelity stops being something the format permits and becomes something it guarantees.

    FID-HTML carries the first two axes the way every other format does. What is new is the other two. Geometry and style are not merely allowed. They are required: an absolute position on every block, and font size, weight and colour inline on every text run. Fidelity becomes a property of the format, not a hope.

    The paper defines six dimensions that FID-HTML encodes. One serves text, two serve logical structure, one serves physical position and two serve appearance:

    1. Textual content, kept at both word and block level, with line breaks and indents.
    2. Hierarchical structure, through nested <div> containers for sections, subsections and logical groups.
    3. Semantic tags, such as <li>, <table>, <tr> and <td>, with meaningful class names.
    4. Positional information: global placement through absolute positioning, and local alignment through relative containers and <p> wrappers.
    5. Styling metadata: font size, colour, bold, italics, underline and strikethrough, as inline CSS.
    6. Figures and backgrounds, layered into the page structure, with alt-text generated by a vision-language model.

    Figure 4 shows real FID-HTML from VFDR-Bench: an excerpt of the ground truth for a dental fact sheet. Select a dimension to see where it lives in the code.

    Figure 4 · Six dimensions in real FID-HTML

    
              
    Figure 4 An excerpt of the FID-HTML ground truth for a "Facts of Life" fact sheet in VFDR-Bench, lightly trimmed (long text runs shortened, some attributes dropped). Each block carries an absolute position and size; each text run carries its size and colour. The class names (title, paragraph, question, picture) carry the semantic role.

    Three design choices in FID-HTML are worth spelling out, because each has a reason.

    Why HTML and not a new format. HTML is web-native: any browser renders it with no special viewer. It is also what language models have read most of, so a model can consume FID-HTML directly. A custom format would need its own renderer and would be unfamiliar to every model. The alt-text on figures, written by a vision-language model, also makes the output readable by a screen reader.

    Why inline styles. Inline styles keep each element self-contained. An element can be cut out of the page with its position and appearance attached, which is exactly what the data engine later needs.

    Why absolute positions. A browser's flow layout decides where text lands from the text itself, the fonts and the container widths. Small differences in any of them move every block below. Absolute positions pin each block to where it was on the source page, so the render cannot drift far. Relative containers inside each block keep local alignment simple.

    FID-HTML serves two roles in the paper. It is the output of REPLICA, and it is the annotation format of the benchmark. The second role matters as much as the first: you cannot score position or style against a Markdown reference.

    Why one model in one pass is not enough

    Given the target, the simplest system is one vision-language model that reads the page image and writes FID-HTML in one pass. That is what the general models in Figure 3 attempt, with generic HTML. Why does it fall short, even with a strong model?

    Count what that single pass must do at once. It must detect every region, read every word, decide the type of each region, recover the tree, order the regions, write each one in the right markup, and attach a position and a style to every element. And it must do all of this in one stream of tokens, with no way to look at what it produced. A misplaced block early in the stream is never revisited.

    Three properties of documents make this harder.

    Prior work splits into lines along these properties. Pipeline parsers such as Marker and MinerU split the job into layout detection, OCR, and table and math parsing, then merge with rules. They produce solid Markdown, JSON or HTML, but typically linearise layouts and leave styling under-specified. End-to-end document models (Nougat, GOT-OCR 2.0, olmOCR, SmolDocling, Dolphin, MonkeyOCR) do the whole job in one model, mostly towards text or Markdown. Screenshot-to-HTML models (Design2Code, WebCode2M, WAFFLE) target web interfaces; some of that line uses iterative rendering and reflection, but the models generalise poorly to dense document pages. Physical reconstruction work such as DREAM models content and layout together to recover element positions, and PDFMathTranslate preserves layout for scientific documents.

    REPLICA takes from each line what it does well. From pipelines it takes the split into stages and the use of deterministic tools. From vision-language models it takes judgment: what a region is, which specialist should handle it, what order a person reads in. From the screenshot-to-code line it takes the idea of checking the render. The organising principle is a division of labour.

    Design principle

    Agents handle judgment. Tools handle deterministic, reproducible steps. Each component gets the part of the job it does best, and the interface between them carries exactly what the next component needs.

    The paper states this formally. Let 𝒜 be the set of agents and 𝒯 the set of tools. Agents perform semantic reasoning, routing, grouping and generation. Tools execute structured operations such as layout detection, position-aware merging and font fitting. Given a page image or PDF I, the goal is HTML H whose rendering R(H) matches I on all four axes. Note where the objective sits: on R(H), the render, not on H, the markup. That choice drives the last stage of the pipeline.

    For background on agents, tools and multi-agent coordination in general, see The Making of an AI Agent and How Multi-Agent Systems Actually Coordinate. REPLICA is a fixed workflow rather than an open-ended agent: the stages and their order are set, and the agents make judgments inside them.

    The REPLICA pipeline

    REPLICA asks four questions in order, one per stage:

    1. Segment. How do we divide the document into meaningful components?
    2. Localize. How do we convert each component into equivalent HTML?
    3. Assemble. How do we put the components back into a coherent structure?
    4. Refine. How do we make the result look like the source?

    Each question exists to protect particular axes, and each answers a failure of the single pass described above. In the talk deck's terms:

    Figure 5 runs the whole pipeline on one page. Tools are drawn as blue squares and agents as orange circles, so you can see at each step which kind of component is doing the work.

    Figure 5 · REPLICA, stage by stage

    Swipe the figure sideways to see all of it.

    Figure 5 A schematic page passes through the four stages. Segment: a document-type tool, a detector ensemble fused by overlap, a labelling agent with colour-coded marks, and a grouping agent that builds the layout tree. Localize: a router agent checks each crop and sends it to one of six specialists, which call tools only when needed. Assemble: a merge tool composes the fragments bottom-up, and a reading-order agent orders them. Refine: tools fit fonts and restore the background, and a reflection agent compares the render with the source.

    Segment: build the layout tree

    The first stage builds a layout tree: every region, its type, its box and its parent. Four components share the work.

    A document-type tool decides how to read the page. It classifies the input as born-digital or scanned. A born-digital PDF already contains its text spans, boxes and font metadata, so a PDF parser reads them directly and the visual detectors are skipped. Only scanned pages need detection.

    A detector ensemble proposes regions. For scanned pages, three detectors run: DocLayout-YOLO for flat layouts, IndicDLP-YOLO for hierarchical structures, and Hi-SAM for fine-grained text segmentation. Their predictions are fused by overlap (IoU-based merging). The three are complementary: one finds blocks, one finds nested groups, and one finds text lines and words.

    Detector proposals are driven by geometry. The paper lists their typical failures: they over-segment, they merge incompatible content, and they miss hierarchy. They also fail on borderless tables and multi-column wraps. So two agents take over.

    A labelling agent judges what each region is. It assigns a structural label (paragraph, table, figure) and auxiliary attributes such as style or subtype. It uses Set-of-Mark prompting: each proposal is drawn on the page as a visible mark, so the vision-language model can refer to regions by their marks while reasoning about both their position and their content. This lets it spot regions that were cut in two and blocks that mix content types.

    A grouping agent builds the tree. It forms a directed graph whose edges are parent-child relations, inferred from containment, reading order and semantic compatibility. Inconsistent or fragmented proposals are merged, reattached or discarded. Enforcing acyclicity and a single parent per node turns the graph into a tree. This step binds captions to their figures, nests lists, and attaches footnotes, none of which geometry alone can decide.

    Localize: one specialist per region

    The second stage turns each node of the tree into a fragment of HTML, called sub-HTML. Each node arrives with four things: its crop of the page, its box, the label from Segment, and structural constraints such as its parent's type.

    A router agent checks before anything is generated. The paper's reason is direct: single-shot generation per region is brittle and prone to hallucination. The router looks at the crop itself, not only at the upstream label. If the crop contradicts the label, for example an equation labelled as text, it overrides the label and sends the region to the right specialist. A wrong label caught here costs one routing decision. Missed here, it becomes wrong HTML that every later stage inherits.

    Six specialists write the HTML. There is one specialist each for text, tables, images, forms, lists and equations. Each writes sub-HTML with position and style inline.

    Tools are called only when needed. The text specialist calls OCR for low-resolution or script-complex crops but skips it for clean digital text. The table specialist queries a table-structure recogniser when it sees merged headers or irregular grids, to get explicit row and column constraints. Text attributes such as bold, italic, underline and strikethrough come from TexTAR, a textual-attribute recogniser. Because nodes are conditionally independent given the tree, all regions can be processed in parallel.

    The paper also mentions a colour-coded variant of Set-of-Mark prompting: boxes are marked with distinct colours instead of numbers or letters, which keeps mark labels from leaking into the generated HTML as text.

    Assemble: merge, then order

    The third stage turns many fragments into one document. It separates two questions that are easy to conflate: where things go, and in what order they are read.

    A position-aware merge tool places the fragments. It composes bottom-up over the layout tree, so children go into their parents, while preserving containment, nesting and spatial alignment.

    A reading-order agent decides the order. Sorting top to bottom and left to right fails on multi-column pages and floating elements. A newspaper page is the extreme case: articles are laid out in a grid, and a person reads one story at a time, not one row at a time. The agent judges textual continuity and contextual coherence across nodes, and the final HTML is linearised in that order. Reading-order accuracy, measured with Kendall's τ against the annotated order, is 0.98.

    The project page and talk run the whole pipeline on a Telugu newspaper, the layout that argues hardest for agents. The grouping agent closes an outline around each article: headline, deck, figure and body columns. The reading-order agent rejects raster order in favour of story-by-story order, because a newspaper has no fixed reading order.

    Refine: make it look right

    Even when the first three stages are structurally correct, the rendered HTML can diverge from the source. The paper names the reason: a browser lays out text with the CSS box model, which differs from how the PDF placed it. Fonts render at different widths, lines wrap at different points, and text can overflow its box. The fourth stage is therefore the only one that looks at the render.

    It has three components. A font-size tool picks the largest font size at which each text block does not overflow its box. A background-restoration tool recovers page-level visual cues (background colours, shading, overlays) and restores them with CSS layering and absolute positioning. In the implementation, the background is reconstructed with OpenCV inpainting guided by region masks. Finally, a reflection agent compares the render with the source and injects targeted CSS fixes, up to five times. The next section is about why this last step matters.

    Who does what

    Every agent in REPLICA runs on one backbone: Qwen3-VL-8B. Labelling and grouping, routing, the six specialists, and reflection all use it. The supporting tools are the three detectors, Gemma-3-4B-it for OCR, docTR for word localisation, TexTAR for text attributes, Surya's table-structure recogniser for tables, and textFit.js for font fitting. Structured output validation and bounded retries keep each fragment well-formed.

    Checking the render, not the markup

    Why should the last stage look at pixels at all? The words are already right by this point. The structure is right. The positions came from the detectors. What is left to check?

    Consider a paragraph whose font is one point too large. Every word is correct. The tag is correct. The box is correct. But the text overflows its box and runs under the next block. Or a heading wraps onto two lines and pushes the paragraph below it out of place. Or a column of text runs underneath a pull quote. None of these errors is visible in the markup. A text similarity score between the output and the reference would not move, because the characters are identical. Only the render shows them.

    Figure 6 runs the refine loop on one block. Watch the two meters: text similarity stays flat while the render changes.

    Figure 6 · The render-and-compare loop

    Swipe the figure sideways to see all of it.

    Figure 6 A schematic run of the Refine stage on one block. Left: the source crop. Middle: the current render of the HTML. Right: the mismatch between them. The font tool searches for the largest size that does not overflow, the background tool restores the shaded panel, and the reflection agent finds the text running under the pull quote and patches the CSS. The bars are illustrative, not measured. Text similarity stays at 100% throughout, because the words never change.

    The font-size tool is a bounded search. For each text block, it tries a size, renders, and checks whether the text overflows its box. If it overflows, the size goes down; if not, it goes up. Because overflow only gets worse as the size grows, a binary search finds the largest size that fits in a few renders. The paper reports that 97% of paragraphs end with no overflow (font fit success, 0.97).

    The reflection agent is different in kind. It looks at the render and the source together, finds perceptual artifacts (overlaps, wrapping differences, misalignment), and injects targeted CSS: a layout adjustment, or a shape-outside rule so text wraps around a shape. It repeats until the render stabilises, for at most five iterations. Its contribution is measured as reflection gain, the average improvement in score per iteration:

    RG = (1/K) ∑k=1K ( S(k) − S(k−1) ) S(k) is the score after iteration k, and K is the number of iterations run. The paper reports RG = +0.06.

    Measuring visual faithfulness

    A reconstruction that keeps position and style needs a benchmark that scores position and style. None existed. Existing benchmarks score text extraction (OCR benchmarks such as CC-OCR) or logical structure through tables (TableBank) and document-to-Markdown conversion (READoc, OmniDocBench, MDEval). None scores where a block lands on the page or what the page looks like.

    VFDR-Bench

    VFDR-Bench (Visually Faithful Document Reconstruction benchmark) has 5,000 documents. They span single- and multi-column layouts, scanned and born-digital sources, and many scripts. They cover more than 15 languages and more than 20 document categories. Every ground-truth page is annotated in FID-HTML by expert human annotators. The talk deck lists the kinds of pages: newspapers and periodicals; government and official records such as birth certificates, tenders and memoranda; textbooks and exam papers, including right-to-left scripts; business and finance documents such as statements and invoices with handwriting and rubber stamps; Indic and archival material on aged paper; and magazines.

    Table 2 · Document benchmarks and the axes they score (from the REPLICA project page). TE text extraction, LS logical structure, PS physical structure, VF visual fidelity.
    BenchmarkImagesLanguagesDomainsFormatTELSPSVF
    OmniAI OCR1,0001n/amd✓✓✗✗
    OmniDocBench98139txt✓✗✗✗
    CC-OCR800106txt✓✗✗✗
    olmOCR-Bench1,4031n/amd✓✓✗✗
    OCRBench v210,000226md✓✓✗✗
    READoc3,576276md✓✓✗✗
    dp-bench20014md✓✓✗✗
    KITAB-Bench91719md✓✓✗✗
    Image2Struct2,10013LaTeX✗✓✗✗
    VFDR-Bench5,00015+20+FID-HTML✓✓✓✓

    How to read this table: the last two columns are the ones the field had not measured. Among the benchmarks compared here, VFDR-Bench is the only one that scores physical structure and visual fidelity, and its annotation format is the only one that can hold them.

    One metric family per axis

    Each axis gets its own metrics. Two axes already had standard ones:

    The other two axes needed new metrics, and the paper introduces three:

    How the position scores work

    GPS and LPS share one recipe, applied to blocks for GPS and to lines for LPS. First, match each ground-truth element to at most one predicted element, using maximum overlap (IoU). Then compute two area-normalised quantities from the overlaps:

    The score is the harmonic mean (F1) of the two. The harmonic mean is low if either is low, so a system cannot score well by predicting one huge box (high recall, low precision) or a few tiny confident ones (high precision, low recall). Figure 7 lets you break a layout and watch the score respond.

    Figure 7 · A position score you can break

    Swipe the figure sideways to see all of it.

    Figure 7 Dashed outlines are ground-truth blocks; filled boxes are a prediction. The readout recomputes precision, recall and their F1 with one-to-one IoU matching and area-normalised overlap, following the paper's description of GPS. This is a simplified re-implementation for illustration; the official metric may differ in details such as the matching threshold. The text-match readout stays at 100% in every case, because moving a block does not change its words.

    "Flatten to one column" is what Figure 3 showed Marker doing. Every word survives, so text metrics barely move, but most of the area no longer overlaps where it should, and the position score collapses.

    Visual fidelity and the overall score

    Appearance is harder to score with a formula. Font, colour, weight and spacing interact, and what matters is how the page looks to a person. So VFS asks a vision-language model to judge the rendered page against the rendered ground truth.

    The overall score averages the four axes, so no system can score well by winning one axis:

    Overall = (TE + LS + PS + VF) / 4 TE = (CRR + WRR) / 2     PS = (GPS + LPS) / 2     VF = VFS LS comes from NTED, where lower is better; the project page plots it as 1 − NTED. To keep pathological OCR failures from dominating multilingual averages, CRR and WRR are clipped at −1 per sample before averaging.

    Do the new metrics agree with people? The paper reports a Pearson correlation above 0.8 between the rankings induced by the metrics and the judgments of seven expert annotators, across 100 documents.

    Evaluating the agents, not only the output

    A system score says whether REPLICA works. It does not say which component failed when it does not. So the paper adds an agent-level protocol that scores intermediate decisions from execution traces. For Segment, Agnostic Text F1 and Agnostic Visual F1 score the geometric quality of text and visual region proposals with the same area-normalised F1 as GPS, ignoring labels (labels are resolved later). Hierarchy Consistency is the fraction of pages whose predicted tree satisfies the structural constraints. For Localize, routing accuracy is the fraction of regions routed correctly, and sub-HTML validity rate is the fraction of fragments that are valid DOM. Tools are scored by call success and by task-specific success rates. This is the same idea as trace-level evaluation for agents in general, discussed in The Agent Evaluation Playbook.

    Results on VFDR-Bench

    The paper compares REPLICA with fifteen baselines in four groups: pipeline tools (Marker, Docling), expert document models (rolmOCR, SmolDocling, olmOCR, Nanonets-OCR-s, GOT-OCR 2.0, ChatDoc-OCRFlux), general vision-language models (Qwen3-VL, Gemma 3, InternVL3, Gemini-2.5-Pro, GPT-5), and screenshot-to-HTML models (WebCode2M, WAFFLE). Figure 8 plots every method on every metric.

    Figure 8 · Sixteen methods, one axis at a time

    Pipeline toolsExpert document modelsGeneral VLMsScreenshot-to-HTMLREPLICA

    Figure 8 Scores from the paper's Table 2 on VFDR-Bench. Bars re-sort when you change the metric. Logical structure is shown as 1 − NTED so that longer bars are better on every tab; the raw NTED is in the label. Text extraction is largely solved across strong systems. Position is where every baseline collapses: no baseline exceeds 0.43 GPS or 0.22 LPS.

    Read Figure 8 one axis at a time.

    Overall, REPLICA scores 0.86, against 0.58 for GPT-5, the best baseline. On the English subset it scores 0.93 and on Chinese 0.89. The claim is not that it wins one column. It is that it has no weak column.

    The numbers are easier to trust after seeing the output. The talk shows the source scan beside REPLICA's FID-HTML, rendered live by the browser: real selectable text and real inline CSS, not an image of the output. Both sides are forced into the same rectangle, so any size difference would be a real layout error. The examples are a Gujarati government notice with a table, a dense receipt with small type and a faint scan, a multi-column magazine spread, and a scientific paper with equations and figures. In each, the column boundaries, typography and spatial layout survive.

    An 8B agentic system against larger single models

    All of REPLICA's agents run on Qwen3-VL-8B. The paper compares this with Qwen3-VL-30B used as a single model. REPLICA reaches 0.86 overall, against 0.47 for the Qwen3-VL row, a gain of 0.39. The paper reports this as a 39% overall gain at 3.75 times fewer parameters and comparable inference time.

    Full results

    Table 3 · Quantitative comparison on VFDR-Bench (paper Table 2). NTED is lower-is-better; all other columns are higher-is-better. OSall all languages, OSen English, OSzh Chinese.
    MethodWRRCRRNTED ↓LPSGPSVFSOSallOSenOSzh
    Pipeline tools
    Marker0.680.820.610.190.340.740.530.600.45
    Docling0.400.490.620.170.260.550.380.450.12
    Expert document models
    rolmOCR0.540.670.950.150.070.560.340.420.35
    SmolDocling0.370.540.890.160.230.540.280.350.02
    olmOCR0.490.640.930.210.090.330.310.380.34
    Nanonets-OCR-s0.250.420.940.180.100.560.260.340.31
    GOT-OCR 2.00.360.390.930.150.250.700.320.490.10
    ChatDoc-OCRFlux0.300.380.880.150.240.440.270.390.34
    General vision-language models
    Qwen3-VL0.660.790.590.220.300.430.470.480.31
    Gemma 30.580.590.850.190.250.380.360.420.37
    InternVL30.060.300.820.190.290.310.220.290.27
    Gemini-2.5-Pro0.670.420.560.140.310.820.470.470.30
    GPT-50.650.790.490.210.430.860.580.620.50
    Screenshot-to-HTML
    WebCode2M0.330.450.820.150.290.390.300.420.13
    WAFFLE (VLM WebSight)0.140.420.840.110.290.190.220.270.11
    REPLICA0.880.930.200.730.860.930.860.930.89

    How to read this table: scan the LPS and GPS columns first. Every baseline sits at or below 0.22 LPS and 0.43 GPS; REPLICA is at 0.73 and 0.86. Then compare OSen with OSzh: most baselines drop sharply beyond English (SmolDocling falls from 0.35 to 0.02), while REPLICA stays at 0.93 and 0.89.

    The language gap is consistent with the paper's robustness finding: existing approaches degrade sharply beyond English and Chinese, while REPLICA keeps high scores across the languages and document types in the benchmark. Tools trained on Indic and multilingual layouts (IndicDLP-YOLO, TexTAR) are part of the reason, which is one more case of giving each step to the component trained for it.

    Agent and tool reliability

    The trace-based evaluation scores each component on its own.

    Table 4 · Agent and tool reliability (paper Table 4).
    ComponentMetricScore
    Segment agentsAgnostic Text F1 (AT-F1)0.98
    Segment agentsAgnostic Visual F1 (AV-F1)0.99
    Segment agentsHierarchy Consistency (HC)0.98
    Router agentRouting Accuracy (RA)0.97
    Localize agentsSub-HTML Validity Rate (SVR)0.96
    Reflection agentReflection Gain (RG)+0.06
    ToolsTool Call Success Rate (TCSR)0.995
    ToolsReading Order Accuracy (ROA, Kendall's τ)0.98
    ToolsFont Fit Success (FFS)0.97
    ToolsBackground Stitch Success (BSS)0.96

    How to read this table: each row isolates one decision. The weakest numbers point at where errors enter: sub-HTML validity (0.96) and background stitching (0.96). Per-component rates also compound: a page with many regions passes through many 0.96 to 0.99 decisions.

    What each stage buys

    The ablation adds REPLICA's components one at a time, starting from a flat layout detector with no agents. Figure 9 steps through the nine configurations and tracks three scores: overall, visual fidelity and global position.

    Figure 9 · Building REPLICA one component at a time

    Swipe the figure sideways to see all of it.

    Figure 9 The paper's Table 3. Each step adds one component to the previous configuration. Bands mark the stage each component belongs to. Strengthening Segment more than doubles global position (0.34 to 0.69). Replacing monolithic generation with the router and specialists gives the largest overall jump (0.76 to 0.86). The three refine steps add steady gains: together, 0.07 overall and 0.07 visual fidelity.

    Three lessons come out of the ablation.

    Geometry is decided in Segment. The first four rows are all Segment improvements, and they carry GPS from 0.34 to 0.69. Hierarchical layout adds 0.14. Hi-SAM's fine text segmentation adds 0.15. Set-of-Mark labelling adds 0.06. Later stages add only 0.14 more GPS in total. A later stage can fix a font or a wrap, but it cannot recover a block that was never detected.

    Specialisation beats a single generator. Moving from monolithic Localize to the router and six specialists lifts the overall score by 0.10, from 0.76 to 0.86. Visual fidelity and GPS rise too, but less; the main gain is in getting content right.

    Refine adds the last step of fidelity. Font fitting, background restoration and reflection each add a little. Together they add 0.07 to the overall score and 0.07 to visual fidelity.

    How the approaches compare

    Table 5 puts the main families of document conversion side by side along the aspects this post introduced: what format they write, whether position and style are required, how the work is split, and whether the system checks its own render. The last two columns give the best score each family reached in the paper's main table.

    Table 5 · Approaches to document conversion, compared along the aspects introduced in this post.
    ApproachExamplesOutput formatPositionStyleHow the work is splitChecks its renderBest GPSBest OSall
    Pipeline parsersMarker, Docling, MinerUMarkdown, JSON, HTMLnot keptunder-specifiedmodules for layout, OCR, tables and math, merged by rulesno0.340.53
    End-to-end document modelsolmOCR, GOT-OCR 2.0, SmolDocling, Nanonets-OCR-splain text, Markdown, DocTagsDocTags only, as tokenslittle or noneone model, one passno0.250.34
    General VLMsGPT-5, Gemini-2.5-Pro, Qwen3-VLgeneric HTMLoptional, usually omittedoptionalone model, one passno0.430.58
    Screenshot-to-HTMLWebCode2M, WAFFLEHTML and CSS for web UIslayout via CSSyesone model; some methods in this line iterate with renderingin some methods0.290.30
    Physical reconstructionDREAM, PDFMathTranslatecontent with layoutyespartialend-to-end model (DREAM); scientific-document pipeline (PDFMathTranslate)not reportednot evaluatednot evaluated
    REPLICAthis workFID-HTMLrequired on every elementrequired, inlineagents for judgment, tools for geometry and fitting, four stagesyes, up to 5 rounds0.860.86

    How to read this table: the pattern to notice is that the two columns REPLICA changes, "Position" and "Checks its render", are the two that line up with the GPS gap. Families that do not require position score at most 0.43 GPS. Rows marked "not evaluated" were not part of the paper's benchmark comparison; the cells for them describe the published methods, not measured scores.

    Limits, costs and open problems

    The paper states three limitations, and the benchmark has limits of its own.

    One page at a time. REPLICA reconstructs single pages. Structures that cross a page break, such as a table that continues on the next page or a figure split across pages, can fragment. The header row of a continued table, for example, lives on the first page only.

    Font families. Bold, italics, underline and colour are recovered reliably. The exact font family is not. Existing font recognisers such as DeepFont mostly cover English and Chinese, and large-scale multilingual font recognition is still an open problem.

    Rendering cost. The Refine stage renders the page in a browser several times. That costs latency compared with a single forward pass of one model. The paper reports comparable inference time to Qwen3-VL-30B, but no absolute latency.

    Metric limits. VFS depends on a judge model. GPS and LPS reward correct boxes but cannot tell whether a correct box holds correct text; that is the job of the text metrics, which is why the overall score averages all four axes. And position metrics need a reference layout, so they work on a benchmark but not on unlabelled pages in production. There, the reflection agent's render comparison is the available signal.

    From reconstruction to training data

    This is where the first idea of the series meets the second. Every page REPLICA rebuilds comes out labelled by construction. Each element has its text, its place in the tree, its box and its style, all explicit, and each can carry an ID. That turns REPLICA into a data engine.

    Consider how grounded question-answer data is usually made. A frontier vision-language model looks at a page image, writes a question and an answer, and writes a box for the evidence. One model does everything at once: read the text, infer the layout, reason, write the question, and type the coordinates. If any step is wrong, nothing shows it.

    The REPLICA route splits the job. REPLICA does perception and writes FID-HTML. A language model reads the FID-HTML, which is the kind of text it reads well, writes a question, and cites the ID of the element that holds the answer. The ID maps straight back to a box in the FID-HTML. A segmenter turns the box into a pixel mask (the talk deck names Hi-SAM for this step). The language model that writes the questions never sees a pixel, which is exactly why it cannot invent a coordinate.

    Figure 10 · From a rebuilt page to grounded training data, and back into REPLICA

    Swipe the figure sideways to see all of it.

    Figure 10 The data engine and the loop. REPLICA writes FID-HTML in which every element has an ID, a box and a style. A language model reads only the HTML and writes a question that cites an element ID. The ID is looked up to a box, and a segmenter turns the box into a mask. At scale this produced about 2M grounded QA pairs for M3Grounder, 1.5M step-wise QA pairs for DoCoG and 80M masks for DocLayout-VL. In the last steps, DocLayout-VL takes the place of the detector ensemble in REPLICA's Segment stage.

    Each part of the data engine does one job:

    The scale reported across the three grounding papers is about 2M grounded QA pairs for M3Grounder, 1.5M step-wise QA pairs plus 20K preference pairs for DoCoG, and 80M masks on 2.5M pages for DocLayout-VL. The details of each model are in the next posts of this series: M3Grounder, DoCoG and DocLayout-VL. For why grounding should be a mask and not a string of coordinates, see the hub post and When Language Must Point.

    Closing the loop with DocLayout-VL

    Return to the ablation. The Segment stage set the ceiling for geometry, and its first component is an ensemble of three off-the-shelf detectors, followed by two agents that repair what the detectors get wrong. Every later stage inherits the ensemble's mistakes.

    Now look at what DocLayout-VL produces: a hierarchical, open-set layout tree for any page, with a mask for every region, and regions that can be asked for in words. That is the job REPLICA's Segment stage does with three detectors and two agents. DocLayout-VL was trained on data that REPLICA generated, about 80M masks on 2.5M pages. It now takes the place of the detector ensemble in REPLICA's Segment stage.

    The two halves of the series now feed each other. In one line: the representation makes the supervision, the supervision makes the models, and the models make the representation better. REPLICA's reconstructions generate the training data. The data trains grounding models. The layout model among them improves the first stage of REPLICA, which produces better reconstructions, which produce better data.

    The talk closes on three claims. First, FID-HTML makes fidelity a property of the format: position and style are required, not optional. Second, VFDR-Bench with GPS, LPS and VFS scores physical structure and rendered appearance, which earlier benchmarks did not. Third, REPLICA uses agents where judgment is needed and tools where determinism is needed, and reaches 0.93 visual fidelity and 0.86 overall. With an 8B backbone it beats Qwen3-VL-30B by 39% overall at 3.75 times fewer parameters. Structured decomposition beat brute-force scale on this task.

    What should you be able to reason about now? Why a text form of a page loses information, and that the loss is mostly decided by the target format. Why a format must require position and style rather than permit them. Why a decomposed system with checks can beat a larger single model, and why the strongest check is on the render. How to score geometry separately from appearance. And how a complete reconstruction turns into grounded training data. The next post picks up that data and asks what kind of model should learn from it.

    Key insights and nuances

    References

    Grouped by topic. Every entry links to its primary source.

    The paper

    Grounding and the loop