Paper: 2602.17655 Authors: Clara Meister, Ahmetcan Yavuz, Pietro Lesci, Tiago Pimentel Categories: cs.CL
Abstract
Language Identification (LID) remains a critical yet challenging task in multilingual NLP, particularly for low-resource languages and closely related dialects. This paper introduces UniLID, an innovative approach that repurposes the UnigramLM tokenization algorithm for language identification. By learning language-conditional unigram distributions over a shared vocabulary while treating segmentation as language-specific, UniLID achieves remarkable sample efficiency—exceeding 70% accuracy with merely five labeled examples per language. The method demonstrates competitive performance against established baselines like fastText, GlotLID, and CLD3 on standard benchmarks, while offering substantial improvements in low-resource scenarios and fine-grained dialect distinction.
Key Contributions
- Tokenizer-as-classifier paradigm: Reframes LID as a probabilistic segmentation problem using UnigramLM’s expectation-maximization framework
- Extreme sample efficiency: Achieves over 70% accuracy with just 5 training samples per language, dramatically outperforming existing methods in few-shot settings
- Incremental language support: Enables adding new languages without retraining existing models, supporting modular and scalable deployment
- Dialect-aware identification: Delivers significant performance gains on fine-grained dialect identification tasks where traditional methods struggle
- Seamless integration: Naturally fits into existing tokenization pipelines, reducing computational overhead in multilingual LM workflows
Methodology: Probabilistic Segmentation for LID
UniLID builds on the UnigramLM tokenization algorithm, which models text segmentation as a probabilistic process. For a given text , the algorithm finds the optimal segmentation by maximizing:
where represents individual tokens in the segmentation. UniLID extends this by introducing language-conditional distributions:
The key insight is treating segmentation preferences as language-specific signals. Languages exhibit distinct tokenization patterns—for instance, agglutinative languages favor longer morpheme-based tokens, while isolating languages prefer character-level segmentation. By learning separate unigram distributions for each language over a shared vocabulary, UniLID captures these linguistic preferences.
Parameter estimation uses the standard EM algorithm from UnigramLM, but applied independently per language. During inference, the model computes the likelihood of the input text under each language model and selects the language with maximum probability. This formulation is computationally efficient, requiring only forward passes through unigram distributions without neural network inference.
Experimental Results and Analysis
The authors evaluate UniLID across multiple dimensions, comparing against three strong baselines: fastText (neural n-gram classifier), GlotLID (transformer-based), and CLD3 (character n-gram with Naive Bayes).
Standard benchmarks: On high-resource test sets, UniLID achieves competitive performance with established methods, demonstrating that the tokenizer-based approach doesn’t sacrifice accuracy for efficiency. The method performs particularly well on languages with distinctive orthographic or morphological characteristics.
Low-resource superiority: The most striking results emerge in few-shot scenarios. With only 5 training samples per language, UniLID surpasses 70% accuracy, while neural baselines like fastText struggle to exceed 40%. At 10 samples, the gap widens further, with UniLID approaching 80% accuracy. This dramatic improvement stems from the method’s inductive bias—unigram distributions require far fewer parameters than neural models, making them less prone to overfitting on limited data.
Dialect identification: UniLID shows substantial gains on fine-grained dialect tasks, such as distinguishing between Arabic varieties or Chinese dialects. Traditional LID systems often collapse closely related varieties into single categories, but UniLID’s segmentation-based approach captures subtle lexical and morphological differences. For instance, dialectal variations in compound formation or affix usage produce distinct tokenization patterns that the model exploits.
Computational efficiency: Training time scales linearly with vocabulary size and corpus size, making UniLID orders of magnitude faster than neural approaches. The method also supports incremental updates—adding a new language requires only estimating its unigram distribution, leaving existing language models untouched.
Implications for Multilingual NLP
UniLID’s design philosophy challenges the prevailing trend toward ever-larger neural models for every NLP task. By demonstrating that classical probabilistic methods can outperform neural approaches in data-constrained settings, the work highlights the importance of inductive biases aligned with task structure.
The incremental learning capability addresses a practical pain point in production systems: as new languages or dialects emerge in user data, systems can adapt without expensive retraining. This modularity is particularly valuable for platforms serving diverse linguistic communities.
Integration with tokenization pipelines offers architectural elegance. Since modern LLMs already employ tokenizers, incorporating LID at this stage adds minimal overhead while providing early language detection for downstream routing, prompt engineering, or model selection. This could enable more efficient multilingual serving architectures where language-specific models are invoked only when needed.
The success on dialect identification opens possibilities for sociolinguistic applications, such as analyzing code-switching patterns, tracking language variation in social media, or building more inclusive language technologies that recognize non-standard varieties.
Takeaways
- Tokenization algorithms encode rich linguistic information that can be repurposed for classification tasks beyond segmentation
- In low-resource settings, simple probabilistic models with appropriate inductive biases can dramatically outperform data-hungry neural approaches
- Treating segmentation as a language-specific phenomenon provides a powerful signal for language identification, especially for closely related varieties
- Modular, incremental learning architectures offer practical advantages for production systems dealing with evolving language distributions
- The gap between high-resource and low-resource LID performance can be substantially narrowed through sample-efficient methods, democratizing multilingual NLP capabilities
论文: 2602.17655 作者: Clara Meister, Ahmetcan Yavuz, Pietro Lesci, Tiago Pimentel 分类: cs.CL
摘要
语言识别(LID)在多语言自然语言处理中至关重要,但在低资源语言和近缘方言场景下仍面临挑战。本文提出 UniLID,一种创新方法,将 UnigramLM 分词算法重新用于语言识别。通过在共享词表上学习语言条件的 unigram 分布,同时将分词视为语言特定现象,UniLID 实现了显著的样本效率——仅用每语言 5 个标注样本就能超过 70% 的准确率。该方法在标准基准上与 fastText、GlotLID 和 CLD3 等成熟基线表现相当,同时在低资源场景和细粒度方言区分上取得大幅提升。
主要贡献
- 分词器即分类器范式: 将语言识别重构为使用 UnigramLM 期望最大化框架的概率分词问题
- 极致样本效率: 仅用每语言 5 个训练样本即达到 70% 以上准确率,在少样本设置下大幅超越现有方法
- 增量语言支持: 可在不重训现有模型的情况下添加新语言,支持模块化和可扩展部署
- 方言感知识别: 在传统方法难以处理的细粒度方言识别任务上实现显著性能提升
- 无缝集成: 自然融入现有分词流程,降低多语言语言模型工作流的计算开销
方法论: 用于语言识别的概率分词
UniLID 基于 UnigramLM 分词算法构建,该算法将文本分词建模为概率过程。对于给定文本 ,算法通过最大化以下目标找到最优分词 :
其中 表示分词中的单个 token。UniLID 通过引入语言条件分布扩展了这一框架:
核心洞察在于将分词偏好视为语言特定信号。不同语言展现出独特的分词模式——例如,黏着语倾向于更长的词素级 token,而孤立语偏好字符级分词。通过为每种语言 在共享词表上学习独立的 unigram 分布 ,UniLID 捕获了这些语言学偏好。
参数估计使用 UnigramLM 的标准 EM 算法,但针对每种语言独立应用。推理时,模型计算输入文本在各语言模型下的似然,选择概率最大的语言。这种形式计算高效,仅需通过 unigram 分布进行前向传播,无需神经网络推理。
实验结果与分析
作者从多个维度评估 UniLID,与三个强基线对比:fastText(神经 n-gram 分类器)、GlotLID(基于 transformer)和 CLD3(字符 n-gram 配合朴素贝叶斯)。
标准基准: 在高资源测试集上,UniLID 与成熟方法表现相当,证明基于分词器的方法不会为效率牺牲准确性。该方法在具有独特正字法或形态特征的语言上表现尤为出色。
低资源优势: 最显著的结果出现在少样本场景。仅用每语言 5 个训练样本,UniLID 就超过 70% 准确率,而 fastText 等神经基线难以超过 40%。在 10 个样本时,差距进一步扩大,UniLID 接近 80% 准确率。这种显著改进源于方法的归纳偏置——unigram 分布所需参数远少于神经模型,在有限数据上更不易过拟合。
方言识别: UniLID 在细粒度方言任务上显示出大幅提升,如区分阿拉伯语变体或汉语方言。传统语言识别系统常将近缘变体归为单一类别,但 UniLID 基于分词的方法能捕获细微的词汇和形态差异。例如,方言在复合词构成或词缀使用上的变化会产生独特的分词模式,模型可以利用这些模式。
计算效率: 训练时间与词表大小和语料规模线性相关,使 UniLID 比神经方法快几个数量级。该方法还支持增量更新——添加新语言仅需估计其 unigram 分布,现有语言模型保持不变。
对多语言自然语言处理的启示
UniLID 的设计理念挑战了为每个 NLP 任务都使用更大神经模型的主流趋势。通过证明经典概率方法在数据受限设置下可以超越神经方法,这项工作强调了与任务结构对齐的归纳偏置的重要性。
增量学习能力解决了生产系统的实际痛点:当用户数据中出现新语言或方言时,系统可以适应而无需昂贵的重训练。这种模块化对服务多样化语言社区的平台尤为宝贵。
与分词流程的集成提供了架构优雅性。由于现代大语言模型已采用分词器,在此阶段整合语言识别仅增加最小开销,同时为下游路由、提示工程或模型选择提供早期语言检测。这可能实现更高效的多语言服务架构,仅在需要时调用特定语言模型。
在方言识别上的成功为社会语言学应用开辟了可能性,如分析语码转换模式、追踪社交媒体中的语言变异,或构建识别非标准变体的更包容性语言技术。
要点总结
- 分词算法编码了丰富的语言学信息,可以重新用于分词之外的分类任务
- 在低资源设置下,具有适当归纳偏置的简单概率模型可以显著超越数据饥渴的神经方法
- 将分词视为语言特定现象为语言识别提供了强大信号,尤其对近缘变体有效
- 模块化增量学习架构为处理演化语言分布的生产系统提供了实用优势
- 通过样本高效方法可以大幅缩小高资源和低资源语言识别性能差距,推动多语言自然语言处理能力的民主化