YellowMIST-Switch-1.0-ESA
YellowMIST Switch tells you the language of every word in mixed-language text, such as a message that moves between
a local language and English or French mid-sentence. It is a tiny on-device model, one per script or region group.
This one covers Central, East and Southern Africa (Latin script): 44 languages, plus other for numbers, punctuation and symbols.
- Built on
olaverse/YellowMIST-Encoder-15M-ESA, a 15M-parameter character encoder, fine-tuned with one label per character and averaged per word. - Works on any spelling: it reads characters, so slang, missing tone marks and typos do not break a tokenizer.
Results
Synthetic mixed text (held-out documents)
Mixed text built the same way as the training examples (runs of words and dropped-in words from two languages), from documents never used in training.
- Word accuracy: 90.1%
- Switch-point F1 (finding where the language changes): 0.839
Hand-labelled messages
11 short messages written the way people mix languages in chat, mostly a local language with English words dropped in, and a few in one language only. Languages named: the app tells the model which languages the user writes. No hint: any language of the group.
| word accuracy | switch-point F1 | whole message right | |
|---|---|---|---|
| languages named | 84.9% | 0.560 | 45.5% |
| no hint | 81.1% | 0.560 | 36.4% |
The set is small, so treat a few points either way as noise. It is used only as a test.
No public code-switching test set covers a pair inside this group yet.
Training
- 6,000 steps of 64 examples built from the YellowMIST corpus. Half of the mixed examples are main-language text with one- or two-word islands of another language, mostly English, the commonest real pattern. The rest alternate runs of words between two languages, and 30% of examples are in one language only.
- English words found inside other languages' paragraphs are labelled English, by comparing how often each word appears in English and in that language, instead of taking the paragraph's language.
- Languages are drawn in proportion to the size of their text (to the power 0.3), so very small languages are not guessed as often as large ones.
- Chat-style noise in training: lower case, no punctuation and missing tone marks.
- All training text comes from the YellowMIST corpus. The LinCE sets are used only as tests and are not stored here.
Use
With the yellowmist library (recommended)
pip install yellowmist # or: npm install yellowmist
import yellowmist as ym
for w in ym.switch("your mixed text", langs=["swh_Latn", "eng_Latn"], sensitivity=0.5):
print(w.text, w.lang, round(w.score, 2))
import * as ym from "yellowmist";
await ym.switch("your mixed text", { langs: ["swh_Latn", "eng_Latn"] });
yellowmist switch "your mixed text" --langs swh_Latn,eng_Latn
The library downloads this model the first time it is needed, picks the right region for each language, and runs it
with ONNX Runtime on the CPU. Name the languages your user writes (langs): it is far more accurate than choosing among every language of the region. sensitivity (0-1) catches more or fewer switches.
Without the library (ONNX Runtime)
import json, unicodedata, numpy as np, onnxruntime as ort
from huggingface_hub import snapshot_download
d = snapshot_download("olaverse/YellowMIST-Switch-1.0-ESA", allow_patterns=["onnx.json", "vocab.json", "model.int8.onnx"])
meta, v = json.load(open(f"{d}/onnx.json")), json.load(open(f"{d}/vocab.json"))
ids = {t: i for i, t in enumerate(v["vocab"])}
labels = meta.get("classes") or v["labels"] + ["other"] # one output per language, then "other"
sess = ort.InferenceSession(f"{d}/model.int8.onnx")
langs = ["swh_Latn", "eng_Latn"] # the languages this user writes
words = unicodedata.normalize("NFC", "your mixed text").split() # up to ~250 characters per call
seq, owner = [ids["<eot>"]], [-1]
for k, w in enumerate(words):
if k: seq.append(ids[" "]); owner.append(-1)
seq += [ids.get(c, 1) for c in w]; owner += [k] * len(w)
x = np.zeros((1, meta["length"]), np.int64); m = np.zeros((1, meta["length"]), np.float32)
x[0, :len(seq)] = seq; m[0, :len(seq)] = 1
logits = sess.run(None, {"ids": x, "mask": m})[0][0, :len(seq)]
allowed = np.array([0.0 if l in langs or l == "other" else -np.inf for l in labels])
owner = np.array(owner)
for k, w in enumerate(words):
s = logits[owner == k].mean(0) + allowed
print(w, labels[int(s.argmax())])
Fine-tune your own
The fine-tuning notebook (open in Colab) walks through continuing pretraining on your own text, fine-tuning a task, exporting to ONNX and sharing it. In short:
from yellowmist import train
import yellowmist as ym
enc = train.Encoder.load("ESA") # this region's base encoder
model = train.finetune_switch(enc, {"swh_Latn": paragraphs_a, "eng_Latn": paragraphs_b})
model.save("my-model") # weights + ONNX, ready for the library
ym.register("switch", "my-model") # your model now serves its languages
pip install "yellowmist[train]" for training (PyTorch and Dew).
More: documentation · GitHub · playground · fine-tuning notebook
Limits
- Real code-switching is messier than spliced text: switches inside a word, borrowed words, and languages outside the group. Expect lower accuracy than the synthetic score.
- A word that is spelled the same in two languages is ambiguous on its own; context helps, but not always.
Licence
Apache-2.0.
Citation
@misc{yellowmist-switch-1.0-esa,
title = {YellowMIST-Switch-1.0-ESA: tiny on-device code-switching detection},
author = {Olaverse},
year = {2026},
url = {https://huggingface.co/olaverse/YellowMIST-Switch-1.0-ESA}
}
- Downloads last month
- 6
Model tree for olaverse/YellowMIST-Switch-1.0-ESA
Base model
olaverse/YellowMIST-Encoder-15M-ESA