---
title: Graph-Aided Paragraph Alignment (GAPA)
url: https://www.emergentmind.com/topics/graph-aided-paragraph-alignment-gapa
type: topic
---

# Graph-Aided Paragraph Alignment (GAPA)

Searching arXiv for the core paper and closely related graph-based paragraph alignment/detection work.
Searching arXiv for related paragraph graph methods and document-level graph context methods to ground cross-references.
Graph-Aided Paragraph Alignment (GAPA) is a paragraph-level alignment algorithm introduced as the core alignment component of the UPRPRC pipeline for constructing a multilingual parallel corpus from United Nations documents. It is designed for arbitrary \(M\!-\!N\) alignment, rather than only \(1\!-\!1\) or fixed blockwise alignment, and it operationalizes alignment as subgraph extraction in a bipartite graph built from word-level Longest Common Subsequence (LCS) evidence after machine translation of the non-English side into English [2509.15789]. In this formulation, paragraphs are the alignment units, graph connectivity encodes candidate correspondences, and filtering by an LCS hit rate suppresses spurious links caused by high-frequency lexical items. The method is explicitly intended for large, structurally variable document collections in which translation may merge or split paragraphs, and it was used to produce a corpus with over 713 million English tokens [2509.15789].

## 1. Definition and problem setting

GAPA addresses the problem of paragraph-level alignment for multilingual document pairs in which the two sides may differ in paragraph count and paragraph boundaries. In the UPRPRC formulation, a document pair is written as \((x,y)\), where \(x = [x_1,x_2,\ldots,x_m]\) is a non-English document and \(y = [y_1,y_2,\ldots,y_n]\) is its English counterpart. The central design requirement is flexibility: the algorithm is not limited to \(1\!-\!1\) matching and is intended to recover arbitrary merges and splits that arise in real translation practice, especially in paragraph- or section-level material [2509.15789].

The motivating contrast is with traditional document alignment procedures that mostly focus on sentence-level \(1\!-\!1\) or block-based alignment such as \(4\!-\!4\). Such schemes are poorly matched to United Nations documents, which often have varying numbers and structures of paragraphs across languages. GAPA therefore treats paragraph alignment as a graph problem rather than as a fixed-window or constant-block segmentation problem. A plausible implication is that the method is aimed less at enforcing a uniform segmentation and more at preserving the translation structure actually present in the source documents.

The output is a mapping list
\[
\mathcal{F}=\left[F_1,\ldots,F_{\min(m,n)}\right],
\]
where each \(F_i\) is either \((x_i,[y_j,\ldots,y_{j+k}])\) or \(([x_i,\ldots,x_{i+k}],y_j)\). This representation encodes the two fundamental nontrivial cases handled by the algorithm: one paragraph aligned to multiple paragraphs, or multiple paragraphs aligned to one paragraph [2509.15789].

## 2. Pipeline and graph construction

