Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Transformer Grammars: Augmenting Transformer Language Models with Syntactic Inductive Biases at Scale

Transformer Grammars add recursive syntax to Transformer language models

  • Problem Recurrent neural network grammars model trees and strings jointly, but they have proven difficult to scale. So it was unclear whether recursive syntactic composition still helps Transformer models at larger sizes.
  • Method Transformer Grammars use a special attention mask that folds each closed constituent into one composed vector, so later words attend to that vector, not its children.
  • Results Across syntactic generalization suites on BLLIP-LG sentences, Transformer Grammars score 82.5, against 80.2 for TXL (trees).

Why recursive syntax is hard to add to large Transformers

Large Transformer language models reach strong benchmark scores without any explicit hierarchical syntax. Linguistic research long held that hierarchical structure is necessary for good generalization, which makes this absence notable. Recurrent neural network grammars model trees and strings jointly and build phrases bottom-up through recursive composition.

Their benefits were shown at small data and model scales, but they have proven difficult to scale.

So the open question is whether recursive composition still helps Transformer models at larger sizes. The authors ask this question for both sentence-level and document-level language modeling.

Composing phrases through the attention mask

The model writes a tree as a sequence of actions: open a nonterminal, emit a terminal, or close the most recent open constituent. In a Transformer, attention is the only route by which earlier positions affect the current prediction, so the mask decides what information can flow. When a constituent closes, the model represents its index by one composed vector, built by attending to the child positions of that constituent.

Later positions can attend to that composed vector but not to the children directly. This restriction forces everything that influences later predictions through a single syntactic bottleneck.

Composing and stacking both have to happen at a closing nonterminal, yet the model performs exactly one attention operation per token. So the authors duplicate each closing nonterminal: the first copy, CNT1, implements COMPOSE, and the second, CNT2, implements STACK. No prediction is emitted at the COMPOSE positions, which keeps the number of prediction events constant.

Algorithm 1 turns the action sequence into the binary attention mask A, where Aij is 1 iff position j may be attended from i.

Because the attention mask is fixed in advance, training computes the composed representations of NP and VP in parallel. Each higher layer composes the outputs of the layer below, so a token at depth d needs at least d layers to affect the topmost composed representation. The STACK mask lets the word sings attend to the closed NP and to its open ancestors.

Because outside information reaches a composed phrase only indirectly, the authors argue that the composition favors bottom-up information.

Positions, segments and memory in Transformer Grammars

Transformer-XL measures the relative position as the distance between two positions, which ignores the tree. TGs replace that distance with the difference in tree depth, written as R_ij = δ(i) − δ(j). The relative position is only computed for pairs that the mask allows to attend. For the sentence in Figure 2, the sings and bird pair never gets a relative position, because the mask blocks it.

Instead, sings gets one with its sibling NP, which covers the blue bird.

TGs process a long input as consecutive fixed-length segments, as Transformer-XL does. Each segment carries a memory of size M from one segment to the next. Each layer runs multi-head self-attention, then a position-wise feed-forward network, and writes a memory update for the next segment. All layers receive the same attention mask and the same relative positions matrix.

TGs store only the positions that may still be attended, because positions inside a composed subtree are never attended later. Keeping this memory requires careful book-keeping that maps memory slots to original input positions.

The authors trained each model type 100 times with independent random initializations. PTB models use 16 layers and 12M parameters, while BLLIP-LG models use 16 layers and 252M parameters. The authors kept the checkpoint with the lowest validation loss, computed with a single gold tree per sentence. Perplexity for the joint models is computed with the approximate marginal over 300 proposal trees.

Perplexity: sentence gains and document-level loss

Joint models define the string probability as a sum over trees, which is intractable to compute exactly. The authors approximate that sum with 300 trees sampled without replacement from a discriminative RNNG proposal model. Because the sum covers only part of the tree space, the joint-model perplexity is an upper bound. The terminal-only perplexity is exact, since it models the word sequence directly.

For documents, the authors greedily pick the single most likely tree for each earlier sentence before adding the 300 proposals for the last sentence.

On PTB, TG scored 61.8 ± 0.2 perplexity, compared to 61.2 ± 0.3 for TXL (trees) and 62.6 ± 0.2 for TXL (terminals). Both structure-aware models beat the terminal-only baseline, while TXL (trees) is slightly better than TG. On BLLIP-LG sentences the ordering is similar, with 30.3 ± 0.5 for TG, 29.8 ± 0.4 for TXL (trees) and 31.2 ± 0.4 for TXL (terminals).

