mda-memory 0.1.1__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.
- mda/__init__.py +3 -0
- mda/core/__init__.py +0 -0
- mda/core/bind.py +39 -0
- mda/core/encoder.py +688 -0
- mda/core/entity.py +319 -0
- mda/core/neuron.py +83 -0
- mda/core/registry.py +157 -0
- mda/data/__init__.py +22 -0
- mda/data/stopwords.txt +733 -0
- mda/data/stopwords_content.txt +57 -0
- mda/inference/__init__.py +0 -0
- mda/inference/associative.py +190 -0
- mda/inference/broca.py +204 -0
- mda/inference/memory.py +119 -0
- mda/inference/reasoning.py +169 -0
- mda/inference/translator.py +218 -0
- mda/integrations/__init__.py +0 -0
- mda/integrations/cli.py +500 -0
- mda/integrations/engine.py +837 -0
- mda/integrations/loader.py +646 -0
- mda/mda.py +561 -0
- mda/training/__init__.py +0 -0
- mda/training/checkpoint.py +192 -0
- mda_memory-0.1.1.dist-info/METADATA +22 -0
- mda_memory-0.1.1.dist-info/RECORD +29 -0
- mda_memory-0.1.1.dist-info/WHEEL +5 -0
- mda_memory-0.1.1.dist-info/entry_points.txt +2 -0
- mda_memory-0.1.1.dist-info/licenses/LICENSE +67 -0
- mda_memory-0.1.1.dist-info/top_level.txt +1 -0
mda/__init__.py
ADDED
mda/core/__init__.py
ADDED
|
File without changes
|
mda/core/bind.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
DIM = 256
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def normalize(v: np.ndarray) -> np.ndarray:
|
|
7
|
+
n = np.linalg.norm(v)
|
|
8
|
+
return v / (n + 1e-8)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def random_vector(dim: int = DIM, seed: int = None) -> np.ndarray:
|
|
12
|
+
rng = np.random.default_rng(seed)
|
|
13
|
+
return normalize(rng.normal(0, 1, dim))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def zero_vector(dim: int = DIM) -> np.ndarray:
|
|
17
|
+
return np.zeros(dim)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def bind(a: np.ndarray, b: np.ndarray) -> np.ndarray:
|
|
21
|
+
return np.real(np.fft.ifft(np.fft.fft(a) * np.fft.fft(b)))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def unbind(compound: np.ndarray, b: np.ndarray) -> np.ndarray:
|
|
25
|
+
F_b = np.fft.fft(b)
|
|
26
|
+
F_b_inv = np.conj(F_b) / (np.abs(F_b) ** 2 + 1e-6)
|
|
27
|
+
b_inv = np.real(np.fft.ifft(F_b_inv))
|
|
28
|
+
return np.real(np.fft.ifft(np.fft.fft(compound) * np.fft.fft(b_inv)))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def bind_many(*vectors: np.ndarray) -> np.ndarray:
|
|
32
|
+
result = vectors[0].copy()
|
|
33
|
+
for v in vectors[1:]:
|
|
34
|
+
result = bind(result, v)
|
|
35
|
+
return result
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def cosine(a: np.ndarray, b: np.ndarray) -> float:
|
|
39
|
+
return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b) + 1e-8))
|