GiLT: Augmenting Transformer Language Models with Dependency Graphs

Tianyu Huang, Yida Zhao, Chuyan Zhou, Kewei Tu

TL;DR

The authors introduce GiLT (Graph-Infused Layers Transformer), a novel approach that injects structural linguistic information—specifically syntactic and semantic dependency graphs—directly into Transformer language models. By modulating attention weights using an incrementally constructed "feature tape" rather than inserting extra structural tokens into the text, GiLT achieves superior syntactic generalization and enables seamless finetuning of pretrained models while maintaining competitive language modeling perplexity.

What Problem Does This Paper Address?

While standard Transformer language models (LMs) excel at capturing statistical patterns in text, they lack explicit awareness of underlying linguistic structures like syntactic or semantic parses. Previous attempts to build "syntactic LMs" have primarily relied on constituency tree structures. However, these methods suffer from two major drawbacks:

  1. Token Insertion: Most existing architectures require inserting extra structural tokens (e.g., parsing actions like shift/reduce) directly into the input and output sequences. This increases sequence length, raises computational costs, and alters the model's symbol space, making it incredibly difficult to finetune a standard pretrained LM into a structurally aware one.
  2. Tree vs. Graph Limitations: Language structure is often better represented as a graph (allowing for multiple parents or cycles, as seen in semantic dependencies) rather than a strict hierarchical tree. Dependency graphs have been largely neglected in this line of research.

The authors propose GiLT to bridge this gap, integrating flexible dependency graphs without altering the LM's core vocabulary or symbol space.

Methods

GiLT simultaneously generates text tokens and incrementally constructs a word-level dependency graph. The architecture modifies the standard Transformer layer through three main steps:

  • Dependency Scoring & Graph Update: When a new word is generated, GiLT uses a biaffine mechanism over hidden states from the middle and penultimate layers to score potential dependencies between the current word and previous words. To keep the beam search space linear rather than exponential, it uses a two-step method: first predicting the number of dependencies, and then selecting the top highest-scoring edges.
  • Feature Extraction (Feature Tapes): From the partially constructed graph, GiLT extracts three key structural features for each token to form a feature tape:
  • Degree: A weighted combination of incoming and outgoing edges.
  • Distance: The weighted shortest path between words in the current graph.
  • Depth: The shortest path to the root node in the graph's undirected backbone.
  • Attention Modulation: These graph features are embedded and directly added to the key ($K$) representations within the Transformer's self-attention mechanism (adapted for Transformer-XL's relative attention framework). This allows the structural layout of the sentence to dynamically guide where the model focuses its attention.
Illustration of feature tape construction during text generation

Datasets

The models were trained and evaluated using the following datasets:

  • BLLIP-LG: Used as the primary training corpus. The text was automatically parsed using the ACE parser to generate silver-standard semantic dependency graphs across three frameworks: Prague Semantic Dependencies (PSD), Enju Predicate-Argument Structures (PAS), and DELPH-IN MRS-Derived Bi-Lexical Dependencies (DM).
  • BLiMP & SG Test Suites: Used to evaluate syntactic generalization capabilities across various linguistic phenomena (e.g., subject-verb agreement, center embedding).
  • GLUE Benchmarks: Tasks including RTE, SST2, MRPC, and STS-B were utilized to evaluate downstream text classification performance after finetuning a pretrained GPT-2 model augmented with GiLT layers.

Key Insights and Ideas

  • Preserving Symbol Space is Crucial: By avoiding the insertion of structural tokens, GiLT can be directly swapped into pretrained architectures (like GPT-2). This unlocks the ability to inject structural inductive biases into large, pretrained models during downstream finetuning.
  • Graphs Over Trees: Models trained on semantic dependency graphs (like GiLT-PSD) maintained better language modeling perplexity than those restricted to strict dependency trees (GiLT-DP). This highlights the benefit of using more flexible graph-based representations.
  • Simplicity Breeds Performance: An analysis of different graph types revealed that datasets with a lower average number of dependencies per sentence (like PSD) yielded better perplexity. Simpler graphs introduce less noise from the automated parsers, making them easier for the LM to model.

Key Results

  • Syntactic Generalization: GiLT-PSD achieved a Syntactic Generalization (SG) score of 79.7, significantly outperforming the Transformer-XL baseline (72.1) and matching or beating other state-of-the-art syntactic LMs.
Performance comparison across the 6 circuits of the SG test suite
  • Perplexity Maintained: Unlike previous structural LMs that suffer from severe perplexity degradation, GiLT models achieved a perplexity (~14.9) virtually identical to the baseline Transformer-XL (14.8).
  • Downstream Boosting: When replacing the last 12 layers of a pretrained GPT-2 with GiLT layers and finetuning on GLUE, GiLT-GPT2 outperformed standard GPT-2 across all four evaluated tasks (e.g., scoring 65.3 vs 64.1 on RTE, and 85.2 vs 84.2 on STS-B).
  • Inference Efficiency: Because it avoids sequence lengthening, GiLT proved to be dramatically faster and more memory-efficient during beam search than token-based alternatives like Dependency Transformer Grammars (DTG). At a beam size of 100, GiLT processed 9.0 tokens/sec using 6.7 GB of CUDA memory, whereas DTG slowed to 0.9 tokens/sec and consumed 22.7 GB.

Limitations and Future Work

Despite its efficiency gains over token-based models, GiLT still relies on beam search over dependency graphs during inference to estimate marginal probabilities, which remains computationally expensive.

Additionally, the authors noted that GiLT underperformed when restricted strictly to tree structures (GiLT-DP). This suggests that the current graph-based feature extraction method does not fully exploit the unique recursive properties inherent to pure trees.

For future work, the authors plan to explore jointly modeling multiple types of dependency graphs simultaneously and investigating unsupervised graph induction to eliminate the need for silver-standard training parses entirely.

Summary updated

BibTeX
@inproceedings{huang2026gilt,
  author = {Tianyu Huang and Yida Zhao and Chuyan Zhou and Kewei Tu},
  title = {{GiLT: Augmenting Transformer Language Models with Dependency Graphs}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.1441},
}
Figure