Transferring Extreme Subword Style Using Ngram Model-Based Logit Scaling

Craig Messner, Tom LippincottNAACL 2025

TL;DR

This paper introduces a novel method for transferring extreme subword stylistic variations (like dialectal spellings) to large language models (LLMs) at inference time. By combining LLM predictions with ngram models trained on specific author corpora, they achieve impressive stylistic transfer without extensive retraining, making LLMs more adaptable to nuanced linguistic styles.

What Problem Does This Paper Address?

Text style transfer (TST) aims to rewrite text in a specific style, but transferring extreme subword stylistic variations, such as those found in historical "dialect literature," poses a significant challenge. LLMs, while powerful, often lack the specific knowledge of these niche styles within their pre-trained weights. Fine-tuning on such limited and specialized data is often impractical. Existing methods like prompt engineering or in-context learning can be insufficient for capturing these extreme variations, and mechanical interpretation approaches require the target style to be well-represented in the model's training data. This paper tackles the problem of effectively and efficiently transferring these extreme subword styles to LLMs at generation time, bridging the gap between general-purpose LLMs and highly specialized linguistic expressions.

Methods

The core of the proposed method is an ngram model-based logit scaling technique. Here's how it works:

  • Ngram Models as Style Experts: The authors train ngram models (specifically, 4-gram models with a "stupid backoff" strategy) on small, single-author or character corpora. These ngram models act as specialized "experts" on the target style, capturing the statistical likelihood of word sequences specific to that author.
  • Logit Scaling: During LLM generation, the output logits (pre-softmax scores) from the LLM are adjusted. This adjustment is a weighted interpolation between the LLM's original logits and the logits derived from the ngram model's predictions.
  • Tunable Interpolation: A parameter, inspired by temperature decoding, is used to control the degree of influence from the ngram model. This allows for fine-tuning the balance between the LLM's fluency and the desired stylistic transfer, making the process "tunable."
  • Subword Focus: The method operates at the subword level, aligning with how modern LLMs tokenize text, allowing it to capture subtle orthographic variations.

Datasets

  • Baseline and Ngram Training: Two 19th-century U.S. fiction corpora from Project Gutenberg (PG) were used:
  • The full texts of "Uncle Remus: His Songs and His Sayings" by Joel Chandler Harris and "Mr. Dooley" series.
  • Dialogue sections manually extracted from PG, attributed to three specific characters identified as nonstandard speakers.
  • Evaluation Prompts: The WRITING-PROMPTS (WP) dataset was used to generate story prompts for evaluation.
  • LLMs: Mistral AI's Mistral-Instruct-7B-v0.2 and Meta's Llama3.2-3B-Instruct were used as the base LLMs.
  • Evaluation Model: OpenAI's GPT2-large was used for perplexity calculations.

Key Insights and Ideas

  • Ngram Models as Efficient Style Capturers: The paper highlights that even small, data-efficient ngram models can effectively capture the statistical essence of an author's unique subword style, making them valuable complements to LLMs, especially for low-resource styles.
  • Inference-Time Adaptability: The logit scaling approach allows for style transfer during inference, avoiding the need for costly fine-tuning or retraining of large LLMs. This is crucial for practical applications where dynamic style adaptation is desired.
  • Tunable Style Intensity: The method provides a mechanism to control the "degree" of stylistic transfer, allowing for smooth interpolations between the original LLM output and the target style, rather than an all-or-nothing approach.
  • Subword Style is Distinct: The results suggest that subword stylistic features, like specific orthographic variations, can be transferred independently of semantic content, demonstrating the model's ability to isolate and manipulate stylistic elements.
  • Model Specificity Matters: The performance of the method varied between LLMs (Mistral performed better than Llama3.2), suggesting that the underlying architecture and training of the LLM play a significant role in how effectively it can integrate external stylistic information.

Key Results

  • Successful Style Transfer: The proposed ngram scaling method successfully transferred extreme subword styles, as evidenced by generated text that exhibited features of the target authors/characters.
  • Perplexity as a Metric: The authors used perplexity measures (both target text perplexity and generation perplexity) to evaluate the success of the style transfer, aiming for generated text perplexity to be close to the target author's perplexity while maintaining low overall perplexity.
  • Sampling Outperforms Greedy Decoding: For style transfer, sampling-based generation strategies proved more effective than greedy decoding in achieving perplexity scores closer to the target styles.
  • Mistral's Superiority: Mistral-Instruct-7B-v0.2 demonstrated better performance in transferring styles compared to Llama3.2-3B-Instruct.
  • Qualitative Success: Generated samples showed plausible sequences and author-characteristic word choices, sometimes even producing novel stylistic hypotheses. For instance, the "Julius" character's style was captured, while unscaled prompts failed to evoke the desired style for that character.

Limitations and Future Work

  • Limited Scope: The current work is limited to 19th-century U.S. literature. Transferring styles from other eras, languages, or cultural contexts may require different approaches.
  • Tokenization Dependency: The method's effectiveness is tied to the subword tokenization system of the pretrained LLM. Different tokenizers might omit or alter stylistic elements, impacting transfer.
  • Ethical Considerations: The authors acknowledge the potential for stylistic forgery but argue that the primary styles transferred are archaic and literary, lessening nefarious utility. They also note that some source texts contain offensive terminology, which could be reproduced.
  • Future Work:
    • Testing the method on other forms of subword variation.
  • Characterizing which specific subword features are transferred relative to the LLM and ngram model.
  • Increasing the precision of optimality determination for scaling weights.
  • Experimenting with hybrid generation across multiple author ngram models.
  • Exploring subword-style extremity for broader stylistic transfer.

Summary updated

BibTeX
@inproceedings{messner2025transferring,
  author = {Craig Messner and Tom Lippincott},
  title = {{Transferring Extreme Subword Style Using Ngram Model-Based Logit Scaling}},
  booktitle = {Conference of the North American Chapter of the Association for Computational Linguistics},
  year = {2025},
}
Figure