MzansiLM 125M

MzansiLM 125M is a 125M-parameter decoder-only language model pretrained from scratch on MzansiText, an open 3.8B-token corpus covering South Africa's eleven official written languages. It was developed by the UCT NLP group and published at LREC 2026.

LREC 2026 GitHub Dataset Collection

Quick start

pip install "transformers>=4.52.4,<5" torch accelerate safetensors
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "uctnlp/mzansilm-125m"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)

prompt = "Namuhla sifunda ngolimi ngoba abantu"
inputs = tokenizer(prompt, return_tensors="pt")
# The tokenizer appends [EOS] to every sequence; drop it before continuing the prompt.
if inputs["input_ids"][0, -1].item() == tokenizer.eos_token_id:
    inputs = {k: v[:, :-1] for k, v in inputs.items()}

outputs = model.generate(
    **inputs,
    max_new_tokens=50,
    eos_token_id=tokenizer.eos_token_id,
    pad_token_id=tokenizer.pad_token_id,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Note on Transformers 5.x

This checkpoint stores an explicit head_dim=56 alongside hidden_size=512 and num_attention_heads=9. Transformers 5's LlamaConfig validator currently rejects configs where hidden_size is not evenly divisible by num_attention_heads, even when head_dim is set explicitly. Use transformers<5 as shown above, or call sallm.models.llama_compatibility.register_llama_compatibility() from Anri-Lombard/sallm before loading under Transformers 5.x.

Intended use and limitations

MzansiLM is a small, base pretrained model rather than an instruction-tuned chat assistant. Out of the box it predicts text continuations; for tasks like classification, named entity recognition, POS tagging, or headline generation, fine-tune it on your target task first.

The model was pretrained on all eleven official written South African languages: Afrikaans (afr), English (eng), isiNdebele (nbl), Sepedi (nso), Sesotho (sot), siSwati (ssw), Setswana (tsn), Xitsonga (tso), Tshivenda (ven), isiXhosa (xho), and isiZulu (zul). Quality varies with the amount of available pretraining text, which is highest for Afrikaans, English, isiZulu, isiXhosa, and Sesotho and much smaller for Setswana, Sepedi, Xitsonga, siSwati, Tshivenda, and isiNdebele (see the token breakdown on uctnlp/mzansi-text).

Architecture and tokenizer

Property Value
Parameters 125,008,384
Architecture Decoder-only LlamaForCausalLM (GQA)
Layers 30
Hidden size 512
Intermediate size 1536
Attention heads / KV heads 9 / 3 (head_dim = 56)
Context length 2048
RoPE theta 10000.0
RMSNorm epsilon 1e-5
Tied word embeddings true
Training attention implementation flash_attention_2

The model uses a custom 65,536-vocabulary Byte-Level BPE tokenizer trained on MzansiText ([BOS] = 0, [EOS] = 1, [PAD] = 2, [UNK] = 3). Two tokenizer details are worth knowing before running downstream evaluation:

  • It normalizes text to NFD, so normalize decoded outputs to NFC before exact-match or string-level metric comparisons.
  • Its post-processor wraps single inputs as [BOS] $A [EOS] and pairs as [BOS] $A [EOS] [BOS] $B [EOS], which is why the generation snippet above strips the trailing [EOS] token before calling model.generate().

Related resources

Resource Link
Paper (LREC 2026) ACL Anthology / arXiv:2603.20732
Raw corpus uctnlp/mzansi-text
Tokenized corpus uctnlp/mzansi-text-tokenized
Training and evaluation code Anri-Lombard/sallm

Citation

If you use MzansiLM in your research, please cite the LREC 2026 paper:

@inproceedings{lombard-etal-2026-mzansitext,
    title = "{M}zansi{T}ext and {M}zansi{LM}: An Open Corpus and Decoder-Only Language Model for {S}outh {A}frican Languages",
    author = "Lombard, Anri M.  and
      Mawere, Simbarashe  and
      Aina, Temi  and
      Wolff, Ethan  and
      Gumede, Sbonelo  and
      Novick, Elan  and
      Meyer, Francois  and
      Buys, Jan",
    booktitle = "Proceedings of the Fifteenth Language Resources and Evaluation Conference",
    year = "2026",
    publisher = "ELRA Language Resource Association",
    url = "https://aclanthology.org/2026.lrec-1.109/",
    doi = "10.63317/4g7i3kqszquh",
    pages = "1394--1408"
}

License

Released under the Apache License 2.0.

Downloads last month
1,103
Safetensors
Model size
0.1B params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for uctnlp/mzansilm-125m

Adapters
2 models
Finetunes
1 model

Spaces using uctnlp/mzansilm-125m 4

Collection including uctnlp/mzansilm-125m

Paper for uctnlp/mzansilm-125m