Enhancing Language Models for Technical Domains with Dynamic Token Injection

Giorgio Giannone, Neil Tenenholtz, James Hall, Nicolo Fusi, David Alvarez-MelisGenBio @ NeurIPS 2023

TL;DR

This paper introduces a novel method to inject specialized knowledge into general-purpose Large Language Models (LLMs) without extensive fine-tuning. By dynamically adding domain-specific "tokens" and aligning their representations, the LLM can better understand and process information from technical fields like genomics, even for concepts it hasn't seen before.

What Problem Does This Paper Address?

Generalist LLMs are powerful but often lack the nuanced understanding required for highly specialized technical domains, such as genomics or engineering. While fine-tuning can adapt LLMs to these domains, it's data-intensive and can degrade the model's broader capabilities. The challenge is to equip LLMs with deep domain expertise without sacrificing their general intelligence or requiring massive retraining. This is particularly important for rapidly evolving fields where new concepts (like novel genes or pathways) emerge frequently.

Methods

The core of the proposed method, "Dynamic Token Injection," involves:

  1. Vocabulary Augmentation: Adding new "specialist tokens" to the LLM's vocabulary, each representing a concept from the target domain (e.g., a gene name). These tokens are initialized using embeddings from a domain-specific model.
  2. Functional Mapping and Alignment: A lightweight adapter network (a small ResNet block) is used to map the new specialist token embeddings into the LLM's existing embedding space. Crucially, this mapping is also used to adjust the model's output "logit distribution," ensuring that the new tokens influence predictions in a meaningful way.
  3. Gromov-Wasserstein (GW) Loss: To geometrically align the general and specialized domains within the model, the authors employ the Gromov-Wasserstein distance. This metric is well-suited for comparing spaces that aren't directly aligned and helps ensure that the relationships between specialized tokens are preserved in the LLM's representation.
  4. Frozen LLM Backbone: The main LLM architecture remains frozen, meaning only the adapter layers are trained. This significantly reduces computational cost and prevents catastrophic forgetting of general knowledge.

Datasets

The primary domain explored is genomics. The authors use a dataset of genes and their descriptions. For evaluation, they create a text2gene task, where the model must identify the correct gene given a textual description. This task involves both "in-distribution" genes (seen during training) and "out-of-distribution" genes (unseen during training) to test generalization capabilities.

Key Insights and Ideas

  • Specialist Tokens as Dynamic Extensions: The idea of treating domain-specific concepts as new tokens that can be dynamically injected and aligned is a powerful way to extend LLM capabilities without full retraining.
  • Functional Alignment for Coherence: Using the same functional mapping for both embedding adaptation and logit adjustment is key to ensuring that the new knowledge is integrated coherently into the model's reasoning process.
  • Gromov-Wasserstein for Heterogeneous Alignment: The application of GW distance is a clever way to align representations from different domains (general text vs. specialized gene concepts), especially when direct correspondence is not obvious.
  • Out-of-Distribution Generalization: The method shows remarkable ability to handle novel gene tokens not seen during training, a significant advantage over traditional fine-tuning.

Key Results

  • The proposed method achieves high accuracy on the text2gene task, significantly outperforming baselines, especially for out-of-distribution genes.
  • For binary classification, the model reached approximately 93.7% accuracy on out-of-distribution genes.
  • For 10-way classification, it achieved 77.2% accuracy on out-of-distribution genes.
  • Qualitative analysis (Figures 5 and 6) shows that the adaptation process aligns the specialized gene representations with the general domain's embeddings and hidden states, indicating better integration of knowledge.
  • The Gromov-Wasserstein loss helps in aligning specialized domain features before and after adaptation, demonstrating the effectiveness of the alignment process.

Limitations and Future Work

  • Scalability with Vocabulary Size: While the method is scalable, the paper notes that the vocabulary can be augmented by up to 30% (17k tokens in their experiment). Further research could explore handling even larger domain-specific vocabularies.
  • Generalizability to Other Domains: The current demonstration is in genomics. The authors suggest that this method has broad applicability to other technical and engineering sciences, which would be an important area for future work.
  • Hyperparameter Sensitivity: The effectiveness of the Gromov-Wasserstein loss is influenced by its weighting factor (λ), suggesting potential sensitivity to hyperparameter tuning.
  • Initialization Strategy: While using embeddings from a domain-specific model (biogpt-large) was effective, exploring other initialization strategies could be beneficial.

Summary updated

BibTeX
@inproceedings{giannone2023enhancing,
  author = {Giorgio Giannone and Neil Tenenholtz and James Hall and Nicolo Fusi and David Alvarez-Melis},
  title = {{Enhancing Language Models for Technical Domains with Dynamic Token Injection}},
  booktitle = {GenBio @ NeurIPS},
  year = {2023},
  url = {https://openreview.net/forum?id=SJYY3nQ0cX},
}
Figure