Manuscript Offprint

arXiv:2609.11029

Rebalancing Token Importance in Language Models with TF-IDF Weighted Cross-Entropy Loss

Zhijian Li, Stefan Larson, Kevin Leach

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models are typically trained under uniform token weighting, which allows frequent and low-information tokens to dominate learning and can increase the tendency to memorize surface-level text spans. To address this, we present an information-weighted cross-entropy loss that rescales token-level contributions using TF-IDF statistics, emphasizing semantically informative tokens while downweighting ubiquitous ones. Experiments on five decoder-only LLMs ranging from 1.1B to 13B parameters show consistent reductions in memorized substring length while preserving perplexity and downstream task performance. Under LoRA fine-tuning, TF-IDF reduces average substring memorization length by 14% across all five models. Under full-weight fine-tuning on TinyLLaMA 1.1B, the reduction reaches 58%. Our approach is architecture-agnostic and can be incorporated into existing training pipelines with less than 3% computational overhead, offering a lightweight and principled way to mitigate memorization without disrupting standard training dynamics.

1 Introduction

Large language models (LLMs) are increasingly deployed in domains where reliability (e.g., clinical decision support), robustness (e.g., legal document analysis), and data stewardship (e.g., copyright-sensitive content generation) are essential. Yet, their training objectives still treat all tokens equally, regardless of how informative, redundant, or noisy those tokens may be (Touvron et al., 2023; Brown et al., 2020). This uniform weighting can misallocate gradient updates, leading to overemphasizing frequent or low-information patterns while underrepresenting distinctive or semantically-rich content (Su et al., 2024). This can lead to memorization of surface-level patterns in the training data (Carlini et al., 2023). When every token is weighted equally, the model has no incentive to treat repeated surface patterns differently from meaningful content, leaving it prone to memorizing sequences verbatim.

Existing interventions include pre-training data deduplication (Kandpal et al., 2022), which requires costly global pre-computation, and privacy-preserving objectives such as differential privacy (Abadi et al., 2016), which trade off model utility. Post-hoc methods such as unlearning (Eldan and Russinovich, 2023) and model editing (Meng et al., 2022) operate after training but do not address how the model learns during training. Token-dropping methods (Hans et al., 2024) offer a lighter-weight alternative but remove supervision on a subset of tokens rather than reweighting all of them. We instead focus on reshaping how the gradient signal is distributed across tokens during training. Our method is designed for the continued pretraining and fine-tuning regime, the dominant paradigm in modern NLP where practitioners adapt publicly released pretrained checkpoints rather than training from scratch (Bommasani et al., 2021; Howard and Ruder, 2018).

We present a TF-IDF-weighted cross-entropy loss that rescales token-level gradients using lexical statistics from the training corpus. The method upweights tokens that are distinctive within context and down-weights those that are globally ubiquitous. Meanwhile, we retain supervision for all tokens, preserving coherent sequence modeling while reducing the incentive to memorize exact surface forms. The design is straightforward, architecture-agnostic, and readily integrates into existing training pipelines.

We evaluate this technique across five pretrained decoder-only LLMs ranging from 1.1B to 13B parameters. Empirically, the TF-IDF-weighted loss preserves perplexity and downstream performance on summarization and question answering (QA), while consistently reducing substring-level memorization and ROUGE-L across all models. The mag-nitude of the reduction is driven by how much memorization occurs under the CE baseline. Smaller models fine-tuned with LoRA already memorize little, leaving less room for improvement in that setting. Under full-weight fine-tuning, where the CE baseline memorizes substantially more, even the smallest model — TinyLLaMA 1.1B — achieves the largest reduction of 58% in average Longest Memorized Substring (LMS). Across all five LoRA models the average reduction is 14%, indicating that TF-IDF loss consistently reduces memorization wherever the baseline permits it. Together, these results demonstrate that token-aware objectives provide an efficient and principled means of mitigating memorization without altering model architectures, standard training procedures, or downstream task performance.