Introduction
Pre-trained Language Models (PLMs) like BERT and RoBERTa have revolutionized NLP, yet they often struggle to capture the underlying syntactic structure of language, such as long-range dependencies between subjects and verbs. Traditional methods to incorporate syntax typically involve adding explicit syntax-aware layers or requiring external parsers during inference. These approaches increase model complexity and introduce brittleness if the parser fails at runtime.
SynCLM (Syntax-guided Contrastive Language Model) addresses these issues by injecting structural linguistic knowledge directly into standard Transformer weights during pre-training. By using contrastive learning objectives, SynCLM teaches the model to internalize syntactic "intuition" without altering its architecture or adding inference-time overhead.
Methodology: Syntax-guided Contrastive Learning
SynCLM introduces two novel contrastive learning objectives that complement the standard Masked Language Modeling (MLM) loss. These objectives use syntax trees as "teachers" during the pre-training phase.
- Phrase-guided Contrastive Learning: This objective utilizes constituency trees to group words into nested phrases. The model is trained to align the attention distributions of tokens within the same phrase, ensuring that words like "the red apple" share similar contextual patterns compared to words outside the phrase.
- Tree-guided Contrastive Learning: Based on dependency trees, this objective focuses on head-modifier relationships. The model learns to represent subtrees by maximizing the similarity between a "true" syntactic subtree representation and the global representation, while contrasting it against "corrupted" subtrees.
Crucially, because these objectives are only active during training, the resulting model remains a standard Transformer, making it a "drop-in" replacement for existing pipelines.
Experimental Results
The authors evaluated SynCLM across a wide range of tasks, including Grammatical Error Detection (GED), Named Entity Recognition (NER), and the GLUE benchmark. Pre-training was conducted on English Wikipedia and BookCorpus, with syntactic labels generated once via the Stanza parser.
Performance on GLUE and Grammatical Tasks
SynCLM demonstrated consistent improvements over baseline models. On the GLUE benchmark, the model showed notable gains in tasks requiring structural understanding, such as RTE (+1.4%) and MRPC (+1.3%).
In grammatical accuracy tests, SynCLM-base achieved a 2.0% improvement on the BLiMP dataset and a 1.3% boost on CoLA compared to RoBERTa-base. Furthermore, structural probing revealed that SynCLM's internal vectors could reconstruct syntax trees with a state-of-the-art UUAS of 84.9, significantly outperforming previous syntax-enhanced models.
Explainability and Efficiency
A key advantage of SynCLM is its explainability. Analysis of attention weights shows that the model naturally learns to assign higher attention between syntactically related tokens (e.g., subject and verb), even across long distances. Moreover, by avoiding additional parameters, SynCLM maintains the efficiency of the original Transformer architecture, making it highly practical for real-world deployment.
Conclusion and Future Work
SynCLM proves that syntactic knowledge can be effectively internalized as a prior rather than a feature. This approach yields significant performance gains, particularly on smaller datasets where linguistic intuition helps generalization. While improvements on sentence-pair tasks like MNLI were more modest, future work will explore integrating semantic relationships alongside syntax to further enhance structural modeling.
Summary updated