FRAGMENT: Factorized Graph Representations for Document Generation and Editing via Entity-Aware Transformations

arXiv:2608.18679 · cs.CV, cs.CL · Submitted 2026-08-19 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.

Tom: We're looking at the paper: "FRAGMENT: Factorized Graph Representations for Document Generation and Editing via Entity-Aware Transformations".

Jane: Here's the gist of the paper. The gist The framework explores representing documents as typed relational graphs and factorizes their distribution as p(structure,content) = p(structure)· p(content structure).

Tom: FRAGMENT Overview FRAGMENT is a generative framework that represents a document as a typed relational graph and factorizes its distribution as p(structure,content) = p(structure)·p(content structure) The framework consists of two stages: the first stage, the Architect, is a causally masked Transformer conditioned on the document category that autoregressively generates the document graph The second stage, the Builder, is a GATv2-based graph attention network with residual pre-normalized message passing that enriches the generated graph with normalized bounding boxes, textual content, and visual attributes through dedicated prediction heads.

Jane: Both stages define explicit likelihood models.

Tom: This factorized formulation yields a tractable document-level likelihood that serves as an anomaly score for synthetic and manipulated document detection.

Paper summary: Tom: So to wrap up on this paper called "FRAGMENT: Factorized Graph Representations for Document Generation and Editing via Entity-Aware Transformations," it’s basically a framework that represents documents as typed relational graphs.

Jane: That means they’re using this graph structure to factorize the distribution into p(structure) times p(content structure). It separates the structural plan from the content realization.

Lu: And they use two stages: an Architect that builds the graph scaffold, and a Builder that populates it with layout and text attributes.

Meng: So for a real user, what does this mean in plain terms? Is it just a fancy way to draw boxes around words?

Tom: It’s more than drawing boxes. It’s about having an explicit plan—a structural blueprint—that you can analyze independently from the actual text and styling of the page.

Jane: And that separation is what allows them to create a document-level likelihood score that lets you spot anomalies by checking if the structure or the content looks strange on its own.

Lu: The paper contributes a unified graph representation for structured documents and an R-tree-based construction procedure that extracts those typed spatial relations from layout annotations.

Tom: And they introduce prompt-conditioned editing, which lets you guide modifications using instructions injected through cross-attention during the Builder stage.

Jane: So the implication is that we can move toward systems where we have a verifiable structural plan and content that is explicitly linked to it.

Meng: It seems like an exploration into making generative models more controllable for structured data, which is something production systems need right now.

Lu: They also explore how to make the system robust by looking at how component trade-offs affect performance, showing where the complexity actually pays off and where it doesn't.

Conclusion: Tom: So we’ve been digging into FRAGMENT, right? It’s about taking documents—invoices, reports, whatever—and treating them like these typed relational graphs instead of just pixels or raw text sequences.

Jane: Right. The authors are looking at how to separate the structure of the document from the actual content and styling that makes it look like a real page.

Lu: Basically, they use this two-stage setup. The Architect stage builds the structural skeleton—the nodes and their relationships—and then the Builder stage populates those nodes with all the details, like where every word is placed or what color the font is.

Meng: From an engineering standpoint, what’s interesting is how they define that document likelihood score. It’s not just one number; it's a product of two separate likelihood models, which makes it good for catching structural weirdness versus content weirdness separately.

Tom: That decomposition is key. It means if we spot an anomaly, we can trace whether the layout is wrong or if the text itself is nonsensical.

Jane: And they show that this framework works on real benchmarks like DocLayNet and FUNSD, giving these scores that actually correlate with how human eyes perceive a document’s quality.

Lu: The paper shows that by using this factorized approach, you get a tractable likelihood score for forgery detection without needing to retrain the whole model on every single fake document.

Meng: For deployment at scale, I gotta ask—how much overhead is this two-stage generation and evaluation process adding to the time it takes to render a complex report?

Tom: That’s a fair question, Meng. The Architect stage is autoregressive, which means it takes time to build that scaffold. But the Builder part uses GATv2 which should keep the per-node attribute prediction pretty efficient once the structure is set up.

