Task-Adaptive Tokenization: Enhancing Long-Form Text Generation Efficacy in Mental Health and Beyond

Siyang Liu, Naihao Deng, Sahand Sabour, Yilin Jia, Minlie Huang, Rada Mihalcea

Introduction

Large Language Models (LLMs) typically rely on task-agnostic tokenizers, such as Byte-Pair Encoding (BPE) or WordPiece, trained on general-purpose corpora like Wikipedia. While effective for general conversation, these tokenizers often struggle with specialized domains like mental health counseling. Professional terms such as "social isolation" are frequently fragmented into multiple meaningless subwords (e.g., [soc] [ial] [iso] [la] [tion]), leading to information dilution and computational inefficiency.

This paper introduces Task-Adaptive Tokenization (TaT), a novel approach that constructs a specialized vocabulary from task-specific data and integrates it into pre-trained models. This method significantly improves generation quality while reducing token usage by up to 60%.

Methodology

The TaT framework employs a three-stage pipeline to adapt a standard model to a specific domain:

  1. Task Vocabulary Construction: Utilizing a unigram language model and subword regularization on domain-specific data (e.g., counseling responses), the system identifies high-value "chunks" of text to be treated as single tokens, such as [a_sense_of_purpose].
  2. Vocabulary Merging: A protocol is established to "stitch" the new vocabulary into the pre-trained model's existing set. By assigning specific scores to these new tokens, the model is encouraged to prioritize longer, semantically rich segments during the sampling process.
  3. Token Mapping: To mitigate the "cold start" problem for new tokens, their initial embeddings are calculated by averaging the embeddings of their original subword components.
Comparison between traditional subword segmentation and the task-adaptive approach, highlighting reduced sequence length and variable segmentation.

Experimental Setup and Datasets

The researchers evaluated TaT across several datasets to ensure robustness:

  • CN PsyQA: A large-scale Chinese psychological question-answering dataset featuring professional responses.
  • MHP Reddit: An English dataset of mental health professional responses.
  • Translated PsyQA: An English version of the CN PsyQA dataset used to determine if performance gains were language-dependent.

Key Results

The implementation of TaT yielded substantial improvements in both efficiency and generation quality:

  • Performance Metrics: On the CN PsyQA task, the TaT approach improved BLEU scores by up to 37% and ROUGE-L by 74% compared to standard GPT-2 baselines.
  • Massive Compression: The models represented the same content using 60% fewer tokens, effectively doubling the functional context window for specialized tasks.
  • Human Evaluation: Professional evaluators consistently rated TaT-generated responses higher in fluency, coherence, and professional expression.
Performance comparison on the CN PsyQA dataset showing significant gains in BLEU and ROUGE-L scores for TaT-enhanced models.

Discussion and Insights

A critical finding of this research is the Efficiency-Quality Paradox: while reducing token counts (compression) usually leads to detail loss, TaT improves quality by allowing the model to focus on higher-level semantic relationships rather than character-level reconstruction. Furthermore, the "Token Mapping" step proved essential for smaller datasets like MHP Reddit, where the model lacked sufficient data to learn new token meanings from scratch.

Conclusion

Task-Adaptive Tokenization represents a significant step forward in making LLMs more effective for specialized professional domains. By aligning the model's "productive vocabulary" with the specific language of the task, TaT achieves superior generation quality with a fraction of the computational cost. Future work will explore the optimal vocabulary sizes for other domains such as legal and medical text.

Summary updated

BibTeX
@inproceedings{liu2023task,
  author = {Siyang Liu and Naihao Deng and Sahand Sabour and Yilin Jia and Minlie Huang and Rada Mihalcea},
  title = {{Task-Adaptive Tokenization: Enhancing Long-Form Text Generation Efficacy in Mental Health and Beyond}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.944},
}
Figure