sovythos commited on
Commit
4acd7cb
·
verified ·
1 Parent(s): 1de1c4e

Upload 7 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ sovythos.png filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,236 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - en
5
+ - ar
6
+ tags:
7
+ - sovereign
8
+ - sovythos
9
+ - llm
10
+ - transformer
11
+ - pytorch
12
+ - arabic
13
+ - english
14
+ - code
15
+ - open-source
16
+ pipeline_tag: text-generation
17
  ---
18
+
19
+ <p align="center">
20
+ <img src="https://huggingface.co/buckets/my0919175/Sovythos-66M-Base/resolve/sovythos.png?download=true" width="320" alt="SOVYTHOS">
21
+ </p>
22
+
23
+ <h1 align="center">🦋 SOVYTHOS-66M-Base</h1>
24
+
25
+ <p align="center">
26
+ <b>The first open-source pretrained language model developed completely from scratch under the Sovereign AI Project.</b>
27
+ </p>
28
+
29
+ <p align="center">
30
+
31
+ ![Open Source](https://img.shields.io/badge/Open%20Source-Yes-success)
32
+ ![Parameters](https://img.shields.io/badge/Parameters-66.7M-blue)
33
+ ![Languages](https://img.shields.io/badge/Languages-Arabic%20%7C%20English-orange)
34
+ ![Framework](https://img.shields.io/badge/PyTorch-2.x-red)
35
+ ![Status](https://img.shields.io/badge/Status-Base%20Release-brightgreen)
36
+
37
+ </p>
38
+
39
+ ---
40
+
41
+ # 🦋 Overview
42
+
43
+ **SOVYTHOS-66M-Base** is a decoder-only Transformer language model trained **entirely from scratch** as part of the **Sovereign AI Project**.
44
+
45
+ Unlike models that continue training from existing checkpoints, SOVYTHOS begins from randomly initialized weights and learns language directly from its training corpus.
46
+
47
+ This repository contains the **Base (Pretrained)** release intended for:
48
+
49
+ - Continued Pretraining
50
+ - Fine-tuning
51
+ - Instruction Tuning
52
+ - Research
53
+ - Educational Purposes
54
+ - Building downstream AI applications
55
+
56
+ > **This model is NOT instruction tuned and is not intended to behave like a production chatbot.**
57
+
58
+ ---
59
+
60
+ # 🚀 Experience the Sovereign Platform
61
+
62
+ SOVYTHOS is the foundation of the **Sovereign AI Platform**.
63
+
64
+ If you'd like to experience the latest AI capabilities through a complete interface, you can try the live platform below.
65
+
66
+ ## 🌐 Live Demo
67
+
68
+ **https://awaken-creation-guidance.ngrok-free.dev/**
69
+
70
+ ### Available Features
71
+
72
+ - 💬 Modern AI Chat Interface
73
+ - ⚡ Flash AI Models
74
+ - 🧠 Advanced Reasoning Models
75
+ - 💻 Coding Assistant
76
+ - 🌍 Arabic & English Support
77
+ - 🔥 Continuous Platform Updates
78
+
79
+ > **Note:** The Sovereign platform may use newer models, APIs, and experimental capabilities beyond this Base release.
80
+
81
+ ---
82
+
83
+ # 📊 Model Specifications
84
+
85
+ | Property | Value |
86
+ |----------|--------|
87
+ | Model | SOVYTHOS-66M-Base |
88
+ | Parameters | ~66.7 Million |
89
+ | Architecture | Decoder-only Transformer |
90
+ | Hidden Size | 512 |
91
+ | Layers | 12 |
92
+ | Attention Heads | 16 |
93
+ | Framework | PyTorch |
94
+ | Tokenizer | Custom |
95
+ | Context Length | Configured during training |
96
+ | Training | From Scratch |
97
+ | Release | Base |
98
+
99
+ ---
100
+
101
+ # 🌍 Languages
102
+
103
+ SOVYTHOS has been trained on multilingual data including:
104
+
105
+ - 🇪🇬 Arabic
106
+ - 🇪🇬 Egyptian Arabic
107
+ - 🇺🇸 English
108
+ - Programming Languages
109
+ - Technical Documentation
110
+ - Mathematical Content
111
+ - General Web Text
112
+
113
+ ---
114
+
115
+ # 🎯 Intended Uses
116
+
117
+ This release is designed for:
118
+
119
+ - Research
120
+ - Fine-tuning
121
+ - Continued Pretraining
122
+ - Instruction Tuning
123
+ - Educational Experiments
124
+ - Language Model Development
125
+ - Custom AI Applications
126
+
127
+ ---
128
+
129
+ # ⚠️ Current Limitations
130
+
131
+ This repository contains the **Base Language Model** only.
132
+
133
+ It has **NOT** been instruction tuned.
134
+
135
+ Current limitations include:
136
+
137
+ - Hallucination of factual information
138
+ - Incorrect reasoning in some cases
139
+ - Repetition
140
+ - Incomplete generations
141
+ - Limited instruction following
142
+
143
+ These limitations are expected for a pretrained base model and will be addressed in future releases.
144
+
145
+ ---
146
+
147
+ # 💻 Example
148
+
149
+ ```python
150
+ prompt = "The capital of Egypt is"
151
+
152
+ output = model.generate(prompt)
153
+ ```
154
+
155
+ ---
156
+
157
+ # 🏗️ Training
158
+
159
+ SOVYTHOS was trained completely from scratch using:
160
+
161
+ - Custom Tokenizer
162
+ - PyTorch
163
+ - CUDA
164
+ - Mixed Precision Training
165
+ - Automatic Best Checkpoint Saving
166
+
167
+ **No pretrained language model weights were used.**
168
+
169
+ ---
170
+
171
+ # 🛣️ Roadmap
172
+
173
+ ✅ SOVYTHOS-66M-Base
174
+
175
+ 🟡 SOVYTHOS-66M-Instruct *(In Development)*
176
+
177
+ ⬜ SOVYTHOS Chat
178
+
179
+ ⬜ Larger Parameter Models
180
+
181
+ ⬜ Advanced Reasoning
182
+
183
+ ⬜ Improved Coding
184
+
185
+ ⬜ Better Arabic Understanding
186
+
187
+ ⬜ Long Context Support
188
+
189
+ ---
190
+
191
+ # 🌌 Sovereign Project
192
+
193
+ SOVYTHOS is the first public language model released under the **Sovereign AI Project**.
194
+
195
+ The long-term vision of Sovereign is to build an open ecosystem of multilingual language models with strong Arabic support, modern reasoning capabilities, and accessible open-source AI technologies.
196
+
197
+ ---
198
+
199
+ # 📖 Citation
200
+
201
+ ```bibtex
202
+ @misc{sovythos66m,
203
+ title={SOVYTHOS-66M-Base},
204
+ author={Mahmoud Yasser},
205
+ year={2026},
206
+ publisher={Hugging Face},
207
+ }
208
+ ```
209
+
210
+ ---
211
+
212
+ # 👨‍💻 Creator
213
+
214
+ **Mahmoud Yasser**
215
+
216
+ Founder of the **Sovereign AI Project**
217
+
218
+ ---
219
+
220
+ # 📄 License
221
+
222
+ **Apache License 2.0**
223
+
224
+ ---
225
+
226
+ <p align="center">
227
+
228
+ ### 🦋 Welcome to the beginning of the Sovereign ecosystem.
229
+
230
+ The current release represents the first public pretrained foundation model.
231
+
232
+ Future releases will introduce instruction tuning, stronger reasoning, improved coding capabilities, and more advanced multilingual intelligence.
233
+
234
+ ⭐ If you find this project interesting, consider following the repository and trying the Sovereign AI Platform.
235
+
236
+ </p>
config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SovythosModel"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_sovythos.SovythosConfig",
7
+ "AutoModelForCausalLM": "modeling_sovythos.SovythosModel"
8
+ },
9
+ "vocab_size": 32000,
10
+ "dim": 512,
11
+ "heads": 16,
12
+ "layers": 12,
13
+ "block_size": 512,
14
+ "model_type": "sovythos"
15
+ }
configuration_sovythos.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PretrainedConfig
2
+
3
+ class SovythosConfig(PretrainedConfig):
4
+ model_type = "sovythos"
5
+
6
+ def __init__(
7
+ self,
8
+ vocab_size=32000,
9
+ dim=512,
10
+ heads=16,
11
+ layers=12,
12
+ block_size=512,
13
+ **kwargs
14
+ ):
15
+ super().__init__(**kwargs)
16
+ self.vocab_size = vocab_size
17
+ self.dim = dim
18
+ self.heads = heads
19
+ self.layers = layers
20
+ self.block_size = block_size
modeling_sovythos.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import torch.nn as nn
3
+ import torch.nn.functional as F
4
+ from transformers import PreTrainedModel, GenerationMixin
5
+ from transformers.modeling_outputs import CausalLMOutput
6
+ from .configuration_sovythos import SovythosConfig
7
+
8
+ class RMSNorm(nn.Module):
9
+ def __init__(self, dim, eps=1e-6):
10
+ super().__init__()
11
+ self.w = nn.Parameter(torch.ones(dim))
12
+ self.eps = eps
13
+
14
+ def forward(self, x):
15
+ rms = x.pow(2).mean(-1, keepdim=True)
16
+ return self.w * x * torch.rsqrt(rms + self.eps)
17
+
18
+ class RoPE(nn.Module):
19
+ def __init__(self, head_dim):
20
+ super().__init__()
21
+ inv_freq = 1.0 / (10000 ** (torch.arange(0, head_dim, 2).float() / head_dim))
22
+ self.register_buffer("inv_freq", inv_freq, persistent=False)
23
+ self._cos_cache = None
24
+ self._sin_cache = None
25
+
26
+ def _build_cache(self, seq_len, device):
27
+ if self._cos_cache is not None and self._cos_cache.shape[0] >= seq_len:
28
+ return
29
+ t = torch.arange(seq_len, device=device).type_as(self.inv_freq)
30
+ freqs = torch.einsum("i,j->ij", t, self.inv_freq)
31
+ emb = torch.cat((freqs, freqs), dim=-1)
32
+ self._cos_cache = emb.cos()
33
+ self._sin_cache = emb.sin()
34
+
35
+ def forward(self, x, seq_len):
36
+ self._build_cache(seq_len, x.device)
37
+ cos = self._cos_cache[:seq_len][None, None, :, :]
38
+ sin = self._sin_cache[:seq_len][None, None, :, :]
39
+ x1, x2 = x[..., :x.shape[-1]//2], x[..., x.shape[-1]//2:]
40
+ return (x * cos) + (torch.cat((-x2, x1), dim=-1) * sin)
41
+
42
+ class TitanAttention(nn.Module):
43
+ def __init__(self, dim, heads):
44
+ super().__init__()
45
+ self.heads = heads
46
+ self.head_dim = dim // heads
47
+ self.q_proj = nn.Linear(dim, dim, bias=False)
48
+ self.k_proj = nn.Linear(dim, dim, bias=False)
49
+ self.v_proj = nn.Linear(dim, dim, bias=False)
50
+ self.o_proj = nn.Linear(dim, dim, bias=False)
51
+ self.q_norm = RMSNorm(self.head_dim)
52
+ self.k_norm = RMSNorm(self.head_dim)
53
+ self.rope = RoPE(self.head_dim)
54
+
55
+ def forward(self, x, is_causal=True):
56
+ B, T, C = x.shape
57
+ q = self.q_proj(x).view(B, T, self.heads, self.head_dim).transpose(1, 2)
58
+ k = self.k_proj(x).view(B, T, self.heads, self.head_dim).transpose(1, 2)
59
+ v = self.v_proj(x).view(B, T, self.heads, self.head_dim).transpose(1, 2)
60
+
61
+ q = self.rope(self.q_norm(q), T)
62
+ k = self.rope(self.k_norm(k), T)
63
+
64
+ out = F.scaled_dot_product_attention(q, k, v, attn_mask=None, is_causal=is_causal)
65
+ out = out.transpose(1, 2).contiguous().view(B, T, C)
66
+ return self.o_proj(out)
67
+
68
+ class Block(nn.Module):
69
+ def __init__(self, dim, heads):
70
+ super().__init__()
71
+ self.n1 = RMSNorm(dim)
72
+ self.attn = TitanAttention(dim, heads)
73
+ self.n2 = RMSNorm(dim)
74
+ self.w1 = nn.Linear(dim, 4 * dim, bias=False)
75
+ self.w2 = nn.Linear(dim, 4 * dim, bias=False)
76
+ self.w3 = nn.Linear(4 * dim, dim, bias=False)
77
+
78
+ def forward(self, x):
79
+ x = x + self.attn(self.n1(x))
80
+ h = self.n2(x)
81
+ x = x + self.w3(F.silu(self.w1(h)) * self.w2(h))
82
+ return x
83
+
84
+ class SovythosModel(PreTrainedModel, GenerationMixin):
85
+ config_class = SovythosConfig
86
+
87
+ def __init__(self, config):
88
+ # حل مشكلة num_hidden_layers بربطها ديناميكياً بالمتغير الحالي
89
+ if not hasattr(config, "num_hidden_layers"):
90
+ config.num_hidden_layers = getattr(config, "layers", 12)
91
+
92
+ super().__init__(config)
93
+ self.emb = nn.Embedding(config.vocab_size, config.dim)
94
+ self.blocks = nn.ModuleList([Block(config.dim, config.heads) for _ in range(config.layers)])
95
+ self.norm = RMSNorm(config.dim)
96
+ self.fc = nn.Linear(config.dim, config.vocab_size, bias=False)
97
+
98
+ self.fc.weight = self.emb.weight
99
+ self.post_init()
100
+
101
+ def get_input_embeddings(self):
102
+ return self.emb
103
+
104
+ def set_input_embeddings(self, value):
105
+ self.emb = value
106
+
107
+ def get_output_embeddings(self):
108
+ return self.fc
109
+
110
+ def set_output_embeddings(self, new_embeddings):
111
+ self.fc = new_embeddings
112
+
113
+ def forward(self, input_ids, attention_mask=None, labels=None, **kwargs):
114
+ x = self.emb(input_ids)
115
+ for blk in self.blocks:
116
+ x = blk(x)
117
+ x = self.norm(x)
118
+ logits = self.fc(x)
119
+
120
+ loss = None
121
+ if labels is not None:
122
+ loss_fn = nn.CrossEntropyLoss()
123
+ loss = loss_fn(logits.view(-1, self.config.vocab_size), labels.view(-1))
124
+
125
+ return CausalLMOutput(loss=loss, logits=logits)
126
+
127
+ def prepare_inputs_for_generation(self, input_ids, attention_mask=None, **kwargs):
128
+ return {
129
+ "input_ids": input_ids,
130
+ "attention_mask": attention_mask
131
+ }
sovythos.png ADDED

Git LFS Details

  • SHA256: 098d3da848727fedc163f275afef2f8f730e6deaa85bf6bff8494b256e0f494e
  • Pointer size: 132 Bytes
  • Size of remote file: 1.58 MB
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "<|endoftext|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "1": {
12
+ "content": "<|pad|>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "2": {
20
+ "content": "<|user|>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "3": {
28
+ "content": "<|assistant|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "4": {
36
+ "content": "<|system|>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "5": {
44
+ "content": "<|code|>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ }
51
+ },
52
+ "bos_token": "<|endoftext|>",
53
+ "clean_up_tokenization_spaces": false,
54
+ "eos_token": "<|endoftext|>",
55
+ "pad_token": "<|pad|>",
56
+ "model_max_length": 512,
57
+ "tokenizer_class": "PreTrainedTokenizerFast",
58
+ "chat_template": "{% for message in messages %}{{'<|' + message['role'] + '|>\n' + message['content'] + '<|endoftext|>\n'}}{% endfor %}{% if add_generation_prompt %}{{'<|assistant|>\n'}}{% endif %}"
59
+ }