SRK-CobuildX commited on
Commit
838f544
·
verified ·
1 Parent(s): bc8f371

Release v0.1

Browse files
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such 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 redistributing 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 consequential 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 any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been 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,
167
+ and 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. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ InDIM-small
2
+ Copyright 2026 Cobuild Tech Private Limited.
3
+
4
+ Licensed under the Apache License, Version 2.0 (see LICENSE): the model weights, configuration, tokenizer, scripts
5
+ and documentation in this repository. Provided "as is", without warranties or conditions of any kind (LICENSE,
6
+ sections 7 and 8); see "Intended use and disclaimer" in README.md.
7
+
8
+ This model contains or was built from the following third-party materials:
9
+
10
+ 1. mmBERT (jhu-clsp/mmBERT-small). InDIM-small was initialised from mmBERT-small's encoder weights (its
11
+ vocabulary replaced by the CBX-Indic tokenizer) and then trained further. Copyright (c) 2025 the mmBERT authors (Marone, Weller, Fleshman,
12
+ Yang, Lawrie, Van Durme). MIT License:
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
15
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
16
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
17
+ persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
20
+ Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
24
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
README.md CHANGED
@@ -1,3 +1,175 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: fill-mask
5
+ language: [as, bn, gu, hi, kn, ml, mr, or, pa, ta, te, ur, en]
6
+ tags: [indic, multilingual, romanized, code-mixed, modernbert, encoder, fill-mask, onnx]
7
  ---
