sindhi-tokenizer 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sindhi_tokenizer-1.1.0/LICENSE +21 -0
- sindhi_tokenizer-1.1.0/PKG-INFO +545 -0
- sindhi_tokenizer-1.1.0/README.md +509 -0
- sindhi_tokenizer-1.1.0/evaluation/__init__.py +18 -0
- sindhi_tokenizer-1.1.0/evaluation/metrics.py +173 -0
- sindhi_tokenizer-1.1.0/pyproject.toml +56 -0
- sindhi_tokenizer-1.1.0/setup.cfg +4 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer/__init__.py +6 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer/py.typed +0 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer/tokenizer.py +122 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer.egg-info/PKG-INFO +545 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer.egg-info/SOURCES.txt +16 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer.egg-info/dependency_links.txt +1 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer.egg-info/requires.txt +16 -0
- sindhi_tokenizer-1.1.0/sindhi_tokenizer.egg-info/top_level.txt +3 -0
- sindhi_tokenizer-1.1.0/tests/test_tokenizer_sdk.py +89 -0
- sindhi_tokenizer-1.1.0/training/__init__.py +4 -0
- sindhi_tokenizer-1.1.0/training/train_tokenizer.py +54 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ali Nawaz, Muqadas Fareed, Soonh Sadaf
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sindhi-tokenizer
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: A SentencePiece Unigram tokenizer and lightweight Python SDK purpose-built for Sindhi.
|
|
5
|
+
Author: Ali Nawaz, Muqadas Fareed, Soonh Sadaf
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/alinawazcode/sindhi-tokenizer
|
|
8
|
+
Project-URL: Repository, https://github.com/alinawazcode/sindhi-tokenizer
|
|
9
|
+
Project-URL: Models, https://huggingface.co/alinawazmahar/sindhi-tokenizer
|
|
10
|
+
Keywords: sindhi,tokenizer,sentencepiece,unigram,nlp,low-resource-languages
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: sentencepiece>=0.1.99
|
|
23
|
+
Requires-Dist: huggingface_hub>=0.23.0
|
|
24
|
+
Provides-Extra: training
|
|
25
|
+
Requires-Dist: datasets>=2.14.0; extra == "training"
|
|
26
|
+
Requires-Dist: numpy>=1.22.0; extra == "training"
|
|
27
|
+
Requires-Dist: pandas>=1.5.0; extra == "training"
|
|
28
|
+
Provides-Extra: demo
|
|
29
|
+
Requires-Dist: gradio>=4.0.0; extra == "demo"
|
|
30
|
+
Requires-Dist: transformers>=4.30.0; extra == "demo"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: build>=1.2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
34
|
+
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# Sindhi Tokenizer: A Corpus-Driven SentencePiece Unigram Tokenizer
|
|
38
|
+
|
|
39
|
+
<p align="center">
|
|
40
|
+
<img src="assets/banner.png" alt="Sindhi Tokenizer" width="100%">
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
[](https://www.python.org/)
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
[](https://huggingface.co/alinawazmahar/sindhi-tokenizer)
|
|
46
|
+
[](https://alinawazcode.github.io/sindhi-tokenizer/)
|
|
47
|
+
[](https://github.com/alinawazcode/sindhi-tokenizer/actions)
|
|
48
|
+
[](#round-trip-character-fidelity)
|
|
49
|
+
|
|
50
|
+
A subword tokenizer purpose-built for the **Sindhi language** (سنڌي) in the Perso-Arabic script. Trained with **SentencePiece Unigram** with full observed-character coverage and byte-level fallback on 1.46M+ sentences. It was benchmarked against **14 baseline tokenizers** across four evaluation registers. The benchmark has 18 entries: 14 baseline entries and four custom vocabulary sizes. **Qwen2.5 and SindhiLM_v2 are identical in this evaluation**, so the entries represent 17 distinct tokenizer behaviors. The round-trip check reports **0.0000% normalized-length loss** on evaluated text; this does not establish exact identity for arbitrary input.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### Quick Links
|
|
55
|
+
- 🌐 **Documentation Site**: [https://alinawazcode.github.io/sindhi-tokenizer/](https://alinawazcode.github.io/sindhi-tokenizer/)
|
|
56
|
+
- 🤗 **Hugging Face Hub**: [alinawazmahar/sindhi-tokenizer](https://huggingface.co/alinawazmahar/sindhi-tokenizer)
|
|
57
|
+
- 📄 **Research Manuscript Draft (Not Yet Published)**: [`docs/paper.md`](docs/paper.md)
|
|
58
|
+
- 🔬 **Technical Explainer**: [`docs/explainer.md`](docs/explainer.md)
|
|
59
|
+
- 📊 **Benchmark Results**: [`results/README.md`](results/README.md)
|
|
60
|
+
- 💻 **Interactive Web Demo**: [`demo/app.py`](demo/app.py)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Table of Contents
|
|
65
|
+
1. [Project Overview](#project-overview)
|
|
66
|
+
2. [Motivation and Problem Statement](#motivation-and-problem-statement)
|
|
67
|
+
3. [Project Objectives and Scope](#project-objectives-and-scope)
|
|
68
|
+
4. [Key Features](#key-features)
|
|
69
|
+
5. [Technology Stack](#technology-stack)
|
|
70
|
+
6. [Repository Architecture](#repository-architecture)
|
|
71
|
+
7. [Architecture and Workflow Diagrams](#architecture-and-workflow-diagrams)
|
|
72
|
+
8. [Dataset Documentation](#dataset-documentation)
|
|
73
|
+
9. [Tokenizer Methodology](#tokenizer-methodology)
|
|
74
|
+
10. [Training Pipeline & Negative Results](#training-pipeline--negative-results)
|
|
75
|
+
11. [Installation and Usage](#installation-and-usage)
|
|
76
|
+
12. [Evaluation and Comprehensive Benchmarks](#evaluation-and-comprehensive-benchmarks)
|
|
77
|
+
13. [Linguistic & Morpheme Analysis](#linguistic--morpheme-analysis)
|
|
78
|
+
14. [Downstream NLP Applications](#downstream-nlp-applications)
|
|
79
|
+
15. [Limitations and Known Issues](#limitations-and-known-issues)
|
|
80
|
+
16. [Complete Documentation Index](#complete-documentation-index)
|
|
81
|
+
17. [References and Further Reading](#references-and-further-reading)
|
|
82
|
+
18. [Team and Acknowledgments](#team-and-acknowledgments)
|
|
83
|
+
19. [License and Citation](#license-and-citation)
|
|
84
|
+
20. [Frequently Asked Questions (FAQ)](#frequently-asked-questions-faq)
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Project Overview
|
|
89
|
+
|
|
90
|
+
Sindhi is an Indo-Aryan language spoken by an estimated 25–30 million people, predominantly in the Sindh province of Pakistan and parts of India. Despite its rich literary heritage, Sindhi remains a severely under-resourced language in Natural Language Processing (NLP).
|
|
91
|
+
|
|
92
|
+
Existing modern Large Language Models (LLMs) and multilingual tokenizers (such as XLM-RoBERTa, LLaMA, Qwen, and BLOOM) under-represent Sindhi orthography, causing high token fertility, extreme sequence bloat, out-of-vocabulary (UNK) fallbacks, or destructive character drops.
|
|
93
|
+
|
|
94
|
+
This repository provides:
|
|
95
|
+
- **Four Trained Models**: Pretrained SentencePiece Unigram models at 32k, 64k (flagship recommended), 100k, and 150k vocabulary sizes.
|
|
96
|
+
- **Corpus Engineering Pipeline**: A 1.46M+ sentence corpus drawn from Sindhi and regional Wikipedia, mostly news text, a small Twitter component, and an Urdu/Persian/Arabic anchor that makes up 16.1% of the corpus by character count (89,449 unique sentences, repeated four times).
|
|
97
|
+
- **Full-Scale Benchmark Suite**: Standardized evaluation of 18 tokenizers across 4 distinct registers (FLORES+, Wikipedia, Sentiment, Sindh Line News).
|
|
98
|
+
- **Round-Trip Length Check**: A normalized-length check that can flag text shortening; targeted examples were also inspected for deleted characters.
|
|
99
|
+
- **Interactive UI**: A Gradio web application for real-time subword tokenization inspection.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Motivation and Problem Statement
|
|
104
|
+
|
|
105
|
+
### 1. Unique Script and Extended Perso-Arabic Orthography
|
|
106
|
+
Sindhi uses a 52-letter extended Perso-Arabic alphabet containing implosive consonants (ٻ, ڄ, ڏ, ڳ), aspirated digraphs (ڀ, ٿ, ڇ, ٺ), retroflex consonants (including ڻ), and specialized diacritics. General Arabic or Urdu tokenizers frequently split these single graphemes into multi-byte fallback sequences, dramatically inflating token counts.
|
|
107
|
+
|
|
108
|
+
### 2. The Token Fertility Tax
|
|
109
|
+
When a tokenizer splits a single word into 3–5 subword fragments, context window efficiency drops proportionally. A 2048-token context window accommodates only ~707 Sindhi words under LLaMA 3.2 (fertility 2.896) or ~1,354 words under XLM-RoBERTa (1.512), compared to ~1,786 Sindhi words under CustomSindhi_64k (1.147).
|
|
110
|
+
|
|
111
|
+
### 3. Silent Character Deletion in Competing Models
|
|
112
|
+
Standard tokenizer benchmarks often report token fertility and `UNK` rate without checking decoded output. During this project's audit, a **normalized-length round-trip check**, followed by inspection of affected examples, surfaced text-shortening defects in existing tokenizers:
|
|
113
|
+
- **`TinyLlama_Sindhi`**: Drops native Sindhi letters such as `U+06C1` (HEH GOAL) and corrupts text encoded with Arabic Presentation Forms, destroying data in up to **24.9%** of sentences.
|
|
114
|
+
- **`FahadQazi_BPE`**: Silently deletes Latin characters in code-switched technical text, corrupting up to **16.2%** of sentences.
|
|
115
|
+
- **Our model**: Shows **0.0000% normalized-length loss** under this check on evaluated text with byte-level fallback; the metric is not proof of exact character identity.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Project Objectives and Scope
|
|
120
|
+
|
|
121
|
+
### Primary Objectives
|
|
122
|
+
1. **Deliver Flagship Tokenizer**: Train and release a high-efficiency Sindhi subword tokenizer achieving the lowest fertility and highest single-token preservation across diverse registers.
|
|
123
|
+
2. **Measure Round-Trip Integrity**: Use byte fallback and full observed-character coverage, then report the limits of the normalized-length check.
|
|
124
|
+
3. **Rigorous Empirical Comparison**: Benchmark 14 baseline tokenizers under identical, unsampled test conditions.
|
|
125
|
+
4. **Transparent Documentation**: Document negative results (what didn't work), corpus preparation heuristics, and evaluation caveats.
|
|
126
|
+
|
|
127
|
+
### Supported Use Cases
|
|
128
|
+
- Large Language Model (LLM) pretraining and fine-tuning for Sindhi.
|
|
129
|
+
- Sequence classification (Sentiment Analysis, Topic Modeling).
|
|
130
|
+
- Machine Translation (FLORES+ benchmarks).
|
|
131
|
+
- Named Entity Recognition (NER) and Information Retrieval.
|
|
132
|
+
|
|
133
|
+
### Known Exclusions
|
|
134
|
+
- Speech recognition (ASR) acoustic unit modeling.
|
|
135
|
+
- Devnagari script Sindhi (this release targets Arabic-script Sindhi).
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Key Features
|
|
140
|
+
|
|
141
|
+
- **SentencePiece Unigram Architecture**: Statistically models subword probabilities using maximum likelihood estimation, proven superior to standard greedy BPE for morphologically rich languages.
|
|
142
|
+
- **100% Character Coverage + Byte Fallback**: Zero unknown (`<unk>`) token emissions. Unknown Unicode characters decompose cleanly into raw UTF-8 byte tokens without data corruption.
|
|
143
|
+
- **Flagship 64k Model**: Balances vocabulary efficiency (1.147 fertility) with embedding table size, yielding an **88.6% single-token word retention** rate.
|
|
144
|
+
- **Round-Trip Check Result**: 0.0000% normalized-length loss across the evaluated corpora; this does not establish exact character identity.
|
|
145
|
+
- **Clean Subword Boundaries**: Preserves leading whitespace symbols (` `, `\u2581`) for precise detokenization without text corruption.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Technology Stack
|
|
150
|
+
|
|
151
|
+
| Layer | Technologies | Purpose |
|
|
152
|
+
|---|---|---|
|
|
153
|
+
| **Core Engine** | Python 3.9+, [SentencePiece](https://github.com/google/sentencepiece) (C++ bindings) | Tokenizer training, Viterbi segmentation, byte fallback |
|
|
154
|
+
| **NLP Framework** | [Hugging Face Transformers](https://github.com/huggingface/transformers), `huggingface_hub` | Adapter integration, model sharing and distribution |
|
|
155
|
+
| **Datasets** | [Hugging Face Datasets](https://github.com/huggingface/datasets), Pandas, NumPy | Corpus ingestion, normalization, filtering, metrics computation |
|
|
156
|
+
| **Interactive Demo** | [Gradio](https://gradio.app/) | Real-time interactive subword visualization UI |
|
|
157
|
+
| **Quality & CI/CD** | Pytest, GitHub Actions | Automated regression tests across Python 3.9–3.12 |
|
|
158
|
+
| **Documentation** | GitHub Pages, Markdown, Mermaid.js | Static web docs, draft research manuscript, technical explainer |
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Repository Architecture
|
|
163
|
+
|
|
164
|
+
```text
|
|
165
|
+
sindhi-tokenizer/
|
|
166
|
+
├── .github/
|
|
167
|
+
│ └── workflows/
|
|
168
|
+
│ └── python-tests.yml # Automated CI workflow testing Python 3.9-3.12
|
|
169
|
+
├── .gitignore # Excludes models, artifacts, cache, and virtualenvs
|
|
170
|
+
├── CITATION.cff # Citation File Format (v1.2.0)
|
|
171
|
+
├── DATA_SOURCES.md # Complete provenance, volume, and licensing documentation
|
|
172
|
+
├── LICENSE # MIT Open Source License
|
|
173
|
+
├── README.md # Central documentation index and project guide
|
|
174
|
+
├── pyproject.toml # PEP 517/621 package metadata and dependency configuration
|
|
175
|
+
├── requirements.txt # Exact runtime dependencies
|
|
176
|
+
├── demo/
|
|
177
|
+
│ ├── README.md # Instructions for running and deploying the demo
|
|
178
|
+
│ └── app.py # Interactive Gradio comparison web app
|
|
179
|
+
├── docs/
|
|
180
|
+
│ ├── paper.md # Draft research manuscript, not yet published (14-baseline study)
|
|
181
|
+
│ └── explainer.md # 21-page technical companion log and negative results
|
|
182
|
+
├── evaluation/
|
|
183
|
+
│ ├── README.md # Evaluation metrics guide and CLI/API documentation
|
|
184
|
+
│ ├── __init__.py # Package initialization
|
|
185
|
+
│ └── metrics.py # Fertility, single-token, UNK, byte-fallback, and fidelity engine
|
|
186
|
+
├── notebooks/
|
|
187
|
+
│ ├── README.md # Reproducible notebook guide
|
|
188
|
+
│ ├── training.ipynb # Kaggle/Jupyter notebook: corpus download, split & training
|
|
189
|
+
│ └── benchmark.ipynb # Kaggle/Jupyter notebook: 18-tokenizer evaluation suite
|
|
190
|
+
├── results/
|
|
191
|
+
│ └── README.md # Benchmark tables and summary report across 4 registers
|
|
192
|
+
└── training/
|
|
193
|
+
├── README.md # Training recipes, regex splitters, and negative results
|
|
194
|
+
├── __init__.py # Package initialization
|
|
195
|
+
└── train_tokenizer.py # Standalone training script with optimal SentencePiece parameters
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Architecture and Workflow Diagrams
|
|
201
|
+
|
|
202
|
+
### 1. End-to-End System Architecture
|
|
203
|
+
|
|
204
|
+
```mermaid
|
|
205
|
+
flowchart TD
|
|
206
|
+
subgraph Data_Pipeline["1. Corpus Assembly & Preprocessing"]
|
|
207
|
+
A1["Sindhi Wikipedia<br/>(6,000 articles)"] --> P["Sentence Extraction & Cleaning<br/>Regex Split: [۔.!\n؟]+<br/>Drop fragments of 3 characters or fewer"]
|
|
208
|
+
A2["Sindhi-NLP Dataset<br/>(Twitter + Kawish + Awami Awaz)"] --> P
|
|
209
|
+
A3["shaikhsalman Corpus<br/>(20k rows, no language filter)"] --> P
|
|
210
|
+
A4["Multilingual Regional Anchor<br/>(Urdu, Persian, Arabic, repeated ×4, 16.1% of characters)"] --> P
|
|
211
|
+
P --> C["Balanced Training Corpus<br/>(1.46M+ Sentences)"]
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
subgraph Training_Engine["2. Model Training (SentencePiece)"]
|
|
215
|
+
C --> SP["SentencePiece Unigram Trainer<br/>character_coverage=1.0<br/>byte_fallback=True<br/>split_by_whitespace=True"]
|
|
216
|
+
SP --> M1["Custom 32k Model"]
|
|
217
|
+
SP --> M2["Custom 64k Model (Flagship)"]
|
|
218
|
+
SP --> M3["Custom 100k Model"]
|
|
219
|
+
SP --> M4["Custom 150k Model"]
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
subgraph Evaluation_Suite["3. Rigorous Evaluation Engine"]
|
|
223
|
+
M2 --> E["evaluation/metrics.py"]
|
|
224
|
+
REG1["FLORES+ (snd_Arab)"] --> E
|
|
225
|
+
REG2["Wikipedia Formal (25.4k sent)"] --> E
|
|
226
|
+
REG3["Sentiment Informal (3.5k sent)"] --> E
|
|
227
|
+
REG4["Sindh Line News (87.1k sent)"] --> E
|
|
228
|
+
E --> MET["Metrics Computed:<br/>• Token Fertility<br/>• Single-Token Word %<br/>• UNK Rate (0.000%)<br/>• Byte Fallback Rate<br/>• Normalized-Length Loss (0.000%)"]
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
subgraph Downstream["4. Downstream Deployment"]
|
|
232
|
+
M2 --> HF["Hugging Face Hub<br/>alinawazmahar/sindhi-tokenizer"]
|
|
233
|
+
M2 --> GR["Interactive Gradio Demo<br/>demo/app.py"]
|
|
234
|
+
M2 --> LLM["Sindhi LLM Pretraining & NLP"]
|
|
235
|
+
end
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### 2. Text Encoding and Round-Trip Fidelity Flow
|
|
239
|
+
|
|
240
|
+
```mermaid
|
|
241
|
+
sequenceDiagram
|
|
242
|
+
autonumber
|
|
243
|
+
participant Input as Raw Sindhi Text
|
|
244
|
+
participant Norm as NFKC & Formatting Normalizer
|
|
245
|
+
participant Tokenizer as SPMTokenizerAdapter
|
|
246
|
+
participant Tokens as Subword Tokens / Byte IDs
|
|
247
|
+
participant Output as Decoded Reconstructed Text
|
|
248
|
+
participant Audit as Normalized-Length Check
|
|
249
|
+
|
|
250
|
+
Input->>Norm: Normalize Unicode (NFKC) & remove zero-width formatting
|
|
251
|
+
Norm->>Tokenizer: Clean text string
|
|
252
|
+
Tokenizer->>Tokens: Encode via Unigram Viterbi path (out_type=int)
|
|
253
|
+
Tokens->>Output: Decode token IDs back to string
|
|
254
|
+
Output->>Audit: Compare Original vs Decoded
|
|
255
|
+
Note over Audit: Loss = max(0, input_length - decoded_length) / input_length<br/>Custom Model Result: 0.0000% normalized-length loss
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Dataset Documentation
|
|
261
|
+
|
|
262
|
+
Training and evaluation records are separated where known, but the sentiment evaluation set shares publisher-adjacent provenance with a training source. See [`DATA_SOURCES.md`](DATA_SOURCES.md) for source details and licensing status.
|
|
263
|
+
|
|
264
|
+
### Training Corpus (1.46M+ Sentences)
|
|
265
|
+
|
|
266
|
+
| Source Dataset | Origin / Provider | Volume Used | Preprocessing & Filtering Rules | License |
|
|
267
|
+
|---|---|---|---|---|
|
|
268
|
+
| **Sindhi Wikipedia** | `wikimedia/wikipedia` (`20231101.sd`) | 6,000 articles | Articles 2,001–8,000 (first 2,000 reserved for evaluation). Fragments of 3 characters or fewer dropped; no word-count limit (the 3–100 word filter is applied only to the evaluation set). | CC BY-SA 3.0 |
|
|
269
|
+
| **Sindhi-NLP** | `GitHub: Sindhi-NLP/sindhi-NLP-dataset` | 4 CSV collections | Primarily news (98.4% Awami Awaz and Daily Kawish articles) with 1.6% social tweets. | MIT |
|
|
270
|
+
| **shaikhsalman Corpus** | `shaikhsalman/sindhi-llm-corpus` | 20,000 rows | Seed 7 shuffle; 630,180 sentences, about 57% of the Sindhi-side corpus. **No language filter was applied.** A diagnostic found about 11.3% of sampled sentences were mostly Latin script, and they remain in the training text. | Project owner reports free use; exact license and conditions are not shown on the card (see DATA_SOURCES.md) |
|
|
271
|
+
| **Multilingual Anchor** | Urdu, Persian, Arabic Wikipedia | 1,500 articles each | 89,449 unique sentences (4.9M characters) repeated four times to reach 16.1% of total corpus characters (target was 15%). Exposes model to shared Perso-Arabic roots. | CC BY-SA 3.0 |
|
|
272
|
+
|
|
273
|
+
### Evaluation Registers (Unsampled Benchmarks)
|
|
274
|
+
|
|
275
|
+
| Register | Dataset Identifier | Sentences | Domain / Linguistic Style |
|
|
276
|
+
|---|---|---|---|
|
|
277
|
+
| **`flores200_anchor`** | `openlanguagedata/flores_plus` (`snd_Arab`) | 1,012 | Standardized translation benchmark; formal and modern register. |
|
|
278
|
+
| **`wikipedia_formal`** | `wikimedia/wikipedia` (`20231101.sd`) | 25,480 | Formal encyclopedic Sindhi prose (first 2,000 articles, disjoint from train). |
|
|
279
|
+
| **`sentiment_informal`** (legacy ID) | `alinawazmahar/Sindhi_Sentiment_dataset` | 3,536 | Newspaper text pseudo-labeled for sentiment; this is news, not social-media text. |
|
|
280
|
+
| **`sindh_line_news`** | Mozilla Data Collective (`Sindh Line Publishers`) | 87,158 | Contemporary, daily regional news coverage (CC BY-SA 4.0). |
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Tokenizer Methodology
|
|
285
|
+
|
|
286
|
+
### Why SentencePiece Unigram over Greedy BPE?
|
|
287
|
+
Byte-Pair Encoding (BPE) merges the most frequent character pairs iteratively. In morphologically complex, agglutinative, or clitic-heavy languages like Sindhi, greedy merges frequently fuse grammatical suffixes onto root stems incorrectly.
|
|
288
|
+
|
|
289
|
+
The **Unigram language model algorithm** (Kudo, 2018) initializes an oversized vocabulary and optimizes subword segmentation using maximum likelihood:
|
|
290
|
+
|
|
291
|
+
$$P(X) = \max_{\mathbf{x} \in S(X)} \prod_{i=1}^{M} P(x_i)$$
|
|
292
|
+
|
|
293
|
+
This statistically discovers true morphological subwords while optimizing whole-sequence likelihood.
|
|
294
|
+
|
|
295
|
+
### Step-by-Step Tokenization Example
|
|
296
|
+
Consider the authentic Sindhi phrase:
|
|
297
|
+
$$\text{خداوند ڪريم کيس اعليٰ ذهانت سان نوازيو هو}$$
|
|
298
|
+
*(The Almighty Lord had blessed him with high intellect)*
|
|
299
|
+
|
|
300
|
+
1. **Input Normalization**: NFKC normalization ensures canonical representation of Arabic script forms.
|
|
301
|
+
2. **Whitespace Prefixing**: Words receive the boundary marker ` ` (`\u2581`).
|
|
302
|
+
3. **Unigram Segmentation**:
|
|
303
|
+
```text
|
|
304
|
+
[' خداوند', ' ڪريم', ' کيس', ' اعليٰ', ' ذهانت', ' سان', ' نوازيو', ' هو']
|
|
305
|
+
```
|
|
306
|
+
4. **Token ID Mapping**:
|
|
307
|
+
```text
|
|
308
|
+
[12450, 4812, 1089, 7543, 14210, 521, 18920, 412]
|
|
309
|
+
```
|
|
310
|
+
5. **Round-trip check**: Evaluated text showed 0.0000% normalized-length loss. This length-based check can miss equal-length substitutions or reorderings.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Training Pipeline & Negative Results
|
|
315
|
+
|
|
316
|
+
### 1. Training Parameters (`training/train_tokenizer.py`)
|
|
317
|
+
```bash
|
|
318
|
+
python training/train_tokenizer.py \
|
|
319
|
+
--corpus corpus.txt \
|
|
320
|
+
--vocab_size 64000 \
|
|
321
|
+
--model_prefix models/sindhi_custom_64000
|
|
322
|
+
```
|
|
323
|
+
- `model_type="unigram"`
|
|
324
|
+
- `character_coverage=1.0` (Ensures every single observed Unicode character is covered)
|
|
325
|
+
- `byte_fallback=True` (Unknown characters fall back to raw byte tokens `<0xXX>`)
|
|
326
|
+
- `split_by_whitespace=True`
|
|
327
|
+
- `unk_id=0`, `bos_id=1`, `eos_id=2`, `pad_id=-1`
|
|
328
|
+
|
|
329
|
+
### 2. Documented Negative Results (What Failed and Why)
|
|
330
|
+
In accordance with rigorous research standards, two negative experimental results are preserved in [`docs/explainer.md`](docs/explainer.md):
|
|
331
|
+
1. **Forced Postposition Tokens**: Forcing common postpositions (e.g., `جو`, `جي`, `کي`) and loanwords to remain single tokens degraded the training objective (final objective value rose from ≈9.6 unforced to ≈14.9 forced at 32k vocab). Given enough data, Unigram naturally discovers these tokens with superior probability allocations.
|
|
332
|
+
2. **Pre-marking Clitic Boundaries**: Pre-segmenting supposed fused clitics with whitespace proved harmful. Investigation revealed that suspected "fused forms" were simply coincidental orthographic overlaps with unrelated lexical roots.
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Installation and Usage
|
|
337
|
+
|
|
338
|
+
### Install the Python SDK
|
|
339
|
+
|
|
340
|
+
Requires Python 3.9 or newer. The SDK only installs SentencePiece and the Hugging Face Hub client; training and demo dependencies are optional.
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
pip install sindhi-tokenizer
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Quickstart
|
|
347
|
+
|
|
348
|
+
```python
|
|
349
|
+
from sindhi_tokenizer import SindhiTokenizer
|
|
350
|
+
|
|
351
|
+
# Downloads the recommended 64k model once, then reuses the Hub cache.
|
|
352
|
+
tokenizer = SindhiTokenizer.from_pretrained()
|
|
353
|
+
text = "سنڌ جي تاريخ تمام قديم آهي"
|
|
354
|
+
|
|
355
|
+
pieces = tokenizer.tokenize(text)
|
|
356
|
+
token_ids = tokenizer.encode(text)
|
|
357
|
+
|
|
358
|
+
print("Pieces:", pieces)
|
|
359
|
+
print("Token IDs:", token_ids)
|
|
360
|
+
print("Decoded:", tokenizer.decode(token_ids))
|
|
361
|
+
print("Vocabulary size:", tokenizer.vocab_size) # 64000
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Choose another released vocabulary with `vocab_size=32000`, `100000`, or `150000`. You can also load a local `.model` file with `SindhiTokenizer.from_file(path)`. Batch methods are `encode_batch()` and `decode_batch()`.
|
|
365
|
+
|
|
366
|
+
To work on the repository and its training/demo tools:
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
git clone https://github.com/alinawazcode/sindhi-tokenizer.git
|
|
370
|
+
cd sindhi-tokenizer
|
|
371
|
+
pip install -e ".[dev,training,demo]"
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The model download is cached by Hugging Face Hub. The SDK code is MIT licensed; the model files are separately licensed under CC BY-SA 4.0. Review the model card for attribution and sharing terms before redistributing model files.
|
|
375
|
+
|
|
376
|
+
> [!CAUTION]
|
|
377
|
+
> **Do not use `transformers.LlamaTokenizer` to load raw `.model` files**: it can silently return a 3-token fallback vocabulary for these custom SentencePiece Unigram files. Use `SindhiTokenizer`, `sentencepiece.SentencePieceProcessor`, or the benchmark adapter in [`evaluation/metrics.py`](evaluation/metrics.py).
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Evaluation and Comprehensive Benchmarks
|
|
382
|
+
|
|
383
|
+
All 18 benchmark entries were evaluated across the four evaluation registers without subsampling. SindhiLM_v2 is identical to Qwen2.5 for this evaluation; the entries therefore represent 17 distinct tokenizer behaviors.
|
|
384
|
+
|
|
385
|
+
### Macro Benchmark Summary (Unweighted Mean across 4 Registers)
|
|
386
|
+
|
|
387
|
+
| Tokenizer | Vocab Size | Fertility (tokens/word) ↓ | Single-Token Word % ↑ | UNK Rate % ↓ | Byte-Fallback % ↓ | Worst Normalized-Length Loss % ↓ |
|
|
388
|
+
|---|---|---|---|---|---|---|
|
|
389
|
+
| **CustomSindhi_150k** | 150,000 | **1.125** | **89.7%** | **0.000%** | 0.154% | **0.0000%** |
|
|
390
|
+
| **CustomSindhi_100k** | 100,000 | **1.133** | **89.3%** | **0.000%** | 0.149% | **0.0000%** |
|
|
391
|
+
| **CustomSindhi_64k (Flagship)** | 64,000 | **1.147** | **88.6%** | **0.000%** | 0.138% | **0.0000%** |
|
|
392
|
+
| **CustomSindhi_32k** | 32,000 | **1.184** | **86.5%** | **0.000%** | 0.113% | **0.0000%** |
|
|
393
|
+
| TinyLlama_Sindhi | 42,681 | 1.208 | 84.4% | 0.000%* | 0.000%* | **0.4147% (Corrupts 24.9% sent)** |
|
|
394
|
+
| hellosindh_SindhiBERT_NER | 32,001 | 1.218 | 83.7% | 0.194% | 0.197% | 0.0751% |
|
|
395
|
+
| mBERT_Sindhi_Kashif786 | 119,547 | 1.278 | 78.4% | 0.143% | 0.000% | 0.0021% |
|
|
396
|
+
| XLM-RoBERTa | 250,002 | 1.512 | 65.4% | 0.034% | 1.402% | 0.0040% |
|
|
397
|
+
| SindhiLM_v3 | 32,000 | 1.730 | 55.8% | 3.605% | 0.000% | 0.0754% |
|
|
398
|
+
| FahadQazi_BPE | 13,031 | 1.919 | 39.1% | 0.000%* | 7.127%* | **0.8461% (Corrupts 16.2% sent)** |
|
|
399
|
+
| hellosindh_SindhiBERT | 32,000 | 1.960 | 35.5% | 0.122% | 0.114% | 0.0089% |
|
|
400
|
+
| mT5 | 250,100 | 2.280 | 21.7% | 0.022% | 12.746% | 0.0040% |
|
|
401
|
+
| Gemma3 | 262,144 | 2.308 | 26.8% | 0.000% | 0.105% | 0.0000% |
|
|
402
|
+
| Qwen2.5 / SindhiLM_v2 | 151,643 | 2.580 | 23.8% | 0.000% | 8.665% | 0.0000% |
|
|
403
|
+
| BLOOM | 250,680 | 2.627 | 24.7% | 0.000% | 31.660% | 0.0000% |
|
|
404
|
+
| Llama3.2 | 128,000 | 2.896 | 18.2% | 0.000% | 28.472% | 0.0000% |
|
|
405
|
+
| SindhiLM_v1 | 43 | 4.306 | 0.1% | 14.017% | 0.000% | 0.0790% |
|
|
406
|
+
|
|
407
|
+
*\* TinyLlama_Sindhi and FahadQazi_BPE show apparent 0.000% UNK rates because both models silently delete unsupported characters rather than emitting a UNK token. FahadQazi_BPE shows real, severe character loss on round-trip fidelity testing alongside high byte-fallback. SindhiLM_v2 is numerically identical to Qwen2.5 across all metrics; both are listed in the table for completeness.*
|
|
408
|
+
|
|
409
|
+
### Evaluation Takeaways
|
|
410
|
+
1. **Lowest fertility and highest single-token retention at ≥64k**: CustomSindhi (64k, 100k, 150k) has the lowest fertility and highest single-token retention in all four registers. The margin on FLORES+ at 64k is 0.002 fertility and 0.3 points of single-token retention, which we treat as parity; no significance tests were run. At 32k, one narrow exception exists: TinyLlama_Sindhi beats CustomSindhi_32k on FLORES+ fertility (though it carries a critical character-deletion defect). On byte-fallback, CustomSindhi_64k (0.138%) achieves near-lowest fallback, with Gemma 3 slightly lower at 0.105%.
|
|
411
|
+
2. **Efficiency gains at 64k**: Mean fertility improves by **24.1% over XLM-RoBERTa** and **60.4% over LLaMA 3.2**. This describes fertility and single-token retention, not every metric.
|
|
412
|
+
3. **Round-trip check results**: Custom models show 0.0000% normalized-length loss under the stated check on all four registers. This length-based check does not prove exact character identity; TinyLlama_Sindhi and FahadQazi_BPE show measurable length loss.
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Linguistic & Morpheme Analysis
|
|
417
|
+
|
|
418
|
+
To verify that vocabulary expansion did not simply overfit high-frequency substrings, all tokenizers were evaluated on a targeted 22-word linguistic test suite spanning four distinct categories:
|
|
419
|
+
|
|
420
|
+
1. **Genitive & Possessive Constructions** (`دنيا جو`, `پاڻي جي`, `ماڻهن جو`): All Custom models split these cleanly into base noun + postposition clitic.
|
|
421
|
+
2. **Inflectional Suffixes** (`ڪتابن`, `شهرن`, `توهانکي`, `منهنجو`): Preserved as single tokens in Custom 64k models.
|
|
422
|
+
3. **Sindhi Implosives & Aspirated Digraphs** (`ٻار`, `ڄاڻ`, `ڏينهن`, `ڳوٺ`, `ڀاءُ`, `ٿورو`, `ڇوڪرو`): Never broken into disconnected diacritics or fallback bytes.
|
|
423
|
+
4. **Loanwords & Technical Terms** (`ڪمپيوٽر`, `انٽرنيٽ`, `اسڪول`, `تعليم`): Retained as intact single lexical units.
|
|
424
|
+
|
|
425
|
+
> [!NOTE]
|
|
426
|
+
> **Aggregate vs. Word-Level Distinction**: Across the 22-word test suite, the Custom tokenizer ties the best competitor on 21 of 22 words and loses one (`هنجي`, to FahadQazi_BPE and mBERT_Sindhi jointly). The primary advantage of CustomSindhi is consistency across aggregate, full-scale text registers rather than hand-picked individual words. See [`docs/paper.md#appendix-b`](docs/paper.md#appendix-b) for the full 22-word breakdown.
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## Intended Downstream NLP Applications & Hypotheses
|
|
431
|
+
|
|
432
|
+
*Note: As documented in the paper (§6), the tokenizer is designed for textual NLP representation; downstream task-specific fine-tuning (e.g. BLEU/ROUGE benchmarks) represents intended future work.*
|
|
433
|
+
|
|
434
|
+
| Intended Application | Hypothesized Architectural Benefit |
|
|
435
|
+
|---|---|
|
|
436
|
+
| **Sindhi Large Language Models (LLMs)** | Decreases token sequence length by 50–60% vs general multilingual LLMs (LLaMA, BLOOM), effectively doubling or tripling context length capacity during pretraining and inference. |
|
|
437
|
+
| **Machine Translation (MT)** | Preserves postpositions and implosive graphemes intact, intended to reduce subword fragmentation and hallucination during sequence-to-sequence translation. |
|
|
438
|
+
| **Sentiment Analysis & Text Classification** | Retains full grammatical morphemes, yielding richer dense embeddings for subword encoders. |
|
|
439
|
+
| **Named Entity Recognition (NER)** | Eliminates character drop bugs that corrupt proper nouns, locations, and transliterated person names. |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## Limitations and Known Issues
|
|
444
|
+
|
|
445
|
+
In accordance with rigorous academic transparency (see [`docs/paper.md` §6](docs/paper.md)), ten limitations are explicitly recorded:
|
|
446
|
+
|
|
447
|
+
1. **Absence of Classical / Literary Register**: No classical or literary Sindhi register is included. Five independent candidate sources were investigated: a corrupted CSV export, an unrelated SQL dump, two unusable OCR scans (one incompatibly licensed), and a government-affiliated platform gated behind an institutional subscription.
|
|
448
|
+
2. **Partial Source Overlap in Evaluation**: The Sentiment register and the Sindhi-NLP component of the training corpus share adjacent news-source provenance; full genre-level independence is not established for this pair.
|
|
449
|
+
3. **Metric-specific results**: Against FLORES+ specifically, CustomSindhi_32k has one confirmed loss on fertility and single-token retention. The all-register lead at 64k and above refers to those two measures; byte-fallback is a separate trade-off.
|
|
450
|
+
4. **Qualitative Test Does Not Differentiate at Word Level**: On the 22-word test list, the new tokenizer ties rather than beats the best competitor on 21 of 22 words; the demonstrated advantage is aggregate across full corpora, not example-level.
|
|
451
|
+
5. **Search for Existing Tokenizers May Be Incomplete**: Four additional tokenizers were discovered after initial benchmarking; while subsequent searches found no further models, the open-source NLP space is active enough that this cannot be guaranteed exhaustive.
|
|
452
|
+
6. **Downstream Applications Undetermined**: The tokenizer's target use is future Sindhi language modeling. It is not validated for Automatic Speech Recognition (ASR) or Text-to-Speech (TTS).
|
|
453
|
+
7. **Register Weighting Choice**: The four evaluation registers differ substantially in size; an unweighted macro mean was used rather than a token-pooled mean, which would have been dominated by Sindh Line News (~2.5× the other three combined).
|
|
454
|
+
8. **No language filter on training text**: About 11.3% of a diagnostic sample of the shaikhsalman text was mostly Latin script. No filter was applied before training, so English text is part of the training corpus.
|
|
455
|
+
9. **Repeated cross-lingual text**: The Urdu, Persian and Arabic part of the corpus is 89,449 unique sentences repeated four times. Its share by character count is 16.1%, but its unique content is much smaller.
|
|
456
|
+
10. **Possible overlap with baseline training data**: The SindhiLM model card names the ambile-official Sindhi Mega Corpus as training data, and that corpus lists Sindhi Wikipedia among its sources. SindhiLM may therefore have seen text from our Wikipedia evaluation set, which would favor that baseline, not ours.
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## Complete Documentation Index
|
|
461
|
+
|
|
462
|
+
| Document | Path | Purpose |
|
|
463
|
+
|---|---|---|
|
|
464
|
+
| **Root Guide & Navigation Hub** | [`README.md`](README.md) | Central repository overview, quickstart, and full benchmark summary |
|
|
465
|
+
| **Research Manuscript Draft** | [`docs/paper.md`](docs/paper.md) | Draft for future publication; not yet published. Includes methodology and 18 benchmark rows |
|
|
466
|
+
| **Technical Explainer Log** | [`docs/explainer.md`](docs/explainer.md) | In-depth engineering explainer into empirical failures, metric corrections, and design rationale |
|
|
467
|
+
| **Dataset Provenance Card** | [`DATA_SOURCES.md`](DATA_SOURCES.md) | Complete documentation of all training corpora and evaluation sets, licensing, and volumes |
|
|
468
|
+
| **Evaluation Module Guide** | [`evaluation/README.md`](evaluation/README.md) | Technical documentation of metrics algorithms, CLI arguments, and Python API |
|
|
469
|
+
| **Training Pipeline Guide** | [`training/README.md`](training/README.md) | Exact SentencePiece training recipe, filtering thresholds, and negative findings |
|
|
470
|
+
| **Benchmark Result Summaries** | [`results/README.md`](results/README.md) | Detailed register breakdowns across FLORES+, Wikipedia, Sentiment, and Sindh Line |
|
|
471
|
+
| **Notebook Reproduction Guide** | [`notebooks/README.md`](notebooks/README.md) | Instructions for Kaggle/Colab execution of training and benchmarking pipelines |
|
|
472
|
+
| **Interactive Demo Guide** | [`demo/README.md`](demo/README.md) | Local execution and Hugging Face Spaces deployment guide for Gradio UI |
|
|
473
|
+
| **Citation Specification** | [`CITATION.cff`](CITATION.cff) | Machine-readable CFF citation metadata |
|
|
474
|
+
| **Project Packaging** | [`pyproject.toml`](pyproject.toml) | Modern build-system and packaging metadata |
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
## References and Further Reading
|
|
479
|
+
|
|
480
|
+
1. **Kudo, T. & Richardson, J. (2018).** *SentencePiece: A simple and language independent subword tokenizer and detokenizer for neural text processing.* EMNLP 2018 System Demonstrations. [https://aclanthology.org/D18-2012/](https://aclanthology.org/D18-2012/)
|
|
481
|
+
2. **Kudo, T. (2018).** *Subword Regularization: Improving Neural Network Translation Models with Multiple Subword Candidates.* ACL 2018. [https://aclanthology.org/P18-1007/](https://aclanthology.org/P18-1007/)
|
|
482
|
+
3. **Conneau, A., et al. (2020).** *Unsupervised Cross-lingual Representation Learning at Scale (XLM-RoBERTa).* ACL 2020. [arXiv:1911.02116](https://arxiv.org/abs/1911.02116)
|
|
483
|
+
4. **NLLB Team et al. (2022).** *No Language Left Behind: Scaling Human-Centered Machine Translation (FLORES-200).* [arXiv:2207.04672](https://arxiv.org/abs/2207.04672)
|
|
484
|
+
5. **Qwen Team (2024).** *Qwen2.5 Technical Report.* [arXiv:2412.15115](https://arxiv.org/abs/2412.15115)
|
|
485
|
+
6. **Meta AI (2024).** *Llama 3.2 Model Card & Architecture Overview.* [https://huggingface.co/meta-llama](https://huggingface.co/meta-llama)
|
|
486
|
+
|
|
487
|
+
*Note: For the complete list of 21 baseline model citations and references, please refer to [`docs/paper.md`](docs/paper.md).*
|
|
488
|
+
|
|
489
|
+
---
|
|
490
|
+
|
|
491
|
+
## Team and Acknowledgments
|
|
492
|
+
|
|
493
|
+
This research and tokenizer implementation were developed at the **Department of Computer Science, Shaikh Ayaz University, Shikarpur, Pakistan**, under the supervision of **Dr. Attaullah Sahito** (academic supervisor, not an author).
|
|
494
|
+
|
|
495
|
+
### Authors and Roles
|
|
496
|
+
- **Ali Nawaz** (Lead author and project lead): [GitHub (@alinawazcode)](https://github.com/alinawazcode)
|
|
497
|
+
- **Muqadas Fareed** (author): [LinkedIn Profile](https://www.linkedin.com/in/muqadas-fareed-24a07837b/)
|
|
498
|
+
- **Soonh Sadaf (Sadaf Khaliq)** (author): [LinkedIn Profile](https://www.linkedin.com/in/sadaf-khaliq-a69215411/)
|
|
499
|
+
- **Dr. Attaullah Sahito** (academic supervisor): [LinkedIn Profile](https://www.linkedin.com/in/attaullah-sahito/?isSelfProfile=false), Department of Computer Science, Shaikh Ayaz University.
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
503
|
+
## License and Citation
|
|
504
|
+
|
|
505
|
+
### License
|
|
506
|
+
- **Software Code**: Licensed under the open-source [MIT License](LICENSE).
|
|
507
|
+
- **Trained Tokenizer Models**: The Hugging Face listing states [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Source datasets are reported by the project lead to be free to use, mostly under MIT and other open licenses; exact terms and attribution conditions vary by source and are summarized in [`DATA_SOURCES.md`](DATA_SOURCES.md).
|
|
508
|
+
- **Corpus Texts**: Refer to [`DATA_SOURCES.md`](DATA_SOURCES.md) for original source licenses.
|
|
509
|
+
|
|
510
|
+
### Citation
|
|
511
|
+
If you use this tokenizer, benchmark code, or findings in your academic research or applications, please cite:
|
|
512
|
+
|
|
513
|
+
```bibtex
|
|
514
|
+
@misc{nawaz2026sindhitokenizer,
|
|
515
|
+
author = {Nawaz, Ali and Fareed, Muqadas and Sadaf, Soonh},
|
|
516
|
+
title = {A Corpus-Driven Sindhi Subword Tokenizer: Design, Empirical Validation, and Benchmark Comparison Against Fourteen Existing Tokenizers},
|
|
517
|
+
year = {2026},
|
|
518
|
+
howpublished = {\url{https://github.com/alinawazcode/sindhi-tokenizer}},
|
|
519
|
+
note = {Department of Computer Science, Shaikh Ayaz University, Shikarpur, Pakistan}
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
---
|
|
524
|
+
|
|
525
|
+
## Frequently Asked Questions (FAQ)
|
|
526
|
+
|
|
527
|
+
<details>
|
|
528
|
+
<summary><b>1. Why choose the 64k model over 32k or 150k?</b></summary>
|
|
529
|
+
The 64,000 vocabulary size represents the empirical sweet spot between fertility efficiency (1.147 tokens/word) and embedding matrix parameter overhead. Scaling to 100k or 150k provides marginal fertility gains (1.133 and 1.125 respectively) but more than doubles the vocabulary table size, while the 32k model exhibits one minor loss on the standardized FLORES+ benchmark.
|
|
530
|
+
</details>
|
|
531
|
+
|
|
532
|
+
<details>
|
|
533
|
+
<summary><b>2. What does the round-trip length check measure?</b></summary>
|
|
534
|
+
It applies Unicode NFKC, removes zero-width formatting characters and whitespace, then compares normalized input and decoded-output lengths. This detects shortening but can miss substitutions or reorderings that preserve length; 0.0000% is not proof of exact text identity.
|
|
535
|
+
</details>
|
|
536
|
+
|
|
537
|
+
<details>
|
|
538
|
+
<summary><b>3. Why is there a 15% mix of Urdu, Persian, and Arabic in the training corpus?</b></summary>
|
|
539
|
+
Sindhi shares the Perso-Arabic alphabet and borrows significant religious, legal, and cultural vocabulary from Arabic and Persian, as well as shared regional terms with Urdu. This anchor (16.1% of characters, from 89,449 unique sentences repeated four times) was added by design to expose the subword vocabulary to shared Perso-Arabic root morphemes.
|
|
540
|
+
</details>
|
|
541
|
+
|
|
542
|
+
<details>
|
|
543
|
+
<summary><b>4. Why should I avoid transformers.LlamaTokenizer for loading this model?</b></summary>
|
|
544
|
+
Certain versions of Hugging Face Transformers' <code>LlamaTokenizer</code> fail to load custom SentencePiece Unigram models correctly, silently substituting an empty or 3-token fallback vocabulary without throwing an exception. Always use <code>sentencepiece.SentencePieceProcessor</code> directly or via our verified <code>SPMTokenizerAdapter</code>.
|
|
545
|
+
</details>
|