@hviana/sema 0.9.3 → 0.9.4
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/docs/INDEX.md +4 -0
- package/docs/PHILOSOPHY.md +317 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
package/docs/INDEX.md
CHANGED
|
@@ -62,6 +62,10 @@ proof in `test/` (pins that fail when the law is broken).
|
|
|
62
62
|
|
|
63
63
|
## Cross-cutting
|
|
64
64
|
|
|
65
|
+
- `docs/PHILOSOPHY.md` — the path of information, end to end: how a deposit
|
|
66
|
+
becomes a content-addressed tree and DAG, the two vector spaces (gist: form;
|
|
67
|
+
halo: use), attention built on the structure, how answers are composed and
|
|
68
|
+
priced, and the hypotheses the path invites.
|
|
65
69
|
- `docs/INVARIANTS.md` — the five invariants (determinism, derived thresholds,
|
|
66
70
|
exact-decides, one cost currency, bounded reads) with file-level routing.
|
|
67
71
|
- `docs/failures/tempting-but-wrong.md` — refuted simplifications that passed
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Philosophy — The Path of Information
|
|
2
|
+
|
|
3
|
+
`docs/INDEX.md` routes the laws. This file follows one piece of information from
|
|
4
|
+
the moment it enters Sema to the moment it is used, and says at each step what
|
|
5
|
+
happens, why it must happen that way, and what it makes possible. One principle
|
|
6
|
+
runs through the whole path:
|
|
7
|
+
|
|
8
|
+
> **Keep exactly what was given. Build ways of finding it. Decide only on what
|
|
9
|
+
> was kept. Charge for what was not found.**
|
|
10
|
+
|
|
11
|
+
Every structure below is either something kept (exact, it may decide) or a way
|
|
12
|
+
of finding (approximate, it may only propose). Holding that distinction is what
|
|
13
|
+
lets a reader predict how any part of Sema behaves.
|
|
14
|
+
|
|
15
|
+
## 1. Information enters
|
|
16
|
+
|
|
17
|
+
**What enters.** A deposit is a pair, a context and what followed it, or a bare
|
|
18
|
+
experience. That is the only relation Sema assumes of the world: _this came
|
|
19
|
+
after that_. It imposes no schema, no entities and no types. Everything else
|
|
20
|
+
must be discovered from what follows what.
|
|
21
|
+
|
|
22
|
+
**As bytes.** There is no tokenizer, no vocabulary and no language. A modality
|
|
23
|
+
is only a reading order: text is read as written, and a grid along a Hilbert
|
|
24
|
+
curve, which keeps most of the plane's locality in the stream. Whatever can be
|
|
25
|
+
read as a stream can be learnt.
|
|
26
|
+
|
|
27
|
+
**Into a tree, cut by the content itself.** A rolling hash runs over the bytes.
|
|
28
|
+
Where it vanishes, a cut falls, and the more digits it vanishes on, the higher
|
|
29
|
+
the cut's level. Higher cuts nest inside lower ones, so the stream folds into a
|
|
30
|
+
tree of about `W` children per node (`W` = 4 by default), level by level
|
|
31
|
+
(`fold-contract.md`). There are three reasons for this shape:
|
|
32
|
+
|
|
33
|
+
- **Content-defined cuts make identity independent of position.** A phrase is
|
|
34
|
+
cut the same way wherever it occurs, so in two different deposits it is the
|
|
35
|
+
same subtree. After a shift, 99.7% of cuts survive, against 14.3% for a fixed
|
|
36
|
+
grid.
|
|
37
|
+
- **A tree, not a flat list.** Recurrence happens at every scale: a word, a
|
|
38
|
+
phrase, a sentence. The hierarchy makes every scale a node, so recurrence is
|
|
39
|
+
caught wherever it happens, and an edit touches only the path from the change
|
|
40
|
+
to the root.
|
|
41
|
+
- **Nothing is imposed that a later question could not reproduce.** No turn
|
|
42
|
+
boundaries, no metadata: a question will be cut by the same rule from its own
|
|
43
|
+
bytes, and any cut it could not reproduce would make the same thing two
|
|
44
|
+
things. When the two sides disagreed, alignment went quadratic (5.2M cells
|
|
45
|
+
against 0) and turns asked verbatim stopped resolving to themselves.
|
|
46
|
+
|
|
47
|
+
**Interned by content.** Every subtree becomes a node named by what it contains:
|
|
48
|
+
a branch by its children, a short run by its bytes. The same subtree in a
|
|
49
|
+
thousand deposits is one node with a thousand parents, so the store is a DAG,
|
|
50
|
+
not a forest. Every window of `W−1` and `W` bytes is also indexed as a node of
|
|
51
|
+
its own and linked to the chunks that contain it, so a span can be found
|
|
52
|
+
whatever the fold did around it. Teaching the same thing twice creates no
|
|
53
|
+
structure.
|
|
54
|
+
|
|
55
|
+
**Linked by succession.** The context's root gets an edge to the continuation's
|
|
56
|
+
root. Each suffix of the context that is already a known form inherits that edge
|
|
57
|
+
too, and inside a bare experience the parts are chained in order. An edge is a
|
|
58
|
+
unique pair, so how many contexts lead to a continuation counts distinct
|
|
59
|
+
contexts, not repetitions.
|
|
60
|
+
|
|
61
|
+
**What this structure can answer, exactly:**
|
|
62
|
+
|
|
63
|
+
- **Is this stored?** Fold it and look the name up. One byte apart is another
|
|
64
|
+
name.
|
|
65
|
+
- **What contains this, and what is it part of?** Climb the parents and
|
|
66
|
+
containers.
|
|
67
|
+
- **What followed this?** Read its edges.
|
|
68
|
+
- **How common is this?** Count the contexts that reach it: a minority
|
|
69
|
+
discriminates, and what reaches nearly everything is scaffolding
|
|
70
|
+
(`commonality.md`).
|
|
71
|
+
- **What of a question is already known?** Recognition decomposes the question
|
|
72
|
+
into every stored form inside it that leads somewhere, with a bounded number
|
|
73
|
+
of probes per byte.
|
|
74
|
+
|
|
75
|
+
**What it cannot answer:** what is _near_. A content address destroys locality
|
|
76
|
+
on purpose, because that is what makes it a name. `colour` and `colours` are as
|
|
77
|
+
far apart, by name, as `colour` and `Zanzibar`. Everything from here on exists
|
|
78
|
+
because of that gap.
|
|
79
|
+
|
|
80
|
+
## 2. Two ways of being near
|
|
81
|
+
|
|
82
|
+
Every node also gets vectors in a high-dimensional space (a vector-symbolic
|
|
83
|
+
architecture: Plate 1995; Kanerva 2009). There are two of them, because there
|
|
84
|
+
are two independent ways for things to be near.
|
|
85
|
+
|
|
86
|
+
**The gist: nearness of form.** Each byte value has a vector from an alphabet
|
|
87
|
+
built by refinement (16 coarse directions, then 64, then 256), so neighbouring
|
|
88
|
+
values resemble each other. A node's gist binds each child to its position, by a
|
|
89
|
+
fixed permutation per seat, counted from both ends so that growth at one edge
|
|
90
|
+
keeps the other edge's coordinates, and then adds them up. The fold is linear,
|
|
91
|
+
so the cosine of two gists reads how many bytes they share in place. The gist
|
|
92
|
+
exists at birth: it is computed from the bytes alone. It puts `colour` near
|
|
93
|
+
`colours`.
|
|
94
|
+
|
|
95
|
+
**The halo: nearness of use.** Each time a fact is deposited, two pours happen:
|
|
96
|
+
|
|
97
|
+
- every newly seen part of the context receives the continuation's signature, in
|
|
98
|
+
the seat for _what it led to_;
|
|
99
|
+
- the continuation receives each part's signature, in the seat for _what led to
|
|
100
|
+
it_.
|
|
101
|
+
|
|
102
|
+
A signature is keyed on a node's identity, never on its gist. Read as whole
|
|
103
|
+
partners, company would almost never recur, since whole deposits rarely repeat.
|
|
104
|
+
So each partner contributes its own signature together with a sketch of its
|
|
105
|
+
constituents: `√D` of them, the capacity of a superposition before each term
|
|
106
|
+
falls below noise, with scaffolding excluded (`halo-sketch.md`). Two words that
|
|
107
|
+
never meet can therefore still share the _kinds_ of things around them. Each
|
|
108
|
+
episode adds one unit, by addition, so order is forgotten and proportion kept.
|
|
109
|
+
The halo is earned by experience. It puts `colour` near `hue`.
|
|
110
|
+
|
|
111
|
+
**Why two, and why kept apart.** Form and use are different axes of meaning, and
|
|
112
|
+
neither predicts the other. The halo is built from identities and never from
|
|
113
|
+
gists, so that resemblance of spelling cannot leak into resemblance of use. When
|
|
114
|
+
the two agree, it is corroboration, not echo.
|
|
115
|
+
|
|
116
|
+
**Why vectors at all, and why they never decide.** A vector restores the
|
|
117
|
+
locality the name destroyed. An index over the vectors (RaBitQ-IVF) finds the
|
|
118
|
+
near ones among millions in one query. But a vector is a lossy summary, and its
|
|
119
|
+
score is an estimate. So the space proposes and the structure decides
|
|
120
|
+
(`exact-vs-approximate.md`). The bars are set against the space's own chance:
|
|
121
|
+
random vectors are nearly orthogonal, with noise `1/√D`, so a resemblance counts
|
|
122
|
+
at `3/√D`, and two halos share a concept at `0.5 + 0.5/√D` (`thresholds.md`).
|
|
123
|
+
The single exception is the store's near-merge at deposit, bounded to one window
|
|
124
|
+
of difference.
|
|
125
|
+
|
|
126
|
+
**Two memories.** The deposits are a record: verbatim, enumerable, each with
|
|
127
|
+
provenance. The halos are a statistic accumulated over that record. This is the
|
|
128
|
+
episodic/semantic distinction (Tulving 1972) with fixed roles: **the statistic
|
|
129
|
+
proposes, the record decides.** A halo can say that two things are of a kind; it
|
|
130
|
+
never says they are the same thing, and it never establishes a fact.
|
|
131
|
+
|
|
132
|
+
**How the three readings are ordered.** Where Sema looks for a span, it tries
|
|
133
|
+
exact bytes first, then the halo's role, then the gist (`match.ts`). A form
|
|
134
|
+
counts as knowledge only if it _leads somewhere_: it has a continuation, or it
|
|
135
|
+
has a halo. Something that never led anywhere is not used.
|
|
136
|
+
|
|
137
|
+
**What the vectors add to reasoning.** They add three things:
|
|
138
|
+
|
|
139
|
+
- **Paraphrase:** a question one byte off its stored twin is found by its gist.
|
|
140
|
+
- **Substitution:** a form with no continuation of its own may borrow a halo
|
|
141
|
+
sibling's, at the price of a concept hop.
|
|
142
|
+
- **Imagination, bounded:** binding stored parts gives the gist of a whole never
|
|
143
|
+
seen, which can be searched for. That search is the most approximate tier of
|
|
144
|
+
all, and is gated hardest, because nothing about it is contained in bytes.
|
|
145
|
+
|
|
146
|
+
## 3. A question arrives
|
|
147
|
+
|
|
148
|
+
The question is folded by the same rule as every deposit, and the identity fold
|
|
149
|
+
names each part by asking the store as it folds. So perceiving a question is
|
|
150
|
+
already recognising what of it memory holds; representation and search begin as
|
|
151
|
+
one act. Recognition returns the question's _sites_: every stored form inside it
|
|
152
|
+
that leads somewhere, each with its exact identity.
|
|
153
|
+
|
|
154
|
+
## 4. Attention, built on the structure
|
|
155
|
+
|
|
156
|
+
The sites say what the question contains. They do not say what the question is
|
|
157
|
+
_about_, meaning which stored contexts its parts point to together. That is
|
|
158
|
+
attention's job, the consensus climb (`attention.ts`).
|
|
159
|
+
|
|
160
|
+
1. **Regions.** Every node of the question's tree, and every recognised site, is
|
|
161
|
+
a region.
|
|
162
|
+
2. **Lookup.** A region that is a stored form looks itself up exactly. Any other
|
|
163
|
+
region searches by gist, and pays a margin: it must beat the best rival
|
|
164
|
+
conclusion by the noise floor, scaled by how much of it is not stored.
|
|
165
|
+
3. **Climb.** Each region climbs the DAG, through parents and containers, to the
|
|
166
|
+
stored contexts it reaches. The climb stops at a named saturation when a node
|
|
167
|
+
reaches more than `√N` contexts, because past that point reading further
|
|
168
|
+
cannot discriminate (`saturation.md`).
|
|
169
|
+
4. **Weigh by rarity.** A region that reaches `c` of `N` contexts weighs
|
|
170
|
+
`ln(N/c)`. This is inverse document frequency, read over structure.
|
|
171
|
+
5. **Agree.** Independent regions add, pooled in the (+, +) semiring of the same
|
|
172
|
+
deduction engine the search uses.
|
|
173
|
+
6. **Join.** When two regions point to different contexts, the stored whole that
|
|
174
|
+
contains both is sought, by exact junction first, then through halo synonyms,
|
|
175
|
+
then by an imagined whole. Exact joint evidence explains the separate votes
|
|
176
|
+
away.
|
|
177
|
+
|
|
178
|
+
The output is a set of points of attention: stored contexts where independent
|
|
179
|
+
parts of the question agree, ranked.
|
|
180
|
+
|
|
181
|
+
Compared with a transformer's attention, which is soft content addressing over a
|
|
182
|
+
context window:
|
|
183
|
+
|
|
184
|
+
- **The keys are stored contexts,** reached by containment across the whole
|
|
185
|
+
memory, not tokens in a window. This is cross-attention, from the question
|
|
186
|
+
into memory.
|
|
187
|
+
- **The weights are rarity,** derived and not learned.
|
|
188
|
+
- **The votes are absolute.** A softmax must attend somewhere, because its
|
|
189
|
+
weights sum to one. Sema's anchors count only above floors derived from `D`
|
|
190
|
+
and `N`, so attention can come back empty.
|
|
191
|
+
- **Nothing is blended.** Mixing values would produce bytes nobody deposited.
|
|
192
|
+
Attention selects, and does not mix.
|
|
193
|
+
- **Exact evidence outranks resemblance.** Only exact evidence may explain a
|
|
194
|
+
vote away.
|
|
195
|
+
|
|
196
|
+
Attention is also spent, not assumed. The climb is the shared analysis the
|
|
197
|
+
market defers until no cheaper bound can rule it out (`mechanism-market.md`).
|
|
198
|
+
|
|
199
|
+
**Why this is the right notion of relevance.** Every judgement of relevance in
|
|
200
|
+
Sema divides a population into what it shares (frame) and what varies (filler).
|
|
201
|
+
Commonality and discrimination are the two sides of that one cut, and the answer
|
|
202
|
+
depends on the population. Sema reads three populations and never confuses them:
|
|
203
|
+
the corpus, the cohort of structures aligned to this question, and the
|
|
204
|
+
containers of a window (`commonality.md`). The rarity weighting is the graded
|
|
205
|
+
form of the cut over the corpus. Attention's deeper role is to _choose the
|
|
206
|
+
population_: its points are the cohort the next steps cut.
|
|
207
|
+
|
|
208
|
+
## 5. How it is used
|
|
209
|
+
|
|
210
|
+
**Many ways of thinking.** Each grounding mechanism reads the same material
|
|
211
|
+
differently:
|
|
212
|
+
|
|
213
|
+
- `cover` composes the question from its sites and follows their edges, by graph
|
|
214
|
+
search.
|
|
215
|
+
- CAST aligns the attention points to the question and cuts that cohort into
|
|
216
|
+
frame and filler. It then carries structure between them: substitution,
|
|
217
|
+
redirection, comparison.
|
|
218
|
+
- `confluence` intersects what independent anchors share, as long as it is not
|
|
219
|
+
scaffolding.
|
|
220
|
+
- `extraction` reads out a located frame.
|
|
221
|
+
- `reference` learns a frame from worked examples and voices its slot with the
|
|
222
|
+
asker's own bytes.
|
|
223
|
+
- `recall` takes the nearest stored form by gist.
|
|
224
|
+
- `prefix-completion` completes a known beginning.
|
|
225
|
+
- The ALU computes, and what it computes is authoritative.
|
|
226
|
+
|
|
227
|
+
**One price.** Every candidate weighs `moves + PASS·unaccounted`, and `PASS` per
|
|
228
|
+
byte of unexplained question outweighs any move (`cost-model.md`). The price is
|
|
229
|
+
not confidence. It is how much of the question remains unaccounted for, so the
|
|
230
|
+
winner is the reading that explains the most. When nothing accounts for the
|
|
231
|
+
question, silence wins, and silence is a first-class answer. An answer that is
|
|
232
|
+
only near says so.
|
|
233
|
+
|
|
234
|
+
**Reasoning that answers to the question.** The winner may be extended, step by
|
|
235
|
+
step, along succession. A step is admitted only if it closes the derivation,
|
|
236
|
+
moves to structure not yet consumed, or carries what the question still owes
|
|
237
|
+
(`closure.md`). A step counts as _named_ when the question, together with the
|
|
238
|
+
node the step stands on, witnesses one of the contexts that establish it
|
|
239
|
+
(`evidence.md`). A step the question did not name is paid from its remaining
|
|
240
|
+
debt. The question owns the inference, so a chain cannot wander off to a fact
|
|
241
|
+
nobody asked for.
|
|
242
|
+
|
|
243
|
+
**Generalization, read and never stored.** When no context is named outright,
|
|
244
|
+
attention's points may hold another instance of the question.
|
|
245
|
+
`Where was Peter Jackson born?` shares the frame of
|
|
246
|
+
`Where was the director of film Beat Girl born?`. Peter Jackson's fact is also
|
|
247
|
+
established by `Peter Jackson place of birth`, which is how the corpus spells
|
|
248
|
+
the relation. The node at hand, `Edmond T. Gréville`, is put into that frame,
|
|
249
|
+
and the result is looked up by content.
|
|
250
|
+
|
|
251
|
+
This is anti-unification (Plotkin 1970): keep what two instances share, put a
|
|
252
|
+
variable where they differ. It is admitted only under three conditions:
|
|
253
|
+
|
|
254
|
+
- the variable is a thing the store knows;
|
|
255
|
+
- two instances agree;
|
|
256
|
+
- what the corpus files under one filler is not credited to the frame.
|
|
257
|
+
|
|
258
|
+
The third condition comes from a real failure. Two people born in Wellington
|
|
259
|
+
once gave an unknown `Zorblax` the same birthplace (`test/76`), Goodman's (1955)
|
|
260
|
+
accidental generalization. The frame is never stored, and neither is any answer.
|
|
261
|
+
A conclusion kept as a deposit would become evidence for itself.
|
|
262
|
+
|
|
263
|
+
**Every answer replays.** The derivation is a hyperpath in an AND/OR hypergraph
|
|
264
|
+
whose axioms are stored nodes (`src/derive/`). Its trace replays byte for byte,
|
|
265
|
+
and ties are broken by the order of teaching, never by chance
|
|
266
|
+
(`determinism.md`). A correction erases nothing. It is a further deposit, and it
|
|
267
|
+
prevails by evidence.
|
|
268
|
+
|
|
269
|
+
## 6. The path, seen whole
|
|
270
|
+
|
|
271
|
+
| Step | What it adds | Kept or finding | It may |
|
|
272
|
+
| ----------------- | ---------------------------------------------- | --------------- | ---------------- |
|
|
273
|
+
| bytes, fold | one tree per stream, cut by content | kept | decide identity |
|
|
274
|
+
| DAG, edges | identity, parthood, succession, commonality | kept | decide |
|
|
275
|
+
| gist | nearness of form | finding | propose |
|
|
276
|
+
| halo | nearness of use | finding | propose |
|
|
277
|
+
| recognition | what of the question is known | kept | decide |
|
|
278
|
+
| attention | where the question's parts agree; a population | finding | propose |
|
|
279
|
+
| mechanisms | readings of the same material | both | offer candidates |
|
|
280
|
+
| price and closure | what remains unexplained; what may follow | kept | decide |
|
|
281
|
+
|
|
282
|
+
Representation, search and reasoning are separate modules, but not separate
|
|
283
|
+
ideas. One fold serves deposit and question. One identity serves every lookup.
|
|
284
|
+
One price serves every mechanism. One law admits every step. Everything that
|
|
285
|
+
finds is kept out of every decision, and everything that decides rests on what
|
|
286
|
+
was given.
|
|
287
|
+
|
|
288
|
+
## 7. Hypotheses the path invites
|
|
289
|
+
|
|
290
|
+
Each of these follows from a gap visible on the path, and none is a plan.
|
|
291
|
+
|
|
292
|
+
- **One cut.** Frame against filler is computed in several places: the three
|
|
293
|
+
commonality measures, `frameSlots`, `coInstanceFiller` and CAST's `depth[]`.
|
|
294
|
+
Is it one operation read over different populations, or several, as
|
|
295
|
+
`commonality.md` holds?
|
|
296
|
+
- **Form, use and identity together.** Two forms with near halos that can stand
|
|
297
|
+
for each other in every stored frame — Leibniz's substitution _salva veritate_
|
|
298
|
+
— would be one referent. That is aliases (`Clara Novello` and
|
|
299
|
+
`Clara Anastasia Novello`) seen by the record, with the halo proposing.
|
|
300
|
+
- **Imagination as hypothesis.** Binding stored parts proposes wholes never
|
|
301
|
+
seen, and today it only joins regions. Proposals made this way, then checked
|
|
302
|
+
by content, are abduction with a guaranteed verifier.
|
|
303
|
+
- **Derivations as instances.** Anti-unify derivations, not texts, and `father`
|
|
304
|
+
twice reads as `grandfather` wherever an instance shows it. Derived material
|
|
305
|
+
must never count as a new context.
|
|
306
|
+
- **Richer company.** The halo has two seats, _what it led to_ and _what led to
|
|
307
|
+
it_. What other relations of use would a seat capture, and what would they let
|
|
308
|
+
attention see?
|
|
309
|
+
- **Other streams.** Whatever has a reading order that preserves locality can
|
|
310
|
+
enter by the same path.
|
|
311
|
+
|
|
312
|
+
## References
|
|
313
|
+
|
|
314
|
+
Goodman (1955), _Fact, Fiction, and Forecast_ · Kanerva (2009), _Cognitive
|
|
315
|
+
Computation_ 1(2) · Plate (1995), _IEEE TNN_ 6(3) · Plotkin (1970), _Machine
|
|
316
|
+
Intelligence_ 5 · Tulving (1972), "Episodic and semantic memory", in
|
|
317
|
+
_Organization of Memory_.
|
package/jsr.json
CHANGED