Zero Labs
Industry News / AI

My Model Thought Tamil Was Telugu: Open-Source Language ID for Hinglish, Tanglish and Kanglish

Source · Towards AI By Latent AI Labs

From the publisher’s feed, collected in the ZeroLabs newsroom.

Bhasha tags every word of code-mixed Indian text with its language. My test said Tamil scored 0.87; human-labelled comments said 0.72.By Arun Prabhakaran · @LatentAILabsTL;DRBhasha (arunp0/bhasha-lid-indic) is a free, open-source model that tags each word of a message with its language: Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Urdu, Odia or English, plus name and other. It reads Roman letters, native scripts and messages that mix both.I found no licensed, released word-level model for romanised Tamil, Malayalam or Kannada mixed with English. On real YouTube comments (LLM-labelled), the released Hindi/Bengali word-level models score 0.28–0.44 and the other released models I tested score 0.64–0.79; Bhasha scores 0.87–0.89.Not best everywhere: a 2022 shared-task Kannada model beats Bhasha on a test from its own shared-task series (0.954 vs 0.903), though Bhasha leads on independent comments (0.888 vs 0.724).On human-labelled sets it scores 0.84–0.90 on Kannada, 0.91–0.95 on Malayalam and 0.90 on Hindi–English (macro-F1).Tamil is its weak spot: 0.72 on human-labelled comments. My own test set had said 0.87. About a third of the Tamil words were tagged Telugu.Every training row was built by code from public text: no hand labels, no LLM-written text. Apache-2.0, 278M parameters, runs on a CPU.Parts of this article were drafted with AI assistants; I checked every number against the model card and the evaluation logs.The problem: one message, two languages, one scriptHere is a made-up comment of the kind you see under any Tamil film trailer:“padam semma mass bro, second half konjam slow but climax vera level”Half of it is Tamil, half English, all of it in Roman letters. Swap the film for cricket and you get the same thing in Hinglish, Manglish (Malayalam) or Kanglish (Kannada). Many people in India type like this on their phones.Most language-ID tools give one label per message. That is fine for routing a whole message, but not when you need to know which words are Tamil:to send each word to the right transliterator or spell-checker,to pick the right tokenizer or translation model,to measure how much code-mixing is in your data,to filter a corpus by language when half of each sentence is English.There are good word-level models for Hinglish. For Tamil, Malayalam and Kannada mixed with English, I found only two downloadable checkpoints, both without a licence: the 2022 shared-task winner for Kannada (a DistilBERT that judges one word at a time) and a Malayalam model with no model card. Newer MIT models such as MixLID cover these languages only in their native scripts. Nothing I found handles romanised Tamil, so I built a model. Bhasha simply means “language”.It works well for Kannada and Malayalam. Tamil taught me something I did not expect: on human-labelled comments, Bhasha calls about a third of Tamil words Telugu, including every Tamil word in the comment above. Most of this post is about how I found that, and why my own test set missed it.It is the fourth model in a small open set for Indian languages, after Yama (zero-shot classification), Chitragupta (PII detection) and Nandi (complaint routing).What Bhasha returns# pip install transformers torch huggingface_hubimport os, sysfrom huggingface_hub import hf_hub_downloadsys.path.insert(0, os.path.dirname(hf_hub_download("arunp0/bhasha-lid-indic", "lid_wrapper.py")))from lid_wrapper import LIDlid = LID("arunp0/bhasha-lid-indic")lid("ನಾಳೆ meeting ಇದೆ")# {'words': [('ನಾಳೆ', 'kn'), ('meeting', 'en'), ('ಇದೆ', 'kn')],# 'main': 'kn', 'script': 'mixed', 'mixed': True, 'share': {'kn': 0.667, 'en': 0.333}}lid("bro naan nalaiku office varala", langs=["ta"]) # you know it is Tamil + English# {'words': [('bro', 'en'), ('naan', 'ta'), ('nalaiku', 'ta'), ('office', 'en'), ('varala', 'ta')], 'main': 'ta', ...}Besides a label per word, you get a message summary: the main language, the script (native, roman or mixed), whether the message is mixed, and the share of each language. Romanised Hindi and Urdu are often the same words, so when the model cannot tell them apart it returns hi/ur instead of guessing.The langs argument matters, and the Tamil section explains why. If you know which language pair your text is in, pass it.Training data: 1.65 million sentences, mixed by codeNo openly licensed, word-labelled code-mixed corpus covers these languages, so every training row was built by code:Start from real native sentences. IndicCorp v2 (CC0) has news and web text in all 11 languages and English.Romanise them the way people type. For each native word, code picked a Roman spelling from Aksharantar (CC-BY), the IndicXlit transliteration model (MIT) and simple rules, weighted by how often each spelling appears in real romanised web text (FineWeb-2 word counts). So नहीं becomes “nahi” most of the time and “nahin” or “nhi” some of the time.Mix in English. Code dropped English spans of 1–6 words into the sentence and recorded the language of every word, so every language label is set by code, not guessed. (Name and English-loanword tags use simple rules, so they are less exact.)Add the mess. Names from Wikidata, emoji, @mentions, numbers, stretched words (“superrr”), dropped vowels (“nhi”), random capitals and native-script words mixed into roman text.The result is 1.65 million rows across 11 languages: romanised, mixed, native, native mixed, mixed script and plain English. No training row overlapped an evaluation set (two native-script test sentences that matched training text were dropped from that test), and a later check found no overlap with the human-labelled sets either. Then I fine-tuned XLM-RoBERTa-base for one epoch, which took about an hour on one L4 GPU.There are no hand labels and no LLM-written text in the training data. That keeps the licence clean, but it has a cost: all of the Indian-language text started as news and web writing. That cost shows up in the Tamil section.My test said 0.87 to 0.89Before training, I wrote down the evaluation plan and a bar for each language pair: beat the better of two GlotLID baselines, with a margin of 0.10 over GlotLID applied word by word. Then I built a real test set: 425 YouTube comments from DravidianCodeMix (CC-BY): 150 Tamil, 150 Malayalam and 125 Kannada, each mixed with English. Each word was labelled by two Claude passes and by Gemini, and a 2-of-3 vote decided. The three labellers agreed on 95–99% of words.These labels are LLM-reviewed, not human-verified. I scored the frozen model once.The released Hinglish and Indic word-level models were built for Hindi, Bengali and Gujarati. They have no Tamil, Malayalam or Kannada label, so they fail here.(Macro-F1 here averages two F1 scores, one for the Indian language and one for English. 1.0 is perfect, and a model that never finds the Indian language tops out near 0.5.)Malayalam 0.888 and Kannada 0.888 clear their bars comfortably.Tamil 0.873 beats the strongest baseline (GlotLID on the whole sentence, 0.812), but misses the bar I set (0.878) by 0.005. That bar is my own, not an external benchmark.Hindi–English: on the COMI-LINGUA test set Bhasha scores 0.896, ahead of muril-hinglish-lid (0.857). On LinCE it scores 0.922 against muril-hinglish-lid’s 0.952. That model was trained on real Hinglish, and I used LinCE as a development check during training, so the LinCE number is not independent.At this point I would have shipped with the Tamil miss stated. Then I found human-labelled data.Human labels said Tamil 0.72I found three sets of Dravidian code-mixed text with word-level language labels written by people:CoLI-Dravidian 2024 (FIRE shared task): Tamil, Malayalam and Kannada YouTube comments in Roman letters, labelled by native speakers.CoLI-Kanglish (ICON 2022): Kannada–English YouTube comments, independent of CoLI-Dravidian (no shared text).WoLLaI (Pondicherry University, CC BY): 12,401 Malayalam–English sentences.I used them for evaluation only, with the model frozen, and scored each set once. I report totals only and do not redistribute them (the CoLI files state no licence). The CoLI files have one word per row and no sentence breaks, so I scored them in 12-word windows.Malayalam and Kannada hold up on human labels. Tamil does not.I also ran the released models I had found on the same sets:distilka, the 2022 Kanglish winner, beats Bhasha on CoLI Kannada: 0.954 against 0.903 (0.936 with the language hint). It was trained on data from the same shared-task series. On my independent Kannada comments, Bhasha leads, 0.888 against 0.724. Two caveats: those comments have LLM labels, and distilka’s labels are unnamed, so I mapped them using its own training data.The Malayalam XLM-R checkpoint ties Bhasha on WoLLaI (0.952 each), but scores 0.682 on CoLI Malayalam and 0.638 on my comments, against 0.911 and 0.888.MixLID gets almost no romanised Indian words right (Indian-language F1 near 0), as expected for a native-script model. On native-script sentences it is close to Bhasha: 0.9916 against 0.9956. I ran it the way its own helper code does (plain Transformers, no remote code), taking each word’s first sub-token as the word’s label.So Bhasha is not the best Kannada model on every test. But it is the only one I found that scores 0.84 or higher on every Kannada and Malayalam set, and the only licensed word-level model I found for romanised Tamil, Malayalam or Kannada.Malayalam and Kannada matched my LLM-labelled test, which is reassuring. Tamil fell from 0.87 to 0.72. A drop that large is a finding, not noise.One caveat: of the three CoLI files, the Tamil one kept its original word order least well, and context helped it least. So part of the drop may come from scoring in windows, not from the model. The error pattern in the next section is there either way.Where the Tamil words wentI counted, for every Tamil word in the human-labelled set, which label the model gave it. I counted labels only and did not read the comments, so the evaluation stayed blind.Telugu is as common an answer as Tamil itself.It is not a labelling mismatch: names, numbers and English barely move. The model calls Tamil words Telugu or another South Indian language. The same pull shows up, more weakly, elsewhere: 9% of Kannada words and 5.5% of Malayalam words are also tagged Telugu.My own 425-comment set did not show this, probably because its Tamil comments were easier. The comment at the top of this post is an example: without a language hint, Bhasha tags padam, semma, konjam and vera as Telugu.My best explanation is the kind of Tamil the model learned. Written Tamil, the kind found in news, differs a lot from spoken Tamil: a newspaper writes irukkiradhu where a commenter writes irukku. Bhasha only ever saw news Tamil, converted to Roman letters. When it meets spoken forms it has never seen, it falls back on the nearest South Indian language it has.A quick fix: tell it the language pairMost users already know their language pair: a Tamil film channel gets Tamil and English. So the wrapper has a langs option that limits the output to the expected language plus English, name and other. It is a fixed rule with nothing tuned on the test sets. I scored it once on every set.It helps every human-labelled Dravidian set. For Tamil it mostly moves the errors to English.For Tamil the details matter more than the total. With Telugu ruled out, the Tamil score itself rises from 0.53 to 0.78. But 2,188 Tamil words then come out as English, and the English score falls from 0.92 to 0.73. Among the allowed labels, the model ranks English above Tamil for those words (another 653 become name), so it does not recognise them as Tamil at all. On my own 425-comment set the hint does not help Tamil either (0.873 to 0.865).That supports the spoken-Tamil explanation, and the one inference-time rule I tried does not fix it. The model needs to see spoken Tamil in training. That is the plan for v2: real CC-BY YouTube comments from DravidianCodeMix’s training split, with word labels from a simple rule, plus chat-style text written by open-weights (Apache-2.0) models. That would be the first LLM-written text in Bhasha’s training data, and the card will say so. The human-labelled sets stay evaluation-only.Where it fitsGood uses:Tagging Kannada, Malayalam or Hindi mixed with English, in Roman or native script.Measuring how much code-mixing a corpus has, or filtering it by language.Choosing a transliterator, tokenizer or translation model word by word.Message-level language ID for code-mixed text. On real comments it gets 0.71 macro-F1 for the main language, against 0.53 for GlotLID.Use with care:Spoken Tamil: always pass langs=["ta"], and expect errors.Telugu, Marathi, Punjabi, Urdu and Odia were tested only on native-script and romanised single-language sentences; I found no real code-mixed test set for them. Bengali and Gujarati were tested in code-mixed text only alongside Hindi and English (IndicTriMix): 0.968 for Bengali, but only 0.678 for Gujarati.Romanised single-language sentences: GlotLID is better here (0.994 against 0.907), possibly because it saw this data in training. For whole romanised sentences in one language, GlotLID is the better tool.English words inside long Hinglish sentences are sometimes tagged Hindi. On COMI-LINGUA, English F1 is 0.836 against 0.956 for Hindi.Names are weak (F1 0.23–0.56). Treat name as a hint.One- or two-word messages carry little context, and accuracy drops sharply.Three lessonsYour own test set is a sample, not the truth. My 150 Tamil comments said 0.87; 11,323 human-labelled words from Tamil comments said 0.72. Before you publish, look for an independent human-labelled set, even a small one.When a score drops, count where the errors go before you fix anything. “Tamil is weak” suggested more data. “Tamil goes to Telugu, and then to English when Telugu is blocked” pointed to the kind of data: spoken Tamil, not more news.Code-built data gets the labels right and the language wrong. Every language label in 1.65 million rows was set by code, not guessed, but the text was news. For Malayalam and Kannada that was enough. For Tamil, where written and spoken forms differ most, it was not.FAQHow is it different from GlotLID or IndicLID? GlotLID and IndicLID give one language per text. Bhasha gives one per word, which is what you need when a sentence mixes two languages. On whole messages, it also beats GlotLID at finding the main language of real code-mixed comments.Is it free for commercial use? Yes. The weights and code are Apache-2.0, and the base model (XLM-RoBERTa-base) is MIT. The training data was built by code from CC0, CC-BY, MIT and ODC-By sources. The wordfreq word lists (CC-BY-SA) were used only as a lookup while building the data and are not in the model; the NOTICE file says so.Was it trained on real comments? No. Training rows were built by code from news and web sentences. Real comments were used only for evaluation and are not redistributed.Try themBhasha (word-level language ID): huggingface.co/arunp0/bhasha-lid-indicNandi (complaint routing): huggingface.co/arunp0/nandi-grievance-indicChitragupta (PII detection and redaction): huggingface.co/arunp0/chitragupta-pii-indicYama (zero-shot classification): huggingface.co/arunp0/yama-indicHow Chitragupta was built: Yama Judges, Chitragupta Keeps the RecordsIf you speak Tamil, Telugu or any of the untested languages and Bhasha gets your text wrong, open a discussion on the model page. Real failure cases are the most useful thing anyone can send me.Bhasha, Nandi, Chitragupta and Yama are independent personal releases by Arun Prabhakaran, licensed Apache-2.0. Evaluation data: CoLI-Dravidian 2024 (FIRE 2024 shared task); CoLI-Kanglish (ICON 2022 shared task); WoLLaI Mal-Eng (Pondicherry University, Mendeley Data, CC BY 4.0); DravidianCodeMix (CC BY 4.0); COMI-LINGUA; LinCE; IndicTriMix; Bhasha-Abhijnaanam (CC0). Training data: IndicCorp v2 (CC0), Aksharantar (CC BY 4.0), IndicXlit (MIT), Wikidata (CC0), FineWeb-2 word counts (ODC-By).My Model Thought Tamil Was Telugu: Open-Source Language ID for Hinglish, Tanglish and Kanglish was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.