Introduction
The Transformer architecture has fundamentally reshaped natural language processing, primarily through its success as a sequence-to-sequence (seq2seq) engine. However, language is rarely a simple linear sequence; it is defined by complex, hierarchical, and relational structures such as dependency trees, semantic roles, and coreference clusters. While standard Transformers capture some of this structure implicitly within their latent attention layers, they often treat these relationships as a "black box."
This research argues that Transformers are natively graph-to-graph (G2G) processors. By formalizing the relationship between attention weights and graph edges, the authors introduce the Graph-to-Graph Transformer (G2GT). This architecture explicitly inputs, models, and predicts complex linguistic structures, achieving state-of-the-art results in tasks that require deep structural understanding, such as syntactic parsing and coreference resolution.
The Graph-to-Graph Framework
The G2GT framework moves beyond the sequence-based paradigm by treating the input and output as graphs where tokens are nodes and relationships are edges.
1. Explicit Graph Input
In a standard Transformer, attention is calculated based on the similarity between queries and keys. G2GT enhances this by injecting known structural information directly into the attention mechanism. If a relationship exists between node $i$ and node $j$ (e.g., a known dependency edge), this "edge" is represented as a learned embedding that biases the attention score. This allows the model to "see" the graph structure of the input sentence explicitly during the encoding phase.
2. Edge Prediction and Output
To produce a graph as an output, the model applies a classifier over pairs of output vectors. This allows the G2GT to predict both the existence and the specific type of an edge between any two nodes in the sequence. This transformation turns the Transformer into a powerful relational predictor capable of generating structured data directly from its internal representations.
3. Recursive Non-autoregressive G2GT (RNGT)
A significant challenge in structured prediction is the computational cost of autoregressive decoding (predicting edges one by one). The authors propose the Recursive Non-autoregressive G2GT (RNGT) to address this. RNGT predicts the entire graph structure in parallel. It then feeds the predicted graph back into the model for subsequent iterations. This iterative refinement allows the model to correct initial errors and capture global dependencies without the latency penalty associated with step-by-step decoding.
Experimental Evaluation
The G2GT framework was evaluated across a diverse set of structured prediction benchmarks:
- Syntactic Parsing: Tested on the English WSJ Treebank (Stanford dependencies) and 13 languages from the Universal Dependencies (UD) Treebanks.
- Semantic Role Labeling (SRL): Evaluated using the CoNLL 2005 dataset.
- Coreference Resolution: Benchmarked on the CoNLL 2012 corpus (OntoNotes).
Key Insights
The research yields several critical insights into the nature of Transformers and linguistic structure:
- Attention is Functionally Equivalent to Structure: The authors demonstrate that attention weights and graph edges serve the same purpose: representing the strength of interaction or "locality" between components.
- Leveraging Pretrained Knowledge: Initializing G2GT with weights from BERT or SpanBERT led to significant performance gains. This suggests that large-scale pretraining already encodes latent linguistic graphs; G2GT provides the necessary interface to make that knowledge explicit and usable.
- Refinement vs. Search: The success of the RNGT model indicates that complex search algorithms (like Beam Search) are not always necessary for high-quality graph prediction. Iterative smoothing of a "noisy" initial graph through Transformer layers is a highly effective alternative.
Results and Performance
The G2GT framework consistently matched or exceeded the performance of specialized, state-of-the-art (SoTA) models:
- Syntactic Parsing: On the English WSJ Treebank, the BERT-initialized G2GT reached a Labeled Attachment Score (LAS) of 94.26, a significant improvement over standard Transformer baselines.
- Semantic Role Labeling: The syntax-aware variant (SynG2G-Tr) outperformed previous SoTA models in both end-to-end and given-predicate scenarios on CoNLL 2005.
- Coreference Resolution: Utilizing SpanBERT-large, the model achieved an average F1 score of 80.5 on the CoNLL 2012 test set. This established a new benchmark while maintaining lower computational complexity than traditional higher-order inference methods.
Limitations and Future Directions
While G2GT represents a significant step forward, several challenges remain. Currently, the model assumes that output nodes are a subset of input nodes, limiting its use in tasks where the output graph contains entirely new entities (e.g., mapping a sentence to a massive knowledge graph). Additionally, the $O(n^2)$ complexity of the attention matrix poses scaling challenges for very large graphs, such as document-level networks.
Future work may focus on integrating these non-autoregressive refinement techniques with generative models to improve factual and structural consistency in text generation, potentially leading to models that are as robust in their reasoning as they are in their fluency.
Summary updated