Abstract
In this paper, we propose FastDoc (Fast Continual Pre-training Technique using Document Level Metadata and Taxonomy), a novel, compute-efficient framework that utilizes Document metadata and Domain-Specific Taxonomy as supervision signals to continually pre-train transformer encoder on a domain-specific corpus. The main innovation is that during domain-specific pretraining, an open-domain encoder is continually pre-trained using sentence-level embeddings as inputs (to accommodate long documents), however, fine-tuning is done with token-level embeddings as inputs to this encoder. We perform such domain-specific pre-training on three different domains namely customer support, scientific, and legal domains, and compare performance on 6 different downstream tasks and 9 different datasets. The novel use of document-level supervision along with sentence-level embedding input for pre-training reduces pre-training compute by around 1,000, 4,500, and 500 times compared to MLM and/or NSP in Customer Support, Scientific, and Legal Domains, respectively. The reduced training time does not lead to a deterioration in performance. In fact we show that FastDoc either outperforms or performs on par with several competitive transformer-based baselines in terms of character-level F1 scores and other automated metrics in the Customer Support, Scientific, and Legal Domains. Moreover, reduced training aids in mitigating the risk of catastrophic forgetting. Thus, unlike baselines, FastDoc shows a negligible drop in performance on open domain.
Introduction
Continual Pre-training (CPT) is the standard methodology for adapting general-purpose language models (like BERT or RoBERTa) into domain-specific experts (like SciBERT). However, the standard approach—Masked Language Modeling (MLM)—is computationally expensive and often ignores broader document-level structures. Furthermore, intensive CPT frequently leads to "catastrophic forgetting," where the model loses its general-purpose reasoning capabilities. FastDoc addresses these challenges by replacing token-level objectives with document-level metadata and taxonomy supervision, achieving massive speedups while preserving general knowledge.
Methods
The core innovation of FastDoc lies in its shift in supervision signals and input granularity:
- Document-Level Supervision: Instead of predicting masked words, FastDoc utilizes two high-level signals: Triplet Loss, which pulls similar documents closer in vector space based on metadata, and Hierarchical Classification, which trains the model to predict a document's position within a domain-specific taxonomy.
- Sentence-to-Token Interoperability: During pre-training, the model uses a frozen sentence transformer to process documents as sequences of sentence embeddings. This allows the model to handle significantly larger contexts. For downstream tasks, the model switches back to token-level embeddings, demonstrating that learned internal representations translate effectively across granularities.
Experimental Setup
The framework was evaluated across three distinct domains:
- Customer Support: Pre-trained on the E-Manuals Corpus; evaluated on TechQA and S10 QA.
- Scientific: Pre-trained on ArXiv papers; evaluated on the SciBERT benchmark.
- Legal: Pre-trained on EURLEX57K; evaluated on the CUAD dataset for clause extraction.
- General Domain: The GLUE benchmark was utilized to measure catastrophic forgetting.
Key Results
FastDoc achieved extreme speedups in pre-training compute: 1,000x in Customer Support, 4,500x in Scientific domains, and 500x in Legal domains compared to MLM baselines. Despite this reduction, the model maintained performance parity with heavyweights like SciBERT and Longformer.
Furthermore, FastDoc demonstrated zero forgetting on the GLUE benchmark. While standard CPT models showed significant performance drops, FastDoc exhibited a negligible decline, retaining its original general intelligence. In few-shot scenarios (50-shot fine-tuning), FastDoc variants significantly outperformed base models, proving the effectiveness of the domain-specific "warm-up."
Conclusion
FastDoc presents a paradigm shift in domain adaptation by leveraging existing metadata and taxonomies as powerful shortcuts for learning. By processing sentence embeddings during pre-training, it overcomes memory limitations and drastically reduces compute costs without sacrificing downstream performance or general-domain capabilities. Future work will focus on extending this framework to generative decoder-only models and improving robustness to metadata noise.
Summary updated