The authors read this as joint modeling helping perplexity even without an explicit composition bias, since TXL (trees) has no attention restriction. They conjecture that nonterminals in the context restrict the word classes that may appear next, which makes the next-token task easier.

With whole documents on BLLIP-LG, the ordering reverses for TG. TG scored 26.3 ± 0.1, compared to 22.1 ± 0.1 for TXL (trees) and 23.1 ± 0.1 for TXL (terminals). The authors suggest that prior-sentence context, kept only as composed syntactic vectors, may explain this degradation. They argue that another memory mechanism, working partly independently of syntactic structures, may matter for long text.

Relative to TXL (trees), the document-level gap is about 4 points, a 19% relative increase.

Parse reranking and syntactic generalization

On parse reranking, the models choose among the 300 RNNG samples for each PTB test sentence and are scored by bracketing F1 computed with EVALB. TG reaches an F1 of 93.7 ± 0.1, compared to 93.6 ± 0.1 for TXL (trees). The authors believe the restricted attention keeps TG from attending to syntactically irrelevant input. They also think this restriction pushes the model to learn informative composed representations of subtrees.

For syntactic generalization, the authors average the SG score over 31 test suites for models trained on BLLIP-LG sentences. TG scores 82.5 ± 1.6, compared to 80.2 ± 1.6 for TXL (trees) and 69.5 ± 2.1 for TXL (terminals). Both linearized-tree models beat the words-only model, and the authors say this holds even against much larger models such as GPT-2, Gopher and Chinchilla.

The authors explain the gap with extra syntactic supervision during training, which lets the models pick good parses from many candidates. They add that approximate marginalization weights valid parses heavily, since the SG score depends on model surprisals on words.

Table 1 also lists GPT-2 at 78.4, Gopher at 79.5 and Chinchilla at 79.7 on SG. These scores come from prior work or other evaluations, so they are not a controlled comparison with TG. The authors note that model scale alone is insufficient to offset the effect for the linearized-tree models. In the per-circuit breakdown, TG and TXL (trees) score very similarly on most circuits.

TG substantially outperforms TXL (trees) on Licensing, and the authors tie this to TG's bias toward structurally local relations.

Figure 4: Per-circuit breakdown of the SG scores

Figure 4 : Per-circuit breakdown of the SG scores.

Original paper · CC BY 4.0 · Laurent Sartran, Samuel Barrett, Adhiguna Kuncoro, Miloš Stanojević, Phil Blunsom, Chris Dyer · Transformer Grammars: Augmenting Transformer Language Models with Syntactic Inductive Biases at Scale · Original paper figure · Extracted the figure area from page 9 of the original PDF.

Ablating the syntactic structure: does TG depend on the correct tree?

The ablation keeps the words and replaces each tree with a binary left-branching, right-branching or reversed structure. The authors build the left-branching version by moving opening nonterminals left and placing each closing nonterminal after a terminal. The apparent structure no longer matches the sentence, so the operations driven by it become unsuitable.

Because TG's operations mechanically depend on the nonterminals, the authors expected this damage for both perplexity and syntactic generalization. For TG on the PTB validation split, perplexity rose from 76.1 ± 0.3 with the original trees to 134.0 ± 0.8 with left-branching trees. So the syntactic structure matters for TG perplexity, because its operations depend on it.

Reversed trees hurt TG perplexity even more, reaching 239.7 ± 11.5 on PTB. Right-branching trees hurt it less, at 91.2 ± 0.4 on PTB. Left-branching trees are comparatively easy to model, since they are a prefix of opening nonterminals followed by interleaved terminals and closing nonterminals. Right-branching trees are similarly easy, and their COMPOSE operations happen only near the end of the sequence.

TXL (trees) is also hurt by the same transformation, moving from 74.9 ± 0.3 to 101.0 ± 0.9. The authors say its degradation is smaller, since TXL (trees) can choose whether to use the syntactic information.

The authors also train a TG variant that uses difference in linear position instead of difference in tree depth. That variant reaches 76.3 ± 0.3 on PTB, close to the depth-based TG at 76.1 ± 0.3. They attribute this small effect to the sparse attention mask, which makes position-based querying matter little. They chose depth-based positions for their theoretical justification, since the empirical results are the same.

What the regressions and probes show about TG's losses

