SW

Model description

This is a transformers model pre-trained on a large corpus of Swahili data in a self-supervised fashion. This means it was pre-trained on the raw texts only, with no humans labeling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it was pre-trained with one objective:

This way, the model learns an inner representation of the Swahili language that can then be used to extract features useful for downstream tasks e.g.

The model is based on the Orginal BERT UNCASED which can be found on google-research/bert readme

Intended uses & limitations

You can use the raw model for masked language modeling, but it's primarily intended to be fine-tuned on a downstream task.

How to use

You can use this model directly with a pipeline for masked language modeling:

Tokenizer

from transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("eolang/SW-v1")

text = "Hii ni tovuti ya idhaa ya Kiswahili ya BBC ambayo hukuletea habari na makala kutoka Afrika na kote duniani kwa lugha ya Kiswahili."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
print(output)

Fill Mask Model

from transformers import AutoTokenizer, AutoModelForMaskedLM
from transformers import pipeline

tokenizer = AutoTokenizer.from_pretrained("eolang/SW-v1")
model = AutoModelForMaskedLM.from_pretrained("eolang/SW-v1")

fill_mask = pipeline("fill-mask", model=model, tokenizer=tokenizer)
sample_text = "Tumefanya mabadiliko muhimu [MASK] sera zetu za faragha na vidakuzi"

for prediction in fill_mask(sample_text):
    print(f"{prediction['sequence']}, confidence: {prediction['score']}")

Limitations and Bias

Even if the training data used for this model could be reasonably neutral, this model can have biased predictions. This is something I'm still working on improving. Feel free to share suggestions/comments via Discussions