Jane: And for anyone who just listens to this show, what does it change? It changes how we think about AI not just generating text, but generating documents that actually *look* plausible and have a verifiable underlying structure.

Lu: They also show how you can hook in prompt-conditioned editing using cross-attention inside the Builder to make semantic changes guided by an instruction, which is pretty ambitious for this kind of architecture.

Tom: So, the main implication is moving toward documents that are not just readable but structurally sound and traceable.

Jane: Exactly. And that leads us next to how they actually test these ideas against other methods, and where they found the biggest trade-offs in their experiments on DocLayNet and SROIE.

Ayoub El Bouchtili, Guilhaume Leroy-Meline

IBM Consulting · IBM Consulting

cs.CV, cs.CL

Submitted: 2026-08-19

Updated: 2026-08-19

License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/

Importance score: 90/100

The gist: The gist The framework explores representing documents as typed relational graphs and factorizes their distribution as p(structure,content) = p(structure)· p(content structure).

Key concepts

Typed Relational Graph
Documents are modeled as graphs where nodes represent semantic layout elements (like titles or text blocks) and edges represent spatial relations (like 'below' or 'right-of'). This structure captures both what is present and how different parts of the document are positioned relative to each other.
Architect Stage
This first stage uses a Transformer to autoregressively generate the document's underlying structure, including node types and spatial connections. It learns p(structure), focusing purely on the logical arrangement of elements before worrying about their exact appearance.
Builder Stage
The Builder takes the generated structure and predicts all visual details—bounding boxes, text content, font styles, and colors. It uses a Graph Attention Network (GATv2) to enrich each element based on its neighbors in the graph.

Summary

The gist The framework explores representing documents as typed relational graphs and factorizes their distribution as p(structure,content) = p(structure)· p(content structure).

FRAGMENT Overview

FRAGMENT is a generative framework that represents a document as a typed relational graph and factorizes its distribution as p(structure,content) = p(structure)·p(content structure) The framework consists of two stages: the first stage, the Architect, is a causally masked Transformer conditioned on the document category that autoregressively generates the document graph The second stage, the Builder, is a GATv2-based graph attention network with residual pre-normalized message passing that enriches the generated graph with normalized bounding boxes, textual content, and visual attributes through dedicated prediction heads. Both stages define explicit likelihood models. This factorized formulation yields a tractable document-level likelihood that serves as an anomaly score for synthetic and manipulated document detection.

Document Representation and Factorization

Documents are represented as typed attributed graphs G = (V,E, τ,ρ,A) where each node v ∈ V corresponds to a semantic layout element with type τ(v) ∈ T (e.g., title, text, table), each directed edge e ∈ E carries a relation type ρ(e) ∈ [BELOW, RIGHT-OF], and A collects node attributes: a normalized bounding box bv in (x1,y1,x2,y2) form, a token sequence tv (WordPiece, max length 50), and style attributes (sv, fv,cv) for font size (normalized to [0,1]), font family (categorical over a normalized font vocabulary), and RGBA color. The first term in the factorization corresponds to the generation of the document scaffold, including semantic entities and their relations, while the second term models the realization of this scaffold through geometry, text, and visual attributes.

The Architect Stage

The Architect models p(structure) = p(V,E, τ,ρ d) autoregressively A document graph is serialized as a sequence of construction steps; step i emits (i) the type of node vi, (ii) a pointer to the existing node that vi attaches to, and (iii) the type of the resulting edge. The backbone is a Transformer encoder applied with a causal mask Category conditioning is implemented by prefixing, where a learned embedding of the document category d is prepended to the sequence. Three heads read the hidden states: a node-type classifier, an edge-type classifier, and a pointer mechanism that scores attachment targets by a scaled dot product between a query projection of the current state and key projections of all previous states.

The Builder Stage

The Builder models p(A G,d) = ∏v∈V p(bv hv)p(tv hv)× p(sv hv)p(fv hv)p(cv hv), where hv denotes the contextual representation of node v produced by the GATv2 message-passing backbone. The message-passing backbone uses four GATv2 layers with 8 heads, edge-type embeddings as edge features, pre-layer-normalization, and residual connections. Each node state feeds three prediction heads: Layout (an MLP with sigmoid output predicting bˆv), Style (separate sub-heads for font size, font family, and RGBA color), and Text (a 2-layer GRU decoder). The text head is modular, allowing the GRU to be replaced by a Transformer decoder or an instruction-tuned language model.

