SAVRN
Search Contact SAVRN

Open-weight model

sinlib

by Ransaka Ravihara Ransaka/sinlib

This repository hosts the official pretrained model checkpoints, vocabularies, and statistical datasets for the sinlib library—a comprehensive Sinhala NLP toolkit.

Parameters
Context
Weights1.9 MB
Licensemit
AccessOpen weights
Monthly Downloads743.3k

Model Card

By Ransaka Ravihara, published under mit, revision 0ba9e053fee8.

This repository hosts the official pretrained model checkpoints, vocabularies, and statistical datasets for the sinlib library—a comprehensive Sinhala NLP toolkit. This repository contains the following files loaded dynamically by sinlib.spellcheck.TypoDetector: bigrudetector.pt: A bidirectional GRU sequence labeling model (BiGRUSequenceLabeler) trained to detect spelling errors and character substitutions at the akshara level. bigrucorrector.pt: A sequence-to-sequence bidirectional GRU encoder-decoder model with Attention (BiGRUSeq2Seq) that performs generative character/akshara corrections. aksharavocab.json: Vocabulary mappings mapping Sinhala phonological units (aksharas) and basic…

Read Ransaka Ravihara's full model card

sinlib: Pretrained Sinhala NLP and Spellchecking Models

This repository hosts the official pretrained model checkpoints, vocabularies, and statistical datasets for the sinlib library—a comprehensive Sinhala NLP toolkit.

Models & Artifacts Hosted

This repository contains the following files loaded dynamically by sinlib.spellcheck.TypoDetector:

  • bigru_detector.pt: A bidirectional GRU sequence labeling model (BiGRUSequenceLabeler) trained to detect spelling errors and character substitutions at the akshara level.
  • bigru_corrector.pt: A sequence-to-sequence bidirectional GRU encoder-decoder model with Attention (BiGRUSeq2Seq) that performs generative character/akshara corrections.
  • akshara_vocab.json: Vocabulary mappings mapping Sinhala phonological units (aksharas) and basic punctuation to token IDs for the neural models.
  • akshara_ngram.json: Stored counts and vocabularies used by the statistical Trigram model (AksharaNGram) for likelihood evaluation.
  • news_unigrams.json & news_bigrams.json: Pre-calculated unigram and bigram word-level frequencies extracted from Sinhala news corpora, used for context-aware candidate re-ranking (Stupid Backoff).
  • dictionary.npy: The canonical baseline dictionary containing ~61K valid Sinhala words.
  • ngram_probs.npy: N-gram probabilities used by the default PreTrainedTokenizer fallback checks.

Additional models, configuration files, and vocabulary resources required by the sinlib package are also included in this repository.


Intended Use

These weights are designed to be loaded directly through the sinlib Python package.

Installation

pip install sinlib

Example Inference (Spellcheck)

from sinlib.spellcheck import TypoDetector

# Automatically downloads and caches the model files from this HF repository
detector = TypoDetector.from_pretrained("Ransaka/sinlib")

# Run spellcheck (with punctuation preservation & unicode normalization)
sentence = "කොළඹ වරායේ සිට බස්නහිර දෙසින් නාවික සැතපුම් 17ක් පමණ දුරන්."
corrected = detector(sentence)

print(corrected)
# Output: "කොළඹ වරායේ සිට බස්නාහිර දෙසින් නාවික සැතපුම් 17ක් පමණ දුරින්."

Typo Detection Fallback

If PyTorch is not installed in the target environment, sinlib falls back automatically to the statistical N-Gram model (akshara_ngram.json) to perform spelling checks.

# Check word suspicion level
is_typo = detector.is_word_suspicious("පසලට") # True

For more details, usage examples, and API references, please refer to the official documentation:

https://sinlib.readthedocs.io/en/latest/

Identity and Version

Repository
Ransaka/sinlib
Publisher
Ransaka Ravihara
Task
Not stated by the source
Modality
Other
Library
Not stated by the source
Parameters
Not stated by the source
Languages
si
Revision
0ba9e053fee892b2906afc2aadc776f165c78dca
First published
2025-03-23
Last updated
2026-08-01

Files and Weights

14 files, 22.3 MB in total. The weights are 2 files totalling 1.9 MB in pt.

Weights2 files · 1.9 MB
Configuration5 files · 13.9 MB
Tokenizer1 file · 13.9 KB
Documentation1 file · 3.1 KB
Other4 files · 6.5 MB
Repository1 file · 1.7 KB
Every file
FileTypeSizeSHA-256
bigru_corrector.ptWeights1.3 MB a282a85086a9
bigru_detector.ptWeights651.9 KB fceec7b26ef4
akshara_vocab.jsonConfiguration9.6 KB
char_map.jsonConfiguration15.3 KB
config.jsonConfiguration260 B
news_bigrams.jsonConfiguration10.7 MB 66d325835c7f
news_unigrams.jsonConfiguration3.1 MB
README.mdDocumentation3.1 KB
dictionary.npyOther5.7 MB 24d74fb6669b
fonts/NotoSansSinhala-Regular.ttfOther243.5 KB 33a77b6965e5
ngram_probs.npyOther582.6 KB 804c4fefbf5d
sinhala_chars_with_special_chars.txtOther384 B
.gitattributesRepository1.7 KB
vocab.jsonTokenizer13.9 KB

License and Download

License
mit
Access
Open weights, no gate
Download size
1.9 MB
Download from Ransaka Ravihara

Released by Ransaka Ravihara through its official repository on Hugging Face. Read the license.

Memory Requirements

PrecisionWeights in memory
As published1.9 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About sinlib

Can I use sinlib commercially?

Yes. sinlib is released under MIT License. The MIT License is a short permissive license. It permits commercial use, modification and redistribution, provided the copyright notice and permission notice are included.