Domain-specific or Uncertainty-aware models: Does it really make a difference for biomedical text classification?
Abstract
The success of pretrained language models (PLMs) across a spate of use-cases has led to significant investment from the NLP community towards building domain-specific foundational models. On the other hand, in mission critical settings such as biomedical applications, other aspects also factor in—chief of which is a model’s ability to produce reasonable estimates of its own uncertainty. In the present study, we discuss these two desiderata through the lens of how they shape the entropy of a model’s output probability distribution. We find that domain specificity and uncertainty awareness can often be successfully combined, but the exact task at hand weighs in much more strongly.
Domain-specific or Uncertainty-aware models: Does it really make a difference for biomedical text classification?
Aman Sinha,, Timothee Mickus, Marianne Clausel, Mathieu Constant and Xavier Coubez Université de Lorraine, Nancy, France University of Helsinki, Helsinki, Finland Institut de Cancérologie, Strasbourg, France Correspondence: [email protected]
1 Introduction
Deep-learning models are trained with data-driven approaches to maximize prediction accuracy Goodfellow et al. (2016). This entails several well-documented pitfalls, ranging from closed-domain limitations Daume III and Marcu (2006) to social systemic biases McCoy et al. (2019); Schnabel et al. (2016). These limitations compound to a severe deterioration of model performances in out-of-domain (OOD) scenarios Hurd et al. (2013); Shah et al. (2020). This has led to engineering efforts towards developing models tailored to specific domains, ranging from the legal (Paul et al., 2023) to the biomedical (Lee et al., 2020; Singhal et al., 2023) ones.
Domain-specific models, while useful, are rarely considered as a definitive answer. Crucially, in the biomedical domain, experts require more reliability from these models—in particular, insofar as accounting for uncertainty in prediction is concerned. For example, in the case of a risk scoring model used to rank patients for live transplant, uncertainty-awareness becomes critical. The lack of uncertainty-aware models may lead to improper allocation of medical resources Steyerberg et al. (2010). Such concerns exemplify the importance of uncertainty aware models and its critical role in model selection.
The compatibility of domain-specific pretraining and uncertainty modeling appears under-assessed. To illustrate this, one can consider the entropy of output distributions: Domain-specific pretraining will lead to more probability mass assigned to a single (hopefully correct) estimate, leading to a lower entropy; whereas uncertainty-aware designs intend to not neglect valid alternatives—meaning that the probability mass should be spread out, which entails a higher entropy when uncertainty is due.
Uncertainty-unaware | Uncertainty-aware | |
General-domain |
||
Domain-specific |
Dataset | Task Description | Splits | Statistics | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
train | val | test | #Class | CIR | avglen | maxlen | |||||
\worldflag
US |
MedABS | Predict the patient condition described, given a medical abstract | 8662 | 2888 | 2888 | 5 | 3.1445 | 180.59 | 597 | ||
\worldflag
US |
MedNLI | Predict the inference type, given a hypothesis and a premise | 11232 | 1395 | 1422 | 3 | 1 | 23.83 | 151 | ||
\worldflag
US |
SMOKING | Predict the patient smoking status, given a medical discharge record | 398 | 100 | 104 | 5 | 23.75 | 654.30 | 2788 | ||
\worldflag
FR |
PxSLU | Predict the drug prescription intent, given a user speech transcription | 1386 | 198 | 397 | 4 | 98.1538 | 11.40 | 48 | ||
\worldflag
FR |
MedMCQA | Predict the number of answers, given a medical multi-choice question | 2171 | 312 | 622 | 5 | 21.1176 | 12.90 | 92 | ||
\worldflag
FR |
MORFITT | Predict the speciality, given a scientific article abstract | 1514 | 1022 | 1088 | 12 | 15.3529 | 226.33 | 1425 |
In this work, we reflect on how model-specificity and uncertainty-awareness articulate with one another. Figure 1 illustrates the experimental setup we use for our study. In practice, we study the performances of frequentist and Bayesian general and domain-specific models on biomedical text classification tasks across a wide array of metrics, ranging from macro F1 to SCE, with a specific focus on entropy Ruder and Plank (2017); Kuhn et al. (2023). More narrowly, we study the following research questions: RQ1: Are the benefits of uncertainty-awareness and domain-specificity orthogonal? RQ2: Given our benchmarking results, should medical practitioners prioritize domain-specificity or uncertainty-awareness?
2 Related Work
Recently, uncertainty quantification has gained attention from the NLP community Xiao and Wang (2019); Xiao et al. (2022); Hu et al. (2023)—particularly in mission critical settings, such as in the medical domain Hwang et al. (2023); Barandas et al. (2024). In parallel, compared to domain adaptation approaches Wiese et al. (2017) for the medical domain, there is a growing interest in domain-specific language models starting from BioBERT Lee et al. (2020) to the recent MedPalM Singhal et al. (2023). Xiao et al. (2022) presented an elaborate study of uncertainty paradigm for general-domain PLMs. While uncertainty modeling has been applied to biomedical data previously (e.g., Begoli et al., 2019; Abdar et al., 2021), surprisingly little has been done for biomedical textual data. Therefore, our study precisely focuses on the interaction between the two paradigms for medical domain NLP tasks. We address this gap by focusing specifically on predictive entropy Ruder and Plank (2017); Kuhn et al. (2023).
3 Methodology
Datasets.
We conduct experiments on six standard biomedical datasets: three English datasets, viz. MedABS Schopf et al. (2023), MedNLI Romanov and Shivade and SMOKING Uzuner et al. (2008); as well as three French datasets, viz. MORFITT Labrak et al. (2023b), PxSLU Kocabiyikoglu et al. (2022) and MedMCQA Labrak et al. (2023a).
For MEDABS, SMOKING, PxSLU, and MEDMCQA, we do not perform any special preprocessing. For MEDMCQA, we perform Task 2, i.e., predicting the number of possible responses (ranging from 1-5) for the input multi choice question. For MEDNLI, we concatenate the statement and hypothesis using the [SEP] token and use it as an input converting it to a multi-class task. For MORFITT, which is originally a multi-label classification task, we use the first label for each sample to convert it to a multi-class problem. The descriptive statistics of these datasets are listed in Table 1, along with class imbalance ratio (CIR; Yu et al., 2022). See Appendix A.4 for more information.
Models.
We derive classifiers from language-specific PLMs: for English datasets, we use BERT Devlin et al. (2018) and BioBERT Lee et al. (2020); for French, we use CamemBERT Martin et al. (2019) and CamemBERT-bio Touchent et al. (2023). We compare two types of models, frequentist deep learning models (DNN) and Bayesian deep learning models (BNNs). The DNN model comprises of a PLM-based encoder, a Dropout unit along with 1-layer classifier. The BNN models are likewise based on a PLM encoder, along with a Bayesian module applied over the classification layer. We also experimented with MC-dropout models Gal and Ghahramani (2016), DropConnect Mobiny et al. (2021), and variational inference Blundell et al. (2015) models. We focus111 We justify our focus on DropConnect empirically, as it yielded the highest validation F1 scores on average in our case. See Sections A.1 and B for details. All main text results for uncertainty-aware classifiers pertain to DropConnect. on the DropConnect architecture which comprises a PLM encoder along a DropConnect dense classification layer. This approach infuses stochasticity into a deterministic model by randomly zeroing out classifier weights with probability . This allows us to sample multiple outputs for a given input, thus enabling to aggregate the predictions and to produce estimates of uncertainty.
For simplicity, we note domain-specific models as (and general models ); uncertainty aware models are referred to as (with frequentist models noted ). We replicate training across 10 seeds per model and dataset; further implementation details can be found in Section A.2.
Evaluation Setup.
We evaluate classifiers on two aspects: task performance and uncertainty awareness. For text classification, we report Macro-F1 and accuracy. For uncertainty quantification we report Brier score (BS; Brier, 1950), Expected Calibration Error (ECE; Naeini et al., 2015), Static Calibration Error (SCE; Nixon et al., 2019), Negative log likelihood (NLL), coverage (Cov%) and entropy (). See Section A.3 for definitions.
![Refer to caption](x5.png)
![Refer to caption](x6.png)
![Refer to caption](x7.png)
4 Results
![Refer to caption](x8.png)
![Refer to caption](x9.png)
![Refer to caption](x10.png)
![Refer to caption](x11.png)
![Refer to caption](x12.png)
![Refer to caption](x13.png)
![Refer to caption](x14.png)
![Refer to caption](x15.png)
Performance.
All results are listed in Table 5 in Appendix B, we highlight some key metrics in Figure 2. Insofar as classification metrics go, configurations outperform ones. More generally, as all scores are highly dependent on the exact dataset considered, we first de-trend them by -normalizing results on a per-dataset basis to simplify analysis. We find classifiers to be strong contenders, although they are often outperformed—especially by models on classification metrics (Figure 2b) and by models on calibration metrics (Figure 2c). As for entropy, we find both and to lead to lower scores. Trends are consistent across languages.
Relative importance.
To interpret results in Figure 2 more rigorously, we rely on SHAP Lundberg and Lee (2017). SHAP is an algorithm to compute heuristics for Shapley values (Shapley, 1953), viz. a game theoretical additive and fair distribution of a given variable to be explained across predetermined factors of interest. Here, we analyze the scores obtained by individual classifiers on all 8 metrics, and try to attribute their values (-normalized per dataset) to domain specificity (), uncertainty awareness () and the dataset one observation corresponds to (ds.).
Results are displayed in Figure 3; specific points correspond to weights assigned to one of the factors for one of the datapoints, factors are sorted from most to least impactful from top to bottom. We can see that which of domain specificity and uncertainty awareness has the strongest impact depends strictly on the metrics: Cases where is assigned on average a greater absolute weight than account for exactly half of the metrics we study. Another import trend is that effects tied to are also often attested for : if domain specificity is useful, then uncertainty awareness is as well.222 There are two notable exceptions: ECE and coverage, where we find to be detrimental. Variation across seeds might explain the discrepancy with Table 5. Lastly, weights assigned to both and are considerably smaller than those assigned to datasets, showcasing that these trends are often overpowered by the specifics of the task at hand.
![Refer to caption](x16.png)
Entropy.
A desideratum we laid out above is to have large entropy scores when the model is incorrect. Focusing on entropy, we display how it compares to the probability mass assigned to the target in Figure 4. In detail, we retrieve all predictions for every datapoint across all classifiers and then -normalize entropy scores and probability assigned the target class.333 When plotting entropy against probability mass assigned to the target class, we can keep in mind some useful points of reference. A perfect classifier that is always confidently correct should display a high probability mass and a low entropy (i.e., top left of our plot); what we hope to avoid is a confidently incorrect classifier (bottom left). As entropy and probability are statistically related, it is impossible to observe a high probability mass and a high entropy (top right). Lastly, assuming the classifier outputs continuous scores, this statistical dependency also dictates that probability mass and entropy be inversely correlated for correct predictions. We can see that incorrect predictions do result in more spread out entropy scores. Moreover, we can notice some tentative differences between the four types of classifiers of our study: Correct predictions from models seem to lead to an especially tight correlation between entropy and probability mass.
effect size | Spearman’s | |||||||
---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
MedABS | ||||||||
MedNLI | ||||||||
SMOKING | ||||||||
PxSLU | ||||||||
MedMCQA | ||||||||
MORFITT |
However, establishing whether this difference is significant requires further testing. We therefore measure whether incorrect predictions lead to higher entropy in two ways: (i) using Mann–Whitney U-tests, from which we derive a common language effect size (as the entropy of incorrect predictions should be higher);444All U-tests suggest entropy for incorrect predictions is significantly higher (). and (ii), by computing Spearman correlation coefficients between the entropy and the mass assigned to the target class (as entropy should degrade with correctness). Corresponding results are listed in Table 2: Across most of the datasets we study, the top or second most coherent distributions we observe are for domain-specific and uncertainty-aware models. However, we also observe that actual performances are highly sensitive to the exact classification task at hand.
5 Discussion & Conclusion
We can now answer our initial research questions.
RQ1: Are the benefits of uncertainty-awareness and domain-specificity orthogonal? We have seen in Table 2 that in most cases, using a classifier that was both domain-specific and uncertainty-aware led to the optimal distribution shape, with entropy more gracefully increasing with incorrectness.
RQ2: Should medical practitioners prioritize domain-specificity or uncertainty-awareness? SHAP attributions in Figure 3 strongly suggest that the evaluation metric dictates the strategy to follow. As one would expect, accuracy is better captured with domain-specific models, whereas uncertainty-aware models tend to be better calibrated.
We also found significant evidence throughout our experiments that the exact classification task at hand weighs in much more strongly than the design of the classifier. This extraneous factor necessarily complicates the relationship between domain-specificity and uncertainty-awareness: In a handful of cases in Figure 2, we observe classifiers that are neither uncertainty-aware nor domain specific faring best among all the models we survey—and conversely domain-specific uncertainty-aware classifiers can also rank dead last. This is also related to the often limited quantitative difference between best and worst models, which for instance can be as low as for F1 on MEDABS (cf. Table 5).
Overall, our experiments suggest a very nuanced conclusion. Domain-specificity and uncertainty-awareness do appear to shape classifiers’ distributions and their entropy in distinct but compatible ways, but they have a lesser impact than the task itself. Hence, while we can often combine uncertainty-awareness and domain-specificity, there are no out-of-the-box solutions, and optimal performances require careful application designs.
Acknowledgments
We thank Sami Virpioja for his comments on an early version of this work.
This work is supported by the ICT 2023 project “Uncertainty-aware neural language models” funded by the Academy of Finland (grant agreement № 345999).
References
- Abdar et al. (2021) Moloud Abdar, Farhad Pourpanah, Sadiq Hussain, Dana Rezazadegan, Li Liu, Mohammad Ghavamzadeh, Paul Fieguth, Xiaochun Cao, Abbas Khosravi, U. Rajendra Acharya, Vladimir Makarenkov, and Saeid Nahavandi. 2021. A review of uncertainty quantification in deep learning: Techniques, applications and challenges. Information Fusion, 76:243–297.
- Barandas et al. (2024) Marília Barandas, Lorenzo Famiglini, Andrea Campagner, Duarte Folgado, Raquel Simão, Federico Cabitza, and Hugo Gamboa. 2024. Evaluation of uncertainty quantification methods in multi-label classification: A case study with automatic diagnosis of electrocardiogram. Information Fusion, 101:101978.
- Begoli et al. (2019) Edmon Begoli, Tanmoy Bhattacharya, and Dimitri Kusnezov. 2019. The need for uncertainty quantification in machine-assisted medical decision making. Nature Machine Intelligence, 1(1):20–23.
- Blundell et al. (2015) Charles Blundell, Julien Cornebise, Koray Kavukcuoglu, and Daan Wierstra. 2015. Weight uncertainty in neural network. In International conference on machine learning, pages 1613–1622. PMLR.
- Brier (1950) Glenn W Brier. 1950. Verification of forecasts expressed in terms of probability. Monthly weather review, 78(1):1–3.
- Daume III and Marcu (2006) Hal Daume III and Daniel Marcu. 2006. Domain adaptation for statistical classifiers. Journal of artificial Intelligence research, 26:101–126.
- Devlin et al. (2018) Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. 2018. Bert: Pre-training of deep bidirectional transformers for language understanding. arXiv preprint arXiv:1810.04805.
- Gal and Ghahramani (2016) Yarin Gal and Zoubin Ghahramani. 2016. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pages 1050–1059. PMLR.
- Goodfellow et al. (2016) Ian Goodfellow, Yoshua Bengio, and Aaron Courville. 2016. Deep learning. MIT press.
- Hu et al. (2023) Mengting Hu, Zhen Zhang, Shiwan Zhao, Minlie Huang, and Bingzhe Wu. 2023. Uncertainty in natural language processing: Sources, quantification, and applications. arXiv preprint arXiv:2306.04459.
- Hurd et al. (2013) Michael D Hurd, Paco Martorell, Adeline Delavande, Kathleen J Mullen, and Kenneth M Langa. 2013. Monetary costs of dementia in the united states. New England Journal of Medicine, 368(14):1326–1334.
- Hwang et al. (2023) Jinha Hwang, Carol Gudumotu, and Benyamin Ahmadnia. 2023. Uncertainty quantification of text classification in a multi-label setting for risk-sensitive systems. In Proceedings of the 14th International Conference on Recent Advances in Natural Language Processing, pages 541–547.
- Kocabiyikoglu et al. (2022) Alican Kocabiyikoglu, François Portet, Prudence Gibert, Hervé Blanchon, Jean-Marc Babouchkine, and Gaëtan Gavazzi. 2022. A spoken drug prescription dataset in french for spoken language understanding. In 13th Language Resources and Evaluation Conference (LREC 2022).
- Kuhn et al. (2023) Lorenz Kuhn, Yarin Gal, and Sebastian Farquhar. 2023. Semantic uncertainty: Linguistic invariances for uncertainty estimation in natural language generation. arXiv preprint arXiv:2302.09664.
- Labrak et al. (2023a) Yanis Labrak, Adrien Bazoge, Richard Dufour, Mickael Rouvier, Emmanuel Morin, Béatrice Daille, and Pierre-Antoine Gourraud. 2023a. Frenchmedmcqa: A french multiple-choice question answering dataset for medical domain. arXiv preprint arXiv:2304.04280.
- Labrak et al. (2023b) Yanis Labrak, Mickael Rouvier, and Richard Dufour. 2023b. MORFITT : Un corpus multi-labels d’articles scientifiques français dans le domaine biomédical. In 18e Conférence en Recherche d’Information et Applications – 16e Rencontres Jeunes Chercheurs en RI – 30e Conférence sur le Traitement Automatique des Langues Naturelles – 25e Rencontre des Étudiants Chercheurs en Informatique pour le Traitement Automatique des Langues, pages 66–70, Paris, France. ATALA.
- Lee et al. (2020) Jinhyuk Lee, Wonjin Yoon, Sungdong Kim, Donghyeon Kim, Sunkyu Kim, Chan Ho So, and Jaewoo Kang. 2020. Biobert: a pre-trained biomedical language representation model for biomedical text mining. Bioinformatics, 36(4):1234–1240.
- Lundberg and Lee (2017) Scott M Lundberg and Su-In Lee. 2017. A unified approach to interpreting model predictions. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems 30, pages 4765–4774. Curran Associates, Inc.
- Martin et al. (2019) Louis Martin, Benjamin Muller, Pedro Javier Ortiz Suárez, Yoann Dupont, Laurent Romary, Éric Villemonte de La Clergerie, Djamé Seddah, and Benoît Sagot. 2019. Camembert: a tasty french language model. arXiv preprint arXiv:1911.03894.
- McCoy et al. (2019) R Thomas McCoy, Ellie Pavlick, and Tal Linzen. 2019. Right for the wrong reasons: Diagnosing syntactic heuristics in natural language inference. arXiv preprint arXiv:1902.01007.
- Mobiny et al. (2021) Aryan Mobiny, Pengyu Yuan, Supratik K Moulik, Naveen Garg, Carol C Wu, and Hien Van Nguyen. 2021. Dropconnect is effective in modeling uncertainty of bayesian deep networks. Scientific reports, 11(1):5458.
- Naeini et al. (2015) Mahdi Pakdaman Naeini, Gregory Cooper, and Milos Hauskrecht. 2015. Obtaining well calibrated probabilities using bayesian binning. In Proceedings of the AAAI conference on artificial intelligence, volume 29.
- Nixon et al. (2019) Jeremy Nixon, Michael W Dusenberry, Linchuan Zhang, Ghassen Jerfel, and Dustin Tran. 2019. Measuring calibration in deep learning. In CVPR workshops, volume 2.
- Paul et al. (2023) Shounak Paul, Arpan Mandal, Pawan Goyal, and Saptarshi Ghosh. 2023. Pre-trained language models for the legal domain: A case study on indian law. In Proceedings of the Nineteenth International Conference on Artificial Intelligence and Law, ICAIL ’23, page 187–196, New York, NY, USA. Association for Computing Machinery.
- (25) Alexey Romanov and Chaitanya Shivade. Lessons from natural language inference in the clinical domain.
- Ruder and Plank (2017) Sebastian Ruder and Barbara Plank. 2017. Learning to select data for transfer learning with Bayesian optimization. In Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing, pages 372–382, Copenhagen, Denmark. Association for Computational Linguistics.
- Schnabel et al. (2016) Tobias Schnabel, Adith Swaminathan, Ashudeep Singh, Navin Chandak, and Thorsten Joachims. 2016. Recommendations as treatments: Debiasing learning and evaluation. In international conference on machine learning, pages 1670–1679. PMLR.
- Schopf et al. (2023) Tim Schopf, Daniel Braun, and Florian Matthes. 2023. Evaluating unsupervised text classification: Zero-shot and similarity-based approaches. In Proceedings of the 2022 6th International Conference on Natural Language Processing and Information Retrieval, NLPIR ’22, page 6–15, New York, NY, USA. Association for Computing Machinery.
- Shah et al. (2020) Harshay Shah, Kaustav Tamuly, Aditi Raghunathan, Prateek Jain, and Praneeth Netrapalli. 2020. The pitfalls of simplicity bias in neural networks. Advances in Neural Information Processing Systems, 33:9573–9585.
- Shapley (1953) Lloyd S Shapley. 1953. A value for n-person games. In Harold W. Kuhn and Albert W. Tucker, editors, Contributions to the Theory of Games II, pages 307–317. Princeton University Press, Princeton.
- Singhal et al. (2023) K. Singhal, Tao Tu, Juraj Gottweis, Rory Sayres, Ellery Wulczyn, Le Hou, Kevin Clark, Stephen R. Pfohl, Heather J. Cole-Lewis, Darlene Neal, Mike Schaekermann, Amy Wang, Mohamed Amin, S. Lachgar, P. A. Mansfield, Sushant Prakash, Bradley Green, Ewa Dominowska, Blaise Agüera y Arcas, Nenad Tomašev, Yun Liu, Renee C Wong, Christopher Semturs, Seyedeh Sara Mahdavi, Joëlle K. Barral, Dale R. Webster, Greg S Corrado, Yossi Matias, Shekoofeh Azizi, Alan Karthikesalingam, and Vivek Natarajan. 2023. Towards expert-level medical question answering with large language models. ArXiv, abs/2305.09617.
- Steyerberg et al. (2010) Ewout W Steyerberg, Andrew J Vickers, Nancy R Cook, Thomas Gerds, Mithat Gonen, Nancy Obuchowski, Michael J Pencina, and Michael W Kattan. 2010. Assessing the performance of prediction models: a framework for traditional and novel measures. Epidemiology, 21(1):128–138.
-
Touchent et al. (2023)
Rian Touchent, Laurent Romary, and Eric De La Clergerie. 2023.
CamemBERT-bio : Un
modèle de langue français savoureux et meilleur pour la santé.
In 18e Conférence en Recherche d’Information et
Applications
16e Rencontres Jeunes Chercheurs en RI
30e Conférence sur le Traitement Automatique des Langues Naturelles
25e Rencontre des Étudiants Chercheurs en Informatique pour le Traitement Automatique des Langues, pages 323–334, Paris, France. ATALA. - Uzuner et al. (2008) Özlem Uzuner, Ira Goldstein, Yuan Luo, and Isaac Kohane. 2008. Identifying patient smoking status from medical discharge records. Journal of the American Medical Informatics Association, 15(1):14–24.
- Wiese et al. (2017) Georg Wiese, Dirk Weissenborn, and Mariana Neves. 2017. Neural domain adaptation for biomedical question answering. arXiv preprint arXiv:1706.03610.
- Xiao and Wang (2019) Yijun Xiao and William Yang Wang. 2019. Quantifying uncertainties in natural language processing tasks. In Proceedings of the AAAI conference on artificial intelligence, volume 33, pages 7322–7329.
- Xiao et al. (2022) Yuxin Xiao, Paul Pu Liang, Umang Bhatt, Willie Neiswanger, Ruslan Salakhutdinov, and Louis-Philippe Morency. 2022. Uncertainty quantification with pre-trained language models: A large-scale empirical analysis. arXiv preprint arXiv:2210.04714.
- Yu et al. (2022) Sihao Yu, Jiafeng Guo, Ruqing Zhang, Yixing Fan, Zizhen Wang, and Xueqi Cheng. 2022. A re-balancing strategy for class-imbalanced classification based on instance difficulty. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 70–79.
![Refer to caption](x17.png)
Appendix A Experimental details
A.1 Supplementary Bayesian models
We include the details for two more Bayesian models: MC-dropout and variational inference. Note that for all the Bayesian models we sample K=3 predictions at inference and use the mean prediction.
MCDropout (MCD)
This model is based on a PLM encoder, similar to the main study models. The difference in this case is that Stochastic Dropout is applied over the classification layer. MCD Gal and Ghahramani (2016) proposes to extend the usage of Dropout but at inference time enabling it to sample a multiple models, to make predictions. The final prediction in the case of classification model can denoted as
.
Variational inference (VI)
This model is based on a PLM encoder, similar to the main study models, with variational inference dense layer as the classification layer. We use the Bayes by BackProp Blundell et al. (2015) for the VI Dense layer. It approximates the distribution of each weight with a Gaussian distribution with parameter . The weights are approximated with Monte Carlo gradient. Finally, the predictions are computed using the predictive posterior distribution, by sampling K weight instances and making one forward pass per set of weights same as MCD.
A.2 Implementation details
We use keras-uncertainty models for implementing our BNN model backbones.
Models | MedABS | MedNLI | SMOKING | PxSLU | MedMCQA | MORFITT | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
lr | E | lr | E | lr | E | lr | E | lr | E | lr | E | |||||||
DNN | 1e-5 | 4 | 5e-6 | 12 | 1e-4 | 15 | 5e-6 | 15 | 5e-6 | 14 | 5e-5 | 15 | ||||||
DC | 5e-6 | 7 | 1e-5 | 11 | 1e-5 | 15 | 5e-6 | 13 | 5e-6 | 15 | 5e-5 | 13 | ||||||
MCD | 5e-5 | 5 | 5e-6 | 15 | 5e-5 | 15 | 1e-5 | 14 | 5e-6 | 11 | 5e-5 | 10 | ||||||
VI | 5e-6 | 7 | 1e-5 | 14 | 5e-6 | 13 | 5e-6 | 14 | 1e-6 | 15 | 5e-5 | 13 | ||||||
DNN | 1e-5 | 4 | 1e-5 | 14 | 5e-5 | 15 | 1e-5 | 15 | 1e-5 | 10 | 5e-5 | 15 | ||||||
DC | 5e-5 | 3 | 1e-5 | 13 | 1e-4 | 13 | 1e-5 | 15 | 5e-6 | 15 | 5e-5 | 13 | ||||||
MCD | 5e-5 | 3 | 5e-5 | 12 | 5e-5 | 10 | 1e-5 | 14 | 1e-5 | 15 | 5e-5 | 13 | ||||||
VI | 1e-5 | 5 | 5e-6 | 13 | 5e-5 | 14 | 1e-5 | 14 | 1e-6 | 15 | 5e-5 | 5 |
Hyperparameter Setting
In all cases, we fine-tune the PLM backbone for all the downstream task with a maximum sequence length of 512 and a batch size of 50 sentences. We perform a grid hyper-parameter search for epochs= {3,4,5, ..., 15} and lr= {1e-7, 5e-6, 1e-6, 5e-5, 1e-5, 5e-4, 1e-4}. We replicate training with 3 seeds for each hyperparameter configuration, select the optimal configuration for validation F1, and replicate training with 7 more seeds for these optimal configurations, so as to obtain 10 models per dataset, PLM and architecture. We also select the main BNN model of the study by selecting the system yielding the highest average rank across all six datasets, as displayed in Figure 5.
We train all models with binary cross entropy loss and Adam optimizer with and . For all BNN models, we obtain 3 sets of predictions after training the models to calculate the mean class probabilities. Corresponding optimal hyperparameters are listed in table 3.
A.3 Calibration metrics definition
In what follows, denotes the number of samples in test set, denotes the number of classes. Lower score for Brier score, ECE, SCE, NLL and Entropy metrics; and higher score for coverage, are indicative of better uncertainty aware model.
Brier score.
Brier (1950) proposed BS which computes the mean square difference between the true classes and the predicted probabilities.
Expected Calibration Error.
Naeini et al. (2015) provides weighted average of the difference between accuracy and confidence across bins.
where acc and conf are the average accuracy and confidence of predictions in bin , respectively. We set in our experiments.
Static Calibration Error.
Nixon et al. (2019) proposed an extension of ECE to multi-class problems to overcome its limitation of dependence of the number of bins.
We set in our experiments.
Negative Log Likelihood.
serves as the primary approach for optimizing neural networks in classification tasks. Interestingly, this loss function can also double as an effective metric for assessing uncertainty.
Coverage Percentage.
The normalized form of number of times the correct class in indeed contain within the prediction set.
Shannon Entropy.
quantifies the expected uncertainty inherent in the possible outcomes of a discrete random variable.
A.4 Dataset
We provided supplementary details about each dataset we used in Table 4.
Dataset | Sample | Classes | Label Distribution | |
---|---|---|---|---|
MedABS Schopf et al. (2023) | {text: "Catheterization of coronary artery bypass graft from the descending aorta. The increasing frequency of reoperation for coronary artery disease has led to the use of a variety of grafts. This report describes the catheter technique for selective opacification of a saphenous vein graft from the descending thoracic aorta to the posterior coronary circulation. ", label: "Cardiovascular diseases" } | {’Neoplasms’, ’Digestive system’, ’Nervous system’, ’Cardiovascular’, ’General pathological’ } | [1925 913 1149 1804 2871] | |
MedNLI Romanov and Shivade | {text: "No history of blood clots or DVTs, has never had chest pain prior to one week ago. [SEP] Patient has angina", label: "entailment"} | {"entailment", "contradict", "neutral" } | [3744 3744 3744] | |
SMOKING Uzuner et al. (2008) | {text: "071962960 bh 4236518 417454 12/10/2001 12:00:00 am discharge summary unsigned dis report status : unsigned discharge summary name : sterpsap , ny unit number : 582-96-88 admission date : 12/10/2001 discharge date : 12/19/2001 principal diagnosis : prosthetic aortic valve dysfunction associated diagnoses : aortic valve insufficiency bacterial endocarditis , active principal procedure : urgent re-do aortic valve replacement and correction of left ventricular to aortic discontinuity . ( 12/13/2001 ) other procedures : aortic root aortogram ( 12/12/2001 ) cardiac ultrasound ( 12/13/2001 ) insertion dual chamber pacemaker ( 12/15/2001 ) picc line placement ( 12/18/2001 ) history and reason for hospitalization : mr. sterpsap …", label: "CURRENT SMOKER"} | {’CURRENT SMOKER’, ’NON-SMOKER’, ’PAST SMOKER’, ’SMOKER’, ’UNKNOWN’ } | [ 27 49 24 8 190] | |
MEDMCQA Labrak et al. (2023a) | {text: "ans la liste suivante, quels sont les antibiotiques utilisables pour traiter une salmonellose chez un adulté?", label: 2} | {1,2,3,4,5} | [595 528 718 296 34] | |
MORFITT Labrak et al. (2023b) | {text: "La survenue de complications postopératoires représente un cauchemar (bien réel), tant pour le patient que pour son chirurgien. Dès lors, quoi de plus fantasmagorique que d’administrer une « potion magique » au patient avant l’intervention pour éliminer ce risque ? Le but de cet article est de résumer l’état des connaissances actuelles concernant les bénéfices potentiels, liés à l’administration d’immunonutrition aux patients traités pour cancer urologique…..", original_label: [ "Immunologie","Chirurgie",], label: "Immunologie"} | {’Vétérinaire’, ’Étiologie’, ’Psychologie’, ’Chirurgie’, ’Génétique’, ’Physiologie’, ’Pharmacologie’, ’Microbiologie’, ’Immunologie’, ’Chimie’, ’Virologie’, ’Parasitologie’ } | [ 82 261 32 122 40 17 152 39 242 185 104 238] | |
PxSLU Kocabiyikoglu et al. (2022) | {text: "antacapone 200 milligrammes 2 comprimés le matin 1 comprimé à midi 2 comprimé le soir traitement pour une durée totale de 4 semaines", label: "medical_prescription"} | {"medical_prescription", "negate","replace", "none" } | [1276 15 82 13] |
Model | Classification | Uncertainty | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Macro-F1() | Accuracy() | BS() | ECE() | SCE() | NLL() | Cov%() | Entropy() | ||||
MedABS \worldflag US | DNN | 60.36330.003 | 60.97650.002 | 0.55350.008 | 0.13870.016 | 0.06830.004 | 1.32610.001 | 0.89760.013 | 1.55790.002 | ||
DC | 60.98550.004 | 61.18420.003 | 0.55180.002 | 0.13420.007 | 0.06740.003 | 1.31920.002 | 0.96110.003 | 1.55560.001 | |||
MCD | 60.69790.004 | 60.09930.006 | 0.56910.015 | 0.15030.014 | 0.06880.01 | 1.32350.008 | 0.94010.013 | 1.55420.002 | |||
VI | 60.87250.001 | 61.16110.001 | 0.55310.006 | 0.13940.004 | 0.06950.003 | 1.31640.003 | 0.9580.001 | 1.55410.001 | |||
DNN | 60.80770.013 | 61.33430.01 | 0.54990.014 | 0.14480.005 | 0.06950.001 | 1.32010.014 | 0.91930.005 | 1.55610.003 | |||
DC | 62.56420.009 | 62.10180.01 | 0.52430.015 | 0.13810.016 | 0.06240.007 | 1.29620.007 | 0.95970.008 | 1.55230.002 | |||
MCD | 62.20380.022 | 62.13070.022 | 0.52260.031 | 0.12380.031 | 0.05930.015 | 1.30560.013 | 0.96660.01 | 1.55620.002 | |||
VI | 63.18930.004 | 63.16940.003 | 0.52340.009 | 0.14640.01 | 0.06530.003 | 1.2880.006 | 0.96030.005 | 1.54910.002 | |||
MedNLI \worldflag US | DNN | 73.89510.013 | 73.83970.015 | 0.39760.006 | 0.12780.02 | 0.08460.012 | 0.81770.015 | 0.91190.008 | 1.01560.008 | ||
DC | 74.81610.019 | 74.87110.018 | 0.42420.021 | 0.1850.007 | 0.12590.005 | 0.79450.014 | 0.85090.007 | 0.99410.002 | |||
MCD | 72.88960.03 | 73.01920.03 | 0.41630.009 | 0.12140.049 | 0.08650.03 | 0.82980.037 | 0.91090.04 | 1.01710.02 | |||
VI | 73.08160.022 | 73.13640.022 | 0.44260.016 | 0.1850.023 | 0.12650.015 | 0.81090.022 | 0.8570.035 | 0.99830.011 | |||
DNN | 77.1720.041 | 77.23860.039 | 0.37830.05 | 0.15790.009 | 0.1070.007 | 0.77360.039 | 0.8570.015 | 0.99520.008 | |||
DC | 79.99450.037 | 80.00470.037 | 0.33750.045 | 0.13920.005 | 0.09560.002 | 0.74860.041 | 0.88720.011 | 0.99240.011 | |||
MCD | 80.10220.014 | 80.16880.014 | 0.34530.02 | 0.15650.009 | 0.10650.005 | 0.74370.012 | 0.86540.004 | 0.98720.001 | |||
VI | 77.06170.043 | 77.10270.042 | 0.3510.046 | 0.10410.019 | 0.07730.01 | 0.78510.046 | 0.92930.025 | 1.01010.015 | |||
SMOKING \worldflag US | DNN | 27.11410.041 | 45.83330.142 | 0.77240.054 | 0.29610.057 | 0.1540.012 | 1.42980.106 | 0.77240.163 | 1.55360.028 | ||
DC | 25.79240.041 | 46.79490.039 | 0.64070.035 | 0.16250.043 | 0.12150.016 | 1.43310.035 | 0.94550.031 | 1.57910.01 | |||
MCD | 26.7070.058 | 45.83330.073 | 0.76090.077 | 0.27710.048 | 0.15070.021 | 1.45190.045 | 0.89420.058 | 1.56510.003 | |||
VI | 23.44850.034 | 32.05130.043 | 0.71970.053 | 0.21710.021 | 0.150.023 | 1.50310.038 | 0.89740.113 | 1.58870.004 | |||
DNN | 24.98220.041 | 51.60260.071 | 0.67640.076 | 0.22620.013 | 0.13340.031 | 1.39280.068 | 0.65710.114 | 1.55960.011 | |||
DC | 27.02930.033 | 47.11540.075 | 0.8410.043 | 0.34410.053 | 0.17380.007 | 1.42970.06 | 0.72760.118 | 1.54190.02 | |||
MCD | 25.00290.051 | 40.38460.058 | 0.67770.022 | 0.2060.019 | 0.14010.014 | 1.4820.014 | 0.94870.04 | 1.58950.003 | |||
VI | 26.11670.03 | 50.32050.094 | 0.7650.175 | 0.32010.094 | 0.15840.045 | 1.38570.094 | 0.750.063 | 1.53970.003 | |||
PxSLU \worldflag FR | DNN | 32.25410.075 | 88.24520.012 | 0.57430.077 | 0.45560.094 | 0.29550.014 | 1.28070.05 | 0.9950.004 | 1.38210.003 | ||
DC | 34.14640.026 | 84.29890.05 | 0.45990.088 | 0.39360.047 | 0.23540.03 | 1.21540.062 | 1.00.0 | 1.37680.007 | |||
MCD | 33.2110.067 | 88.69020.018 | 0.52320.103 | 0.48520.079 | 0.26150.027 | 1.25710.062 | 1.00.0 | 1.38060.004 | |||
VI | 25.98830.041 | 88.91690.013 | 0.53930.021 | 0.50140.026 | 0.25520.007 | 1.26660.014 | 1.00.0 | 1.38140.001 | |||
DNN | 33.11310.097 | 80.17630.238 | 0.53890.116 | 0.39290.057 | 0.28670.037 | 1.25480.06 | 0.98310.018 | 1.380.003 | |||
DC | 40.33720.07 | 89.11840.039 | 0.26490.127 | 0.25760.105 | 0.15680.058 | 1.05390.111 | 0.99970.001 | 1.34960.021 | |||
MCD | 34.15710.029 | 89.14360.026 | 0.54030.043 | 0.50740.015 | 0.26630.013 | 1.26940.026 | 1.00.0 | 1.38210.002 | |||
VI | 41.82790.073 | 91.09990.015 | 0.16340.051 | 0.14030.064 | 0.08610.029 | 0.94640.066 | 0.99580.004 | 1.32460.019 | |||
MEDMCQA \worldflag FR | DNN | 28.57270.03 | 63.880.055 | 0.67870.1 | 0.32560.043 | 0.15750.021 | 1.53470.062 | 0.96250.033 | 1.60630.003 | ||
DC | 32.02910.003 | 63.55840.007 | 0.48220.015 | 0.1650.01 | 0.10990.0 | 1.38460.009 | 0.97640.007 | 1.58880.001 | |||
MCD | 28.36480.029 | 61.36120.103 | 0.75330.044 | 0.38190.084 | 0.15180.02 | 1.58480.024 | 1.00.0 | 1.60910.0 | |||
VI | 23.19770.042 | 48.55310.046 | 0.74990.023 | 0.2420.033 | 0.13290.004 | 1.58220.013 | 1.00.0 | 1.60890.0 | |||
DNN | 28.15490.045 | 61.09320.089 | 0.68590.12 | 0.30260.009 | 0.15820.01 | 1.53880.077 | 0.97750.02 | 1.60640.004 | |||
DC | 29.75580.07 | 60.3430.103 | 0.66870.17 | 0.29730.069 | 0.12780.018 | 1.52160.122 | 0.98930.019 | 1.60250.012 | |||
MCD | 31.09120.016 | 68.43520.033 | 0.55410.115 | 0.31220.059 | 0.14770.031 | 1.45430.081 | 0.99360.011 | 1.59990.007 | |||
VI | 23.12430.035 | 49.85530.031 | 0.74150.017 | 0.23360.026 | 0.12220.008 | 1.57650.01 | 1.00.0 | 1.60850.0 | |||
MORFITT \worldflag FR | DNN | 49.75060.009 | 59.0380.012 | 0.64990.022 | 0.23230.021 | 0.03980.005 | 2.07480.015 | 0.7960.045 | 2.44540.003 | ||
DC | 55.45510.01 | 62.53060.008 | 0.61340.003 | 0.22430.003 | 0.04250.001 | 2.03320.006 | 0.87750.014 | 2.44110.001 | |||
MCD | 48.32690.008 | 57.35290.008 | 0.63090.021 | 0.15190.05 | 0.04640.007 | 2.26920.03 | 0.98560.006 | 2.47670.003 | |||
VI | 53.08340.014 | 61.67280.01 | 0.64080.042 | 0.25710.039 | 0.04770.006 | 2.02450.007 | 0.77240.047 | 2.43690.004 | |||
DNN | 53.49630.019 | 61.80150.014 | 0.60810.017 | 0.20980.014 | 0.03630.002 | 2.05380.015 | 0.83340.01 | 2.44530.002 | |||
DC | 56.44180.018 | 62.95960.02 | 0.61480.027 | 0.23250.018 | 0.04330.003 | 2.02510.015 | 0.86670.03 | 2.43940.001 | |||
MCD | 51.85190.015 | 60.53920.006 | 0.57180.003 | 0.06870.022 | 0.02980.0 | 2.14260.01 | 0.96510.005 | 2.46290.002 | |||
VI | 54.29930.011 | 62.71450.01 | 0.53460.008 | 0.04880.018 | 0.02790.002 | 2.10640.014 | 0.97520.007 | 2.46020.002 |
Appendix B Full results
We present the detailed Table for all the configurations in Table 5. As noted in the main text, the most obvious trend across the board is that scores are tightly coupled with datasets: The range of scores achieved by all classifiers we study tends to be fairly limited across a given dataset, whereas we can observe often spectacular differences from one dataset to the next.
Insofar as classification metrics go, we observe that models almost always occupy the top ranks. This is especially salient in MedABS and MedNLI, where all classifiers outperform all classifiers both in terms of F1 and accuracy. In PxSLU, the only model that deviates from this trend is the model, which appears to suffer from an especially low accuracy. In the two other French datasets, along with SMOKING, classification metrics do not exhibit as clear a division between domain-specific and general PLMs.
As for calibration metrics, we find a very similar behavior to what we highlight in the main text: uncertainty-unaware model almost never rank among the top two contenders. Rankings per metric tend to be fairly stable as long as we control for domain-specificity.
Lastly, having a look at the various Bayesian architecture, we can see that DropConnect is not necessarily the most optimal system across all uncertainty-aware classifiers. Selecting the best architectures given 3 seeds, and then expanding to 10 seeds most likely led to some degree of sampling bias, explaining this discrepancy. It does however constitute a strong contender across many situations: it still remains the best ranking Bayesian architecture on average both in terms of F1 across the validation set, as well as in terms of test BS., ECE, SCE, NLL and Entropy.
In fact, differences in terms of ranks across datasets per architecture are not always significant: If we normalize all 80 classifiers per dataset by taking their rank, then Kruskal-Wallis H-test suggest that F1, accuracy and ECE do not lead to significant rank differences across architectures (assuming a threshold of ). Likewise, comparing and models with the same procedure does not lead to significant differences in terms of ECE, SCE, and coverage.