8
+
9
+ # InDIM-small (32M)
10
+
11
+ **InDIM** (Indic Decision Intelligence Models) are compact encoders for Indian languages. **InDIM-small** has 32M
12
+ parameters and covers 12 Indian languages and English: Assamese, Bengali, Gujarati, Hindi, Kannada, Malayalam,
13
+ Marathi, Odia, Punjabi, Tamil, Telugu, Urdu and English. It reads native script, romanized text (Hindi, Tamil, … in
14
+ Latin letters) and code-mixed text.
15
+
16
+ It is a base model: fine-tune it for classification, token tagging (NER, PII) or retrieval. On our fine-tuned tasks
17
+ it beats [mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small) (140M) on 12 of 15 benchmarks at about a
18
+ quarter of the size, runs about 3× faster on CPU and keeps its outputs under int8 quantisation.
19
+
20
+ | | |
21
+ |---|---|
22
+ | Parameters | 31.5M encoder (+0.3M masked-LM head) |
23
+ | Architecture | ModernBERT encoder: 12 layers, hidden 384, FFN 576, 6 heads, RoPE, global attention every third layer and 128-token local attention in the others |
24
+ | Vocabulary | 128,064-piece Unigram tokenizer for Indic + English; factorized 128-dim word embedding, tied with the output layer |
25
+ | Pretraining length | 512 tokens (longer inputs work; see the PII results below) |
26
+ | Precision | fp32 weights; fp16 inference is exact; int8 friendly (see Precision) |
27
+
28
+ ## Usage
29
+
30
+ The factorized embedding needs the model code in this repository (`trust_remote_code=True`).
31
+
32
+ ```python
33
+ from transformers import AutoTokenizer, AutoModel, AutoModelForMaskedLM, pipeline
34
+
35
+ tok = AutoTokenizer.from_pretrained("CobuildX-AI/InDIM-small", trust_remote_code=True)
36
+ mlm = AutoModelForMaskedLM.from_pretrained("CobuildX-AI/InDIM-small", trust_remote_code=True)
37
+ fill = pipeline("fill-mask", model=mlm, tokenizer=tok)
38
+ fill("भारत की राजधानी [MASK] है।") # top prediction: "दिल्ली"
39
+
40
+ encoder = AutoModel.from_pretrained("CobuildX-AI/InDIM-small", trust_remote_code=True)
41
+ ```
42
+
43
+ Fine-tuning: `AutoModelForSequenceClassification` and `AutoModelForTokenClassification` load the stock ModernBERT
44
+ heads on top (`classifier_pooling` "cls" or "mean"). Learning rates of 2e-4 to 8e-4 worked best for our tasks (higher
45
+ than for larger models).
46
+
47
+ ONNX: `onnx/model.onnx` (fp32) and `onnx/model_int8.onnx` (dynamic int8) take `input_ids` and `attention_mask`
48
+ [batch, length] and return the last hidden state.
49
+
50
+ ## Results
51
+
52
+ All fine-tuned numbers use the same recipe for every model within a task (plain fine-tuning, no distillation), a
53
+ learning rate picked per model on validation, and the mean of 3 training runs unless marked. Higher is better unless marked.
54
+
55
+ ### Fine-tuned tasks: InDIM-small vs mmBERT-small
56
+
57
+ | Task | Test set | Metric | **InDIM-small (32M)** | mmBERT-small (140M) |
58
+ |---|---|---|---|---|
59
+ | Intent (60 intents, 7 languages) | MASSIVE test | accuracy | **85.2** | 84.2 |
60
+ | Sentiment | IndicSentiment (13 languages, human labels) | accuracy | 0.822 | **0.839** |
61
+ | Sentiment | Telugu / English / romanized Hindi sources, human labels | macro F1 | **0.512** | 0.508 |
62
+ | Slot filling (55 slot types) | MASSIVE test | span F1 | **0.700** | 0.680 |
63
+ | PII (27 types) | our synthetic test | span F1 | 0.992 | **0.993** |
64
+ | PII | Ylemis India-PII (independent) | typed F1 | **0.989** | 0.987 |
65
+ | PII | IndiaPII-Bench (independent) | typed F1 | **0.960** | 0.950 |
66
+ | PII | [IndicPIIDetX](https://huggingface.co/datasets/CobuildX-AI/IndicPIIDetX) test, 14 shared types | typed F1 | **0.950** | 0.930 |
67
+ | PII | IndicPIIDetX test, all 27 types | typed F1 | **0.906** | 0.894 |
68
+ | Profanity / abuse (5 labels) | gold set (3,980 held-out texts, LLM-labelled) | macro F1 | 0.703 | **0.725** |
69
+ | Hate | Hindi HateCheck | PR-AUC | **0.749** | 0.742 |
70
+ | Causal reasoning (trained on English only) | IndicCOPA, 18 languages | accuracy, 1 run | **0.533** | 0.530 |
71
+ | Paraphrase (trained on English only) | IndicXParaphrase, 10 languages | accuracy, 1 run | **0.571** | 0.561 |
72
+ | Named entities | Naamapadam, 11 languages | entity F1, 1 run | **0.704** | 0.671 |
73
+
74
+ - **Where InDIM-small is weaker:** sentiment on IndicSentiment (−0.017), profanity / insult detection (−0.022 macro
75
+ F1) and transfer from English-only training (COPA and paraphrase are close to chance, 0.50, for both models).
76
+ English is its weakest language.
77
+ - **PII on long text:** on our PII test, rows longer than 512 tokens score 0.996 against 0.991 for shorter rows, so
78
+ the model works beyond its pretraining length.
79
+ - **Fine-tuned models built on InDIM-small**, each compared with mmBERT-small, mmBERT-base and IndicBERT v2:
80
+ [intent](https://huggingface.co/CobuildX-AI/cbx-indim-intent-classifier-32M),
81
+ [sentiment](https://huggingface.co/CobuildX-AI/cbx-indim-sentiment-classifier-32M),
82
+ [PII](https://huggingface.co/CobuildX-AI/cbx-indim-pii-extractor-32M),
83
+ [profanity](https://huggingface.co/CobuildX-AI/cbx-indim-profanity-detector-32M).
84
+
85
+ ### Without fine-tuning
86
+
87
+ **Masked-word prediction** (whole-word pseudo-log-likelihood, bits per character; lower is better). Held-out text,
88
+ but from the same kinds of sources as InDIM-small's pretraining data, which favours InDIM-small: read it as a check
89
+ of script and register coverage, not as a fair language-modelling comparison.
90
+
91
+ | Text | **InDIM-small** | mmBERT-small |
92
+ |---|---|---|
93
+ | All Indic (macro) | **1.571** | 2.314 |
94
+ | Native script | **1.263** | 1.737 |
95
+ | Romanized (natural) | **1.856** | 3.051 |
96
+ | Romanized (transliterated) | **1.410** | 2.907 |
97
+ | Code-mixed | **2.146** | 2.377 |
98
+ | English | 0.986 | **0.731** |
99
+
100
+ **Cross-lingual retrieval** (FLORES devtest, English ↔ language, mean-pooled embeddings, accuracy@1, macro over 12
101
+ languages; "centered" subtracts each language's mean embedding):
102
+
103
+ | | **InDIM-small** | mmBERT-small |
104
+ |---|---|---|
105
+ | English → native script, centered | **0.502** | 0.248 |
106
+ | Native script → English, centered | **0.513** | 0.228 |
107
+ | English → romanized (transliterated), centered | **0.345** | 0.077 |
108
+ | English → native script, raw | **0.133** | 0.070 |
109
+
110
+ The raw embeddings are not aligned across languages (no sentence-level training); fine-tune for retrieval.
111
+
112
+ ### Efficiency
113
+
114
+ CPU latency (Intel i7-10700, batch 1, median ms, encoder only, PyTorch fp32) at 64 / 128 / 512 tokens:
115
+
116
+ | | Parameters | 8 threads | 1 thread |
117
+ |---|---|---|---|
118
+ | **InDIM-small** | 31.5M | **8 / 12 / 37** | **22 / 40 / 183** |
119
+ | mmBERT-small | 140.5M | 20 / 30 / 99 | 64 / 117 / 494 |
120
+
121
+ The tokenizer also uses fewer tokens for Indic text than mmBERT's (for example 25 against 36 tokens for a mixed
122
+ Hindi / romanized sentence), so real texts are shorter sequences as well.
123
+
124
+ ### Precision
125
+
126
+ - **fp16:** exact. Masked-token predictions agree 99.3% with fp32 (the rest are near-ties) and no value overflows.
127
+ Fine-tuned InDIM-small models give the same labels in fp16 as in fp32.
128
+ - **int8 (dynamic, per-channel):** the encoder's last hidden state keeps a cosine similarity of 0.999 with fp32 in
129
+ PyTorch and 0.998 in ONNX Runtime; mmBERT-small keeps 0.886 / 0.037. Masked-LM loss rises by 0.11 nats.
130
+ For fine-tuned classifiers, int8 changes 3–7% of decisions in our tests, so measure on your task before
131
+ deploying int8.
132
+
133
+ ## Limitations
134
+
135
+ - **32M parameters** is small: on harder tasks (sentiment, abuse detection) larger models such as mmBERT-base or
136
+ IndicBERT v2 score higher. Choose InDIM-small when speed, memory or CPU cost matters.
137
+ - **English** is its weakest language, and transfer from English-only training data to Indian languages is weak.
138
+ Fine-tune on data in the languages you need.
139
+ - Coverage is uneven: Odia and Assamese have less pretraining text than Hindi, Bengali or Tamil; romanized and
140
+ code-mixed text is covered for the main languages, but natural romanized text exists for fewer languages than
141
+ native script.
142
+ - It is a masked-language encoder: it does not generate text, and it does not know facts reliably.
143
+ - Biases in web text can carry over into the model and into models fine-tuned from it.
144
+
145
+ ## Intended use and disclaimer
146
+
147
+ **Intended use:** a base for fine-tuning classifiers, taggers and retrieval models for Indian-language text,
148
+ especially where models must run on CPU or at low cost. **Not intended** for decisions about individual people
149
+ (hiring, credit, moderation penalties, surveillance) without evaluation on your data and a person reviewing each
150
+ case. The model is provided "as is", without warranties of any kind; Cobuild Tech Private Limited is not liable for
151
+ its use. You are responsible for checking that it suits your data and for complying with the laws that apply to your
152
+ use.
153
+
154
+ ## Citation
155
+
156
+ If you use InDIM models, please cite:
157
+
158
+ ```bibtex
159
+ @misc{indim2026,
160
+ title = {InDIM: Compact Encoders for Indian Languages},
161
+ author = {{Sudalai Rajkumar} and {Sairaam Varadarajan}},
162
+ organization = {CobuildX AI},
163
+ year = {2026},
164
+ version = {0.1},
165
+ publisher = {Hugging Face},
166
+ howpublished = {\url{https://huggingface.co/CobuildX-AI/InDIM-small}}
167
+ }
168
+ ```
169
+
170
+ ## Licence
171
+
172
+ Apache-2.0 (see LICENSE). InDIM-small was initialised from [mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small)
173
+ (MIT); see NOTICE.
174
+
175
+ Questions: hello@cobuildx.ai.
checksums.sha256 ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4 LICENSE
2
+ f72171311878ec5c40e6b23a18a9680f228a730eb6bd772f01d25d491dff5e81 NOTICE
3
+ 118d68f0c02068a0b5ef59d9e12c33f761efbe39c810cddac4e537db337aa6da README.md
4
+ da1d166fb50f55573bf7a884fff7cdd051b1d2172f9fe9cdbdeb5d5eb5101788 config.json
5
+ e1bdfb9335bd0c573d9aeb0e120e040787e9a894aa104ba73da2b50f450f54ce configuration_indim.py
6
+ dace8d0723e5de085efce0fb54c335d541ab031cf2d03ceb9feb1c4220cdb224 model.safetensors
7
+ 74a1f678a7072ebea73176c9ad5e6c6581e7772057aa1fcb457ace8c030c40a3 modeling_indim.py
8
+ 56323142e1b64fe3f9acaae5c3521a7d97eb732d863035cd3c7402199f499571 onnx/model.onnx
9
+ c81e7e7ab4605b3f1e3a0f945335c562d55d95487a3d97a06247d68603a52f5f onnx/model_int8.onnx
10
+ 2b6def6747a678e69a68226fa5a1febc79a5f70d8d97186123ab3e99feb355c3 special_tokens_map.json
11
+ 3c574c633a95676b37a4546179bd239d21c9fe7938efadf82194ea19f19bff87 tokenizer.json
12
+ 64254ba8648099296bc576fe5239b7537b3964e630bebd3f48c79f8d378a465c tokenizer_config.json
config.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "InDIMForMaskedLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "auto_map": {
8
+ "AutoConfig": "configuration_indim.InDIMConfig",
9
+ "AutoModel": "modeling_indim.InDIMModel",
10
+ "AutoModelForMaskedLM": "modeling_indim.InDIMForMaskedLM",
11
+ "AutoModelForSequenceClassification": "modeling_indim.InDIMForSequenceClassification",
12
+ "AutoModelForTokenClassification": "modeling_indim.InDIMForTokenClassification"
13
+ },
14
+ "bos_token_id": null,
15
+ "classifier_activation": "gelu",
16
+ "classifier_bias": false,
17
+ "classifier_dropout": 0.0,
18
+ "classifier_pooling": "cls",
19
+ "cls_token_id": 128001,
20
+ "decoder_bias": true,
21
+ "deterministic_flash_attn": false,
22
+ "dtype": "float32",
23
+ "embedding_dropout": 0.0,
24
+ "embedding_rank": 128,
25
+ "eos_token_id": null,
26
+ "hidden_activation": "gelu",
27
+ "hidden_size": 384,
28
+ "initializer_cutoff_factor": 2.0,
29
+ "initializer_range": 0.02,
30
+ "intermediate_size": 576,
31
+ "layer_types": [
32
+ "full_attention",
33
+ "sliding_attention",
34
+ "sliding_attention",
35
+ "full_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "full_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "full_attention",
42
+ "sliding_attention",
43
+ "sliding_attention"
44
+ ],
45
+ "local_attention": 128,
46
+ "mask_token_id": 128003,
47
+ "max_position_embeddings": 8192,
48
+ "mlp_bias": false,
49
+ "mlp_dropout": 0.0,
50
+ "model_type": "indim",
51
+ "norm_bias": false,
52
+ "norm_eps": 1e-05,
53
+ "num_attention_heads": 6,
54
+ "num_hidden_layers": 12,
55
+ "pad_token_id": 128000,
56
+ "rope_parameters": {
57
+ "full_attention": {
58
+ "rope_theta": 160000.0,
59
+ "rope_type": "default"
60
+ },
61
+ "sliding_attention": {
62
+ "rope_theta": 160000.0,
63
+ "rope_type": "default"
64
+ }
65
+ },
66
+ "sep_token_id": 128002,
67
+ "sparse_pred_ignore_index": -100,
68
+ "sparse_prediction": false,
69
+ "tie_word_embeddings": false,
70
+ "transformers_version": "5.22.2",
71
+ "vocab_size": 128064
72
+ }
configuration_indim.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """InDIM configuration: ModernBERT with a factorized (ALBERT-style) word embedding.
2
+
3
+ InDIM-small (32M) keeps a 128,064 x 128 word table and projects it to the 384-wide encoder; the masked-LM output
4
+ layer reuses the same table (tied). Everything else is the ModernBERT encoder as in `transformers`.
5
+ """
6
+ from transformers import ModernBertConfig
7
+
8
+
9
+ class InDIMConfig(ModernBertConfig):
10
+ model_type = "indim"
11
+
12
+ def __init__(self, embedding_rank=128, **kwargs):
13
+ super().__init__(**kwargs)
14
+ self.embedding_rank = embedding_rank
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dace8d0723e5de085efce0fb54c335d541ab031cf2d03ceb9feb1c4220cdb224
3
+ size 127274032
modeling_indim.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """InDIM models (Cobuild Tech): ModernBERT encoder + factorized word embedding.
2
+
3
+ from transformers import AutoTokenizer, AutoModel, AutoModelForMaskedLM
4
+ tok = AutoTokenizer.from_pretrained("CobuildX-AI/InDIM-small")
5
+ model = AutoModel.from_pretrained("CobuildX-AI/InDIM-small", trust_remote_code=True)
6
+
7
+ Classes: InDIMModel (encoder), InDIMForMaskedLM, InDIMForSequenceClassification, InDIMForTokenClassification.
8
+ The task heads are the stock ModernBERT heads (`classifier_pooling` "cls" or "mean"); only the word embedding differs.
9
+ """
10
+ import torch
11
+ import torch.nn as nn
12
+ import torch.nn.functional as F
13
+ from transformers.modeling_outputs import MaskedLMOutput
14
+ from transformers.models.modernbert.modeling_modernbert import (
15
+ ModernBertForSequenceClassification,
16
+ ModernBertForTokenClassification,
17
+ ModernBertModel,
18
+ ModernBertPredictionHead,
19
+ ModernBertPreTrainedModel,
20
+ )
21
+
22
+ try:
23
+ from .configuration_indim import InDIMConfig
24
+ except ImportError: # loaded as a plain module (local checks)
25
+ from configuration_indim import InDIMConfig
26
+
27
+
28
+ class FactorizedEmbedding(nn.Module):
29
+ """ids -> table[V x r] -> up[r -> hidden]. `weight` is the table (also the masked-LM output layer)."""
30
+
31
+ def __init__(self, vocab_size, rank, hidden_size):
32
+ super().__init__()
33
+ self.weight = nn.Parameter(torch.empty(vocab_size, rank))
34
+ self.up = nn.Linear(rank, hidden_size, bias=False)
35
+
36
+ def forward(self, input_ids):
37
+ return self.up(F.embedding(input_ids, self.weight))
38
+
39
+
40
+ def _factorize(model, config):
41
+ model.embeddings.tok_embeddings = FactorizedEmbedding(config.vocab_size, config.embedding_rank, config.hidden_size)
42
+ std = config.initializer_range
43
+ nn.init.trunc_normal_(model.embeddings.tok_embeddings.weight, std=std, a=-3 * std, b=3 * std)
44
+ nn.init.trunc_normal_(model.embeddings.tok_embeddings.up.weight, std=std, a=-3 * std, b=3 * std)
45
+
46
+
47
+ class InDIMModel(ModernBertModel):
48
+ config_class = InDIMConfig
49
+
50
+ def __init__(self, config):
51
+ super().__init__(config)
52
+ _factorize(self, config)
53
+
54
+
55
+ class InDIMForMaskedLM(ModernBertPreTrainedModel):
56
+ config_class = InDIMConfig
57
+
58
+ def __init__(self, config):
59
+ super().__init__(config)
60
+ self.model = InDIMModel(config)
61
+ self.head = ModernBertPredictionHead(config)
62
+ self.down = nn.Linear(config.hidden_size, config.embedding_rank, bias=False)
63
+ self.decoder_bias = nn.Parameter(torch.zeros(config.vocab_size))
64
+ self.post_init()
65
+
66
+ def get_output_embeddings(self):
67
+ return None # tied to the factorized table inside forward
68
+
69
+ def forward(self, input_ids=None, attention_mask=None, labels=None, **kwargs):
70
+ h = self.model(input_ids=input_ids, attention_mask=attention_mask, **kwargs).last_hidden_state
71
+ logits = F.linear(self.down(self.head(h)), self.model.embeddings.tok_embeddings.weight, self.decoder_bias)
72
+ loss = None
73
+ if labels is not None:
74
+ loss = F.cross_entropy(logits.view(-1, logits.size(-1)).float(), labels.view(-1), ignore_index=-100)
75
+ return MaskedLMOutput(loss=loss, logits=logits)
76
+
77
+
78
+ class InDIMForSequenceClassification(ModernBertForSequenceClassification):
79
+ config_class = InDIMConfig
80
+
81
+ def __init__(self, config):
82
+ super().__init__(config)
83
+ _factorize(self.model, config)
84
+
85
+
86
+ class InDIMForTokenClassification(ModernBertForTokenClassification):
87
+ config_class = InDIMConfig
88
+
89
+ def __init__(self, config):
90
+ super().__init__(config)
91
+ _factorize(self.model, config)
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56323142e1b64fe3f9acaae5c3521a7d97eb732d863035cd3c7402199f499571
3
+ size 127326930
onnx/model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c81e7e7ab4605b3f1e3a0f945335c562d55d95487a3d97a06247d68603a52f5f
3
+ size 33004916
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "unk_token": "<unk>",
3
+ "pad_token": "[PAD]",
4
+ "cls_token": "[CLS]",
5
+ "sep_token": "[SEP]",
6
+ "mask_token": "[MASK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "tokenizer_class": "PreTrainedTokenizerFast",
3
+ "unk_token": "<unk>",
4
+ "pad_token": "[PAD]",
5
+ "cls_token": "[CLS]",
6
+ "sep_token": "[SEP]",
7
+ "mask_token": "[MASK]",
8
+ "model_max_length": 8192,
9
+ "clean_up_tokenization_spaces": false
10
+ }