## 3 Materials and Methods
### Loss Function  
For entity extraction, the task involves extracting the heads and tails of subjects and objects for a specific relation. This model employs a sparse version of the multi-label cross-entropy loss function, which compares the scores of target categories with non-target categories to balance the weight of each category and address the issue of class imbalance [39]. The sparse version of the function reduces the transmission cost by only transmitting the indices corresponding to positive classes, instead of transmitting all the negative classes. The formula for this method is represented as follows:  
\[\begin{split}\mathrm{L}=\log(1+\sum\limits_{i\in\mathrm{P}} \mathrm{e}^{-\mathrm{s}_{i}})+\log(1+\sum\limits_{i\in\mathrm{N}}\mathrm{e}^{ \mathrm{s}_{i}})\\ =\log(1+\sum\
olimits_{i\in\mathrm{P}}\mathrm{e}^{-\mathrm{s}_{i }})+\log(1+\sum\
olimits_{i\in\mathrm{A}}\mathrm{e}^{\mathrm{s}_{i}})+\log(1- \mathrm{e}^{\log(\sum\
olimits_{i\in\mathrm{P}}\mathrm{e}^{\mathrm{s}_{i}})- \log(1+\sum\
olimits_{i\in\mathrm{A}}\mathrm{e}^{\mathrm{s}_{i}})})\end{split} \tag{10}\]  
where \(\mathrm{L}\) represents the loss of the global pointer network decoding module, \(\mathrm{P}\) and \(\mathrm{N}\) are the sets of positive and negative classes, \(\mathrm{A}=\mathrm{P}\cup\mathrm{N}\), and \(\mathrm{P}\) calculates the loss corresponding to negative classes, while the loss for positive classes remains unchanged. \(\mathrm{S}_{i}\) denotes the predicted value for the \(\mathrm{i}\)th position in the label. The entity extraction task is divided into entity extraction, extraction of subject heads for a specific relation, and extraction of object tails for a specific relation. Since these three tasks are similar, they all use Formula (10) for the loss function. Therefore, the total loss combines the loss functions of the three tasks directly, as follows:  
\[\mathrm{L}_{\mathrm{GP}}=\mathrm{L}_{\mathrm{GP\_entity}}+\mathrm{L}_{ \mathrm{GP\_head}}+\mathrm{L}_{\mathrm{GP\_tail}} \tag{11}\]  
where \(\mathrm{L}_{\mathrm{GP}}\) represents the total loss, \(\mathrm{L}_{\mathrm{GP\_entity}}\) represents the loss value for entity extraction, \(\mathrm{L}_{\mathrm{GP\_head}}\) represents the loss value for the head entity based on a specific relation, and \(\mathrm{L}_{\mathrm{GP\_tail}}\) represents the loss value for the tail entity based on a specific relation.  
For the relation filtering task, a cross-entropy loss function is employed:\[\mathrm{L_{rel}}=-\frac{1}{k}\sum_{i=1}^{k}[y_{i}\mathrm{log}(P_{i}^{r})+(1-y_{i}) \mathrm{log}(1-P_{i}^{r})] \tag{12}\]  
where \(\mathrm{L_{rel}}\) denotes the loss of the relation filtering decoding module and K represents the total number of relations in the predefined relation set. \(y_{i}\) represents the true label of the relation r, and \(P_{i}^{r}\) represents the probability corresponding to the ith relation.  
Since entity extraction and relation filtering are distinct tasks, this research adopts a loss function optimization strategy using the uncertainty weighting method from reference [32] to adaptively adjust the weights of the loss functions for these two tasks. This strategy allows the weights of the loss functions for the two tasks to be adaptively adjusted, based on maximizing the likelihood of Gaussian uncertainty with the same variance. Tasks with low noise and high certainty are assigned higher weights, enabling adaptive weight adjustments during model training and thereby saving time on parameter tuning. The derived multi-task loss function is as follows:  
\[\mathrm{L}(W,\Sigma_{1},\Sigma_{2})=\frac{1}{\Sigma_{1}^{2}}\mathrm{L_{GP}}( W)+\frac{1}{\Sigma_{2}^{2}}\mathrm{L_{REL}}(W)+\mathrm{LOG}\Sigma_{1}\Sigma_{2} \tag{13}\]  
where \(\sigma_{1}\) and \(\sigma_{2}\) represent the noise parameters for the entity relation extraction by the global pointer and for the relation filtering.