Inducing Character-level Structure in Subword-based Language Models with Type-level Interchange Intervention Training (2023)

Abstract: Language tasks involving character-level manipulations (e.g., spelling corrections, arithmetic operations, word games) are challenging for models operating on subword units. To address this, we develop a causal intervention framework to learn robust and interpretable character representations inside subword-based language models. Our method treats each character as a typed variable in a causal model and learns such causal structures by adapting the interchange intervention training method of Geiger et al. (2021). We additionally introduce a suite of character-level tasks that systematically vary in their dependence on meaning and sequence-level context. While character-level models still perform best on purely form-based tasks like string reversal, our method outperforms character-level models on more complex tasks that blend form, meaning, and context, such as spelling correction in context and word search games. Compared with standard subword-based models, our approach also significantly improves robustness on unseen token sequences and leads to human-interpretable internal representations of characters.

## introduction many common natural language tasks can fruitfully be described in terms of character-level manipulations. for instance, we resolve spelling mistakes with character-level edits, we perform unit conversions by moving decimal points and changing specific digits, and we play language games that center around anagrams, word reversals, character transpositions, and other operations on characters. for some of these tasks, the best models may be ones that tokenize their inputs and outputs at the character level. such models likely have the best chance of learning character-level concepts and operations. however, with only a few exceptions @xcite @xcite , our best general-purpose models at present do not tokenize their inputs into characters, but rather into words and subword units @xcite @xcite @xcite @xcite . there is thus a tension between solving character-level tasks and developing taskagnostic solutions. in this paper, we develop a causal interventionbased framework for pushing subword-based models to encode character-level information in their internal representations, in effect teaching them which characters their tokens contain. the techniques are based on the interchange intervention training (iit) method of @xcite , which trains neural hidden representations to correspond to variables in a high-level causal model capturing aspects of the task domain. we apply iit at the level of variable types (type-level iit), which allows us to learn robust, position-independent representations of characters in the hidden states of subword-based models. we compare against ap-proaches that tokenize inputs and/or outputs at the character level. we introduce a suite of character-level evaluation tasks (figure 1 ). all of these tasks depend heavily on character-level manipulation of forms, but they differ in terms of how much they (a) involve meaning and (b) depend on the full context of the input string (see ## character-level interventions character-level inputs or outputs provide models with direct evidence for learning about characters (a) intervention on the high-level causal model for the reversal task. the variable representing the last character of the word "abc" is set to the value of the variable representing the first character of the word "def". the effect of intervention is the output of the base example is changed from "cba" to "dba". our core method for doing this is interchange intervention training (iit; @xcite ). iit has three steps. (1) define a high-level causal model of the problem domain. (2) align a variable v in that causal model with a set of neurons n in one's target neural model. (3) train the neural model to make predictions according to the causal model using not only standard input-output pairs, but also interchange interventions: counterfactual instances created by replacing the values of n in a target example with those obtained by processing a distinct input, with the counterfactual label provided by the causal model from step (1). the effect of this process is to train the model to represent the variable v in the neurons n , which leads to modular internal structure for the network. ## experiments to evaluate how character, subword, and intervention-based models generalize with respect to form, meaning, and context, we experiment on the six character manipulation tasks in figure 1 . ## conclusion character-level tasks have emerged as an achilles heel for large language models that use subword tokenization. these models do not reliably represent the mapping from subword tokens to the characters they contain, and thus they stumble with characterlevel manipulations. we showed that type-level iit can help. using type-level iit, we trained networks to internally represent characters, and we introduced a new suite of tasks that assess models on character-level tasks involving different combi-nations of form, meaning, and context. while our subword+iit models lag behind character-level tokenization models on simple character-level tasks, they are superior for tasks that blend form, meaning, and context. overall, these findings suggest that intervention-based methods like iit provide a powerful set of techniques for training models to modularly represent different kinds of information at different levels of abstraction.