## 3 Materials and Method
### Proposed Method
#### 3.3.4 Synchronous Loss Function  
In deep learning and NLP tasks, the loss function is a crucial part of model training that defines the discrepancy between the model's output and the true labels. For models based on the transformer architecture, the cross-entropy loss is a common loss function that is widely applied in classification tasks. However, for specific tasks, including cyberattack behavior detection, more specialized loss functions are designed to improve model performance. The synchronous loss function described here aims to optimize the model's processing capability for complex tasks by synchronizing the loss incurred when processing multisource data. Compared to the cross-entropy loss, the synchronous loss function incorporates additional terms to harmonize the information processing and model learning synchronization between different data sources. Assuming that the model's predicted output is \(\hat{y}\) and that the true label is \(y\), the traditional cross-entropy loss is expressed as  
\[L_{CE}=-\sum_{i}y_{i}\log(\hat{y}_{i}), \tag{16}\]  
where \(i\) represents the index of categories and \(y_{i}\) and \(\hat{y}_{i}\) are the probabilities of the true label and predicted output for the \(i\)th category, respectively. Building on this, the synchronous loss function introduces an additional synchronization term \(L_{sync}\) to enhance the model's synchronicity and coordination when processing different data sources. The design of the synchronization term is based on the consistency between the model output and the cross-data source synchronization signals, specifically expressed as follows:  
\[L_{sync}=\sum_{j}\lVert F(\hat{y}_{j})-S_{j}\rVert_{2}^{2} \tag{17}\]  
where \(j\) represents the index of different data sources, \(F(\hat{y}_{j})\) is the synchronization signal generated based on the model output \(\hat{y}_{j}\), \(S_{j}\) is the actual synchronization signal from other data sources, and \(\lVert\cdot\rVert_{2}^{2}\) denotes the L2 norm. Therefore, the total expression for the synchronous loss function is  
\[L_{total}=L_{CE}+\lambda L_{sync}, \tag{18}\]  
where \(\lambda\) is a tuning parameter used to balance the impact of the cross-entropy loss and the synchronization term. The design of the synchronous loss function is based on the following considerations:  
1. It improves the model's synchronicity when processing multisource data. In complex tasks such as cyberattack behavior detection, different data sources may have inherent connections and complementary information. The \(L_{sync}\) term encourages the model to maintain consistency and coordination when processing different data sources, allowing it to make better use of cross-data source information.
2. It enhances the model's generalization ability by promoting consistency between the model output and cross-data source synchronization signals. This helps the model to capture the commonalities between different data sources, improving its generalization ability for unseen data.  
Overall, the design of the synchronous loss function aims to enhance the model's capability to process complex multisource data, which is particularly suitable for tasks such as cyberattack behavior detection that require comprehensive utilization of various data sources. By introducing a synchronization term into the loss function, the model can better coordinate and synchronize the information processing of different data sources during learning, improving its detection accuracy and efficiency.