Editor’s introduction
The study analyzed trial documentation using domain-specific transformer embeddings such as BioBERT, ClinicalBERT, PubMedBERT, and MedCPT, combined with structured trial features. BioBERT achieved the highest performance with an ROC-AUC of 0.794, outperforming ClinicalBERT by 3.95%. Combining multiple embeddings did not improve results, suggesting redundancy or noise in the concatenated representations. The study found that trial phase and primary purpose features improved model performance despite not meeting statistical significance thresholds, highlighting the role of domain knowledge in feature selection. A major limitation was severe class imbalance, with 95.4% of trials labeled as error-free, reflecting under-reporting of dosing errors in registries. This imbalance may distort performance metrics, as ROC-AUC can be misleading in such settings, limiting the generalizability of results to real-world error detection scenarios.
Introduction
Clinical trials provide the structured and rigorously controlled framework required to evaluate the safety and efficacy of novel pharmaceutical compounds in human populations. However, this process is both costly and uncertain. Only 14% of compounds entering clinical trials ultimately receive regulatory approval, despite substantial financial investment at each phase. Median costs are estimated at USD 3.4 million for Phase I, USD 8.6 million for Phase II, and USD 21.4 million for Phase III studies.
Beyond financial risk, trial protocols are inherently complex, involving numerous interacting variables, multiple treatment arms, and strict procedural constraints. This complexity increases the likelihood of operational and methodological errors, which may compromise statistical validity, delay development timelines, or invalidate findings entirely, resulting in wasted resources and lost therapeutic opportunity.
Medication errors are unintended failures in the drug treatment process that cause, or have the potential to cause, patient harm. These errors can include: incorrect timing of doses, incorrect dosage, additional unintended doses, or inappropriate administration rates, as well as errors in randomisation, masking, and broader experimental design. Medication errors remain one of the most frequently occurring yet preventable causes of adverse patient outcomes within clinical settings. The same medication errors that occur in clinical settings can also arise during clinical trials. Medication errors during clinical trials can lead to reduced efficacy of the trial, serious toxicity, compromised patient safety, adverse drug events, and can also pose a threat to internal validity and interpretability of clinical trial outcomes.
Given the substantial consequences of erroneous approval decisions related to new compounds, rigorous monitoring and statistically robust evaluation are essential during the entire clinical trial process. Regulatory bodies such as the Food and Drug Administration (FDA) and European Medicines Agency (EMA), emphasise the importance of proactively identifying, monitoring and mitigating dosing errors during clinical trials due to their potential to contribute to a public health burden. In addition, timely identification of dosing errors in clinical trials can reduce both financial costs and patient risk by facilitating earlier correction or termination of ineffective studies.
However, clinical trial documentation often consists of large volumes of unstructured textual data, making the extraction of relevant methodological details time-consuming and challenging. This complicates verification of trial integrity, particularly with respect to correct dosing and administration schedules across study arms and cohorts. The predominance of unstructured textual documentation within clinical trial reports and protocols, highlights the need for automated methods capable of systematically extracting and verifying critical methodological details.
In the context of the medical field and more specifically when evaluating clinical reports, Natural Language Processing (NLP) provides a scalable approach for identifying and structuring relevant information embedded within narrative clinical text. Natural language processing is a subfield of computer science and artificial intelligence, which allows computers and digital devices to recognise and understand text and speech data. Beyond information extraction from text, NLP techniques also support downstream analytical tasks such as diagnosis explanation, disease progression modelling, and treatment effectiveness assessment. Recent advances in machine learning have led to the development of increasingly sophisticated NLP algorithms with broad applications in information extraction and summarisation. These developments within the field of NLP are particularly relevant to medical documentation, where clinical notes and reports generated from medical practise and research typically take the form of large volumes of unstructured text. NLP methods have already been applied within the medical field for some use-cases, including: extracting dosage information and administration schedules, identifying clinical and treatment events, and detecting adverse drug events and reactions. Recent research has also investigated specific applications of these NLP methodologies within the context of clinical trials, including: automating report drafting, extracting drug-to-drug interactions (DDI) and optimising protocol design in CTs.
The rapid proliferation of transformer-based language models has significantly advanced NLP research. These models leverage self-supervised learning and attention mechanisms to learn feature-rich, general-purpose representations from large volumes of unlabelled text corpora. As a consequence of extensive pre-training on a large amount of data, only relatively small amounts of task-specific data are required to achieve strong performance on downstream tasks, since the pre-trained parameters within each model already encode substantial linguistic and semantic structure derived from the training corpora.
Dataset and Problem Formulation
As part of the CT-DEB’26 challenge (Detecting Dosing Errors from Clinical Trials), a dataset was generated, containing structured and unstructured information for a large number of different clinical trials (written in the English language), collected from the ClinicalTrials.gov site. Each row corresponded to a single clinical trial study and included long-form textual fields as well as several numerical and categorical variables related to each specific trial. As part of the dataset construction process, a binary label was generated: a label of 1 was assigned if the lower bound of the 95% Wilson confidence interval for the dosing error rate exceeded 0.01%.
The objective of this research was to compare several pre-trained biomedical models for encoding text features, and to develop and evaluate machine learning models (both classical and neural networks) capable of predicting which clinical trials met this elevated dosing error risk criterion. The study systematically evaluated the impact of different feature subsets, alternative input representations of textual data, and varying model architectures on predictive performance.
Given the presence of substantial unstructured text, it was necessary to transform textual data into machine-readable representations. To this end, several pre-trained transformer-based models were evaluated, including ClinicalBERT, BioBERT, PubMedBERT, and MedCPT. These models, pre-trained on large-scale biomedical corpora, can generate contextualised vector representations of input text that capture domain-specific semantic information. The resulting embeddings were used as input features for downstream machine learning classifiers, including both traditional machine learning models, as well as more advanced neural networks. A controlled experimental framework was applied throughout the research process, modifying a single variable at a time while holding others constant to isolate individual effects of experimental changes. Standard machine learning practice was followed by using a separate subset of data to analyse the predictive performance of each model, to prevent bias by showing the model data it has already seen before during the training process.
In the final modelling pipeline, textual features (briefSummary, detailedDescription, armDescriptions, and interventionDescriptions) were encoded using BioBERT embeddings. Structured categorical variables, including allocation method, intervention model, primary purpose, oversightHasDmc, and trial phase, were one-hot encoded and concatenated with the text embeddings. Continuous numerical variables such as enrollmentCount, numArms, and numLocations were not included in the final models. The numArms variable demonstrated a weak statistical association with the target variable, while enrollmentCount and numLocations were not considered likely to provide meaningful predictive signal beyond the structured and textual features already incorporated.
The protocolPdfText field was not incorporated into the modelling pipeline due to substantial data sparsity and extreme variability in length. In the training set, 81.3% of records (23,963 of 29,478) contained no extracted PDF text, whereas only 3.2% of validation records were empty. This imbalance raised concerns that the model could implicitly learn the presence of non-empty PDF text as a proxy for dataset partition, thereby introducing distributional bias. Furthermore, when data was available within the protocolPdfText field, the extracted protocol text was extremely long (training max: 11,298,927 characters; validation max: 6,424,120 characters), with highly skewed distributions and very large standard deviations. Encoding such long documents within a fixed transformer context window would require aggressive truncation, potentially discarding the majority of the content and introducing inconsistent representation quality across samples. Given the high proportion of missing entries in training data, the substantial computational burden of processing very long documents, and the risk of introducing noise through heavily truncated representations, this feature was excluded from the final experiments.
As the primary objective of this study was to evaluate the comparative effectiveness of pretrained biomedical language models for encoding unstructured clinical trial documentation, the modelling framework was designed to isolate the contribution of textual representations. Accordingly, only categorical structured features were included alongside the embeddings, and continuous numerical variables were excluded.
Phase 2: Iteration of Model Architectures and Training Processes
The final set of inputs features was selected based on statistical analysis and domain knowledge, by combining BioBERT embeddings for all text fields and one-hot encoded categorical features (specifically: intervention model, allocation type, oversight, primary purpose, phase). These features were features that gave the model the most discriminative predictive power in determining if the probability of a dosage error having occurred within a specific clinical trial exceeded the defined threshold.
As the dataset exhibited substantial class imbalance (approximately 95.4% of training records labelled as no dosage error - 28,126 of 29,478 data-points), it was necessary to investigate methodologies for mitigating this large imbalance. A series of experiments evaluated the impact of varying class weights during training. By varying the class weights, we can instruct a machine learning model to place greater importance on examples from a certain class during the training process. These experiments consisted of the following stages: no weighting (all examples assigned equal importance), fixed weighting ratios (1:5, 1:10, 1:20) toward the minority class, and automatically computed class weights based on the proportional amount of each element within the dataset (around 0.5:11 weighting, for 0 and 1 dosage error variables, respectively).
Once the final set of input features was fixed, and an optimal class weighting had been identified, several experiments were undertaken to vary the type of machine learning model that was used to make predictions, and thus change the manner in which the model is learning from the input data. These models included both classical machine learning models and more advanced neural network architectures. The classical machine learning models that were examined were as follows: Logistic Regression, Linear Support Vector Classifier, Support Vector Classifier, K-Nearest Neighbours Classifier, Naïve Bayes, Decision Trees, XGBoost and LightGBM. Due to the high dimensionality of transformer embeddings, some classical models experienced convergence or computational limitations. Comparative evaluation identified Logistic Regression, SVC variants, as well as Gradient Boosting models as the strongest classical baselines. The top performing models had hyperparameter optimisation performed using GridSearch to identify the combination of model parameters that gave the best predictive power.
Following the evaluation of the classical machine learning models, multiple neural network architectures were explored: simple multi-layer perceptron (MLP), wide multi-layer perceptron, residual neural network (with skip connections), text-tower architecture (separate processing streams for text and categorical features, merged at a later part of the neural network). Specific implementation details of the various neural network architectures can be found in Appendix A.6.
Performance differences between neural network architectures was analysed using consistent feature representations and with other neural network training parameters fixed (e.g. loss, optimiser, learning rate, training epochs). During the later stages of investigation into neural network models, once the best performing architecture was identified, the training process itself was further optimised. This included the following methodologies: early stopping based on validation ROC-AUC, learning rate scheduling (ReduceLROnPlateau, OneCycleLR), loss function comparison (binary cross-entropy vs focal loss), and model check-pointing to retain best parameters against the validation data. These experiments aimed to optimise convergence behaviour during model training and reduce over-fitting to the training data. All models were evaluated on held-out validation data to assess generalisation performance on unseen data. The primary evaluation metric was ROC-AUC, with secondary metrics used to characterise performance under class imbalance conditions.
Extensive hyperparameter optimisation of the neural network models was not performed. Instead, the architectures were constructed to represent common and practically relevant structural variations, such as wide networks, residual connections, and gated text towers, rather than to exhaustively tune each configuration for maximal performance. Although more comprehensive optimisation could potentially improve absolute predictive performance, this was beyond the scope of the present study. The reported results therefore reflect controlled and representative configurations designed to enable a fair and consistent comparison across modelling approaches.
Results for Class Weighting
A significant methodological challenge in this study was the pronounced class imbalance within the dataset, with approximately 95.4% of training records labelled as 0 (28,126 of 29,478), indicating that the lower bound of the 95% Wilson confidence interval for the dosing error rate did not exceed the predefined threshold for those clinical trials. This distribution reflects the real-world rarity of formally reported dosing errors in clinical trial registries, where medication errors are known to be systematically under-reported. Moreover, using ROC-AUC as an evaluation metric can be misleading in highly imbalanced applications, as strong performance may still coincide with poor minority class detection. To address this, additional evaluation metrics, including precision, recall, and balanced accuracy, were incorporated to ensure that models were meaningfully identifying cases where dosing error likelihood surpassed the defined threshold, rather than defaulting to majority-class predictions.
When using simpler machine learning models such as logistic regression, varying the class weights for the minority class had no meaningful impact on logistic regression performance, with ROC-AUC against the validation set remaining within a narrow range (0.791–0.798) across all weighting strategies (mean: 0.795, standard deviation of 0.003). This suggests that re-weighting did not materially alter ranking-based discriminative performance with respect to ROC-AUC. Alternative approaches, such as upsampling the minority class, may potentially improve sensitivity; however, this was not explored in the present study. In medical contexts, synthetic or repeated sampling strategies must be applied cautiously, as they may introduce over-fitting, distort clinically meaningful distributions, or amplify noise in rare but heterogeneous cases.
In contrast to logistic regression, the neural network demonstrated improved ability to predict dosage error when class weighting was applied, with ROC-AUC increasing from 0.806 (no weighting) to 0.838 using automatically computed class weights based on the proportion of examples of each class within the training data. This indicates that the neural architecture was more responsive to imbalance-aware training, improving its ability to detect minority class instances (dosing error probability surpassed defined threshold) without sacrificing overall discriminative performance (mean: 0.835, standard deviation of 0.002, across experiments where class weighting was applied).
Limitations
Firstly, compute constraints prevented the evaluation of language models with larger amounts of parameters, such as BioGPT and SciFive. Encodings from these models may have produced stronger semantic representations of clinical trial protocol text. Secondly, the binary target variable conflates dosing errors of varying severity and type into a single label, limiting the granularity of predictions. Future work could explore multi-class formulations that distinguish between error types such as incorrect dose, incorrect frequency, and omission errors, as taxonomised in prior work. Thirdly, the dataset is derived exclusively from the ClinicalTrials.gov registry, which captures structured protocol information but may not reflect the full complexity of dosing procedures described in supplementary protocol documents or internal trial management systems. As noted in prior work, registry data is subject to selective reporting and inconsistent documentation practices.
Finally, while feature importance scores can be extracted from XGBoost and LightGBM, interpreting which specific textual patterns in protocol descriptions drive predictions remains an open challenge that warrants further investigation using explainability techniques such as SHAP values or attention-based visualisation. In addition, the neural network models provide difficulty in explainability of results due to the ’black-box’ nature of the neural network’s internal learning processes.


