@hviana/sema 0.1.0
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.
- package/AGENTS.md +470 -0
- package/AUTHORS.md +12 -0
- package/COMMERCIAL-LICENSE.md +19 -0
- package/CONTRIBUTING.md +15 -0
- package/HOW_IT_WORKS.md +4210 -0
- package/LICENSE.md +117 -0
- package/README.md +290 -0
- package/TRADEMARKS.md +19 -0
- package/example/demo.ts +46 -0
- package/example/train_base.ts +2675 -0
- package/index.html +893 -0
- package/package.json +25 -0
- package/src/alphabet.ts +34 -0
- package/src/alu/README.md +332 -0
- package/src/alu/src/alu.ts +541 -0
- package/src/alu/src/expr.ts +339 -0
- package/src/alu/src/index.ts +115 -0
- package/src/alu/src/kernel-arith.ts +377 -0
- package/src/alu/src/kernel-bits.ts +199 -0
- package/src/alu/src/kernel-logic.ts +102 -0
- package/src/alu/src/kernel-nd.ts +235 -0
- package/src/alu/src/kernel-numeric.ts +466 -0
- package/src/alu/src/operation.ts +344 -0
- package/src/alu/src/parser.ts +574 -0
- package/src/alu/src/resonance.ts +161 -0
- package/src/alu/src/text.ts +83 -0
- package/src/alu/src/value.ts +327 -0
- package/src/alu/test/alu.test.ts +1004 -0
- package/src/bytes.ts +62 -0
- package/src/config.ts +227 -0
- package/src/derive/README.md +295 -0
- package/src/derive/src/deduction.ts +263 -0
- package/src/derive/src/index.ts +24 -0
- package/src/derive/src/priority-queue.ts +70 -0
- package/src/derive/src/rewrite.ts +127 -0
- package/src/derive/src/trie.ts +242 -0
- package/src/derive/test/derive.test.ts +137 -0
- package/src/extension.ts +42 -0
- package/src/geometry.ts +511 -0
- package/src/index.ts +38 -0
- package/src/ingest-cache.ts +224 -0
- package/src/mind/articulation.ts +137 -0
- package/src/mind/attention.ts +1061 -0
- package/src/mind/canonical.ts +107 -0
- package/src/mind/graph-search.ts +1100 -0
- package/src/mind/index.ts +18 -0
- package/src/mind/junction.ts +347 -0
- package/src/mind/learning.ts +246 -0
- package/src/mind/match.ts +507 -0
- package/src/mind/mechanisms/alu.ts +33 -0
- package/src/mind/mechanisms/cast.ts +568 -0
- package/src/mind/mechanisms/confluence.ts +268 -0
- package/src/mind/mechanisms/cover.ts +248 -0
- package/src/mind/mechanisms/extraction.ts +422 -0
- package/src/mind/mechanisms/recall.ts +241 -0
- package/src/mind/mind.ts +483 -0
- package/src/mind/pipeline-mechanism.ts +326 -0
- package/src/mind/pipeline.ts +300 -0
- package/src/mind/primitives.ts +201 -0
- package/src/mind/rationale.ts +275 -0
- package/src/mind/reasoning.ts +198 -0
- package/src/mind/recognition.ts +234 -0
- package/src/mind/resonance.ts +0 -0
- package/src/mind/trace.ts +108 -0
- package/src/mind/traverse.ts +556 -0
- package/src/mind/types.ts +281 -0
- package/src/rabitq-hnsw/README.md +303 -0
- package/src/rabitq-hnsw/src/database.ts +492 -0
- package/src/rabitq-hnsw/src/heap.ts +90 -0
- package/src/rabitq-hnsw/src/hnsw.ts +514 -0
- package/src/rabitq-hnsw/src/index.ts +15 -0
- package/src/rabitq-hnsw/src/prng.ts +39 -0
- package/src/rabitq-hnsw/src/rabitq.ts +308 -0
- package/src/rabitq-hnsw/src/store.ts +994 -0
- package/src/rabitq-hnsw/test/hnsw.test.ts +1213 -0
- package/src/store-sqlite.ts +928 -0
- package/src/store.ts +2148 -0
- package/src/vec.ts +124 -0
- package/test/00-extract.test.mjs +151 -0
- package/test/01-floor.test.mjs +20 -0
- package/test/02-roundtrip.test.mjs +83 -0
- package/test/03-recall.test.mjs +98 -0
- package/test/04-think.test.mjs +627 -0
- package/test/05-concepts.test.mjs +84 -0
- package/test/08-storage.test.mjs +948 -0
- package/test/09-edges.test.mjs +65 -0
- package/test/11-universality.test.mjs +180 -0
- package/test/13-conversation.test.mjs +228 -0
- package/test/14-scaling.test.mjs +503 -0
- package/test/15-decomposition-gap.test.mjs +0 -0
- package/test/16-bridge.test.mjs +250 -0
- package/test/17-intelligence.test.mjs +240 -0
- package/test/18-alu.test.mjs +209 -0
- package/test/19-nd.test.mjs +254 -0
- package/test/20-stability.test.mjs +489 -0
- package/test/21-partial.test.mjs +158 -0
- package/test/22-multihop.test.mjs +130 -0
- package/test/23-rationale.test.mjs +316 -0
- package/test/24-generalization.test.mjs +416 -0
- package/test/25-embedding.test.mjs +75 -0
- package/test/26-cooperative.test.mjs +89 -0
- package/test/27-saturation-drop.test.mjs +637 -0
- package/test/28-unknowable.test.mjs +88 -0
- package/test/29-counterfactual.test.mjs +476 -0
- package/test/30-conflict-resolution.test.mjs +166 -0
- package/test/31-audit.test.mjs +288 -0
- package/test/32-confluence.test.mjs +173 -0
- package/test/33-multi-candidate.test.mjs +222 -0
- package/test/34-cross-region.test.mjs +252 -0
- package/tsconfig.json +16 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
> Required Notice: Copyright Sema Authors — Henrique Viana, Marcelo Oliveira dos
|
|
6
|
+
> Reis, Rogerio Nascimento (hv5088@gmail.com)
|
|
7
|
+
|
|
8
|
+
## Acceptance
|
|
9
|
+
|
|
10
|
+
In order to get any license under these terms, you must agree to them as both
|
|
11
|
+
strict obligations and conditions to all your licenses.
|
|
12
|
+
|
|
13
|
+
## Copyright License
|
|
14
|
+
|
|
15
|
+
The licensor grants you a copyright license for the software to do everything
|
|
16
|
+
you might do with the software that would otherwise infringe the licensor's
|
|
17
|
+
copyright in it for any permitted purpose. However, you may only distribute the
|
|
18
|
+
software according to [Distribution License](#distribution-license) and make
|
|
19
|
+
changes or new works based on the software according to
|
|
20
|
+
[Changes and New Works License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license to distribute copies of
|
|
25
|
+
the software. Your license to distribute covers distributing the software with
|
|
26
|
+
changes and new works permitted by
|
|
27
|
+
[Changes and New Works License](#changes-and-new-works-license).
|
|
28
|
+
|
|
29
|
+
## Notices
|
|
30
|
+
|
|
31
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
32
|
+
also gets a copy of these terms or the URL for them above, as well as copies of
|
|
33
|
+
any plain-text lines beginning with `Required Notice:` that the licensor
|
|
34
|
+
provided with the software. For example:
|
|
35
|
+
|
|
36
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
37
|
+
|
|
38
|
+
## Changes and New Works License
|
|
39
|
+
|
|
40
|
+
The licensor grants you an additional copyright license to make changes and new
|
|
41
|
+
works based on the software for any permitted purpose.
|
|
42
|
+
|
|
43
|
+
## Patent License
|
|
44
|
+
|
|
45
|
+
The licensor grants you a patent license for the software that covers patent
|
|
46
|
+
claims the licensor can license, or becomes able to license, that you would
|
|
47
|
+
infringe by using the software.
|
|
48
|
+
|
|
49
|
+
## Noncommercial Purposes
|
|
50
|
+
|
|
51
|
+
Any noncommercial purpose is a permitted purpose.
|
|
52
|
+
|
|
53
|
+
## Personal Uses
|
|
54
|
+
|
|
55
|
+
Personal use for research, experiment, and testing for the benefit of public
|
|
56
|
+
knowledge, personal study, private entertainment, hobby projects, amateur
|
|
57
|
+
pursuits, or religious observance, without any anticipated commercial
|
|
58
|
+
application, is use for a permitted purpose.
|
|
59
|
+
|
|
60
|
+
## Noncommercial Organizations
|
|
61
|
+
|
|
62
|
+
Use by any charitable organization, educational institution, public research
|
|
63
|
+
organization, public safety or health organization, environmental protection
|
|
64
|
+
organization, or government institution is use for a permitted purpose
|
|
65
|
+
regardless of the source of funding or obligations resulting from the funding.
|
|
66
|
+
|
|
67
|
+
## Fair Use
|
|
68
|
+
|
|
69
|
+
You may have "fair use" rights for the software under the law. These terms do
|
|
70
|
+
not limit them.
|
|
71
|
+
|
|
72
|
+
## No Other Rights
|
|
73
|
+
|
|
74
|
+
These terms do not allow you to sublicense or transfer any of your licenses to
|
|
75
|
+
anyone else, or prevent the licensor from granting licenses to anyone else.
|
|
76
|
+
These terms do not imply any other licenses.
|
|
77
|
+
|
|
78
|
+
## Patent Defense
|
|
79
|
+
|
|
80
|
+
If you make any written claim that the software infringes or contributes to
|
|
81
|
+
infringement of any patent, your patent license for the software granted under
|
|
82
|
+
these terms ends immediately. If your company makes such a claim, your patent
|
|
83
|
+
license ends immediately for work on behalf of your company.
|
|
84
|
+
|
|
85
|
+
## Violations
|
|
86
|
+
|
|
87
|
+
The first time you are notified in writing that you have violated any of these
|
|
88
|
+
terms, or done anything with the software not covered by your licenses, your
|
|
89
|
+
licenses can nonetheless continue if you come into full compliance with these
|
|
90
|
+
terms, and take practical steps to correct past violations, within 32 days of
|
|
91
|
+
receiving notice. Otherwise, all your licenses end immediately.
|
|
92
|
+
|
|
93
|
+
## No Liability
|
|
94
|
+
|
|
95
|
+
_**As far as the law allows, the software comes as is, without any warranty or
|
|
96
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
97
|
+
out of these terms or the use or nature of the software, under any kind of legal
|
|
98
|
+
claim.**_
|
|
99
|
+
|
|
100
|
+
## Definitions
|
|
101
|
+
|
|
102
|
+
The **licensor** is the individual or entity offering these terms, and the
|
|
103
|
+
**software** is the software the licensor makes available under these terms.
|
|
104
|
+
|
|
105
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
106
|
+
|
|
107
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of
|
|
108
|
+
organization that you work for, plus all organizations that have control over,
|
|
109
|
+
are under the control of, or are under common control with that organization.
|
|
110
|
+
**Control** means ownership of substantially all the assets of an entity, or the
|
|
111
|
+
power to direct its management and policies by vote, contract, or otherwise.
|
|
112
|
+
Control can be direct or indirect.
|
|
113
|
+
|
|
114
|
+
**Your licenses** are all the licenses granted to you for the software under
|
|
115
|
+
these terms.
|
|
116
|
+
|
|
117
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
███████╗ ███████╗ ███╗ ███╗ █████╗
|
|
5
|
+
██╔════╝ ██╔════╝ ████╗ ████║ ██╔══██╗
|
|
6
|
+
███████╗ █████╗ ██╔████╔██║ ███████║
|
|
7
|
+
╚════██║ ██╔══╝ ██║╚██╔╝██║ ██╔══██║
|
|
8
|
+
███████║ ███████╗ ██║ ╚═╝ ██║ ██║ ██║
|
|
9
|
+
╚══════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
### The mind without weights.
|
|
13
|
+
|
|
14
|
+
**A reasoning engine grounded in a _vector-symbolic architecture_ and
|
|
15
|
+
_instance-based memory_ — not in billions of trained parameters.**
|
|
16
|
+
|
|
17
|
+
No weights. No gradients. No training loop. No neural network. No GPU.
|
|
18
|
+
|
|
19
|
+
`Deterministic` · `Auditable` · `CPU-only`
|
|
20
|
+
|
|
21
|
+
— ⬡ — ⬡ — ⬡ —
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
> [!IMPORTANT]
|
|
26
|
+
> **© Sema is not a large language model.** Today's LLMs compress the world into
|
|
27
|
+
> opaque floating-point weights and answer by sampling from them. Sema does the
|
|
28
|
+
> opposite: it **keeps your knowledge as knowledge** — content-addressed,
|
|
29
|
+
> inspectable, exact — and _reasons_ over it on demand. The store **is** the
|
|
30
|
+
> model. What it knows, you can read. Why it answered, you can trace.
|
|
31
|
+
>
|
|
32
|
+
> Formally, Sema is a **non-parametric, instance-based reasoning system**: a
|
|
33
|
+
> Vector Symbolic Architecture (Plate 1995; Kanerva 2009) over a
|
|
34
|
+
> content-addressable memory, with inference by weighted automated deduction
|
|
35
|
+
> (Knuth 1977; Felzenszwalb & McAllester 2007). Each term is grounded in
|
|
36
|
+
> [HOW_IT_WORKS.md](HOW_IT_WORKS.md).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## ✦ Retrieval and reasoning, one search
|
|
41
|
+
|
|
42
|
+
Two questions, asked of every query — and Sema answers both in a single pass:
|
|
43
|
+
|
|
44
|
+
<div align="center">
|
|
45
|
+
|
|
46
|
+
| | The question it asks |
|
|
47
|
+
| :--------------- | :--------------------------------------------------- |
|
|
48
|
+
| 🔎 **Retrieval** | _"What do I already know that bears on this?"_ |
|
|
49
|
+
| 🧠 **Deduction** | _"What can I conclude or decide from what I found?"_ |
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
┌──────────────────────────────────────────────┐
|
|
55
|
+
Your question │"The Weeping Woman was painted by Picasso." │
|
|
56
|
+
└──────────────────────┬───────────────────────┘
|
|
57
|
+
▼
|
|
58
|
+
🔎 Retrieve resonate the query against the memory
|
|
59
|
+
· "… painted by … → the painter" (a learned pattern)
|
|
60
|
+
· "Picasso → co-founded the Cubist movement"
|
|
61
|
+
▼
|
|
62
|
+
🧠 Deduce connect · derive · compose
|
|
63
|
+
· lift the painter from a sentence never seen
|
|
64
|
+
· follow that name onward to what it implies
|
|
65
|
+
▼
|
|
66
|
+
✅ Answer "Pablo Picasso co-founded the Cubist movement"
|
|
67
|
+
(a fact that appears in no word of the question)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Retrieval and reasoning are not two bolted-together stages — they are **one
|
|
71
|
+
search** over **one memory**, which is why the answer can be something no single
|
|
72
|
+
stored fact contains. Watch it happen below.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## ✦ Why Sema
|
|
77
|
+
|
|
78
|
+
<table>
|
|
79
|
+
<tr>
|
|
80
|
+
<td width="50%" valign="top">
|
|
81
|
+
|
|
82
|
+
### 🧩 Symbolic, not statistical
|
|
83
|
+
|
|
84
|
+
Knowledge is stored as a **content-addressed graph**, not smeared across a
|
|
85
|
+
weight matrix. Every fact is an edge you can point at. Nothing is hallucinated
|
|
86
|
+
out of a probability distribution.
|
|
87
|
+
|
|
88
|
+
</td>
|
|
89
|
+
<td width="50%" valign="top">
|
|
90
|
+
|
|
91
|
+
### 🔀 Retrieval and reasoning, unified
|
|
92
|
+
|
|
93
|
+
Retrieval and reasoning are **one mechanism**, not a brittle pipeline of bolted-
|
|
94
|
+
together components. A query enters the graph where it _resonates_ and a single
|
|
95
|
+
lightest-derivation search composes the answer.
|
|
96
|
+
|
|
97
|
+
</td>
|
|
98
|
+
</tr>
|
|
99
|
+
<tr>
|
|
100
|
+
<td width="50%" valign="top">
|
|
101
|
+
|
|
102
|
+
### 🔍 Fully auditable
|
|
103
|
+
|
|
104
|
+
Every answer is a **derivation** over explicit facts. No black box. Trace any
|
|
105
|
+
output back to the exact deposits that produced it — a hard requirement for
|
|
106
|
+
regulated, high-stakes, and safety-critical deployments.
|
|
107
|
+
|
|
108
|
+
</td>
|
|
109
|
+
<td width="50%" valign="top">
|
|
110
|
+
|
|
111
|
+
### ♻️ Deterministic & reproducible
|
|
112
|
+
|
|
113
|
+
Same seed + same bytes → **identical result, every time.** No temperature, no
|
|
114
|
+
sampling, no drift between runs. Reproducibility is a property of the
|
|
115
|
+
architecture, not a flag you toggle.
|
|
116
|
+
|
|
117
|
+
</td>
|
|
118
|
+
</tr>
|
|
119
|
+
<tr>
|
|
120
|
+
<td width="50%" valign="top">
|
|
121
|
+
|
|
122
|
+
### ⚡ Instant training
|
|
123
|
+
|
|
124
|
+
Training **is** depositing — one pass, no epochs, no gradient descent, no
|
|
125
|
+
fine-tuning jobs. Teach it a fact and it knows the fact. Now.
|
|
126
|
+
|
|
127
|
+
</td>
|
|
128
|
+
<td width="50%" valign="top">
|
|
129
|
+
|
|
130
|
+
### 🔒 Total data sovereignty
|
|
131
|
+
|
|
132
|
+
Runs entirely on **your** hardware. No API calls, no telemetry, no weights to
|
|
133
|
+
leak. Everything a trained mind knows lives in a few files on your disk.
|
|
134
|
+
|
|
135
|
+
</td>
|
|
136
|
+
</tr>
|
|
137
|
+
</table>
|
|
138
|
+
|
|
139
|
+
> [!TIP]
|
|
140
|
+
> **No GPU. No cluster. No cloud bill.** Sema runs on an ordinary CPU with a
|
|
141
|
+
> tiny memory footprint, because it never multiplies a weight matrix — it walks
|
|
142
|
+
> a graph. The economics of deploying intelligence change completely.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## ✦ See it think
|
|
147
|
+
|
|
148
|
+
Give Sema four plain notes — the way you'd jot them down — then ask things **no
|
|
149
|
+
note answers**. From three worked examples it learns the _shape_ of "X was
|
|
150
|
+
painted by Y", lifts the painter out of a sentence it has **never seen**, and —
|
|
151
|
+
in the same pass — reasons onward to a separate fact about that painter. The
|
|
152
|
+
reply contains no word from the question: it is **retrieval, generalization, and
|
|
153
|
+
reasoning composing as a single act**.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
// demo.ts — one short session that drives the WHOLE pipeline from one memory.
|
|
157
|
+
//
|
|
158
|
+
// We give Sema a handful of plain notes, then ask things that no single note
|
|
159
|
+
// answers. The headline query is the third one: from three worked examples Sema
|
|
160
|
+
// learns the shape of "X was painted by Y", lifts the painter out of a sentence
|
|
161
|
+
// it has NEVER seen, and then — in the same pass — reasons forward to a separate
|
|
162
|
+
// fact about that painter. The reply contains no word from the question. That is
|
|
163
|
+
// retrieval, generalization, and reasoning composing as a single act, with every
|
|
164
|
+
// step traceable back to the notes behind it.
|
|
165
|
+
|
|
166
|
+
import { Mind } from "../src/index.js";
|
|
167
|
+
import { SQliteStore } from "../src/store-sqlite.js";
|
|
168
|
+
|
|
169
|
+
async function main(): Promise<void> {
|
|
170
|
+
const mind = new Mind({ store: new SQliteStore({ path: ":memory:" }) });
|
|
171
|
+
const ask = async (q: string) => (await mind.respondText(q)).trim();
|
|
172
|
+
|
|
173
|
+
// ── Jot down what we know. Each line is just (context → what follows). ──
|
|
174
|
+
await mind.ingest([
|
|
175
|
+
// One relation, shown three times — a pattern taught purely by example:
|
|
176
|
+
["The Mona Lisa was painted by Leonardo da Vinci.", "Leonardo da Vinci"],
|
|
177
|
+
["The Starry Night was painted by Vincent van Gogh.", "Vincent van Gogh"],
|
|
178
|
+
[
|
|
179
|
+
"The Night Watch was painted by Rembrandt van Rijn.",
|
|
180
|
+
"Rembrandt van Rijn",
|
|
181
|
+
],
|
|
182
|
+
// One stray fact, keyed on a name none of the examples mention:
|
|
183
|
+
["Pablo Picasso", "Pablo Picasso co-founded the Cubist movement"],
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
// 1) GENERALIZE — apply the learned pattern to an unseen sentence and read out
|
|
187
|
+
// the painter. "Pablo Picasso" was never given as an answer; Sema locates it
|
|
188
|
+
// by analogy to the three examples.
|
|
189
|
+
console.log(await ask("The Weeping Woman was painted by Pablo Picasso."));
|
|
190
|
+
// → "Pablo Picasso co-founded the Cubist movement"
|
|
191
|
+
// …and, having found the painter, it KEEPS GOING: the name bridges into the
|
|
192
|
+
// one fact it holds about him. The answer appears in no word of the question.
|
|
193
|
+
|
|
194
|
+
// 2) COMPUTE — exact arithmetic, grounded right where the notes go silent.
|
|
195
|
+
console.log(await ask("a museum charges 12*4 for a family ticket"));
|
|
196
|
+
// → "48"
|
|
197
|
+
|
|
198
|
+
await mind.store.close();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
main();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
Pablo Picasso co-founded the Cubist movement
|
|
206
|
+
48
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
> [!NOTE]
|
|
210
|
+
> This is **[example/demo.ts](example/demo.ts)**, verbatim — run it yourself
|
|
211
|
+
> with `npm run demo`. Look closely at the first answer: the question names a
|
|
212
|
+
> painting Sema was never shown and asks nothing explicit, yet the reply is a
|
|
213
|
+
> fact about Picasso that appears **nowhere** in the question. Sema generalized
|
|
214
|
+
> "_painted by_" from three examples to recognize _Pablo Picasso_ as the answer
|
|
215
|
+
> slot, then followed that name to the one thing it knows about him — retrieval,
|
|
216
|
+
> an analogy, and a reasoning hop, in one query. The second answer is exact, not
|
|
217
|
+
> a plausible-looking guess. Every step traces back to the four notes above.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## ✦ Engineered from three solved problems
|
|
222
|
+
|
|
223
|
+
Sema is composed of three self-contained, independently documented engines. They
|
|
224
|
+
are fully decoupled — Sema reaches them only through interfaces.
|
|
225
|
+
|
|
226
|
+
| Engine | What it solves | Result |
|
|
227
|
+
| :---------------- | :----------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
|
|
228
|
+
| **`rabitq-hnsw`** | _"Given a vector, find the nodes whose gist resonates with it — fast, at scale, on disk."_ | HNSW over 1-bit RaBitQ codes · ~32× compression · bounded RAM · sub-linear queries |
|
|
229
|
+
| **`derive`** | _"Explore a huge implicit space of derivations and return the single lightest one."_ | adapted A\*LD (adapted A\* Lightest Derivation) over a weighted deduction hypergraph — Sema's thinking _is_ one call to this |
|
|
230
|
+
| **`alu`** | _"Compute, exactly and symbolically, the things that are rules, not facts."_ | A tiny irreducible kernel from which arithmetic, logic, and n-dimensional computation are derived |
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## ✦ Learn more
|
|
235
|
+
|
|
236
|
+
| Document | What's inside |
|
|
237
|
+
| :------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
238
|
+
| 📘 **[HOW_IT_WORKS.md](HOW_IT_WORKS.md)** | The full theory: vector symbolic architectures, the Merkle DAG, distributional halos, weighted deduction — concepts, diagrams, and extensive pseudocode. |
|
|
239
|
+
| 🛠️ **[AGENTS.md](AGENTS.md)** | The development manual: repo layout, build/test, internals, invariants, and recipes for extending the system. |
|
|
240
|
+
| ⚖️ **[LICENSE.md](LICENSE.md)** | PolyForm Noncommercial License 1.0.0. |
|
|
241
|
+
| 💼 **[COMMERCIAL-LICENSE.md](COMMERCIAL-LICENSE.md)** | Commercial licensing terms and contact. |
|
|
242
|
+
| 🤗 **[Trained examples](https://huggingface.co/buckets/hviana/sema-trained-v1)** | Pre-trained memory files you can download and use directly. |
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
<div align="center">
|
|
247
|
+
|
|
248
|
+
## ⚖️ Licensing & compliance — please read
|
|
249
|
+
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
> [!WARNING]
|
|
253
|
+
> **Sema is the product of serious, sustained research — and it is protected.**
|
|
254
|
+
> It is released under the **PolyForm Noncommercial License 1.0.0**. Personal
|
|
255
|
+
> study, academic research, experimentation, and use by noncommercial
|
|
256
|
+
> organizations are welcome and explicitly permitted.
|
|
257
|
+
|
|
258
|
+
> [!CAUTION]
|
|
259
|
+
> **Commercial use requires a separate paid license.** This includes — but is
|
|
260
|
+
> not limited to — use by a company; use to provide paid services or serve
|
|
261
|
+
> clients; use inside a SaaS, hosted product, or any revenue-generating
|
|
262
|
+
> platform; and use to reduce business costs or support business operations.
|
|
263
|
+
>
|
|
264
|
+
> Operating Sema commercially (artifacts and algorithmic logic) without a
|
|
265
|
+
> license is a violation of its terms. See
|
|
266
|
+
> **[COMMERCIAL-LICENSE.md](COMMERCIAL-LICENSE.md)** to obtain one, and
|
|
267
|
+
> **[TRADEMARKS.md](TRADEMARKS.md)** — the **Sema** name, logos, and brand are
|
|
268
|
+
> _not_ covered by the source license.
|
|
269
|
+
|
|
270
|
+
<div align="center">
|
|
271
|
+
|
|
272
|
+
**Respecting these terms funds the research that makes work like this
|
|
273
|
+
possible.** If Sema creates value for your business, license it — and help keep
|
|
274
|
+
independent, weight-free AI research alive.
|
|
275
|
+
|
|
276
|
+
**© Sema Author** — Henrique Viana (creator).
|
|
277
|
+
|
|
278
|
+
## Academic purpose:
|
|
279
|
+
|
|
280
|
+
**hv5088@gmail.com**
|
|
281
|
+
|
|
282
|
+
## Commercial licensing:
|
|
283
|
+
|
|
284
|
+
**reis.marcelo@gmail.com**, **rogernact@gmail.com**
|
|
285
|
+
|
|
286
|
+
**© Sema Supporters** — Marcelo Oliveira dos Reis · Rogerio Nascimento
|
|
287
|
+
|
|
288
|
+
— ⬡ — ⬡ — ⬡ —
|
|
289
|
+
|
|
290
|
+
</div>
|
package/TRADEMARKS.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Trademarks and Brand Assets
|
|
2
|
+
|
|
3
|
+
The software code is licensed under the PolyForm Noncommercial License 1.0.0.
|
|
4
|
+
|
|
5
|
+
The following are not licensed under the software license:
|
|
6
|
+
|
|
7
|
+
- redistribute its algorithmic logic: that is, how algorithms and mathematical
|
|
8
|
+
techniques are combined to develop its machinery;
|
|
9
|
+
- visual identity;
|
|
10
|
+
- project name;
|
|
11
|
+
- logos;
|
|
12
|
+
- icons;
|
|
13
|
+
- brand assets;
|
|
14
|
+
- domain names;
|
|
15
|
+
- product names;
|
|
16
|
+
- visual identity;
|
|
17
|
+
- marketing materials.
|
|
18
|
+
|
|
19
|
+
Permission to use the source code does not grant permission to use the brand.
|
package/example/demo.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// demo.ts — one short session that drives the WHOLE pipeline from one memory.
|
|
2
|
+
//
|
|
3
|
+
// We give Sema a handful of plain notes, then ask things that no single note
|
|
4
|
+
// answers. The headline query is the third one: from three worked examples Sema
|
|
5
|
+
// learns the shape of "X was painted by Y", lifts the painter out of a sentence
|
|
6
|
+
// it has NEVER seen, and then — in the same pass — reasons forward to a separate
|
|
7
|
+
// fact about that painter. The reply contains no word from the question. That is
|
|
8
|
+
// retrieval, generalization, and reasoning composing as a single act, with every
|
|
9
|
+
// step traceable back to the notes behind it.
|
|
10
|
+
|
|
11
|
+
import { Mind } from "../src/index.js";
|
|
12
|
+
import { SQliteStore } from "../src/store-sqlite.js";
|
|
13
|
+
|
|
14
|
+
async function main(): Promise<void> {
|
|
15
|
+
const mind = new Mind({ store: new SQliteStore({ path: ":memory:" }) });
|
|
16
|
+
const ask = async (q: string) => (await mind.respondText(q)).trim();
|
|
17
|
+
|
|
18
|
+
// ── Jot down what we know. Each line is just (context → what follows). ──
|
|
19
|
+
await mind.ingest([
|
|
20
|
+
// One relation, shown three times — a pattern taught purely by example:
|
|
21
|
+
["The Mona Lisa was painted by Leonardo da Vinci.", "Leonardo da Vinci"],
|
|
22
|
+
["The Starry Night was painted by Vincent van Gogh.", "Vincent van Gogh"],
|
|
23
|
+
[
|
|
24
|
+
"The Night Watch was painted by Rembrandt van Rijn.",
|
|
25
|
+
"Rembrandt van Rijn",
|
|
26
|
+
],
|
|
27
|
+
// One stray fact, keyed on a name none of the examples mention:
|
|
28
|
+
["Pablo Picasso", "Pablo Picasso co-founded the Cubist movement"],
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
// 1) GENERALIZE — apply the learned pattern to an unseen sentence and read out
|
|
32
|
+
// the painter. "Pablo Picasso" was never given as an answer; Sema locates it
|
|
33
|
+
// by analogy to the three examples.
|
|
34
|
+
console.log(await ask("The Weeping Woman was painted by Pablo Picasso."));
|
|
35
|
+
// → "Pablo Picasso co-founded the Cubist movement"
|
|
36
|
+
// …and, having found the painter, it KEEPS GOING: the name bridges into the
|
|
37
|
+
// one fact it holds about him. The answer appears in no word of the question.
|
|
38
|
+
|
|
39
|
+
// 2) COMPUTE — exact arithmetic, grounded right where the notes go silent.
|
|
40
|
+
console.log(await ask("a museum charges 12*4 for a family ticket"));
|
|
41
|
+
// → "48"
|
|
42
|
+
|
|
43
|
+
await mind.store.close();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main();
|