arXiv:2609.05099cs.CLSep 2026

Manuscript Offprint

arXiv:2609.05099

Improving Language Identification for Code-Switched Utterances with Integer Linear Programming

Joanna Radoła, Josep Maria Crego, François Yvon

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original. This text is shared under the same licence.

Abstract

Automatic identification of code-switched (CS) utterances remains a challenge for language identification (LID) systems, causing such texts to be underrepresented in the training data of Large Language Models. In this paper, we revisit MaskLID, a state-of-the art approach for CS identification, which requires no training and detects arbitrary language combinations. We make three main contributions: (a) we reveal, and address, a major issue of MaskLID: its overreliance on word-level language association scores; (b) we reformulate the underlying optimization algorithm as an Integer Linear Program, enabling us to experiment with a large set of clear and interpretable constraints; (c) each of these improvements vastly improves the baseline system, as we illustrate in experiments involving 10 diverse languages, where we observe a strong boost in performance on CS benchmarks. We release our code and data for reproducibility.

github.com/jradola/ILP4LID

1 Introduction

The development of multilingual language technologies (LTs), illustrated by the rise of multilingual models trained on webscale corpora (Imani et al., 2023; Kudugunta et al., 2023; Üstün et al., 2024), requires effective multilingual natural language processing (NLP) tools, capable to handle as many languages as possible. Among these, language identification (LID) tools stand out as they are usually used in early stages of the data collection and filtering (Abadji et al., 2021; Kargaran et al., 2024a; Penedo et al., 2025): high-precision LIDs are especially critical for low-resource languages, which can easily get mixed with dominant languages, thereby compromising the quality of the resulting LTs (Kreutzer et al., 2022).

In its basic form, Language Identification (LID) is framed as a supervised text classification task,

where the language code of the text is the target label to be predicted. Modern LIDs detect several hundreds languages, with recent work claiming to cover over a thousand (Brown, 2014; Dunn, 2020; NLLB Team et al., 2024; Adebara et al., 2022; Jauhiainen et al., 2022; Burchell et al., 2023; Kargaran et al., 2023, 2024a). Many of these rest on a FastText backbone (Bojanowski et al., 2017), which provides an efficient implementation for text classification at scale and also ships with a pretrained LID model recognizing 176 languages.¹

Challenges of contemporary LIDs are reviewed in e.g., (Jauhiainen et al., 2019; Caswell et al., 2020; Burchell et al., 2024; Goot, 2025). They include the discrimination of typologically related languages and the computation of well-calibrated posterior probabilities. LIDs also often struggle with short texts, especially when written in a non-standard orthographies, as social media posts. A last challenge, that we address in this work, is their inability to handle intra-sentential code-switching (CS), where several languages simultaneously occur in the same sentence. This phenomenon is particularly widespread in informal communication contexts (Doğruöz et al., 2021).

Our starting point is MaskLID (Kargaran et al., 2024b), which turns generic LIDs into CS LIDs thanks to a simple post-processing layer. This approach is conceptually simple, requires no training and enables to recognize arbitrary language combinations. It thus provides us with a strong baseline, with many desirable properties.

We make three main contributions: (a) we reveal a major issue of MaskLID: its over-reliance on inaccurate word-level language association scores that we address using an improved underlying LID; (b) we reformulate the language assignment algorithm as an Integer Linear Program, enabling us to ex-

¹https://fasttext.cc/docs/en/language-identification.html periment with a large set of clear and interpretable constraints on CS utterances; (c) we observe, in experiments involving 10 languages, both low and high resource, that each of these improvements vastly improve the baseline system, with boosts in accuracy up to +100% on several CS benchmarks.

References (21)