SonicPerformance 1.0__py3-none-any.whl

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.
sonic/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .sonic import *
sonic/sonic.py ADDED
@@ -0,0 +1,88 @@
1
+ import os
2
+ import numpy
3
+ import re
4
+
5
+
6
+ def OpenFile(file):
7
+ path = os.path.join(os.path.dirname(__file__), file)
8
+
9
+ with open(path, "r", encoding="utf-8") as f:
10
+ return f.read()
11
+
12
+
13
+ def Parameters(tdim, words):
14
+ print(f"True Dimensions: {tdim}")
15
+ print(f"Vocab: {len(words)}")
16
+
17
+
18
+ def Tokenize(text, by=None):
19
+ return text.split(by)
20
+
21
+
22
+ def Probs(words):
23
+ probs = {}
24
+
25
+ for word in words:
26
+ probs[word] = probs.get(word, 0) + 1
27
+
28
+ return probs
29
+
30
+
31
+ class Model:
32
+ def __init__(self, dim, batch, ddiv=32, mdiv=32):
33
+ self.dim = dim
34
+ self.batch = batch
35
+ self.ddiv = ddiv
36
+ self.mdiv = mdiv
37
+
38
+ self.InitModel()
39
+
40
+ def InitModel(self):
41
+ if self.batch == self.dim or self.batch == self.mdiv:
42
+ raise ValueError("Model size invalid")
43
+
44
+ self.mdiv = int(self.mdiv * self.dim / self.batch)
45
+
46
+ self.tdiv = self.ddiv * self.mdiv
47
+ self.tdim = round(self.dim / self.ddiv)
48
+
49
+ def Generate(self, words, input):
50
+ output = []
51
+ next_word = input
52
+
53
+ for _ in range(self.mdiv + 1):
54
+ pos_probs = {}
55
+
56
+ for position, word in enumerate(words[:-1]):
57
+ if word == next_word:
58
+ following = words[position + 1]
59
+ pos_probs[following] = pos_probs.get(following, 0) + 1
60
+
61
+ if not pos_probs:
62
+ break
63
+
64
+ keys = list(pos_probs.keys())
65
+
66
+ p = numpy.array(
67
+ list(pos_probs.values()),
68
+ dtype=numpy.float64
69
+ )
70
+
71
+ p = p ** (self.tdim / 32)
72
+ p /= p.sum()
73
+
74
+ next_word = str(
75
+ numpy.random.choice(keys, p=p)
76
+ )
77
+
78
+ output.append(next_word)
79
+
80
+ output_string = " ".join(output)
81
+
82
+ output_string = re.sub(
83
+ r"User:|Assistant:|[\[\]\'\",]",
84
+ "",
85
+ output_string
86
+ )
87
+
88
+ return re.sub(r"\s+", " ", output_string).strip()
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: SonicPerformance
3
+ Version: 1.0
4
+ Summary: A statistical, low-memory AI-model pipeline for generation or tokenizing.
5
+ Author: AobanZ
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/AobanZ-MinecraftYoutuber/PySonic
8
+ Project-URL: Issues, https://github.com/AobanZ-MinecraftYoutuber/PySonic/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Dynamic: license-file
15
+
16
+ # Sonic
17
+
18
+ Sonic is a lightweight statistical AI model pipeline written in Python. Any of its functions can be incorporated in many projects.
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install sonic
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ```python
29
+ import sonic
30
+
31
+ text = sonic.OpenFile("all.txt")
32
+ words = sonic.Tokenize(text)
33
+
34
+ model = sonic.Model(32, 16)
35
+ model.InitModel()
36
+
37
+ print(model.Generate(words, "the"))
38
+ ```
39
+
40
+ ## Features
41
+
42
+ * Simple text tokenization
43
+ * Word frequency analysis
44
+ * Statistical text generation
45
+ * Lightweight NumPy-based implementation
46
+
47
+ ## Requirements
48
+ * NumPy
49
+
50
+ ## License
51
+
52
+ MIT
53
+
54
+ ## Incorporation
55
+ Sonic can be used as a pipeline in text-generation projects, tokenizing, or NLP experimenting for beginners.
@@ -0,0 +1,7 @@
1
+ sonic/__init__.py,sha256=NB7nV5FyQu8hBuLhu6JAu7ToLgbLwifcTBYjO-nNZa4,20
2
+ sonic/sonic.py,sha256=7DkjJFHRZf7VpIZzjAZ0aXQnvHraWUu_vUwUD-RV0bo,2056
3
+ sonicperformance-1.0.dist-info/licenses/LICENSE,sha256=A6c-_o0eAny9d_X-Gy7JJ8Ua0GSICn8fzAtNIKnRrvY,1085
4
+ sonicperformance-1.0.dist-info/METADATA,sha256=aA-kIEkz7blABHwq6-I8pyY2m9_64H4iKR6P0u42WHw,1273
5
+ sonicperformance-1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
+ sonicperformance-1.0.dist-info/top_level.txt,sha256=DpRcIcJfRAIJEs1E8O8sPpFlxfpCTP4UzDa_JOEt2n4,6
7
+ sonicperformance-1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AobanLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ sonic