Ransaka commited on
Commit
0ba9e05
·
verified ·
1 Parent(s): ef8bbfc

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -0
README.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - si
4
+ license: mit
5
+ tags:
6
+ - sinhala
7
+ - nlp
8
+ - spellcheck
9
+ - typo-detection
10
+ - seq2seq
11
+ - sequence-labeling
12
+ - pytorch
13
+ metrics:
14
+ - accuracy
15
+ ---
16
+
17
+ ![image](https://cdn-uploads.huggingface.co/production/uploads/60f2e10dadf471cbdf8bb661/MHw89go_R_-fcceMu2zRT.png)
18
+
19
+ # sinlib: Pretrained Sinhala NLP and Spellchecking Models
20
+
21
+ This repository hosts the official pretrained model checkpoints, vocabularies, and statistical datasets for the **`sinlib`** library—a comprehensive Sinhala NLP toolkit.
22
+
23
+ ## Models & Artifacts Hosted
24
+
25
+ This repository contains the following files loaded dynamically by `sinlib.spellcheck.TypoDetector`:
26
+
27
+ * **`bigru_detector.pt`**: A bidirectional GRU sequence labeling model (`BiGRUSequenceLabeler`) trained to detect spelling errors and character substitutions at the akshara level.
28
+ * **`bigru_corrector.pt`**: A sequence-to-sequence bidirectional GRU encoder-decoder model with Attention (`BiGRUSeq2Seq`) that performs generative character/akshara corrections.
29
+ * **`akshara_vocab.json`**: Vocabulary mappings mapping Sinhala phonological units (aksharas) and basic punctuation to token IDs for the neural models.
30
+ * **`akshara_ngram.json`**: Stored counts and vocabularies used by the statistical Trigram model (`AksharaNGram`) for likelihood evaluation.
31
+ * **`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).
32
+ * **`dictionary.npy`**: The canonical baseline dictionary containing ~61K valid Sinhala words.
33
+ * **`ngram_probs.npy`**: N-gram probabilities used by the default `PreTrainedTokenizer` fallback checks.
34
+
35
+ Additional models, configuration files, and vocabulary resources required by the `sinlib` package are also included in this repository.
36
+
37
+ ---
38
+
39
+ ## Intended Use
40
+
41
+ These weights are designed to be loaded directly through the `sinlib` Python package.
42
+
43
+ ### Installation
44
+ ```bash
45
+ pip install sinlib
46
+ ```
47
+
48
+ ### Example Inference (Spellcheck)
49
+ ```python
50
+ from sinlib.spellcheck import TypoDetector
51
+
52
+ # Automatically downloads and caches the model files from this HF repository
53
+ detector = TypoDetector.from_pretrained("Ransaka/sinlib")
54
+
55
+ # Run spellcheck (with punctuation preservation & unicode normalization)
56
+ sentence = "කොළඹ වරායේ සිට බස්නහිර දෙසින් නාවික සැතපුම් 17ක් පමණ දුරන්."
57
+ corrected = detector(sentence)
58
+
59
+ print(corrected)
60
+ # Output: "කොළඹ වරායේ සිට බස්නාහිර දෙසින් නාවික සැතපුම් 17ක් පමණ දුරින්."
61
+ ```
62
+
63
+ ### Typo Detection Fallback
64
+ 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.
65
+ ```python
66
+ # Check word suspicion level
67
+ is_typo = detector.is_word_suspicious("පසලට") # True
68
+ ```
69
+
70
+ For more details, usage examples, and API references, please refer to the official documentation:
71
+
72
+ https://sinlib.readthedocs.io/en/latest/