TransPolymer: a Transformer-based Language Model for Polymer Property Predictions

Changwen Xu, Yuyang Wang, Amir Barati Farimani · DOI

Abstract

Predicting the physical and chemical properties of polymers is a cornerstone of materials science, yet traditional methods are often computationally expensive or limited in their ability to capture complex structural dependencies. We present TransPolymer, the first Transformer-based language model specifically engineered for polymer property prediction. By employing a novel chemical-aware tokenizer and large-scale self-supervised pretraining on 5 million sequences, TransPolymer learns a robust "chemical grammar." Our model achieves state-of-the-art performance across ten diverse benchmarks, demonstrating significant improvements over traditional graph-based and recurrent neural network baselines.

Introduction

The design of functional polymers—essential for applications ranging from battery electrolytes to solar cells—traditionally relies on labor-intensive "wet lab" experiments or intensive molecular dynamics simulations. While machine learning (ML) has emerged as a powerful accelerant, polymers pose unique challenges. Unlike small molecules, polymers exhibit hierarchical structures, varying degrees of polymerization, and properties sensitive to external factors like temperature.

Existing ML approaches, such as Graph Neural Networks (GNNs) and Recurrent Neural Networks (RNNs), often struggle to represent these long-range interactions or the specific nuances of polymer chains. TransPolymer addresses these limitations by treating polymer sequences as a formal language, leveraging the self-attention mechanism of Transformers to capture complex, non-local dependencies within the material's structure.

Methodology

The TransPolymer framework is built upon four pillars: chemical-aware tokenization, large-scale pretraining, data augmentation, and task-specific finetuning.

Chemical-aware Tokenization and Architecture

A primary innovation is the "chemical-aware" tokenizer. Standard natural language processing (NLP) tokenizers often fragment chemical symbols (e.g., splitting 'Si' into 'S' and 'i'), destroying semantic meaning. Our tokenizer treats chemical elements as atomic units and integrates structural descriptors—such as molecular weight or glass transition temperature ($T_g$)—directly into the input sequence alongside special separators for copolymers.

Figure 1: TransPolymer architecture overview, including (a) chemical-aware tokenization, (b) the two-step training process, and (c) the internal Transformer block structure.

The core architecture is based on RoBERTa, utilizing multiple layers of multi-head self-attention to process these enriched sequences.

Pretraining and Finetuning

The model undergoes a two-stage training process. First, it is pretrained using Masked Language Modeling (MLM) on the PI1M database, which was augmented from 1 million to 5 million sequences using non-canonical SMILES strings. This stage allows the model to learn the underlying "grammar" of polymer chemistry without requiring labeled data.

Figure 2: Detailed view of the (left) pretraining stage using Masked Language Modeling and (right) the finetuning stage for property regression.

In the second stage, the pretrained model is equipped with a Multi-Layer Perceptron (MLP) head and finetuned on specific labeled datasets to predict numerical properties such as conductivity, bandgap, and refractive index.

Results and Discussion

TransPolymer was evaluated against ten downstream benchmarks covering electronic, physical, and energy-related properties.

Performance Benchmarks

The model achieved state-of-the-art (SOTA) results on all ten benchmarks. Notably, on the PE-I conductivity dataset, TransPolymer reached an $R^2$ of 0.69, a substantial improvement over the best traditional baseline (Random Forest at 0.32). Across all tasks, the model demonstrated an average reduction in Root Mean Square Error (RMSE) of 7.7% compared to previous best-in-class models.

Insights into Chemical Grammar

Our results support the "Chemical Grammar" hypothesis: pretraining on large unlabeled datasets allows the model to develop a sophisticated internal representation of chemical space. Visualization of attention heads reveals that the model naturally prioritizes chemically significant tokens, such as polymerization sites ('*') and critical descriptors like $T_g$, when making predictions. Furthermore, we observed that the scale of pretraining data is vital; small-scale pretraining can lead to biased representations that perform worse than training from scratch.

Conclusion

TransPolymer demonstrates the power of Transformer architectures in materials science. By treating polymers as a language and preserving chemical semantics through specialized tokenization, the model overcomes the limitations of previous sequence and graph-based models. While future work is needed to improve interpretability and incorporate 3D conformational data, TransPolymer provides a robust foundation for the accelerated discovery of novel polymer materials through active learning and high-throughput screening.

Summary updated

BibTeX
@misc{xu2022transpolymer,
  author = {Changwen Xu and Yuyang Wang and Amir Barati Farimani},
  title = {{TransPolymer: a Transformer-based Language Model for Polymer Property Predictions}},
  year = {2022},
  eprint = {2209.01307},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2209.01307},
}
Figure