S2SNet: A Pretrained Neural Network for Superconductivity Discovery
Superconductivity allows electrical current to flow without any energy loss,
and thus making solids superconducting is a grand goal of physics, material
science, and electrical engineering. More than 16 Nobel Laureates have been
awarded for their contribution to superconductivity research. Superconductors
are valuable for sustainable development goals (SDGs), such as climate change
mitigation, affordable and clean energy, industry, innovation and
infrastructure, and so on. However, a unified physics theory explaining all
superconductivity mechanism is still unknown. It is believed that
superconductivity is microscopically due to not only molecular compositions but
also the geometric crystal structure. Hence a new dataset, S2S, containing both
crystal structures and superconducting critical temperature, is built upon
SuperCon and Material Project. Based on this new dataset, we propose a novel
model, S2SNet, which utilizes the attention mechanism for superconductivity
prediction. To overcome the shortage of data, S2SNet is pre-trained on the
whole Material Project dataset with Masked-Language Modeling (MLM). S2SNet
makes a new state-of-the-art, with out-of-sample accuracy of 92% and Area Under
Curve (AUC) of 0.92. To the best of our knowledge, S2SNet is the first work to
predict superconductivity with only information of crystal structures. This
work is beneficial to superconductivity discovery and further SDGs. Code and
datasets are available in https://github.com/zjuKeLiu/S2SNet
Ke Liu, Kaifan Yang, Jiahong Zhang, Renjun Xu
# S2Net: A Pretrained Neural Network for Superconductivity Discovery

###### Abstract