The authors hypothesize that restricted attention keeps TG from learning non-syntactic co-occurrences, so rare terminals should suffer most. They compute the empirical unigram distribution of terminals in the BLLIP-LG document training split and split terminals into three frequency buckets. The buckets are high-frequency (f ≥ 10−3), medium-frequency (10−5 ≤ f < 10−3), and low-frequency (f < 10−5).

They regress the difference in log probabilities on three binary indicators using ordinary least squares on the BLLIP-LG validation set. The coefficients are −0.0488 for high frequency, −0.2419 for medium frequency and −0.5481 for low frequency, with an adjusted R2 of 0.039. So TG predicts frequent terminals almost as well as TXL (trees), but it struggles with rarer ones.

A second regression asks whether the true terminal appears in a previous sentence, in the current sentence, or nowhere in the context. The coefficients are −0.2871 for a previous sentence, −0.1003 for the current sentence and −0.1340 for no context, with an adjusted R2 of 0.010. The authors read this as a priming effect that TXL (trees) benefits from and TG lacks.

In TG, a terminal can attend to another terminal only if that terminal is in its left-context and is its sibling, which limits copying.

The probing study uses the information-theoretic framework of Voita and Titov (2020), scoring each probe by its code length on the validation set. Four tasks are used: POS tags, grandparent constituent tags, the top constituent, and word content. TG and TXL (trees) explain the POS tags about equally well. TG's STACK representations predict ancestor constituents much more easily than TXL (trees), because ancestors remain on the stack when a subtree closes.

COMPOSE representations make the top constituent easy to predict, since they attend over the immediate children. TXL (terminals), which gets no syntactic supervision, does predictably worse on these three syntactic tasks. Word-content probes are easier on TXL (trees) than on either TG representation, which suggests TXL (trees) keeps the context words better.

What remains open after these experiments

The experiments cover only PTB and BLLIP-LG, and the BLLIP-LG models are at the medium scale of about 40M words. They don't test larger data or model sizes, so the scaling question for TGs stays open. Transformer Grammars don't provide probability estimates as easily as autoregressive language models do. Obtaining those estimates requires more computation, or further research into efficient methods for probability estimation.

Joint-model perplexity is approximated by marginalizing over N = 300 proposal trees from a discriminative RNNG. For documents, the model greedily picks the single most likely tree for each earlier sentence, so the TG comparison depends on that approximation. The reported perplexity is an upper bound, which the authors flag with a dagger in Table 2.

The paper suggests a different memory mechanism for long text, but it doesn't build one. Scores for the large LMs come from prior work, so they aren't controlled comparisons.

Paper info

Authors
Laurent Sartran, Samuel Barrett, Adhiguna Kuncoro, Miloš Stanojević, Phil Blunsom, Chris Dyer
Venue
arXiv · Preprint
First published
2022-3-1
Added
2026-11-6
Updated
2022-12-6
Version
v2
arXiv
2203.00633
DOI
10.1162/tacl_a_00526
Category
cs.CL
Original paper terms
CC BY 4.0
What we show
Paper info, commentary and permitted figures from the original paper

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Abstract

We introduce Transformer Grammars (TGs), a novel class of Transformer language models that combine (i) the expressive power, scalability, and strong performance of Transformers and (ii) recursive syntactic compositions, which here are implemented through a special attention mask and deterministic transformation of the linearized tree. We find that TGs outperform various strong baselines on sentence-level language modeling perplexity, as well as on multiple syntax-sensitive language modeling evaluation metrics. Additionally, we find that the recursive syntactic composition bottleneck which represents each sentence as a single vector harms perplexity on document-level language modeling, providing evidence that a different kind of memory mechanism -- one that is independent of composed syntactic representations -- plays an important role in current successful models of long text.

Quote from the paper

Laurent Sartran, Samuel Barrett, Adhiguna Kuncoro, Miloš Stanojević, Phil Blunsom, Chris Dyer (2022). Transformer Grammars: Augmenting Transformer Language Models with Syntactic Inductive Biases at Scale. arXiv:2203.00633v2. https://doi.org/10.1162/tacl_a_00526

BibTeX
@article{sartran2022transformer,
  title = {{Transformer Grammars: Augmenting Transformer Language Models with Syntactic Inductive Biases at Scale}},
  author = {Laurent Sartran and Samuel Barrett and Adhiguna Kuncoro and Miloš Stanojević and Phil Blunsom and Chris Dyer},
  year = {2022},
  eprint = {2203.00633},
  archivePrefix = {arXiv},
  doi = {10.1162/tacl_a_00526},
  url = {https://arxiv.org/abs/2203.00633v2}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up