akshara-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.
@@ -0,0 +1,194 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or
82
+ contributory patent infringement, then any patent licenses granted to
83
+ You under this License for that Work shall terminate as of the date
84
+ such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or
92
+ Derivative Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, reproduce, modify,
120
+ prepare Derivative Works of, distribute, and sublicense such
121
+ modifications and Derivative Works as a whole, provided Your use,
122
+ reproduction, and distribution of the Work otherwise complies with
123
+ the conditions stated in this License.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (including but not limited to damages for loss of goodwill,
156
+ work stoppage, computer failure or malfunction, or all other
157
+ commercial damages or losses), even if such Contributor has been
158
+ advised of the possibility of such damages.
159
+
160
+ 9. Accepting Warranty or Additional Liability. While redistributing
161
+ the Work or Derivative Works thereof, You may choose to offer, and
162
+ charge a fee for, acceptance of support, warranty, indemnity,
163
+ or other liability obligations and/or rights consistent with this
164
+ License. However, in accepting such obligations, You may act only
165
+ on Your own behalf and on Your sole responsibility, not on behalf
166
+ of any other Contributor, and only if You agree to indemnify,
167
+ defend, and hold each Contributor harmless for any liability
168
+ incurred by, or claims asserted against, such Contributor by reason
169
+ of your accepting any such warranty or additional liability.
170
+
171
+ END OF TERMS AND CONDITIONS
172
+
173
+ APPENDIX: How to apply the Apache License to your work.
174
+
175
+ To apply the Apache License to your work, attach the following
176
+ boilerplate notice, with the fields enclosed by brackets "[]"
177
+ replaced with your own identifying information. (Don't include
178
+ the brackets!) The text should be enclosed in the appropriate
179
+ comment syntax for the file format in question. Please also include
180
+ a "NOTICE" file with your name and affiliation.
181
+
182
+ Copyright 2026 Gursimran Singh
183
+
184
+ Licensed under the Apache License, Version 2.0 (the "License");
185
+ you may not use this file except in compliance with the License.
186
+ You may obtain a copy of the License at
187
+
188
+ http://www.apache.org/licenses/LICENSE-2.0
189
+
190
+ Unless required by applicable law or agreed to in writing, software
191
+ distributed under the License is distributed on an "AS IS" BASIS,
192
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
193
+ implied. See the License for the specific language governing
194
+ permissions and limitations under the License.
@@ -0,0 +1,7 @@
1
+ IYRA Akshara Tokenizer
2
+ Copyright 2026 Gursimran Singh
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Patent pending: Indian provisional patent application 202611071450.
@@ -0,0 +1,436 @@
1
+ Metadata-Version: 2.4
2
+ Name: akshara-tokenizer
3
+ Version: 1.1.0
4
+ Summary: Linguistically-correct Akshara boundary tokenizer for Brahmic scripts
5
+ Author-email: Gursimran Singh <gursimranbasra1322@gmail.com>
6
+ License: Apache License
7
+ Version 2.0, January 2004
8
+ http://www.apache.org/licenses/
9
+
10
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11
+
12
+ 1. Definitions.
13
+
14
+ "License" shall mean the terms and conditions for use, reproduction,
15
+ and distribution as defined by Sections 1 through 9 of this document.
16
+
17
+ "Licensor" shall mean the copyright owner or entity authorized by
18
+ the copyright owner that is granting the License.
19
+
20
+ "Legal Entity" shall mean the union of the acting entity and all
21
+ other entities that control, are controlled by, or are under common
22
+ control with that entity. For the purposes of this definition,
23
+ "control" means (i) the power, direct or indirect, to cause the
24
+ direction or management of such entity, whether by contract or
25
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
26
+ outstanding shares, or (iii) beneficial ownership of such entity.
27
+
28
+ "You" (or "Your") shall mean an individual or Legal Entity
29
+ exercising permissions granted by this License.
30
+
31
+ "Source" form shall mean the preferred form for making modifications,
32
+ including but not limited to software source code, documentation
33
+ source, and configuration files.
34
+
35
+ "Object" form shall mean any form resulting from mechanical
36
+ transformation or translation of a Source form, including but
37
+ not limited to compiled object code, generated documentation,
38
+ and conversions to other media types.
39
+
40
+ "Work" shall mean the work of authorship made available under
41
+ the License, as indicated by a copyright notice that is included in
42
+ or attached to the work (an example is provided in the Appendix below).
43
+
44
+ "Derivative Works" shall mean any work, whether in Source or Object
45
+ form, that is based on (or derived from) the Work and for which the
46
+ editorial revisions, annotations, elaborations, or other modifications
47
+ represent, as a whole, an original work of authorship. For the purposes
48
+ of this License, Derivative Works shall not include works that remain
49
+ separable from, or merely link (or bind by name) to the interfaces of,
50
+ the Work and Derivative Works thereof.
51
+
52
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
53
+ in the Work by the copyright owner or by an individual or Legal Entity
54
+ authorized to submit on behalf of the copyright owner. For the purposes
55
+ of this definition, "submitted" means any form of electronic, verbal,
56
+ or written communication sent to the Licensor or its representatives,
57
+ including but not limited to communication on electronic mailing lists,
58
+ source code control systems, and issue tracking systems that are managed
59
+ by, or on behalf of, the Licensor for the purpose of discussing and
60
+ improving the Work, but excluding communication that is conspicuously
61
+ marked or designated in writing by the copyright owner as "Not a
62
+ Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
65
+ whom a Contribution has been received by the Licensor and subsequently
66
+ incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a cross-claim
85
+ or counterclaim in a lawsuit) alleging that the Work or any
86
+ Contribution embodied within the Work constitutes direct or
87
+ contributory patent infringement, then any patent licenses granted to
88
+ You under this License for that Work shall terminate as of the date
89
+ such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, You must include a readable copy of the
110
+ attribution notices contained within such NOTICE file, in
111
+ at least one of the following places: within a NOTICE text
112
+ file distributed as part of the Derivative Works; within
113
+ the Source form or documentation, if provided along with the
114
+ Derivative Works; or, within a display generated by the
115
+ Derivative Works, if and wherever such third-party notices
116
+ normally appear. The contents of the NOTICE file are for
117
+ informational purposes only and do not modify the License.
118
+ You may add Your own attribution notices within Derivative
119
+ Works that You distribute, alongside or as an addendum to
120
+ the NOTICE text from the Work, provided that such additional
121
+ attribution notices cannot be construed as modifying the License.
122
+
123
+ You may add Your own license statement for Your modifications and
124
+ may provide additional grant of rights to use, reproduce, modify,
125
+ prepare Derivative Works of, distribute, and sublicense such
126
+ modifications and Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or reproducing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or exemplary damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or all other
162
+ commercial damages or losses), even if such Contributor has been
163
+ advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer, and
167
+ charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format in question. Please also include
185
+ a "NOTICE" file with your name and affiliation.
186
+
187
+ Copyright 2026 Gursimran Singh
188
+
189
+ Licensed under the Apache License, Version 2.0 (the "License");
190
+ you may not use this file except in compliance with the License.
191
+ You may obtain a copy of the License at
192
+
193
+ http://www.apache.org/licenses/LICENSE-2.0
194
+
195
+ Unless required by applicable law or agreed to in writing, software
196
+ distributed under the License is distributed on an "AS IS" BASIS,
197
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
198
+ implied. See the License for the specific language governing
199
+ permissions and limitations under the License.
200
+
201
+ Project-URL: Homepage, https://github.com/1322Guru/akshara-tokenizer
202
+ Project-URL: Repository, https://github.com/1322Guru/akshara-tokenizer
203
+ Project-URL: Bug Tracker, https://github.com/1322Guru/akshara-tokenizer/issues
204
+ Project-URL: HuggingFace, https://huggingface.co/GursimranSinghBasra/akshara-tokenizer
205
+ Keywords: nlp,tokenizer,indic,brahmic,hindi,punjabi,tamil,telugu,bengali,kannada,akshara,sentencepiece
206
+ Classifier: Development Status :: 3 - Alpha
207
+ Classifier: Intended Audience :: Science/Research
208
+ Classifier: License :: OSI Approved :: Apache Software License
209
+ Classifier: Programming Language :: Python :: 3
210
+ Classifier: Programming Language :: Python :: 3.10
211
+ Classifier: Programming Language :: Python :: 3.11
212
+ Classifier: Programming Language :: Python :: 3.12
213
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
214
+ Classifier: Topic :: Text Processing :: Linguistic
215
+ Classifier: Natural Language :: Hindi
216
+ Classifier: Natural Language :: Tamil
217
+ Requires-Python: >=3.10
218
+ Description-Content-Type: text/markdown
219
+ License-File: LICENSE
220
+ License-File: NOTICE
221
+ Provides-Extra: dev
222
+ Requires-Dist: pytest>=7.0; extra == "dev"
223
+ Provides-Extra: model
224
+ Requires-Dist: sentencepiece>=0.2.0; extra == "model"
225
+ Dynamic: license-file
226
+
227
+ # IYRA Akshara Tokenizer (IAT)
228
+
229
+ Linguistically-correct tokenization for Brahmic (Indic) scripts. It has two layers:
230
+ a rule-based Akshara segmenter that never splits an orthographic syllable, and a
231
+ trained SentencePiece model on top of it.
232
+
233
+ ## Supported Scripts
234
+
235
+ Rule-based segmentation covers six scripts:
236
+
237
+ | Script | Languages |
238
+ |------------|--------------------------|
239
+ | Devanagari | Hindi, Sanskrit, Marathi |
240
+ | Gurmukhi | Punjabi |
241
+ | Tamil | Tamil |
242
+ | Telugu | Telugu |
243
+ | Bengali | Bengali |
244
+ | Kannada | Kannada |
245
+
246
+ ## Why Akshara instead of BPE?
247
+
248
+ Byte-level BPE tokenizers split Brahmic text mid-character. A conjunct such as
249
+ ज्ञा, or a consonant plus vowel sign such as ਪੰ, is one orthographic syllable
250
+ (one Akshara), but BPE sees only UTF-8 bytes and cuts wherever its merges fall.
251
+ Captured output below: the same strings through the Qwen3-14B tokenizer and
252
+ through this tokenizer's segmenter. Each BPE token is decoded independently; a
253
+ `�` is a token that holds only a fragment of one character's bytes.
254
+
255
+ | Input | Qwen3-14B BPE tokens | Akshara segments |
256
+ |-------|----------------------|------------------|
257
+ | ज्ञान (Hindi) | `['ज', '्�', '�', 'ा�', '�']` (5 tokens) | `['ज्ञा', 'न']` (2 units) |
258
+ | ਪੰਜਾਬ (Punjabi) | `['ਪ', '�', '�', 'ਜ', '�', '�', 'ਬ']` (7 tokens) | `['ਪੰ', 'ਜਾ', 'ਬ']` (3 units) |
259
+ | நியாயம் (Tamil) | `['�', '�', 'ி�', '�', '�', '�', 'ய', 'ம', '்']` (9 tokens) | `['நி', 'யா', 'ய', 'ம்']` (4 units) |
260
+
261
+ The rule-based segmenter never splits an Akshara: that guarantee is exact, for
262
+ every input. At the SentencePiece layer the guarantee is statistical, not
263
+ absolute: aksharas too rare for the 16,000-piece vocabulary decompose into
264
+ sub-pieces or byte-fallback pieces, measured at 1.86 percent of aksharas overall
265
+ on FLORES-200 devtest (0.15 to 3.65 percent by script; see
266
+ `benchmark_2026_07/results_v1_1.md`). The fertility tables below quantify the
267
+ efficiency effect corpus-wide.
268
+
269
+ ## Pipeline
270
+
271
+ Two layers: a rule-based Akshara segmenter (pure Unicode rules, no model), then
272
+ a trained SentencePiece model over the segmented sequence. One real example end
273
+ to end, with the actual ids from the shipped 16,000-piece v1.1 model:
274
+
275
+ ```
276
+ Unicode text "न्याय दर्शन"
277
+ |
278
+ rule-based akshara segmenter
279
+ |
280
+ akshara sequence ['न्या', 'य', ' ', 'द', 'र्श', 'न']
281
+ |
282
+ SentencePiece (16k vocab, byte_fallback)
283
+ |
284
+ pieces ['▁न्या', '▁य', '▁द', '▁र्श', '▁न']
285
+ token ids [1734, 338, 364, 1398, 270]
286
+ ```
287
+
288
+ ## Model
289
+
290
+ This release ships one trained SentencePiece model (byte_fallback enabled):
291
+
292
+ | Model | Vocab | Trained scripts | File |
293
+ |-------|------:|-----------------|------|
294
+ | v1.1 (six-script) | 16,000 | all six, with the anusvara fix | `akshara_tokenizer/model/akshara_tokenizer_v1_1.model` |
295
+
296
+ An earlier 7,000-vocab model trained on Hindi, Punjabi, and Tamil was the originally
297
+ filed artifact and is not distributed in this release.
298
+
299
+ ## Fertility (verified)
300
+
301
+ FLORES-200 devtest, tokens per whitespace word (lower is better). Numbers from
302
+ `benchmark_2026_07/results_v1_1.md`.
303
+
304
+ | Script (language) | v1.1 (16k) | Qwen3-14B |
305
+ |--------------------|-----------:|----------:|
306
+ | Devanagari (Hindi) | 2.45 | 4.77 |
307
+ | Gurmukhi (Punjabi) | 2.68 | 7.80 |
308
+ | Tamil (Tamil) | 5.01 | 10.06 |
309
+ | Telugu (Telugu) | 3.71 | 11.41 |
310
+ | Bengali (Bengali) | 3.38 | 7.16 |
311
+ | Kannada (Kannada) | 4.17 | 11.88 |
312
+ | English (info) | 5.08 | 1.26 |
313
+
314
+ ![Fertility by script on FLORES-200 devtest, AksharaTokenizer v1.1 vs Qwen3-14B](https://raw.githubusercontent.com/1322Guru/akshara-tokenizer/e0f893394b9d96d2f47044e7d80556ec499a15e7/assets/fertility_v1_1.svg)
315
+
316
+ Byte-fallback rate, percent (lower is better):
317
+
318
+ | Script | v1.1 (16k) |
319
+ |---------|-----------:|
320
+ | Hindi | 0.77 |
321
+ | Punjabi | 0.73 |
322
+ | Tamil | 0.02 |
323
+ | Telugu | 0.08 |
324
+ | Bengali | 0.09 |
325
+ | Kannada | 0.36 |
326
+
327
+ ![Byte-fallback rate by script for v1.1](https://raw.githubusercontent.com/1322Guru/akshara-tokenizer/e0f893394b9d96d2f47044e7d80556ec499a15e7/assets/byte_fallback_v1_1.svg)
328
+
329
+ v1.1 fertility is below Qwen3-14B on all six Indic scripts, and its Telugu, Bengali,
330
+ and Kannada byte-fallback is under 0.4 percent. On English, Qwen3 is more efficient,
331
+ as expected for an English-centric byte-level BPE.
332
+
333
+ Both charts are generated from `benchmark_2026_07/results_v1_1.csv` by
334
+ `benchmark_2026_07/make_charts_v1_1.py`, so they can be reproduced from the
335
+ shipped data.
336
+
337
+ ## Install
338
+
339
+ Requires Python >=3.10 (as declared in `pyproject.toml`).
340
+
341
+ ```bash
342
+ git clone https://github.com/1322Guru/akshara-tokenizer
343
+ cd akshara-tokenizer
344
+ pip install . # rule-based segmenter only
345
+ pip install ".[model]" # includes sentencepiece, needed for the trained model
346
+ ```
347
+
348
+ The base install is all you need for `segment_aksharas` and `count_aksharas`.
349
+ The `model` extra is needed to encode with the trained SentencePiece model.
350
+
351
+ ## Usage
352
+
353
+ Rule-based segmentation (no model needed):
354
+
355
+ ```python
356
+ from akshara_tokenizer import segment_aksharas, count_aksharas
357
+
358
+ segment_aksharas("ਨਿਆਯ ਦਰਸ਼ਨ")
359
+ # ["ਨਿ", "ਆ", "ਯ", " ", "ਦ", "ਰ", "ਸ਼", "ਨ"]
360
+
361
+ segment_aksharas("ज्ञान")
362
+ # ["ज्ञा", "न"]
363
+
364
+ count_aksharas("ਪੰਜਾਬ")
365
+ # 3
366
+ ```
367
+
368
+ Encoding with the trained model (segment, then SentencePiece):
369
+
370
+ ```python
371
+ import sentencepiece as spm
372
+ from importlib.resources import files, as_file
373
+ from akshara_tokenizer import segment_aksharas
374
+
375
+ # Load the model from the installed package (works after pip install, no repo path needed)
376
+ model_res = files("akshara_tokenizer").joinpath("model", "akshara_tokenizer_v1_1.model")
377
+ with as_file(model_res) as model_path:
378
+ sp = spm.SentencePieceProcessor(model_file=str(model_path))
379
+
380
+ ids = sp.encode(" ".join(segment_aksharas("न्याय दर्शन")))
381
+ ```
382
+
383
+ ## Akshara Formation Rules
384
+
385
+ 1. C + virama + C forms a single conjunct (Devanagari, Telugu, Bengali, Kannada).
386
+ 2. C + vowel sign forms one Akshara.
387
+ 3. C + virama alone is a dead consonant and a complete Akshara.
388
+ 4. An independent vowel is its own Akshara.
389
+ 5. Anusvara, visarga, nukta, addak, tippi, bindi, and candrabindu attach to the
390
+ preceding Akshara.
391
+ 6. Latin letters, digits, and punctuation are one token each.
392
+
393
+ ## Limitations (honest)
394
+
395
+ - Round-trip is not lossless. The tokenizer is encode-optimized. `decode(encode(text))`
396
+ is not guaranteed to be byte-identical, because Akshara segmentation joins units with
397
+ spaces and SentencePiece normalizes whitespace. Use it for tokenization and fertility,
398
+ not for lossless reconstruction. A detokenizer is planned. (Verified: round-trip is not
399
+ byte-identical for any script in results_v1_1.md.)
400
+ - Script coverage. Telugu, Bengali, and Kannada are well-supported from v1.1 onward; the
401
+ earlier 7,000-vocab model covered only Hindi, Punjabi, and Tamil and is not shipped here.
402
+
403
+ ## Run Tests
404
+
405
+ pytest is not part of the base install; get it via the dev extra, then run the suite:
406
+
407
+ ```bash
408
+ pip install ".[dev]"
409
+ python -m pytest tests/ -v
410
+ ```
411
+
412
+ ## Script-level Notes
413
+
414
+ | Script | Conjuncts | Notes |
415
+ |------------|-----------|-------|
416
+ | Devanagari | Yes | Standard C + virama + C conjuncts |
417
+ | Gurmukhi | No | Virama creates dead consonants; addak doubles the next consonant |
418
+ | Tamil | No | Pulli always creates a dead consonant |
419
+ | Telugu | Yes | Conjuncts via virama |
420
+ | Bengali | Yes | Hasanta conjuncts |
421
+ | Kannada | Yes | Conjuncts via virama |
422
+
423
+ ## Direction
424
+
425
+ Akshara-based segmentation is one instance of a more general idea: tokenizing
426
+ on the orthographic units a writing system is built from, rather than on bytes.
427
+ The same principle extends to other syllable-block writing systems.
428
+
429
+ ## Patent and Copyright
430
+
431
+ Patent pending: Indian provisional patent application 202611071450.
432
+ Copyright 2026 Gursimran Singh.
433
+
434
+ ## License
435
+
436
+ Apache License 2.0. See `LICENSE` and `NOTICE`.