The GAPA workflow begins with preprocessing. For each document pair, paragraphs are extracted, tabular structures are flattened, and encoding artifacts are removed. The non-English document is then machine-translated into English using an offline NMT engine, Argos, while preserving paragraph boundaries. This translated sequence \(x'\) is aligned against the original English document \(y\) [2509.15789].

Candidate correspondences are obtained through word-level LCS between \(x'\) and \(y\). Each common word \(z_i\) identified by the LCS is located on both sides, and its first occurrence is used to assign a paragraph index on the translated non-English side and a paragraph index on the English side. These paragraph indices define candidate links. The resulting structure is a bipartite graph \(G(x,y)\) whose nodes are the paragraphs of \(x\) and \(y\), and whose edges \((i,j)\) indicate that LCS found a common word linking paragraph \(x_i\) and paragraph \(y_j\) [2509.15789].

Once the graph is built, alignment is extracted by connected-component analysis. Each connected subgraph is interpreted as a candidate alignment region. According to the reported formulation, a connected subgraph corresponds either to \((x_i,[y_j,\ldots,y_{j+k}])\) or to \(([x_i,\ldots,x_{i+k}],y_j)\). Standard graph traversal procedures such as BFS or DFS are used for this stage.

| Stage | Mechanism | Output |
|---|---|---|
| Preprocessing | Paragraph extraction, table flattening, artifact removal, Argos translation | Translated non-English document \(x'\) |
| Candidate extraction | Word-level LCS between \(x'\) and \(y\); first-word-match rule | Paragraph-to-paragraph links |
| Graph construction | Bipartite graph \(G(x,y)\) | Edge set over paragraph nodes |
| Alignment extraction | Connected components via BFS or DFS | \(M\!-\!N\) paragraph mappings |

The graph is therefore not an auxiliary visualization but the operational representation from which the final alignment is read off. A common misconception is to equate “graph-aided” with graph neural modeling; in GAPA, the graph is a deterministic alignment structure derived from translation and LCS evidence rather than a learned message-passing architecture.

## 3. Mathematical structure and filtering

The principal noise-control device in GAPA is the LCS hit rate. Because high-frequency function words such as “the” or “is” can generate accidental graph links, the method assigns each paragraph a score measuring how much of its content is supported by LCS evidence under the first-word-match rule. The definition given is
\[
h(x_i):=\frac{\sum_{w \in \mathrm{LCS}\cap_{\mathrm{fwmr}\ x_i}} \mathrm{L}(w)}{\sum_{w \in x_i}\mathrm{L}(w)},
\]
where \(\mathrm{L}(w)\) is the number of letters in word \(w\). Paragraphs with hit rate below the threshold \(h_c\) have their edges dropped, which removes weakly supported nodes from the alignment graph [2509.15789].

This filtering mechanism is important because the graph is induced by lexical overlap after translation. Without additional control, frequent or weakly informative words could create connected components that are topologically valid but semantically uninformative. The hit-rate criterion constrains the graph to regions with sufficient accumulated LCS evidence. This suggests that GAPA couples a permissive candidate-generation stage with a conservative graph-cleaning stage.

The LCS computation itself is implemented using the Hunt–Szymanski algorithm. The reported asymptotic complexity is a central part of the method’s design. Prior work is summarized as having time complexity \(O(S^2 \cdot L)\), where \(S\) is the number of sentences per document and \(L\) is the number of tokens per sentence, with space complexity \(O(S^2+L)\). GAPA is reported as
\[
O((R+N)\log N)
\]
in time and
\[
O(R+N)
\]
in space, where \(R\) is the number of matching token pairs and \(N\) is the total number of tokens per document [2509.15789]. The intended significance is scalability for very large files and large corpora.

The pseudocode described for the method is correspondingly simple: translate \(x\) to \(x'\), compute \(LCS(x',y)\), create graph edges from first matched occurrences, compute paragraph hit rates, remove nodes with \(h(node)<h_c\), and extract connected components as merged paragraph correspondences. The simplicity of this control flow underlies the paper’s emphasis on transparency and reproducibility.

## 4. Alignment behavior and operational characteristics

GAPA is explicitly described as handling arbitrary \(M\!-\!N\) alignment rather than only \(1\!-\!1\) or fixed block sizes. Its operational behavior is to recover paragraph groupings that reflect translation structure rather than positional regularity. The illustrative case given is a Chinese–English document pair in which Chinese paragraph 5 matches English paragraphs 8–9; the algorithm outputs the merged correspondence rather than forcing a single-paragraph boundary on either side [2509.15789].

The method is also presented as flexible with respect to document size and pipeline deployment. It is reported to handle files up to approximately 20MB of text, more than quadruple previous approaches, and the surrounding UPRPRC pipeline includes a minimalist single-machine example together with optional distributed computing steps for scalability. The machine translation phase is the step for which distributed support is emphasized [2509.15789].

Several properties are highlighted in connection with this operational profile. GAPA is described as efficient, flexible, deterministic given fixed MT, self-contained, and released as open source. Its code and resulting corpus are accessible under the MIT License. These properties matter because prior UN-derived corpora are characterized as having opaque processes, difficulty of reproduction, and limited scale [2509.15789].

The same section of the literature also makes clear what GAPA is not. It is not primarily a sentence aligner, not a constant-window segmenter, and not a neural cross-encoder that scores all paragraph pairs. Its graph is built from LCS witnesses after translation, and its final alignment emerges from subgraph connectivity plus thresholded lexical support. A plausible implication is that its strongest use case is high-throughput, structurally variable document alignment rather than semantically abstract matching without lexical anchors.

## 5. Use in the United Nations parallel corpus

GAPA serves as the paragraph-alignment core of UPRPRC, a fully reproducible end-to-end pipeline spanning web scraping, preprocessing, and text alignment for United Nations documents. The resulting corpus is reported to contain over 713 million English tokens, more than doubling the scale of prior work. The release is described as the largest publicly available parallel corpus composed entirely of human-translated, non-AI-generated content [2509.15789].

The scale figures associated with the aligned output are substantial: more than 162,000 aligned documents and over 16 million aligned paragraph blocks. The English token count is reported as increasing from approximately 335 million in prior UN corpora to approximately 713 million in the new resource. These quantities are presented as a direct consequence of the pipeline’s reproducibility and the alignment algorithm’s ability to process large, structurally irregular files [2509.15789].

Alignment quality was evaluated across multiple bilingual pairings. At the adopted LCS hit-rate threshold \(h_c = 0.3\), document-level accuracy is reported as greater than 94% for GPT-4 and greater than 99% for ChatGLM3 and Qwen2. Human audits on top of the LLM evaluations showed extremely low disagreement rates. The evaluation is therefore framed not only as scale validation but also as evidence that paragraph merges and splits inferred by the graph reflect genuine translation structure [2509.15789].

These results are significant because paragraph-level alignment is often a bottleneck in corpus construction: overly rigid aligners lose data, while permissive aligners accumulate noise. GAPA’s documented combination of arbitrary \(M\!-\!N\) matching, graph-based extraction, and hit-rate filtering is presented as the mechanism that makes large-scale, high-quality UN corpus construction feasible.

## 6. Relation to adjacent graph-based paragraph research

The term “graph-aided paragraph alignment” sits within a broader family of graph-based formulations for paragraph structure and paragraph interaction, although these formulations target different tasks. In multilingual corpus construction, GAPA denotes the LCS-derived bipartite paragraph alignment algorithm just described [2509.15789]. In document layout analysis, however, graph-based paragraph methods usually address paragraph detection or paragraph grouping rather than bilingual alignment.

A prominent example is the unified graph convolutional approach to line and paragraph detection, which formulates document layout as a two-level clustering problem from word-level text detections. There, graph nodes are geometric boxes, edges encode local spatial proximity through a \(\beta\)-skeleton graph plus 2-hop connections, and global paragraph grouping emerges by transitive closure over local line and paragraph adjacency predictions [2203.09638]. A closely related post-OCR formulation likewise uses \(\beta\)-skeleton graphs and GCNs for line splitting and line clustering, relying only on layout features and reporting model sizes around 100 KB per model [2101.12741]. These systems are graph-aided and paragraph-centric, but their objective is physical paragraph recognition in document images, not bilingual paragraph correspondence.

In multi-paragraph reasoning for open-domain question answering, graph structure is used in yet another sense. The KGNN model constructs an entity graph from multiple paragraphs, connecting identical entities across paragraphs and adding knowledge-graph relation edges; paragraph representations are then updated through graph-derived context, reset gates, and self-attention so that evidence can be aligned across paragraphs for multi-hop QA [1911.02170]. Here “alignment” refers to evidence aggregation and cross-paragraph reasoning rather than corpus alignment.

Document-level machine translation provides a further neighboring formulation. G\(^2\)C-MT represents each paragraph as a node in a weighted directed acyclic graph, with edges combining semantic similarity, sequential adjacency, and keyword overlap, and then uses a depth-biased random walk to sample backward context paths for translation prompting [2606.03078]. This is again graph-guided paragraph interaction, but the objective is context selection for DocMT rather than establishing bilingual paragraph pairs.

Taken together, these lines of work suggest that graph-aided paragraph methods share a common local-to-global intuition: local lexical, spatial, entity, or discourse relations are encoded as graph structure, and paragraph-level behavior is recovered by graph traversal, clustering, or message propagation. Within that broader landscape, GAPA in UPRPRC is specifically the graph-based extraction of paragraph correspondences from translated lexical overlap and connected-component structure.

Source: https://www.emergentmind.com/topics/graph-aided-paragraph-alignment-gapa