File size: 5,869 Bytes
874985c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f47342
 
874985c
 
 
 
 
8f47342
 
874985c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f47342
 
874985c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
library_name: pytorch
tags:
- hungarian
- transformer
- encoder
- tokenization-free
- character-based
- glass-box
license: cc-by-sa-4.0
datasets:
- webkorpusz-2.0
metrics:
- pos-accuracy
- word-reconstruction
---

# 🧠 HuBrain: Tokenization-free Hungarian Semantic Encoder / Tokenizáció-mentes magyar szemantikai encoder

[English Version](#english) | [Magyar Változat](#magyar)

🔗 **GitHub Repository:** [https://github.com/BraienStorm/hubrain-encoder](https://github.com/BraienStorm/hubrain-encoder)

---

<a name="english"></a>
## 🌍 English Description

🔗 **Source Code (GitHub):** [https://github.com/BraienStorm/hubrain-encoder](https://github.com/BraienStorm/hubrain-encoder)

HuBrain is an experimental, character-based **Glass-Box Semantic Encoder** designed to model the morphological richness and semantic relationships of the Hungarian language without traditional tokenization (e.g., BPE).

### 🚀 Live Visualization
View the 1280-dimensional semantic latent space projection (PCA/T-SNE) here:
👉 **[HuBrain Projector Visualization](https://projector.tensorflow.org/?config=https://jevcsak.hu/model/hubrain.json)**

![Latent Space Projection](latens_space.png)

### 📈 Training Progress (latest logs)
The model is currently in **Phase 2 (Joint Training)**. Recent logs show high stability and emergent factual knowledge:
- **POS Accuracy (Pm):** ~91.5% - 97.1%
- **Word Reconstruction (Wm):** ~30% - 74% (Emerging)
- **Latent Stability (Mag):** ~100 (Balanced vector magnitude)
- **Learning Rate:** 2.4e-05

### 🛠️ Technical Specifications
- **Architecture:** Transformer Encoder with RoPE support.
- **Dimensions:** 1536 (256 Anchors + 1280 Semantic Context).
- **Layers:** 18 Layers, 24 Heads.
- **Input:** Raw characters (64-char fixed word length).
- **Vocab:** No OOV issues (Character-level coverage).

### 📥 Model Download
The weighted model files (`.pth`) are stored on Hugging Face due to their large size (6.7 GB). You can download them using the following command:

```bash
# Required: pip install huggingface_hub
python download_model.py
```
Or manually from: [https://huggingface.co/Braien/HuBrain-Encoder](https://huggingface.co/Braien/HuBrain-Encoder)

### ⚙️ Requirements
```bash
pip install torch numpy huggingface_hub
```

### 🧪 Diagnostic Tools
- **`test_mask_prediction.py`**: Context-based word recovery.
- **`test_analogy.py`**: Semantic analogies (e.g. King-Man+Woman).
- **`export_projector.py`**: Export to TF Projector format.

### ⚖️ Licensing & Data Sources
This model was trained using the **Webkorpusz 2.0** dataset. By using this model, you agree to comply with the following licenses:
- **Common Crawl subcorpus**: Used under the same terms as [Common Crawl](https://commoncrawl.org/terms-of-use/) itself.
- **Wikipedia subcorpus & processed data**: Licensed under **Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)**.
- **Disclaimer**: The training data originates from automated web crawling; the model creator assumes no responsibility for the content.

---

<a name="magyar"></a>
## 🇭🇺 Magyar leírás

🔗 **Forráskód (GitHub):** [https://github.com/BraienStorm/hubrain-encoder](https://github.com/BraienStorm/hubrain-encoder)

A HuBrain egy kísérleti, karakter-alapú **Glass-Box Szemantikai Encoder**, amely a magyar nyelv morfológiai gazdagságát és szemantikai összefüggéseit modellezi hagyományos tokenizáció (pl. BPE) használata nélkül.

### 🚀 Élő Vizualizáció
A modell látens terének 1280 dimenziós szemantikai leképzése megtekinthető itt:
👉 **[HuBrain Projector Visualization](https://projector.tensorflow.org/?config=https://jevcsak.hu/model/hubrain.json)**

![Látens tér projekció](latens_space.png)

### 📈 Tréning Állapot (utolsó logok)
A modell jelenleg a **Phase 2 (Joint Training)** fázisban van. Az utolsó logok stabil tanulást és kialakuló tudást mutatnak:
- **POS Pontosság (Pm):** ~91.5% - 97.1%
- **Szó Rekonstrukció (Wm):** ~30% - 74% (Folyamatosan javul)
- **Látens Stabilitás (Mag):** ~100 (Kiegyensúlyozott vektor magnitúdó)
- **Tanulási ráta:** 2.4e-05

### 🛠️ Technikai adatok
- **Architektúra:** Transformer Encoder RoPE támogatással.
- **Dimenziók:** 1536 (256 Horgony + 1280 Szemantikai kontextus).
- **Rétegszám:** 18 réteg, 24 fej.
- **Bemenet:** Nyers karakterek (64 karakteres fix szóhossz).
- **Vocab:** Nincs OOV (szótáron kívüli szó) probléma a karakter-szintű lefedettség miatt.

### 📥 Modell letöltése
A nagyméretű modellfájlok (`.pth`, összesen 6.7 GB) a Hugging Face-en tárolódnak. Az alábbi parancs futtatásával töltheted le őket:

```bash
# Szükséges: pip install huggingface_hub
python download_model.py
```
Vagy manuálisan innen: [https://huggingface.co/Braien/HuBrain-Encoder](https://huggingface.co/Braien/HuBrain-Encoder)

### ⚙️ Követelmények
```bash
pip install torch numpy huggingface_hub
```

### 🧪 Diagnosztikai eszközök
- **`test_mask_prediction.py`**: Környezet alapú szó-visszafejtés.
- **`test_analogy.py`**: Szemantikai analógiák (pl. király - férfi + nő).
- **`export_projector.py`**: Exportálás TF Projector vizualizációhoz.

### ⚖️ Licenc és Adatforrások
A modell tanításához a **Webkorpusz 2.0** adatbázist használtuk fel. A modell használatával Ön elfogadja az alábbi licencfeltételeket:
- **Common Crawl alkorpusz**: A [Common Crawl](https://commoncrawl.org/terms-of-use/) saját felhasználási feltételei szerint került felhasználásra.
- **Wikipedia alkorpusz és feldolgozott adatok**: A **Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)** licenc alá tartoznak.
- **Felelősségkizárás**: Az adatok automatizált webes gyűjtésből származnak, a tartalmukért a modell készítője nem vállal felelősséget.