Superconductivity allows electrical current to flow without any energy loss, and thus making solids superconducting is a grand goal of physics, material science, and electrical engineering. More than 16 Nobel Laureates have been awarded for their contribution in superconductivity research. Superconductors are valuable for sustainable development goals (SDGs), such as climate change mitigation, affordable and clean energy, industry, innovation and infrastructure, and so on. However, a unified physics theory explaining all superconductivity mechanism is still unknown. It is believed that superconductivity is microscopically due to not only molecular compositions but also the geometric crystal structure. Hence a new dataset, S2S, containing both crystal structures and superconducting critical temperature, is built upon SuperCon and Material Project. Based on this new dataset, we propose a novel model, S2SNet, which utilizes the attention mechanism for superconductivity prediction. To overcome the shortage of data, S2SNet is pre-trained on the whole Material Project dataset with Masked-Language Modeling (MLM). S2SNet makes a new state-of-the-art, with out-of-sample accuracy of 92% and Area Under Curve (AUC) of 0.92. To the best of our knowledge, S2SNet is the first work to predict superconductivity with only information of crystal structures. This work is beneficial to superconductivity discovery and further SDGs. Code and datasets are available in [https://github.com/zjuKeLiu/S2SNet](https://github.com/zjuKeLiu/S2SNet)

## 1 Introduction

Superconductors are crucial for sustainable everyday applications and attractive for the United Nations' sustainable development goals (SDGs) [16]. Superconductors have zero resistance, which allows perfect current transmission without losses. With superconducting cables, a continuous supply of power can be obtained for a timely availability of irrigation water in remote areas, which is a key to sustainability in performing agriculture. Then hunger can be effectively alleviated since it is partly caused by the lack of sustainability in performing agriculture. Affordable and clean energy can also be obtained because DC energy from places where power is plentiful, like solar plants in Africa (365 sunny days) can be delivered worldwide without losses. Zero resistance means "no heat-generation and no energy-loss", which is the key contribution in the climate action. For good health and well-being, superconducting magnets, which can produce magnetic field of high-quality, high-intensity, are well used as high-field magnets in magnetic resonance imaging, nuclear magnetic resonance, water purification, magnetic drug delivery, and so on.

Superconductivity has been a hot topic along many fields for its great significance to human beings and SDGs. However, the theory of superconductivity is still a puzzle till now. Benefiting from massive publicly available datasets in the area of material science, many machine learning methods have been applied to predicting material properties, generating structures, and so on [1]. It also sheds a light to modeling superconductors with machine learning methods. Much of the recent interest in superconductivity modelling has focused on critical temperature regression using measured properties of the material [21, 1], which is computationally expensive since feature engineering is required.

In AI for physical science, a lot of efforts have been made to model molecules with Graph Neural Networks (GNN) [20, 18] since the molecules are graphs naturally. However, quite few methods have been proposed for crystal modelling [12, 22, 23]. Due to the different annotations among different datasets, the current supervised learning models can only be trained on small datasets, while other unlabeled data are not fully utilized.

Recently, attention mechanism is widely used in Natural Language Processing (NLP) [1] and Computer Vision (CV) [15] to model the interaction of contexts. The pre-training task, Masked-Language Modeling (MLM) task, in both NLP and CV, has shown great potential to get model better and more robust with astounding experimental results [1, 16]. Besides, with pre-training tasks, the unlabeled data can be utilized properly.
According to BCS theory, superconductivity can be microscopically explained as the interaction between electrons and lattice vibrations (phonons) [1]. Therefore, we propose a machine learning model for the way from **S**tructure **to**S**uperconductivity (**S2SNet**), in which only crystal structures are required, to model the interaction in order to predict potential superconducting. Attention mechanism is applied to crystal structures. S2SNet is pre-trained on a large amount of unlabeled data to learn the interaction between different atoms in lattice.

Through S2SNet, we try to model the potential interaction between lattice dynamics and cooper pairs to predict the potential superconductor properties of material. It is experimentally verified that S2SNet outperforms other existing models. To the best of our knowledge, S2SNet is the first work showing that it is possible to predict the superconductivity of materials via their crystal structures.

The main contributions of our work can be summarized as follows:

* We propose a novel neural network to discover potential superconductivity of materials given only information of crystal structures for the first time.
* A new dataset S2S containing both crystal structure and superconductivity critical temperature is built for the first time. It provides a benchmark for future machine learning based superconductor discovery.
* To provide insight and guide the superconductivity research for physicists, we present a list of potential superconductors for future experimental validation.

## 2 Related Work

Superconductivity Prediction.Previous machine learning methods focus on predicting the superconductivity through the measured properties of materials, while these properties are obtained through complex and expensive feature engineering. The averaged valence-electron numbers, orbital radii differences, and metallic electronegativity differences were three critical features used in [23]. Materials Agnostic Platform for Informatics and Exploration (Magpie) and AFLOW were used for feature engineering in [22, 1].

Crystal Modeling.Quite few methods are proposed for crystal modeling. By connecting the atoms within a distance threshold, crystals were modeled as a graph with atoms as nodes in CGCNN [13, 14]. External environmental conditions are taken into consideration by taking it as an additional nodes and connecting it with all the other nodes in MEGNet [2].

Unsupervised Learning.Various approaches have been proposed to make full use of the unlabeled data, most of which pre-train a model with the unlabeled dataset and fine-tune it on specific labeled dataset [1]. Contrastive learning is commonly used for pre-training in CV [11]. As pre-training tasks in NLP, diverse techniques such as mask language model (MLM), replaced token detection (RTD), and so on are often employed [15]. Following the pre-training model Bert, Zhang et. al. proposed "MG-Bert" for molecule modelling with unsupervised learning [14].

## 3 Methodology

Attention mechanism is proposed in the filed of NLP and widely used in CV recently [15, 16]. It is applied to the crystals in this study.

### S2SNet

Fig. 1 shows the overall illustration of S2SNet and the attention mechanism. In this paper, it is defined that a crystal \(c\in C\) consists of atoms \(A=\{a_{1},a_{2},\cdots,a_{n}\}\), the location of atoms \(P=\{p_{1},p_{2},\cdots,p_{n}\}\), and the lattice parameters \(U=\{u_{1},u_{2},u_{3}\}\), i.e. \(c=\{A,P,U\}\). \(n\), \(a\), \(p\) and \(U\) denote the number of atoms in a unit cell, the atomic number, the actual 3-D location of an atom in the crystal, and the physical dimension of a unit cell respectively. The overall workflow of S2SNet can be described as followings:

1. Atoms \(A\) are embedded into 512-dim vectors through the Embedding layer. Expanded distance with Gaussian basis centered at 512 points linearly placed between 0 and 5.12 A is applied to the location \(P\) of atoms in the crystal [2]. Specifically, the Euclidean distances \(P^{\prime}\) between atoms and the center of crystal i.e. the mean coordinates of all atoms, are calculated. Then Gaussian basis are performed as Eq. 1, where \(P^{\prime}_{0}\) are 512 distances from 0 to 5.12 A and \(\sigma=2\)[2]. \[A^{\prime} =embedding(A),\] \[\hat{P} =e^{-\frac{(P^{\prime}-P^{\prime}_{0})^{2}}{\sigma^{2}}}\] (1)
2. The embedding of atoms \(A^{\prime}\) are atom-wise aggregated with the distance \(\hat{P}\) as Eq. 2, where \(W_{\alpha}\) is a matrix to

Figure 1: Illustration of S2SNet and attention mechanism. (a) Overall illustration of S2SNet. The Attention Module are performed for 10 times. \(FC1\) and \(FC2\) are two fully connected hidden layers. \(FC2\) outputs the target \(\hat{y}_{t}\). (b) Illustration of the Attention mechanism. The computation of representation of Atom \(a_{1}\) is presented. Best view in color.
get the position \(\hat{P}\) into the same dimension as \(A^{\prime}\) and model the interaction between different positions. \[A^{\prime\prime}=A^{\prime}+W_{\alpha}\cdot\hat{P}\] (2)
3. Attention mechanism is performed on each atom respectively with its neighborhood atoms. Thus the embedding of atom contains all the information of itself and neighbors. \(neighbor(a^{\prime\prime})\) is defined as the atoms within the Euclidean distance, \(\rho\), from \(a^{\prime\prime}\). In this paper, \(\rho\) equals to 2 A according to [3]. \[a_{i}^{\prime\prime\prime}=Attention(a_{i}^{\prime\prime},neighbor(a_{i}^{ \prime\prime}))\] (3)
4. To aggregate the embedding of all atoms in crystal, the \(Set2Set\)[21] is performed on the set \(A^{\prime\prime\prime}\). \[b=Set2Set(A^{\prime\prime\prime})\] (4)
5. Lattice parameters are aggregated to get the final representation of crystal as Eq. 5, where \(W_{\theta}\) is a matrix to get the lattice parameters \(U\) into the same dimension as \(b\). \[b^{\prime}=b+W_{\theta}\cdot U\] (5)
6. Through the \(FC2\) layer, target can be obtained and loss function is binary cross entropy as Eq. 6, where \(y_{t}\) is the ground truth of whether it is a superconductor and \(\hat{y}_{t}\) is the prediction of S2SNet. \[\mathcal{L}_{finetune}=-\frac{1}{2}[y_{t}\log\hat{y}_{t}+(1-y_{t})\log(1-\hat{ y}_{t})]\] (6)

In Fig. 1(b), an example of the attention mechanism is illustrated. Suppose that the neighbors of atom \(a_{1}\) are \(a_{2}\) and \(a_{3}\). To get the representation of atom \(a_{1}\), \(a_{1}\) and its neighbors, \(a_{2}\) and \(a_{3}\), are firstly multiplied with \(W_{Q}\), \(W_{K}\) and \(\hat{W}_{V}\) respectively. Three different groups of \(\{q,k,v\}\) are obtained. \(q_{1}\) from \(a_{1}\) is multiplied with \(k_{1},k_{2},k_{3}\) from all the atoms to get the \(score\) as Eq. 7, where \(d_{k}\) is the dimension of \(k\). Finally, the representation of atom \(a_{1}\) can be obtained as the weighted sum of \(V\) from all the atoms as Eq. 8, where \(N\) is the number of \(a_{1}\)'s neighbors plus one. Representations of other atoms \(a_{i}\in A\) can also be obtained like this. \[scores=\frac{softmax(q_{1}\cdot K^{T})}{\sqrt{d_{k}}}\] (7) \[a_{1}^{\prime\prime\prime}=\sum_{i=1}^{N}scores_{i}\cdot v_{i}\] (8)

### MLM Pre-training Task

MLM pre-training task is a self-supervised learning method to model the interaction between atoms via classification as Fig. 2. In this task, 15% (at least 2) of the atoms in a crystal are masked, and the model are trained to predict the class of masked atoms. Therefore no extra labels except the structure of the crystal are required. Since there are 95 elements in S2S dataset, this pre-training is a 95-classification task. The objective of this pre-training can be defined as Eq. 9, where \(N\) and \(95\) denote the number of masked atoms and the number of element classes respectively. \(y_{i,j}\) is the ground truth and \(\hat{y}_{i,j}\) is the prediction of S2SNet for "atom \(i\) is the element \(j\)", 0 for False and 1 for True.

\[\mathcal{L}_{pre-train}=-\frac{1}{N}\sum_{i=1}^{N}\sum_{j=1}^{95}y_{i,j}\log \hat{y}_{i,j} \tag{9}\]

After convergence of training, the _Embedding_, _Aggregate_, and _Attention_ layers are cloned. Finally, S2SNet is then fine-tuned on S2S dataset with the pre-trained layers frozen.

## 4 Experiments

To verify S2SNet, a dataset of superconductors is constructed, on which extensive experiments are conducted. Compared with other models, the experiments demonstrate that S2SNet effectively captures the crystal structural information for superconductivity prediction.

### Setup

S2S Dataset.We collect a total of 69,239 crystal structures from Material Project database [15], each of which contains lattice structure, formation energy, and band gap of crystals. 33,810 superconductors and their critical temperatures are obtained from SuperCon*, which stores the critical temperature of substances. In addition, this paper also obtains structural information of part of materials from databases such as OQMD [19], and ICSD [1]. The information in the databases above are used to construct S2S dataset with 1,685 crystals, which includes 421 currently known crystal superconductors and other 1,264 materials without known superconductivity sampled from Material Project database. Each entry includes the name of the substance, its crystal structure(atoms, location of atoms and lattice parameters), and whether it is a superconductor. This statistics of S2S dataset and pre-training dataset are shown in Table 1.

\begin{table}
\begin{tabular}{c c c c} \hline Dataset & \(|U|\) & \(Max\left(|\mathbf{A}|\right)\) & \(|V|\) \\ \hline S2S & 1,685 & 248 & 95 \\ pre-train & 69,239 & 444 & 95 \\ \hline \end{tabular}
\end{table}
Table 1: Statistics of the datasets. \(|V|\) indicates the number of classes of atoms. \(|U|\) indicates the number of materials

Figure 2: Illustration of MLM pre-training task. Classifier contains a layer with 95 neurons and a \(softmax\) layer and outputs \(N\) vectors of 95-dimension \(\hat{y}\).
Compared Approaches.We mainly compare our proposal with several superconductivity prediction methods, **MEGNet**[3], **Statistic**[14], and **CGCNN**[15]. MEGNet uses graph networks to model molecules and crystals universally for property prediction. Statistic achieves a pleasant result on predicting superconductor which calculates 145 properties of materials with MAGPIE [1] and put these features into a random forest for training. CGCNN is specifically designed for accurate and interpretable prediction of crystal material properties where convolutional neural networks are performed on crystal graph.

Evaluation Metrics.We mainly employ Accuracy (**ACC**) and Area Under Curve (**AUC**) for superconductor prediction. In addition, we also use visualization and interpretability analysis to verify our S2SNet.

### Experimental Results and Discussion

Comparison on S2S Dataset.All these models are trained and tested directly on S2S dataset. To bridge the shortage of data, MEGNet and CGCNN are pre-trained with the task of predicting formation energy following the paper [3] and S2SNet is pre-trained with the MLM task both on the Material Project database. 80% of S2S dataset are randomly selected to train the models and the left 20% are used to test the models. All the models are evaluated in the same way. Adam optimizer is used in S2SNet and the settings of other models follow their papers.

The experimental results are shown in Table 2. S2SNet consistently outperforms the other competitors both on accuracy (ACC) and Area Under Curve (AUC). For example, S2SNet gets about 6% improvements on ACC than Statistic and about 7% improvements on AUC than CGCNN without pre-training and almost 11%/14% improvements than MEGNet on ACC/AUC. With the pre-training task, all these three models, MEGNet, CGCNN and S2SNet are improved significantly. Since S2SNet is pre-trained on the unsupervised MLM task, it can be pre-trained on other much bigger dataset without any labels. However, MEGNet and CGCNN must be trained on the dataset with specific labels such as formation energy and so on. This also means that S2SNet can be further improved with larger dataset in the future work.

Fig. 3 shows the receiver operating characteristic (ROC) curve for the superconductor classifier. The overall test accuracy is 91.28%, and the area under curve for the receiver operation conditions is 0.9118.

### Ablation Study

Ablation studies are also conducted to verify our S2SNet. Table 3 shows the experimental results of S2SNet with different number of attention layers on S2S dataset. Experiments demonstrate that more layers lead to better AUC. For both efficiency and accuracy, the number of attention layers in our S2SNet is 10.

\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{pre-train} & \multicolumn{2}{c}{without pre-train} \\  & ACC(\%) & AUC(\%) & ACC(\%) & AUC(\%) \\ \hline MEGNet & 80.30 & 79.10 & 78.37 & 75.43 \\ Statistic & - & - & 83.33 & 78.52 \\ CGCNN & 82.42 & 86.40 & 79.69 & 82.45 \\ S2SNet(ours) & **91.28** & **91.18** & **89.53** & **90.24** \\ \hline \hline \end{tabular}
\end{table}
Table 2: The experimental results of different models on the S2S dataset.

Figure 4: Pearson correlations between elemental embedding vectors. Elements are arranged in order of increasing Mendeleev number for easier visualization of trends. The number denotes the Mendeleev number.

Figure 3: ROC curve for test data of 10 attention layer pre-trained S2SNet. The horizontal and vertical coordinates are FPR and TPR respectively.
Further experiments are conducted to verify that the lattice parameters are helpful in S2SNet. Table 4 shows results of 10 attention layer S2SNet without the input of lattice parameters. With lattice parameters, models perform much better no matter pre-trained or not.

### Interpretability on S2SNet

According to [22], the interpretability and reproducibility of known chemical common knowledge for machine learning models in material science is critical. To this end, the embeddings of all the element are extracted from S2SNet. The Pearson correlation coefficient between different elements are calculated as Eq. 10, where \(m\) is the dimension of elemental embedding vector. As is shown in Fig. 4, the Pearson correlation coefficient between elemental embedding vectors follow the trend of the periodic table of elements. For example, the chalcogen, halogen, lanthanoid, transition metals, metalloid, and actinoid show highest similarities within their groups. For better observation on the elemental embedding vectors, t-SNE[10] is used to map the high-dimension embedding vectors into 2-dimension space in Fig. 5. Elements with similar properties are close to each other, such as the Actinoid, the Chalcogen, the Halogen and so on. All the visualizations show that S2SNet learns the common intuition in chemistry.

\[r_{ij}=\frac{\sum_{k=1}^{m}(a_{ik}-\overline{a}_{i})(a_{jk}-\overline{a}_{j})} {\sqrt{\sum_{k=1}^{m}(a_{ik}-\overline{a}_{i})^{2}\sum_{k=1}^{m}(a_{jk}- \overline{a}_{j})^{2}}} \tag{10}\]

### Potential Superconducting Materials

In order to provide more insight to the field of superconducting materials research, all the materials we have are fed into S2SNet to predict whether they are superconductors or not. Frequency of elements in materials that our model determines to be superconductors is shown in Fig. A1 in Appendix A. Orange and blue ones denote the number of atoms and the number of materials that contain corresponding atom respectively. Si, S, B, La, Fe, Se, Ge, P, Al, N, O, Bi, C, Ca, Te, Ti and Ni appear in more than 300 superconductors which, in our opinion, are supposed to be crucial elements for superconductor. And the known superconducting elements Nb, Pb, and so on are also identified as the crucial elements in S2SNet. To verify that whether our model has learned these knowledge, we make the embedding layer learnable and train the overall model with the superconductivity prediction. Atomic embeddings are visualized by t-sne in Fig. 6. The atoms with high frequency are grouped together.

We get 5468 potential superconductors out of the 69239 materials, and the element combination of part of representative potential superconductors are list in Table A1 in Appendix A. The existing Iron-based, Cuprate, Hydrogen-based and Metal superconductors are identified with high score by our model. Some potential superconductors with similar

\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{Method} & \multicolumn{2}{c}{pre-train} & \multicolumn{2}{c}{without pre-train} \\  & w & w/o & w & w/o \\ \hline ACC(\%) & **91.28** & 90.41 & **89.53** & 87.79 \\ AUC(\%) & **91.18** & 89.22 & **90.24** & 86.20 \\ \hline \hline \end{tabular}
\end{table}
Table 4: The experimental results of 10 attention layer models without the input of lattice parameters, where w and w/o denote the models with and without lattice parameters respectively.

Figure 5: Elemental embeddings in 2-dimension with t-SNE.

\begin{table}
\begin{tabular}{c c c c} \hline \hline \# attention layers & 5 & 10 & 15 \\ \hline ACC(\%) & 89.83 & 91.28 & **92.31** \\ AUC(\%) & 89.38 & 91.18 & **92.27** \\ \hline \hline \end{tabular}
\end{table}
Table 3: The experimental results of models with different numbers of attention layers.

Figure 6: Elemental embeddings in 2-dimension with t-SNE. The darker the color, the more often the element appears in the materials that our model determines to be superconductors.
structures are also predicted. Besides, the other potential superconductors with extremely high score are also given for further experimental synthesis verification. The results are reasonable, since \(Graphene\) and \(SiC\), which are not in the training set, are predicted to be superconductors. The prediction accuracies for Iron-based, Cuprate, Hydrogen-based superconductors are 97.64%, 92.00% and 96.89% respectively. It is worth mentioning that all the 21 Iron-based superconductors are correctly predicted.

### Why Are They Superconductors

Class Activation Map (CAM) is used to explore how superconductivity comes [21]. CAM is a technique commonly used in CV for interpretability, i. e., highlighting the parts of a picture where the model identifies it as a specific class. Herein, we highlight the atoms in crystals that are critical for superconductivity with CAM. The experimental findings are consistent with the previously proposed theories. We take the BaFe\({}_{2}\)S\({}_{3}\), H\({}_{3}\)S, and Sr\({}_{2}\)CuClO\({}_{2}\) for example. The contribution of atoms in each crystal to superconductivity is shown in Fig. 7 and the color denotes the contribution. BaFe\({}_{2}\)S\({}_{3}\) in Fig. 7(a) represents the Iron-based superconductors and the Fe is more crucial for superconductivity. H\({}_{3}\)S represents the Hydrogen-based superconductors. Fig. 7(b) shows that both H and S are important for superconductivity and the three hydrogen atoms are of different importance. The hydrogen atoms that are closer to the S is more crucial which is consistent to previous experimental results that with higher pressure, the atoms in a crystal are closer, which can cause the superconductivity. Sr\({}_{2}\)CuClO\({}_{2}\) represents the superconductors based on Cuprate. Fig. 7(c) demonstrate that Cu and O are crucial atoms.

## 5 Conclusion

A new dataset, S2S, is built as a benchmark for future machine learning based superconductivity discovery. Based on S2S, a novel pre-trained neural network, S2Snet, is built for superconductivity prediction solely from their crystal structures. S2SNet leverages attention mechanism to model the interaction of atoms in the crystal cells. With the pre-training task, MLM, massive unlabeled data can be properly utilized for S2SNet to learn better representation of atoms under interactions. Indeed S2SNet outperforms other methods significantly no matter with or without pre-training. Furthermore, it is straightforward to extend S2SNet to predict other properties of crystals as well. We expect that S2S dataset and S2SNet could inspire the machine learning community to make more impact on AI for science and SDGs. Finally, the current dataset is still relatively small. Enriching S2S dataset will be our future work.

## Appendix A Potential Superconductors

Potential superconductors are shown in Table A1. Frequency of elements in materials that our model determines to be superconductors is shown in Fig. A1. Here, we predict whether a material has the potential to be superconducting, regardless of temperature and pressure.
