Part-Of-Speech Sensitivity of Routers in Mixture of Experts Models

Elie Antoine, Frédéric Béchet, Philippe Langlais · 2024

Read Part-Of-Speech Sensitivity of Routers in Mixture of Experts Models by Elie Antoine, Frédéric Béchet, Philippe Langlais (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-16971.txt.

Introduction

Elie Antoine, Frédéric Béchet, and Philippe Langlais check whether expert routers in language models care about grammar. Their paper appeared in two thousand twenty-four. Mixture of experts models send each token to a few chosen subnetworks. The router makes that choice on the fly. The authors ask if routing follows part of speech. Nouns, verbs, and other classes might get their own experts.

They trace token paths through six popular models of this kind. Experts do specialize for certain word classes. Routing paths alone predict a token's part of speech with high accuracy. The pattern holds across different architectures. That makes paths a useful lens on tokens. The study shows linguistic structure emerging inside the routing machinery.

Catalog record

CREATORElie Antoine, Frédéric Béchet, Philippe Langlais
YEAR2024
COLLECTIONPAPERS
FORMATTXT
FILE SIZE22 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2412-16971

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Part-Of-Speech Sensitivity of Routers in Mixture of Experts Models Elie Antoine, Frédéric Béchet, Philippe Langlais Abstract This study investigates the behavior of model-integrated routers in Mixture of Experts (MoE) models, focusing on how tokens are routed based on their linguistic features, specifically Part-of-Speech (POS) tags. The goal is to explore across different MoE architectures whether experts specialize in processing tokens with similar linguistic traits. By analyzing token trajectories across experts and layers, we aim to uncover how MoE models handle linguistic information. Findings from six popular MoE models reveal expert specialization for specific POS categories, with routing paths showing high predictive accuracy for POS, highlighting the value of routing paths in characterizing tokens. 1 Introduction Mixture of Experts (MoE) models, inspired by ensemble methods, offer an efficient parameter-to-performance ratio by partitioning the Feed Forward Network (FFN) layers into sub-groups of parameters called " experts ". A router model learns to direct each token to a subset of these experts, resulting in bare computation (or effective parameter count) that is significantly lower than what would be required for an equivalent dense model. While many studies on MoE training include analyses of expert coactivations and potential specializations, often focusing on language or domain-specific tasks, comprehensive evaluations and comparisons of expert behavior across different MoE models remain scarce. These studies typically address specific aspects of MoE performance, leaving broader trends in expert behavior underexplored. Notably, related analyses of token routing, such as those in OpenMoE Xue et al. (2024) and OLMoE Muennighoff et al. (2024) , were part of broader investigations into model training. They revealed that tokens with the same token ID are often routed to the same expert regardless of context, suggesting inherent biases in routing mechanisms. Mixtral Jiang et al. (2024) additionally hinted at syntactic specialization occurring, but this phenomenon has yet to be systematically studied across models. Similarly, Zoph et al. (2022) found that in an encoder-decoder network, specialization on syntactic features occurred only in the encoder experts, with no specialization in the decoder ones. However, the specific types of specialization carried out by these experts, particularly from a linguistic perspective, and whether these specializations are consistent across different model architectures remain unclear. We propose in this study to analyze routing decisions in open-weight MoE models to investigate whether experts specialize based on the syntactic nature of tokens represented by their parts-of-speech (POS) labels. By examining the top- k experts chosen at each layer, we explore specialization in terms of tokens’ POS labels both within individual layers and across the entire routing path of tokens. We use POS because they serve as the fundamental building block for the entire syntactic structure of a sentence. Our aim is thus to determine whether the routers acquired this crucial linguistic knowledge during the token processing. We also leverage model-integrated routers from each layer as probing tools inspired by traditional probing methods such as the one of Shi et al. (2016) by examining the sequence of top- k experts selected at each layer. The goal of this study is to answer these two research questions: • Q_{1} : Are routers in Mixture of Experts models sensitive to the part of speech of tokens? • Q_{2} : Does this specialization occur in specific layers, or do the entire routing paths also encode syntactic information at the token level? 2 Background on MoE architecture with Transformers A dense transformer Vaswani et al. (2017) model is constructed by stacking L layers of transformer blocks, each comprising a self-attention module and a FFN. MoE language models typically replace FFNs with MoE layers that consist of multiple "experts", which are smaller FFNs. In most cases, these experts are not trained to specialize in specific parts of the data; rather, they are subdivisions of the dense FFN layer into smaller networks aimed at computational efficiency. The top- k routing mechanism, originally proposed by Shazeer et al. (2017) is composed at each layer by a router (or gating network) which directs tokens to specific experts based on their relevance as follows. The router is a learned linear layer that maps input representations x to logits h(x) using a trainable weight matrix W_{r} . This can be expressed as: h(x)=W_{r}\cdot x\vskip-5.69054pt The logits h(x) are normalized using a softmax function to produce routing probabilities p(x) , ensuring they sum to one. The probability of routing token x to the i^{th} expert among N is given by : p_{i}(x)=\frac{e^{h(x)_{i}}}{\sum_{j=1}^{N}e^{h(x)_{j}}}\vskip-5.69054pt The router selects the top- k experts based on the highest routing probabilities. This selection is implemented by taking the softmax over the top- k logits of the linear layer. Formally, we define: G(x):=\text{Softmax}(\text{TopK}(x\cdot W_{r}))\vskip-5.69054pt where \text{TopK}(\ell)_{i}:=\ell_{i} if \ell_{i} is among the top- k coordinates of logits \ell\in\mathbb{R}^{N} and -\infty otherwise. Each selected expert E_{i} processes the input x . The output of each expert is then weighted by its respective routing probability p_{i}(x) . The final output of the MoE layer is the weighted sum of the outputs from the selected experts where T denotes the set of indices of the top- k selected experts: y=\sum_{i\in T}p_{i}(x)E_{i}(x) This mechanism allows for efficient and adaptive routing of tokens, using only the most relevant experts per token. The value of k corresponding to the number of experts used per token, is a key hyperparameter that modulates the amount of computation required for processing each token. By increasing the total number of experts ( N ) while keeping k fixed, one can expand the model’s parameter count (sparse parameter count) without significantly increasing computational cost, as only k experts are active per token. Various optimizations, including sparse matrix multiplications and expert parallelism, can further enhance performance and manage GPU load balancing. For more details, see Fedus et al. (2022) . While classical MoE models do not have experts specifically trained for distinct data aspects, some research explored the concept of experts as fully independent models Gururangan et al. (2022) ; Li et al. (2022) . Leveraging modularity and composability allows experts to be trained on specific domains, thereby enabling the construction of custom networks from these specialized components. We are not interested in the latter, but want to analyse whether model experts who are not trained in a specific way for a sub-task show specialization. Figure 1: Example of token routing with 2 of 8 selected experts. For "human_", the path is [(1,4),(8,3),\ldots,(1,2)] ; for "_ities", it is [(6,4),(2,5),\ldots,(2,8)] . 3 Methodology In this study, we utilize model-integrated routers primarily designed to direct tokens to relevant experts. Although their main function is to route tokens efficiently, we leverage these routers as probing tools to gain insights into the model behavior. These routers, already part of the trained model architecture, allow us to analyze the sequence of top- k experts chosen at each layer. By inputting sentences into various models, we record the sequence of experts assigned to each token per layer, as shown in Figure 1 . The signals we use for our analysis are thus very light, in the worst case being of size \mathcal{S}=\#route\;expert\times\#layer . For example, with Mixtral-8x7B-v0.1 Jiang et al. (2024) , a model of 32 layers having 2 of 8 experts routed for each token lead to a 32\times 2

Read the complete text