flatmem 0.1.0__tar.gz
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.
- flatmem-0.1.0/LICENSE +21 -0
- flatmem-0.1.0/PKG-INFO +175 -0
- flatmem-0.1.0/README.md +151 -0
- flatmem-0.1.0/flatmem/__init__.py +50 -0
- flatmem-0.1.0/flatmem/core.py +479 -0
- flatmem-0.1.0/flatmem/encoders.py +117 -0
- flatmem-0.1.0/flatmem.egg-info/PKG-INFO +175 -0
- flatmem-0.1.0/flatmem.egg-info/SOURCES.txt +14 -0
- flatmem-0.1.0/flatmem.egg-info/dependency_links.txt +1 -0
- flatmem-0.1.0/flatmem.egg-info/requires.txt +4 -0
- flatmem-0.1.0/flatmem.egg-info/top_level.txt +1 -0
- flatmem-0.1.0/pyproject.toml +35 -0
- flatmem-0.1.0/setup.cfg +4 -0
- flatmem-0.1.0/setup.py +3 -0
- flatmem-0.1.0/tests/test_basics.py +161 -0
- flatmem-0.1.0/tests/test_universality.py +185 -0
flatmem-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prince Siddhpara — Mura ALife Labs
|
|
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.
|
flatmem-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flatmem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Constant-RAM content-addressable memory substrate for digital organisms and Artificial Life agents.
|
|
5
|
+
Author-email: Prince Siddhpara <princesiddhpara67@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs
|
|
8
|
+
Project-URL: Repository, https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs
|
|
9
|
+
Project-URL: Paper, https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs/blob/main/PAPER.md
|
|
10
|
+
Keywords: memory,sdm,vsa,hdc,alife,artificial-life,sparse-distributed-memory,vector-symbolic,hyperdimensional,agent-based,online-learning
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Life
|
|
17
|
+
Requires-Python: >=3.8
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: numpy>=1.20
|
|
21
|
+
Provides-Extra: test
|
|
22
|
+
Requires-Dist: pytest>=7.0; extra == "test"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# flatmem
|
|
26
|
+
|
|
27
|
+
**A brain you can fit in 233 MB that absorbs frontier-scale text and memory never grows.**
|
|
28
|
+
**Not a model. An organism.**
|
|
29
|
+
|
|
30
|
+
`flatmem` is a constant-RAM, content-addressable memory substrate for digital organisms, Artificial Life simulations, agent-based models, robotics, and language organisms. The total memory footprint is **fixed** regardless of how much data is written. Inspired by, and mathematically grounded in, the Marr-Albus-Kanerva cerebellar model.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Why this exists
|
|
35
|
+
|
|
36
|
+
Traditional memory in AI grows with data: embedding tables (`{id: vector}`), bigram dicts, replay buffers, vector databases. RAM scales linearly with experience. Brains do not — adult human cortex is ~86 billion neurons fixed; lifetime memories live in **synaptic strengths in a fixed matrix**, not in growing dictionaries.
|
|
37
|
+
|
|
38
|
+
`flatmem` is that fixed matrix in software. Every memory you write superposes into existing counter weights at sparse locations. Recall is reconstructive (gist-based, like human memory). The substrate is **modality-blind**: text, sensor arrays, chemical gradients, robot joint angles — anything that can be encoded as a high-dimensional pattern.
|
|
39
|
+
|
|
40
|
+
## The 5-piece architecture
|
|
41
|
+
|
|
42
|
+
1. **Sparse Distributed Memory (SDM)** — fixed bank of `M` random hard-location addresses + counter rows. Writes activate top-`k` nearest by cosine; counters accumulate.
|
|
43
|
+
2. **VSA role-binding** — `addr(item, role) = key(item) ⊙ ROLE` (Hadamard complex multiply). Multiple relation types in ONE substrate without interference.
|
|
44
|
+
3. **Traffic-class bank separation** — high-traffic channels (co-occurrence) and low-traffic channels (sparse facts) live in separate fixed banks; otherwise dense traffic swamps sparse signal at shared locations.
|
|
45
|
+
4. **Computed-identity keys** — zero stored bytes per item. Identity = char-trigram + whole-word random phasor projection. Infinite vocabulary, no embedding table.
|
|
46
|
+
5. **Read-time mean-removal** — Arora's all-but-the-top, adapted to live recall. Subtracts the dominant common direction; scale-invariant sensory adaptation.
|
|
47
|
+
|
|
48
|
+
Each piece has prior art (Kanerva 1988, Plate 1995, Frady-Sommer TPAM, Arora 2017). The **integration** as a working lifelong-learning constant-RAM memory organism is novel.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install flatmem
|
|
54
|
+
# or from source
|
|
55
|
+
git clone https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs
|
|
56
|
+
cd flatmem
|
|
57
|
+
pip install -e .
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Only dependency: `numpy>=1.20`.
|
|
61
|
+
|
|
62
|
+
## Quick start
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from flatmem import MultiRoleMemory
|
|
66
|
+
|
|
67
|
+
mem = MultiRoleMemory(d=512, M=16384, k=64)
|
|
68
|
+
|
|
69
|
+
# Inject knowledge with reinforcement
|
|
70
|
+
mem.assert_relation('cat', 'isa', 'mammal', n=20)
|
|
71
|
+
mem.assert_relation('dog', 'isa', 'mammal', n=20)
|
|
72
|
+
mem.assert_relation('mammal', 'property', 'warm', n=20)
|
|
73
|
+
|
|
74
|
+
# Query
|
|
75
|
+
print(mem.query('cat', 'isa')) # ('mammal', 1.0)
|
|
76
|
+
print(mem.query('dog', 'isa')) # ('mammal', 1.0)
|
|
77
|
+
|
|
78
|
+
# Cross-channel composition (the property of a cat's hypernym)
|
|
79
|
+
mid, end = mem.chain('cat', 'isa', ['mammal', 'flower', 'tree'],
|
|
80
|
+
'property', ['warm', 'cold', 'tall'])
|
|
81
|
+
print(f'{mid} -> {end}') # 'mammal -> warm'
|
|
82
|
+
|
|
83
|
+
# Read text — co-occurrence accumulates in fixed substrate
|
|
84
|
+
for sentence in ["the cat sat on the mat", "the dog ran fast"] * 50:
|
|
85
|
+
mem.expose_cooccur(sentence)
|
|
86
|
+
print(mem.similarity('cat', 'dog')) # > 0 (semantic neighbors)
|
|
87
|
+
|
|
88
|
+
# Substrate is FIXED regardless of how much you write
|
|
89
|
+
print(f'{mem.substrate_bytes() / 1_048_576:.0f} MB') # always the same
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Universal interface
|
|
93
|
+
|
|
94
|
+
The substrate exposes **two functions**:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
mem.write(addr, data) # via .relate / .write_relation / .expose_*
|
|
98
|
+
mem.read(addr) # via .recall / .query / .similarity / .neighbors
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Anything that can be encoded as a `d`-dim phasor HV can address it. `flatmem.encoders` provides helpers for the common ALife encodings:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from flatmem.encoders import (
|
|
105
|
+
scalar_phasor, # encode a scalar (reward, concentration, joint angle)
|
|
106
|
+
position_phasor, # encode 2D position with spatial topology
|
|
107
|
+
random_projection_encoder,# encode an arbitrary numeric vector
|
|
108
|
+
bind, unbind, bundle, permute, # VSA primitives
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## ALife integration patterns
|
|
113
|
+
|
|
114
|
+
The `examples/` directory shows drop-in patterns for several ALife domains:
|
|
115
|
+
|
|
116
|
+
| File | Paradigm | What it shows |
|
|
117
|
+
|------|----------|---------------|
|
|
118
|
+
| `01_text_organism.py` | Language organism | Co-occurrence + IS-A + similarity in one substrate |
|
|
119
|
+
| `02_maze_agent.py` | Grid-world RL | Q-values per (state, action) without a Q-table dict |
|
|
120
|
+
| `03_boids_memory.py` | Flocking / swarms | Experiential steering from past visual states |
|
|
121
|
+
| `04_chemotaxis.py` | Chemical gradients | Running-mean concentration via phasor superposition |
|
|
122
|
+
|
|
123
|
+
The same substrate object handles all four. No special-case code.
|
|
124
|
+
|
|
125
|
+
## What it's NOT for
|
|
126
|
+
|
|
127
|
+
`flatmem` is a **cognitive / episodic / symbolic** memory substrate. It is the **wrong** choice for:
|
|
128
|
+
- Mass-cellular-automata grid storage at 60 Hz (use raw VRAM arrays for the grid; put `flatmem` in the agents that navigate it).
|
|
129
|
+
- Lookup tables requiring **exact** retrieval (recall is reconstructive / gist).
|
|
130
|
+
- Anything where you need 100% precision and have unlimited RAM.
|
|
131
|
+
|
|
132
|
+
If your problem is "I want to remember the GIST of a lifetime of experience in fixed bytes" — this is the right tool.
|
|
133
|
+
|
|
134
|
+
## Engineering notes
|
|
135
|
+
|
|
136
|
+
- **Real-time loops**: top-`k` activation is O(M·d). Cache strategically; don't query per frame at 60 Hz.
|
|
137
|
+
- **Multi-agent**: each agent has its own `MultiRoleMemory` (`~192 MB default`). Decentralize.
|
|
138
|
+
- **Federated merge**: agents with same `seed` have aligned hard locations; counter banks can be summed (`C_merged = C_a + C_b`) for emergent hive intelligence or generational inheritance. Capacity wall at ~hundreds of agents (noise floor grows as √N).
|
|
139
|
+
- **GPU**: not optimized for GPU yet. SDM top-`k` selection causes warp divergence; replace with differentiable softmax for GPU port.
|
|
140
|
+
|
|
141
|
+
## Run the tests
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python tests/test_basics.py # core correctness
|
|
145
|
+
python tests/test_universality.py # ALife integration patterns
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Research paper
|
|
149
|
+
|
|
150
|
+
See [PAPER.md](./PAPER.md) for the full architecture rationale, empirical results, prior-art discussion, and novelty analysis. Originally developed inside the **Ikigai** organism project at **Mura ALife Labs** as the constant-RAM memory substrate for a language-grounded digital organism.
|
|
151
|
+
|
|
152
|
+
## Cite
|
|
153
|
+
|
|
154
|
+
If you use `flatmem` in research:
|
|
155
|
+
|
|
156
|
+
```bibtex
|
|
157
|
+
@misc{siddhpara2026flatmem,
|
|
158
|
+
author = {Siddhpara, Prince},
|
|
159
|
+
title = {flatmem: A Constant-RAM Content-Addressable Memory Substrate for Digital Organisms},
|
|
160
|
+
year = {2026},
|
|
161
|
+
publisher = {Mura ALife Labs},
|
|
162
|
+
howpublished = {\url{https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs}},
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT. See [LICENSE](./LICENSE).
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
<p align="center">
|
|
173
|
+
<b>Mura ALife Labs</b> · 2026<br>
|
|
174
|
+
<i>Building digital organisms, not models.</i>
|
|
175
|
+
</p>
|
flatmem-0.1.0/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# flatmem
|
|
2
|
+
|
|
3
|
+
**A brain you can fit in 233 MB that absorbs frontier-scale text and memory never grows.**
|
|
4
|
+
**Not a model. An organism.**
|
|
5
|
+
|
|
6
|
+
`flatmem` is a constant-RAM, content-addressable memory substrate for digital organisms, Artificial Life simulations, agent-based models, robotics, and language organisms. The total memory footprint is **fixed** regardless of how much data is written. Inspired by, and mathematically grounded in, the Marr-Albus-Kanerva cerebellar model.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Why this exists
|
|
11
|
+
|
|
12
|
+
Traditional memory in AI grows with data: embedding tables (`{id: vector}`), bigram dicts, replay buffers, vector databases. RAM scales linearly with experience. Brains do not — adult human cortex is ~86 billion neurons fixed; lifetime memories live in **synaptic strengths in a fixed matrix**, not in growing dictionaries.
|
|
13
|
+
|
|
14
|
+
`flatmem` is that fixed matrix in software. Every memory you write superposes into existing counter weights at sparse locations. Recall is reconstructive (gist-based, like human memory). The substrate is **modality-blind**: text, sensor arrays, chemical gradients, robot joint angles — anything that can be encoded as a high-dimensional pattern.
|
|
15
|
+
|
|
16
|
+
## The 5-piece architecture
|
|
17
|
+
|
|
18
|
+
1. **Sparse Distributed Memory (SDM)** — fixed bank of `M` random hard-location addresses + counter rows. Writes activate top-`k` nearest by cosine; counters accumulate.
|
|
19
|
+
2. **VSA role-binding** — `addr(item, role) = key(item) ⊙ ROLE` (Hadamard complex multiply). Multiple relation types in ONE substrate without interference.
|
|
20
|
+
3. **Traffic-class bank separation** — high-traffic channels (co-occurrence) and low-traffic channels (sparse facts) live in separate fixed banks; otherwise dense traffic swamps sparse signal at shared locations.
|
|
21
|
+
4. **Computed-identity keys** — zero stored bytes per item. Identity = char-trigram + whole-word random phasor projection. Infinite vocabulary, no embedding table.
|
|
22
|
+
5. **Read-time mean-removal** — Arora's all-but-the-top, adapted to live recall. Subtracts the dominant common direction; scale-invariant sensory adaptation.
|
|
23
|
+
|
|
24
|
+
Each piece has prior art (Kanerva 1988, Plate 1995, Frady-Sommer TPAM, Arora 2017). The **integration** as a working lifelong-learning constant-RAM memory organism is novel.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install flatmem
|
|
30
|
+
# or from source
|
|
31
|
+
git clone https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs
|
|
32
|
+
cd flatmem
|
|
33
|
+
pip install -e .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Only dependency: `numpy>=1.20`.
|
|
37
|
+
|
|
38
|
+
## Quick start
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from flatmem import MultiRoleMemory
|
|
42
|
+
|
|
43
|
+
mem = MultiRoleMemory(d=512, M=16384, k=64)
|
|
44
|
+
|
|
45
|
+
# Inject knowledge with reinforcement
|
|
46
|
+
mem.assert_relation('cat', 'isa', 'mammal', n=20)
|
|
47
|
+
mem.assert_relation('dog', 'isa', 'mammal', n=20)
|
|
48
|
+
mem.assert_relation('mammal', 'property', 'warm', n=20)
|
|
49
|
+
|
|
50
|
+
# Query
|
|
51
|
+
print(mem.query('cat', 'isa')) # ('mammal', 1.0)
|
|
52
|
+
print(mem.query('dog', 'isa')) # ('mammal', 1.0)
|
|
53
|
+
|
|
54
|
+
# Cross-channel composition (the property of a cat's hypernym)
|
|
55
|
+
mid, end = mem.chain('cat', 'isa', ['mammal', 'flower', 'tree'],
|
|
56
|
+
'property', ['warm', 'cold', 'tall'])
|
|
57
|
+
print(f'{mid} -> {end}') # 'mammal -> warm'
|
|
58
|
+
|
|
59
|
+
# Read text — co-occurrence accumulates in fixed substrate
|
|
60
|
+
for sentence in ["the cat sat on the mat", "the dog ran fast"] * 50:
|
|
61
|
+
mem.expose_cooccur(sentence)
|
|
62
|
+
print(mem.similarity('cat', 'dog')) # > 0 (semantic neighbors)
|
|
63
|
+
|
|
64
|
+
# Substrate is FIXED regardless of how much you write
|
|
65
|
+
print(f'{mem.substrate_bytes() / 1_048_576:.0f} MB') # always the same
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Universal interface
|
|
69
|
+
|
|
70
|
+
The substrate exposes **two functions**:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
mem.write(addr, data) # via .relate / .write_relation / .expose_*
|
|
74
|
+
mem.read(addr) # via .recall / .query / .similarity / .neighbors
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Anything that can be encoded as a `d`-dim phasor HV can address it. `flatmem.encoders` provides helpers for the common ALife encodings:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from flatmem.encoders import (
|
|
81
|
+
scalar_phasor, # encode a scalar (reward, concentration, joint angle)
|
|
82
|
+
position_phasor, # encode 2D position with spatial topology
|
|
83
|
+
random_projection_encoder,# encode an arbitrary numeric vector
|
|
84
|
+
bind, unbind, bundle, permute, # VSA primitives
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## ALife integration patterns
|
|
89
|
+
|
|
90
|
+
The `examples/` directory shows drop-in patterns for several ALife domains:
|
|
91
|
+
|
|
92
|
+
| File | Paradigm | What it shows |
|
|
93
|
+
|------|----------|---------------|
|
|
94
|
+
| `01_text_organism.py` | Language organism | Co-occurrence + IS-A + similarity in one substrate |
|
|
95
|
+
| `02_maze_agent.py` | Grid-world RL | Q-values per (state, action) without a Q-table dict |
|
|
96
|
+
| `03_boids_memory.py` | Flocking / swarms | Experiential steering from past visual states |
|
|
97
|
+
| `04_chemotaxis.py` | Chemical gradients | Running-mean concentration via phasor superposition |
|
|
98
|
+
|
|
99
|
+
The same substrate object handles all four. No special-case code.
|
|
100
|
+
|
|
101
|
+
## What it's NOT for
|
|
102
|
+
|
|
103
|
+
`flatmem` is a **cognitive / episodic / symbolic** memory substrate. It is the **wrong** choice for:
|
|
104
|
+
- Mass-cellular-automata grid storage at 60 Hz (use raw VRAM arrays for the grid; put `flatmem` in the agents that navigate it).
|
|
105
|
+
- Lookup tables requiring **exact** retrieval (recall is reconstructive / gist).
|
|
106
|
+
- Anything where you need 100% precision and have unlimited RAM.
|
|
107
|
+
|
|
108
|
+
If your problem is "I want to remember the GIST of a lifetime of experience in fixed bytes" — this is the right tool.
|
|
109
|
+
|
|
110
|
+
## Engineering notes
|
|
111
|
+
|
|
112
|
+
- **Real-time loops**: top-`k` activation is O(M·d). Cache strategically; don't query per frame at 60 Hz.
|
|
113
|
+
- **Multi-agent**: each agent has its own `MultiRoleMemory` (`~192 MB default`). Decentralize.
|
|
114
|
+
- **Federated merge**: agents with same `seed` have aligned hard locations; counter banks can be summed (`C_merged = C_a + C_b`) for emergent hive intelligence or generational inheritance. Capacity wall at ~hundreds of agents (noise floor grows as √N).
|
|
115
|
+
- **GPU**: not optimized for GPU yet. SDM top-`k` selection causes warp divergence; replace with differentiable softmax for GPU port.
|
|
116
|
+
|
|
117
|
+
## Run the tests
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python tests/test_basics.py # core correctness
|
|
121
|
+
python tests/test_universality.py # ALife integration patterns
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Research paper
|
|
125
|
+
|
|
126
|
+
See [PAPER.md](./PAPER.md) for the full architecture rationale, empirical results, prior-art discussion, and novelty analysis. Originally developed inside the **Ikigai** organism project at **Mura ALife Labs** as the constant-RAM memory substrate for a language-grounded digital organism.
|
|
127
|
+
|
|
128
|
+
## Cite
|
|
129
|
+
|
|
130
|
+
If you use `flatmem` in research:
|
|
131
|
+
|
|
132
|
+
```bibtex
|
|
133
|
+
@misc{siddhpara2026flatmem,
|
|
134
|
+
author = {Siddhpara, Prince},
|
|
135
|
+
title = {flatmem: A Constant-RAM Content-Addressable Memory Substrate for Digital Organisms},
|
|
136
|
+
year = {2026},
|
|
137
|
+
publisher = {Mura ALife Labs},
|
|
138
|
+
howpublished = {\url{https://github.com/HitoshiFTW/Flatmem-Mura-ALife-Labs}},
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT. See [LICENSE](./LICENSE).
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
<p align="center">
|
|
149
|
+
<b>Mura ALife Labs</b> · 2026<br>
|
|
150
|
+
<i>Building digital organisms, not models.</i>
|
|
151
|
+
</p>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
flatmem -- Constant-RAM content-addressable memory for digital organisms.
|
|
3
|
+
|
|
4
|
+
A universal flat-memory substrate based on Sparse Distributed Memory + VSA
|
|
5
|
+
role-binding + computed-identity keys + read-time mean-removal. Designed as
|
|
6
|
+
a drop-in lifelong-learning memory for Artificial Life simulations,
|
|
7
|
+
agent-based models, robotics, and language organisms.
|
|
8
|
+
|
|
9
|
+
Two-function interface:
|
|
10
|
+
write(addr, data)
|
|
11
|
+
read(addr) -> cleaned data
|
|
12
|
+
|
|
13
|
+
Substrate size is FIXED regardless of how many items are written.
|
|
14
|
+
Modality-blind: addresses can be any high-dimensional pattern.
|
|
15
|
+
|
|
16
|
+
Quick start:
|
|
17
|
+
from flatmem import MultiRoleMemory, ComputedKey
|
|
18
|
+
mem = MultiRoleMemory(d=512, M=16384, k=64, roles=('next', 'reward'))
|
|
19
|
+
mem.relate('cat', 'isa', 'mammal')
|
|
20
|
+
print(mem.query('cat', 'isa')) # ('mammal', 1.0)
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from .core import (
|
|
24
|
+
ComputedKey,
|
|
25
|
+
VSASDM,
|
|
26
|
+
MultiRoleMemory,
|
|
27
|
+
tokenize,
|
|
28
|
+
cos,
|
|
29
|
+
renorm,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from .encoders import (
|
|
33
|
+
scalar_phasor,
|
|
34
|
+
decode_scalar,
|
|
35
|
+
position_phasor,
|
|
36
|
+
random_projection_encoder,
|
|
37
|
+
bind,
|
|
38
|
+
unbind,
|
|
39
|
+
bundle,
|
|
40
|
+
permute,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
__version__ = "0.1.0"
|
|
44
|
+
__all__ = [
|
|
45
|
+
"ComputedKey", "VSASDM", "MultiRoleMemory",
|
|
46
|
+
"tokenize", "cos", "renorm",
|
|
47
|
+
"scalar_phasor", "decode_scalar", "position_phasor",
|
|
48
|
+
"random_projection_encoder",
|
|
49
|
+
"bind", "unbind", "bundle", "permute",
|
|
50
|
+
]
|