emrd95 commited on
Commit
0a81147
·
verified ·
1 Parent(s): a627c88

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +217 -0
README.md ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - af
4
+ - am
5
+ - ar
6
+ - hy
7
+ - az
8
+ - bn
9
+ - ba
10
+ - be
11
+ - bs
12
+ - bg
13
+ - ca
14
+ - zh
15
+ - hr
16
+ - cs
17
+ - da
18
+ - nl
19
+ - en
20
+ - eo
21
+ - et
22
+ - eu
23
+ - fil
24
+ - fi
25
+ - fr
26
+ - fur
27
+ - gl
28
+ - ka
29
+ - de
30
+ - el
31
+ - gu
32
+ - ha
33
+ - haw
34
+ - he
35
+ - hi
36
+ - hu
37
+ - is
38
+ - id
39
+ - ga
40
+ - it
41
+ - ja
42
+ - kn
43
+ - kk
44
+ - km
45
+ - ko
46
+ - ky
47
+ - lo
48
+ - la
49
+ - lv
50
+ - lt
51
+ - mk
52
+ - mg
53
+ - ms
54
+ - ml
55
+ - mt
56
+ - mr
57
+ - mn
58
+ - my
59
+ - ne
60
+ - nn
61
+ - oc
62
+ - om
63
+ - ps
64
+ - fa
65
+ - pl
66
+ - pt
67
+ - ro
68
+ - ru
69
+ - sa
70
+ - sat
71
+ - sr
72
+ - sn
73
+ - si
74
+ - sk
75
+ - sl
76
+ - es
77
+ - sw
78
+ - sv
79
+ - gsw
80
+ - ta
81
+ - tt
82
+ - te
83
+ - th
84
+ - bo
85
+ - tr
86
+ - udm
87
+ - uk
88
+ - ur
89
+ - uz
90
+ - vi
91
+ - cy
92
+ - xh
93
+ - yi
94
+ - yo
95
+ - zu
96
+ tags:
97
+ - keyboardrage
98
+ - semantic-search
99
+ - embeddings
100
+ - typing-game
101
+ - multilingual
102
+ - faiss
103
+ - granite-embedding
104
+ license: mit
105
+ datasets:
106
+ - wiktionary
107
+ - monkeytype
108
+ ---
109
+
110
+ # KeyboardRage Semantic Models
111
+
112
+ Precomputed multilingual semantic embeddings and neighbor indices for the [KeyboardRage](https://github.com/EMRD95/keyboardrage) typing game's Galaxy visualization.
113
+
114
+ ## Overview
115
+
116
+ This repository contains the trained semantic models that power the 3D semantic word galaxy in KeyboardRage. 2,250,636 words across 108 languages are embedded into a 384-dimensional space using IBM's Granite multilingual embedding model, then projected to 3D via UMAP. Precomputed nearest-neighbor indices enable real-time similarity queries.
117
+
118
+ ## Contents
119
+
120
+ ### Global embeddings & index (15 GB)
121
+ | File | Size | Description |
122
+ |------|------|-------------|
123
+ | `semantic_embeddings.f32.npy` | 3.3 GB | Float32 embeddings for all 2.25M words (384-dim, inner-product normalized) |
124
+ | `semantic_faiss_hnsw.index` | 3.3 GB | FAISS flat inner-product index (exact cosine similarity over normalized vectors) |
125
+ | `neighbor_ids.npy` | 1.7 GB | Precomputed global top-200 neighbor IDs (rows × 200, int64) |
126
+ | `neighbor_scores.npy` | 1.7 GB | Precomputed global top-200 cosine similarity scores (float32) |
127
+ | `semantic_index_meta.json` | ~1 KB | Model metadata (embedding model, dimensions, row count) |
128
+
129
+ ### Per-language neighbor indices
130
+ 108 languages, each with 4 files:
131
+ - `neighbor_ids_{lang}.npy` — precomputed within-language top-200 neighbor IDs
132
+ - `neighbor_scores_{lang}.npy` — cosine similarity scores
133
+ - `lang_index_{lang}.npy` — global-ID → local-ID mapping
134
+ - `neighbor_meta_{lang}.json` — per-language statistics
135
+
136
+ ### 3D projection metadata
137
+ | File | Size | Description |
138
+ |------|------|-------------|
139
+ | `atlas_data.parquet` | 88 MB | Word metadata: 3D UMAP coordinates (x, y, z), word, language, definition |
140
+
141
+ ### Raw word embeddings (834 MB)
142
+ `words_emb_merged/{lang}.json` — raw embedding vectors per language, used for regeneration workflows.
143
+
144
+ ## Model Details
145
+
146
+ - **Embedding model**: [ibm-granite/granite-embedding-97m-multilingual-r2](https://huggingface.co/ibm-granite/granite-embedding-97m-multilingual-r2)
147
+ - **Embedding dimension**: 384
148
+ - **Total words embedded**: 2,250,636
149
+ - **Languages**: 108
150
+ - **Similarity metric**: Cosine similarity via normalized inner product
151
+ - **3D projection**: UMAP (n_components=3, metric='cosine')
152
+ - **Neighbor count**: Top 200 per word (global + per-language)
153
+
154
+ ## 108 Supported Languages
155
+
156
+ afrikaans, albanian, amharic, arabic (+egypt, +morocco), armenian (+western), azerbaijani, bangla, bashkir, belarusian (+lacinka), bosnian, bulgarian, catalan, chinese_simplified, chinese_traditional, croatian, czech, danish, dutch, english, esperanto (+h_sistemo, +x_sistemo), estonian, euskera, filipino, finnish, french, friulian, galician, georgian, german, greek, gujarati, hausa, hawaiian, hebrew, hindi, hungarian, icelandic, indonesian, irish, italian, japanese (hiragana, katakana, romaji), kannada, kazakh, khmer, korean, kyrgyz, lao, latin, latvian, lithuanian, macedonian, malagasy, malay, malayalam, maltese, marathi, mongolian, myanmar, nepali, norwegian_nynorsk, occitan, oromo, pashto, persian, polish, portuguese (+acentos_e_cedilha), romanian, russian, sanskrit, santali, serbian (+latin), shona, sinhala, slovak, slovenian, spanish, swahili, swedish, swiss_german, tamil, tatar (+crimean, +crimean_cyrillic), telugu, thai, tibetan, turkish, udmurt, ukrainian (+latynka), urdu, uzbek, vietnamese, welsh, xhosa, yiddish, yoruba, zulu
157
+
158
+ ## On-Premise Deployment
159
+
160
+ ### Prerequisites
161
+ - Python 3.10+
162
+ - FastAPI, NumPy, DuckDB, PyArrow
163
+
164
+ ### Quick start
165
+
166
+ ```bash
167
+ # 1. Clone the game code
168
+ git clone https://github.com/EMRD95/keyboardrage
169
+ cd keyboardrage
170
+
171
+ # 2. Download models from HuggingFace
172
+ ./setup.sh
173
+
174
+ # 3. Run the semantic neighbors API
175
+ cd galaxy/semantic
176
+ pip install fastapi uvicorn numpy duckdb pyarrow
177
+ python semantic_neighbors_server.py
178
+ # API available at http://localhost:8703
179
+ ```
180
+
181
+ ### API Endpoints
182
+
183
+ | Endpoint | Description |
184
+ |----------|-------------|
185
+ | `GET /health` | Server status, available languages, row count |
186
+ | `GET /point/{id}` | Get word metadata by global ID |
187
+ | `GET /neighbors/{id}?k=10&language=french` | Get nearest neighbors (global or per-language) |
188
+ | `GET /search?q=mot&language=french` | Full-text word search |
189
+
190
+ ## Source Code
191
+
192
+ The KeyboardRage game source code and visualization themes are at:
193
+ **[github.com/EMRD95/keyboardrage](https://github.com/EMRD95/keyboardrage)**
194
+
195
+ ## Regeneration
196
+
197
+ To rebuild these models from scratch:
198
+
199
+ ```bash
200
+ # 1. Rebuild embeddings from merged word lists
201
+ cd galaxy && ./rebuild_from_merged_words.sh
202
+
203
+ # 2. Rebuild semantic index
204
+ cd semantic && python build_semantic_index.py
205
+
206
+ # 3. Precompute neighbors
207
+ python precompute_neighbors.py --per-language
208
+
209
+ # 4. Rebuild 3D projection
210
+ cd ../3D_galaxy && ./run_umap50_projection_rebuild.sh
211
+ ```
212
+
213
+ All rebuild scripts are in the [GitHub repository](https://github.com/EMRD95/keyboardrage/tree/develop/galaxy).
214
+
215
+ ## License
216
+
217
+ MIT — same as KeyboardRage.