Downloads · 30 days
0
Godsonntungi2/swahili-5gram-lm
swahili-5gram-lm is a machine learning model from Godsonntungi2. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A KenLM language model trained on 20969855 Swahili sentences from Common Voice.
Downloads · 30 days
0
Access
Public
Updated Dec 17, 2025
Repo size
6 GB
Likes
0
Public
Click a slice to open those files.
.txt3.5 GB · 64%
From the Hugging Face model README
A KenLM language model trained on 20969855 Swahili sentences from Common Voice.
from pyctcdecode import build_ctcdecoder
from huggingface_hub import hf_hub_download
import json
# Download files
vocab_path = hf_hub_download("Godsonntungi2/swahili-5gram-lm", "vocab.json")
lm_path = hf_hub_download("Godsonntungi2/swahili-5gram-lm", "5gram.arpa")
unigrams_path = hf_hub_download("Godsonntungi2/swahili-5gram-lm", "unigrams.txt")
# Load vocab
with open(vocab_path) as f:
vocab_dict = json.load(f)
vocab_list = [k for k, v in sorted(vocab_dict.items(), key=lambda x: x[1])]
# Load unigrams
with open(unigrams_path) as f:
unigrams = [line.strip() for line in f]
# Build decoder
decoder = build_ctcdecoder(
labels=vocab_list,
kenlm_model_path=lm_path,
unigrams=unigrams,
)
# Decode with LM
text = decoder.decode(logits)
5gram.arpa - ARPA format LMvocab.json - Character vocabularyunigrams.txt - Word unigrams for boostingcorpus.txt - Training text corpus