Editing and Detection Capabilities

The framework supports two auxiliary capabilities: prompt-conditioned editing via cross-attention and the composite log-likelihood used for forgery detection. For editing, the instruction is encoded by a frozen pre-trained BERT encoder into a sequence of embeddings C Inside the Builder, each message-passing block is augmented with a multi-head cross-attention sublayer in which node states query the instruction. An edit mask, derived by thresholding the cross-attention mass each node receives, restricts re-generation to affected nodes. For forgery detection, the composite log-likelihood is defined as log p(G,A d) = log p(G d) + log p(A G,d). This decomposition across nodes and attribute heads enables structural and attribute-level anomaly localization.

Evaluation and Findings

Experiments on DocLayNet, FUNSD, and SROIE evaluate FRAGMENT alongside representative autoregressive, layout-only, and graph-based baselines. The results illustrate that FRAGMENT exhibits competitive Doc-EMD scores on layout metrics, and the decomposable likelihood provides an informative score without requiring explicit tampered training data. Ablation results highlight component trade-offs, such as substituting GATv2 with GCN leading to lower layout and style scores. Future extensions include incorporating higher-capacity text decoders and exploring continuous generative models for attribute generation. The framework serves as a useful exploration into structured, controllable, and verifiable document generation.

How it works

(a) Architect scaffold

The Architect autoregressively generates a typed document graph conditioned on a category prefix This stage models p(structure) = p(V,E, τ,ρ d).

(b) Builder realization

The Builder instantiates this scaffold by predicting geometric, textual, and visual attributes It models p(A G,d) = ∏v∈V p(bv hv)p(tv hv)× p(sv hv)p(fv hv)p(cv hv).

(c) Rendered page

The final output is the rendered document, which incorporates layout attributes, textual content, and visual styling.

Summary of Contributions

  1. We formulate a unified graph representation for structured documents together with an R-tree-based construction procedure that extracts typed spatial relations from layout annotations.

  2. We propose a two-stage generative architecture that separates structural generation from content realization through an autoregressive graph-based Architect and a GATv2-based Builder.

  3. We define a composite document log-likelihood that provides a measure of document plausibility for forgery detection.

  4. We introduce a prompt-conditioned editing mechanism based on cross-attention that supports semantic and entity-aware document modification.

  5. We present the training methodology and an evaluation protocol examining layout fidelity, semantic quality, and forgery detection across benchmark datasets.

Limitations

The two spatial edge types capture Manhattan-style layouts effectively but provide limited representation for nested or deeply hierarchical structures. Additionally, the GRU text decoder presents capacity limitations for long text fields, and OCR errors can propagate during end-to-end editing workflows. Finally, likelihood-based anomaly detection requires per-category calibration to maintain score consistency across different document domains<ref:2608.

Improvements for AI systems

  1. No longer rely solely on pixel or token-level generation by implementing FRAGMENT to represent documents as a typed relational graph and factorizing its distribution as p(structure,content) = p(structure)· p(content structure). This allows for explicit modeling of document structure while preserving the flexibility required for content generation.

  2. Develop an AI system capable of anomaly scoring by calculating the composite document log-likelihood defined by Equation 5: log p(G,A d) = log p(G d) Architect, Eq. 2 + log p(A G,d) Builder, Eq. 4. This provides a measure of document plausibility for forgery detection that is localized to structural and attribute-level anomaly localization.

  3. Implement controlled document editing by utilizing the prompt-conditioned extension which inject[s] instruction embeddings into the Builder through cross-attention, enabling semantic and entity-aware modifications. This allows for operations like updating fields based on instructions such as “add a 15% tip” while preserving untouched content.

  4. Enhance document understanding by leveraging the explicit intermediate representations provided by FRAGMENT, which separates generation into two complementary stages where the Architect first generates a typed relational scaffold describing the semantic entities and their relations. This allows for inspecting and constraining the structural plan before content realization.

Sources

Related papers