Abstract
Clinical document classification, or "computable phenotyping," is often hindered by the extreme length of medical records, which far exceed the 512-token limit of standard transformer models. This paper introduces a hierarchical framework that leverages pre-trained, short-context models like DistilBERT by partitioning documents into chunks and aggregating their representations. Experimental results on the i2b2 Obesity and Injury Severity datasets show that fine-tuning this hierarchical structure achieves competitive performance with domain-specific models, highlighting an efficient path for clinical NLP without exhaustive domain-specific pre-training.
Introduction
In clinical Natural Language Processing (NLP), identifying patient cohorts from medical records is a foundational task. However, clinical notes are characteristically long; for instance, discharge summaries in the MIMIC III dataset average over 8,000 words. While transformer-based models like BERT and RoBERTa represent the state-of-the-art, their quadratic attention mechanism imposes a strict 512-token input limit. Common workarounds, such as text truncation or training "efficient" long-context transformers from scratch, either lose critical information or require prohibitive computational resources. This study explores a middle ground: a hierarchical approach using powerful, pre-trained, short-context models to process long medical notes efficiently.
Methods
The proposed hierarchical framework operates in two distinct stages: word-level encoding and chunk-level aggregation.
1. Word-level Encoding (The "Chunker")
The input document is partitioned into equal-length chunks (e.g., 202 tokens). Each chunk is processed through DistilBERT to generate a vector representation. The authors evaluated two pooling strategies:
- [CLS] Pooling: Utilizing the representation of the special classification token.
- Weighted Sum: A learned weighted average of hidden states across all six DistilBERT layers.
2. Chunk-level Aggregation (The "Summarizer")
To synthesize the individual chunk vectors into a global document representation, four aggregation architectures were tested:
- Transformer Encoder: A small transformer sequence model.
- LSTM: A recurrent network for sequential processing.
- CNN: Convolutions to capture local cross-chunk patterns.
- Average Pooling: A simple mean of all chunk vectors.
The study specifically compared Fine-tuning (updating the entire model end-to-end) against Feature Extraction (freezing DistilBERT weights).
Results and Discussion
The framework was evaluated on the i2b2 2008 Obesity Challenge (1,237 summaries) and an in-house Injury Severity Dataset.
The Necessity of Fine-tuning
A primary finding was the significant performance gap between fine-tuning and feature extraction. As shown in the results table, models with frozen DistilBERT weights performed markedly worse. Fine-tuning allows the base encoder to learn task-specific features essential for effective document-level aggregation.
Aggregation Performance
The Transformer Encoder emerged as the superior aggregator. Interestingly, adding positional embeddings to chunks slightly decreased performance, suggesting that the presence of specific clinical indicators is more critical than their exact location within a long note. Furthermore, the hierarchical DistilBERT model (trained on general web text) performed nearly as well as the Hierarchical Attention Network (HAN) pre-trained on the medical-specific MIMIC III dataset.
Task-Specific Variations
On the i2b2 Obesity task, the best hierarchical model (DistilBERT + Transformer) achieved a macro F1-score of 0.7434, outperforming standard truncated DistilBERT (0.6000). However, on the Injury Severity task, a simple linear SVM baseline (AUC-ROC 0.9101) outperformed the transformer (0.8860). This suggests that certain clinical tasks may rely on specific "trigger words" rather than complex linguistic context, where simpler keyword-based models remain highly effective.
Conclusion and Future Work
This hierarchical framework provides a robust method for applying standard transformers to long clinical texts. While highly effective, the study noted that LSTMs performed surprisingly poorly as aggregators, a phenomenon requiring further investigation. Additionally, while 1,800 tokens is "long" for BERT, future research should explore the scaling limits of this approach on documents exceeding 10,000 tokens. Determining the optimal trade-off between transformer complexity and simpler linear models for specific clinical tasks remains a key practical challenge.
Summary updated