YellowMIST-Switch-1.0-INS
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 South Indic scripts: 6 languages, plus other for numbers, punctuation and symbols.
- Built on
olaverse/YellowMIST-Encoder-15M-INS, 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)
Runs of words from two real paragraphs, spliced at word boundaries, from documents never used in training.
- Word accuracy: 99.9%
- Switch-point F1 (finding where the language changes): 0.997
No public code-switching test set covers a pair inside this group yet, so the synthetic test is the only one.
Training
- 6,000 steps of 64 examples. Each example splices runs of words from two languages of the group, at word boundaries. The main language carries about 65% of the words, and the other is usually a lingua franca (English, French, Spanish, Portuguese, Arabic, Russian, Hindi or Swahili where the group has it). 30% of examples are in one language only, so the model learns not to see switches that are not there.
- 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=["tam_Taml", "kan_Knda"], sensitivity=0.5):
print(w.text, w.lang, round(w.score, 2))
import * as ym from "yellowmist";
await ym.switch("your mixed text", { langs: ["tam_Taml", "kan_Knda"] });
yellowmist switch "your mixed text" --langs tam_Taml,kan_Knda
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-INS", 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 = ["tam_Taml", "kan_Knda"] # 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("INS") # this region's base encoder
model = train.finetune_switch(enc, {"tam_Taml": paragraphs_a, "kan_Knda": 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-ins,
title = {YellowMIST-Switch-1.0-INS: tiny on-device code-switching detection},
author = {Olaverse},
year = {2026},
url = {https://huggingface.co/olaverse/YellowMIST-Switch-1.0-INS}
}
- Downloads last month
- 4
Model tree for olaverse/YellowMIST-Switch-1.0-INS
Base model
olaverse/YellowMIST-Encoder-15M-INS