@hviana/sema 0.1.5 → 0.1.7
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 +6 -5
- package/CITATION.cff +49 -0
- package/HOW_IT_WORKS.md +11 -12
- package/README.md +7 -5
- package/dist/example/demo.js +25 -25
- package/dist/example/train_base.d.ts +19 -21
- package/dist/example/train_base.js +1700 -1952
- package/dist/src/alphabet.d.ts +3 -3
- package/dist/src/alphabet.js +24 -27
- package/dist/src/alu/src/alu.d.ts +169 -194
- package/dist/src/alu/src/alu.js +374 -414
- package/dist/src/alu/src/expr.d.ts +36 -43
- package/dist/src/alu/src/expr.js +252 -278
- package/dist/src/alu/src/index.d.ts +9 -98
- package/dist/src/alu/src/index.js +10 -64
- package/dist/src/alu/src/kernel-arith.d.ts +1 -5
- package/dist/src/alu/src/kernel-arith.js +195 -285
- package/dist/src/alu/src/kernel-bits.d.ts +1 -5
- package/dist/src/alu/src/kernel-bits.js +81 -115
- package/dist/src/alu/src/kernel-logic.js +33 -63
- package/dist/src/alu/src/kernel-nd.js +155 -195
- package/dist/src/alu/src/kernel-numeric.d.ts +16 -80
- package/dist/src/alu/src/kernel-numeric.js +259 -331
- package/dist/src/alu/src/operation.d.ts +112 -132
- package/dist/src/alu/src/operation.js +149 -163
- package/dist/src/alu/src/parser.d.ts +168 -175
- package/dist/src/alu/src/parser.js +382 -421
- package/dist/src/alu/src/resonance.d.ts +16 -25
- package/dist/src/alu/src/resonance.js +49 -56
- package/dist/src/alu/src/text.d.ts +3 -7
- package/dist/src/alu/src/text.js +31 -37
- package/dist/src/alu/src/value.d.ts +14 -14
- package/dist/src/alu/src/value.js +150 -160
- package/dist/src/alu/test/alu.test.js +543 -656
- package/dist/src/bytes.d.ts +1 -5
- package/dist/src/bytes.js +33 -40
- package/dist/src/config.d.ts +99 -102
- package/dist/src/config.js +78 -83
- package/dist/src/derive/src/deduction.d.ts +60 -62
- package/dist/src/derive/src/deduction.js +103 -109
- package/dist/src/derive/src/index.d.ts +1 -7
- package/dist/src/derive/src/priority-queue.d.ts +8 -8
- package/dist/src/derive/src/priority-queue.js +57 -61
- package/dist/src/derive/src/rewrite.d.ts +15 -18
- package/dist/src/derive/src/rewrite.js +59 -67
- package/dist/src/derive/src/trie.d.ts +56 -56
- package/dist/src/derive/src/trie.js +175 -179
- package/dist/src/derive/test/derive.test.js +96 -100
- package/dist/src/extension.d.ts +13 -16
- package/dist/src/geometry.d.ts +29 -43
- package/dist/src/geometry.js +324 -268
- package/dist/src/index.d.ts +2 -17
- package/dist/src/index.js +2 -12
- package/dist/src/ingest-cache.d.ts +25 -30
- package/dist/src/ingest-cache.js +108 -127
- package/dist/src/mind/articulation.d.ts +1 -5
- package/dist/src/mind/articulation.js +77 -112
- package/dist/src/mind/attention.d.ts +40 -108
- package/dist/src/mind/attention.js +754 -872
- package/dist/src/mind/canonical.d.ts +4 -19
- package/dist/src/mind/canonical.js +27 -31
- package/dist/src/mind/graph-search.d.ts +201 -225
- package/dist/src/mind/graph-search.js +742 -821
- package/dist/src/mind/index.d.ts +2 -10
- package/dist/src/mind/junction.d.ts +31 -58
- package/dist/src/mind/junction.js +172 -237
- package/dist/src/mind/learning.d.ts +16 -52
- package/dist/src/mind/learning.js +143 -165
- package/dist/src/mind/match.d.ts +20 -69
- package/dist/src/mind/match.js +259 -318
- package/dist/src/mind/mechanisms/alu.js +16 -16
- package/dist/src/mind/mechanisms/cast.d.ts +9 -13
- package/dist/src/mind/mechanisms/cast.js +363 -456
- package/dist/src/mind/mechanisms/confluence.d.ts +8 -12
- package/dist/src/mind/mechanisms/confluence.js +152 -183
- package/dist/src/mind/mechanisms/cover.d.ts +2 -8
- package/dist/src/mind/mechanisms/cover.js +148 -210
- package/dist/src/mind/mechanisms/extraction.d.ts +8 -34
- package/dist/src/mind/mechanisms/extraction.js +234 -288
- package/dist/src/mind/mechanisms/recall.d.ts +6 -10
- package/dist/src/mind/mechanisms/recall.js +141 -185
- package/dist/src/mind/mind.d.ts +194 -155
- package/dist/src/mind/mind.js +392 -289
- package/dist/src/mind/pipeline-mechanism.d.ts +112 -124
- package/dist/src/mind/pipeline-mechanism.js +161 -172
- package/dist/src/mind/pipeline.d.ts +4 -14
- package/dist/src/mind/pipeline.js +125 -189
- package/dist/src/mind/primitives.d.ts +20 -33
- package/dist/src/mind/primitives.js +124 -120
- package/dist/src/mind/rationale.d.ts +86 -98
- package/dist/src/mind/rationale.js +113 -121
- package/dist/src/mind/reasoning.d.ts +2 -13
- package/dist/src/mind/reasoning.js +129 -166
- package/dist/src/mind/recognition.d.ts +1 -4
- package/dist/src/mind/recognition.js +198 -210
- package/dist/src/mind/resonance.d.ts +5 -22
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +6 -25
- package/dist/src/mind/trace.js +50 -58
- package/dist/src/mind/traverse.d.ts +29 -58
- package/dist/src/mind/traverse.js +344 -356
- package/dist/src/mind/types.d.ts +122 -127
- package/dist/src/mind/types.js +60 -69
- package/dist/src/rabitq-ivf/src/database.d.ts +113 -0
- package/dist/src/rabitq-ivf/src/database.js +201 -0
- package/dist/src/rabitq-ivf/src/index.d.ts +7 -0
- package/dist/src/{rabitq-hnsw → rabitq-ivf}/src/index.js +1 -3
- package/dist/src/rabitq-ivf/src/ivf.d.ts +200 -0
- package/dist/src/rabitq-ivf/src/ivf.js +1165 -0
- package/dist/src/rabitq-ivf/src/prng.d.ts +19 -0
- package/dist/src/rabitq-ivf/src/prng.js +36 -0
- package/dist/src/rabitq-ivf/src/rabitq.d.ts +95 -0
- package/dist/src/rabitq-ivf/src/rabitq.js +283 -0
- package/dist/src/sema.d.ts +9 -13
- package/dist/src/sema.js +26 -40
- package/dist/src/store-sqlite.d.ts +171 -166
- package/dist/src/store-sqlite.js +768 -662
- package/dist/src/store.d.ts +597 -630
- package/dist/src/store.js +1434 -1581
- package/dist/src/vec.d.ts +5 -9
- package/dist/src/vec.js +61 -73
- package/example/train_base.ts +33 -15
- package/index.html +65 -0
- package/package.json +1 -1
- package/src/alu/README.md +1 -1
- package/src/alu/src/index.ts +1 -1
- package/src/config.ts +19 -27
- package/src/geometry.ts +93 -1
- package/src/index.ts +6 -11
- package/src/mind/attention.ts +11 -6
- package/src/mind/mechanisms/recall.ts +29 -13
- package/src/mind/mind.ts +250 -19
- package/src/mind/primitives.ts +43 -6
- package/src/mind/recognition.ts +26 -8
- package/src/mind/traverse.ts +47 -0
- package/src/mind/types.ts +20 -21
- package/src/rabitq-ivf/README.md +56 -0
- package/src/rabitq-ivf/src/database.ts +276 -0
- package/src/{rabitq-hnsw → rabitq-ivf}/src/index.ts +2 -5
- package/src/rabitq-ivf/src/ivf.ts +1330 -0
- package/src/{rabitq-hnsw → rabitq-ivf}/src/prng.ts +1 -1
- package/src/store-sqlite.ts +204 -9
- package/src/store.ts +27 -34
- package/test/08-storage.test.mjs +3 -3
- package/test/13-conversation.test.mjs +190 -20
- package/test/14-scaling.test.mjs +2 -2
- package/test/35-ivf.test.mjs +263 -0
- package/test/36-bloom.test.mjs +123 -0
- package/dist/src/rabitq-hnsw/src/database.d.ts +0 -202
- package/dist/src/rabitq-hnsw/src/database.js +0 -405
- package/dist/src/rabitq-hnsw/src/heap.d.ts +0 -22
- package/dist/src/rabitq-hnsw/src/heap.js +0 -94
- package/dist/src/rabitq-hnsw/src/hnsw.d.ts +0 -125
- package/dist/src/rabitq-hnsw/src/hnsw.js +0 -500
- package/dist/src/rabitq-hnsw/src/index.d.ts +0 -15
- package/dist/src/rabitq-hnsw/src/prng.d.ts +0 -19
- package/dist/src/rabitq-hnsw/src/prng.js +0 -38
- package/dist/src/rabitq-hnsw/src/rabitq.d.ts +0 -95
- package/dist/src/rabitq-hnsw/src/rabitq.js +0 -299
- package/dist/src/rabitq-hnsw/src/store.d.ts +0 -162
- package/dist/src/rabitq-hnsw/src/store.js +0 -916
- package/dist/src/rabitq-hnsw/test/hnsw.test.d.ts +0 -1
- package/dist/src/rabitq-hnsw/test/hnsw.test.js +0 -1197
- package/src/rabitq-hnsw/README.md +0 -303
- package/src/rabitq-hnsw/src/database.ts +0 -492
- package/src/rabitq-hnsw/src/heap.ts +0 -90
- package/src/rabitq-hnsw/src/hnsw.ts +0 -514
- package/src/rabitq-hnsw/src/store.ts +0 -994
- package/src/rabitq-hnsw/test/hnsw.test.ts +0 -1213
- /package/src/{rabitq-hnsw → rabitq-ivf}/src/rabitq.ts +0 -0
package/AGENTS.md
CHANGED
|
@@ -44,7 +44,7 @@ store.ts AbstractStore: ALL domain logic of the DAG store
|
|
|
44
44
|
store-sqlite.ts the one concrete backend (thin SQL wrappers)
|
|
45
45
|
geometry.ts + vec/alphabet/sema
|
|
46
46
|
vectors, the fold, and every derived threshold
|
|
47
|
-
derive/ · alu/ · rabitq-
|
|
47
|
+
derive/ · alu/ · rabitq-ivf/
|
|
48
48
|
firewalled sublibraries with their own READMEs and tests
|
|
49
49
|
```
|
|
50
50
|
|
|
@@ -80,7 +80,8 @@ D, the perception window W, or the corpus size N, defined once in
|
|
|
80
80
|
`src/geometry.ts` (`mergeThreshold`, `identityBar`, `reachThreshold`,
|
|
81
81
|
`significanceBar`, `estimatorNoise`, `conceptThreshold`, `consensusFloor`,
|
|
82
82
|
`dominates`, …). `src/config.ts` holds **capacities and budgets only** (cache
|
|
83
|
-
byte budgets, batch sizes,
|
|
83
|
+
byte budgets, batch sizes, vector-index parameters, query k, ALU precision, the
|
|
84
|
+
seed).
|
|
84
85
|
|
|
85
86
|
_Follow it:_ if you are about to add a tunable cutoff to config, derive it in
|
|
86
87
|
`geometry.ts` instead. A threshold knob is a design bug here — one was already
|
|
@@ -360,7 +361,7 @@ story of the fix.
|
|
|
360
361
|
| Post-grounding (reason, fuse, articulate) | `src/mind/reasoning.ts`, `src/mind/articulation.ts` |
|
|
361
362
|
| Rationale / trace | `src/mind/rationale.ts`, `src/mind/trace.ts` |
|
|
362
363
|
| Extension host types | `src/extension.ts` |
|
|
363
|
-
| Sublibraries (own READMEs, own tests) | `src/derive/`, `src/alu/`, `src/rabitq-
|
|
364
|
+
| Sublibraries (own READMEs, own tests) | `src/derive/`, `src/alu/`, `src/rabitq-ivf/` |
|
|
364
365
|
|
|
365
366
|
Mind functions are **free functions over `MindContext`** (`mind/types.ts`), not
|
|
366
367
|
methods — `mind.ts` is a thin assembly that implements the context and
|
|
@@ -453,9 +454,9 @@ against the built `dist/` (`npm test`; one suite:
|
|
|
453
454
|
silence). A "simplification" that fails an existing test is wrong until you
|
|
454
455
|
can argue the _test_ is wrong — several guards exist precisely because a
|
|
455
456
|
plausible simplification once failed a dozen suites.
|
|
456
|
-
- Sublibraries test themselves (`src/{alu,derive,rabitq-
|
|
457
|
+
- Sublibraries test themselves (`src/{alu,derive,rabitq-ivf}/test/`) with zero
|
|
457
458
|
Sema dependency. Keep it so.
|
|
458
|
-
- Performance claims are tested (the rabitq-
|
|
459
|
+
- Performance claims are tested (the rabitq-ivf benchmark asserts sub-linear
|
|
459
460
|
scaling and compression). Changing index behaviour means running it.
|
|
460
461
|
|
|
461
462
|
---
|
package/CITATION.cff
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: >-
|
|
3
|
+
If you use Sema in academic work, please cite the accompanying preprint.
|
|
4
|
+
For software-specific references, you may also cite this repository.
|
|
5
|
+
title: "Sema"
|
|
6
|
+
abstract: >-
|
|
7
|
+
Sema is a non-parametric, instance-based reasoning system built as a
|
|
8
|
+
Vector Symbolic Architecture over content-addressable memory, with
|
|
9
|
+
inference performed by weighted automated deduction.
|
|
10
|
+
type: software
|
|
11
|
+
authors:
|
|
12
|
+
- family-names: "Viana"
|
|
13
|
+
given-names: "Henrique Emanoel"
|
|
14
|
+
orcid: "https://orcid.org/0000-0002-7119-5867"
|
|
15
|
+
affiliation: "NONE"
|
|
16
|
+
repository-code: "https://github.com/hviana/sema"
|
|
17
|
+
url: "https://github.com/hviana/sema"
|
|
18
|
+
license: "PolyForm-Noncommercial-1.0.0"
|
|
19
|
+
version: "0.1.0"
|
|
20
|
+
date-released: "2026-07-16"
|
|
21
|
+
keywords:
|
|
22
|
+
- artificial intelligence
|
|
23
|
+
- cognitive architecture
|
|
24
|
+
- non-parametric reasoning
|
|
25
|
+
- instance-based reasoning
|
|
26
|
+
- vector symbolic architecture
|
|
27
|
+
- hyperdimensional computing
|
|
28
|
+
- content-addressable memory
|
|
29
|
+
- weighted automated deduction
|
|
30
|
+
- symbolic reasoning
|
|
31
|
+
- explainable artificial intelligence
|
|
32
|
+
- TypeScript
|
|
33
|
+
|
|
34
|
+
preferred-citation:
|
|
35
|
+
type: article
|
|
36
|
+
title: "Sema: Reasoning by Example over a Vector-Symbolic Memory"
|
|
37
|
+
authors:
|
|
38
|
+
- family-names: "Viana"
|
|
39
|
+
given-names: "Henrique Emanoel"
|
|
40
|
+
orcid: "https://orcid.org/0000-0002-7119-5867"
|
|
41
|
+
affiliation: "NONE"
|
|
42
|
+
year: 2026
|
|
43
|
+
month: 7
|
|
44
|
+
day: 16
|
|
45
|
+
version: "0.1.0"
|
|
46
|
+
doi: "10.5281/zenodo.21385723"
|
|
47
|
+
url: "https://doi.org/10.5281/zenodo.21385723"
|
|
48
|
+
publisher:
|
|
49
|
+
name: "Zenodo"
|
package/HOW_IT_WORKS.md
CHANGED
|
@@ -575,11 +575,13 @@ controlled amount of recall for sub-linear query time.
|
|
|
575
575
|
|
|
576
576
|
Sema uses two established techniques in combination:
|
|
577
577
|
|
|
578
|
-
- **
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
578
|
+
- **IVF (inverted-file partitioning)** — the collection is split into clusters,
|
|
579
|
+
each with a binary pivot code; a query ranks the pivots and scans only the few
|
|
580
|
+
nearest clusters. Cluster size is bounded (an oversized cluster
|
|
581
|
+
deterministically splits in two), so the work per query is set by the number
|
|
582
|
+
of probes, not by the collection — decisively sub-linear. Inserting is
|
|
583
|
+
route-and-append: one RAM scan of the pivot table, no graph maintenance, so
|
|
584
|
+
ingestion cost stays flat as the collection grows.
|
|
583
585
|
- **RaBitQ 1-bit quantization** (Gao & Long 2024). Each stored vector is
|
|
584
586
|
randomly rotated and reduced to one _sign bit_ per dimension — a 32×
|
|
585
587
|
compression — with an unbiased, theoretically-grounded estimator of the
|
|
@@ -663,7 +665,7 @@ RELATIONS │ continuation edges (what follows what) │
|
|
|
663
665
|
(distributional, §4) │ halos (what company each node keeps) │
|
|
664
666
|
├─────────────────────────────────────────┤
|
|
665
667
|
INDEXES │ gist index + halo index │
|
|
666
|
-
(ANN, §6) │ (
|
|
668
|
+
(ANN, §6) │ (IVF over 1-bit RaBitQ codes) │
|
|
667
669
|
└──────────────────┬──────────────────────┘
|
|
668
670
|
│ axioms & rule candidates
|
|
669
671
|
▼
|
|
@@ -1696,7 +1698,7 @@ requirements:
|
|
|
1696
1698
|
|
|
1697
1699
|
- **ANN index: 1-bit RaBitQ, irreversible.** The same halo vector, projected
|
|
1698
1700
|
through a random rotation and reduced to one sign bit per dimension (32×
|
|
1699
|
-
compression), serves as a search code in the
|
|
1701
|
+
compression), serves as a search code in the IVF index. This code is _never_
|
|
1700
1702
|
decoded back — it only answers "which halos are near this query?" The
|
|
1701
1703
|
estimator is unbiased (expected cosine is recoverable from the bit count), so
|
|
1702
1704
|
ranking quality is preserved despite the loss of reversibility.
|
|
@@ -4124,8 +4126,8 @@ terms of art borrowed from the literature.
|
|
|
4124
4126
|
§4.
|
|
4125
4127
|
- **Hash-consing** — constructing structures modulo equality so equal
|
|
4126
4128
|
substructures are shared. §3.2.
|
|
4127
|
-
- **
|
|
4128
|
-
|
|
4129
|
+
- **IVF** — inverted-file partitioned ANN index; bounded-probe sub-linear search
|
|
4130
|
+
over clustered codes. §6.1.
|
|
4129
4131
|
- **Hilbert curve** — the locality-preserving space-filling curve used to
|
|
4130
4132
|
linearize grids. §6.3.
|
|
4131
4133
|
- **Hyperdimensional computing** — Kanerva's (2009) umbrella term for computing
|
|
@@ -4193,9 +4195,6 @@ Foundations cited in this document, in alphabetical order:
|
|
|
4193
4195
|
Processing Letters 6(1), 1–5.
|
|
4194
4196
|
- Kolodner, J. L. (1992). _An Introduction to Case-Based Reasoning._ Artificial
|
|
4195
4197
|
Intelligence Review 6, 3–34.
|
|
4196
|
-
- Malkov, Y. A. & Yashunin, D. A. (2018). _Efficient and Robust Approximate
|
|
4197
|
-
Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs._ IEEE
|
|
4198
|
-
TPAMI 42(4), 824–836.
|
|
4199
4198
|
- Merkle, R. C. (1987). _A Digital Signature Based on a Conventional Encryption
|
|
4200
4199
|
Function._ Proc. CRYPTO.
|
|
4201
4200
|
- Plate, T. A. (1995). _Holographic Reduced Representations._ IEEE Transactions
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@hviana/sema)
|
|
2
|
+
|
|
1
3
|
<div align="center">
|
|
2
4
|
|
|
3
5
|
```
|
|
@@ -223,11 +225,11 @@ Pablo Picasso co-founded the Cubist movement
|
|
|
223
225
|
Sema is composed of three self-contained, independently documented engines. They
|
|
224
226
|
are fully decoupled — Sema reaches them only through interfaces.
|
|
225
227
|
|
|
226
|
-
| Engine
|
|
227
|
-
|
|
|
228
|
-
| **`rabitq-
|
|
229
|
-
| **`derive`**
|
|
230
|
-
| **`alu`**
|
|
228
|
+
| Engine | What it solves | Result |
|
|
229
|
+
| :--------------- | :----------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| **`rabitq-ivf`** | _"Given a vector, find the nodes whose gist resonates with it — fast, at scale, on disk."_ | Partitioned (IVF) index over 1-bit RaBitQ codes · ~32× compression · bounded RAM · flat inserts, bounded queries |
|
|
231
|
+
| **`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 |
|
|
232
|
+
| **`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
233
|
|
|
232
234
|
---
|
|
233
235
|
|
package/dist/example/demo.js
CHANGED
|
@@ -10,30 +10,30 @@
|
|
|
10
10
|
import { Mind } from "../src/index.js";
|
|
11
11
|
import { SQliteStore } from "../src/store-sqlite.js";
|
|
12
12
|
async function main() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
const mind = new Mind({ store: new SQliteStore({ path: ":memory:" }) });
|
|
14
|
+
const ask = async (q) => (await mind.respondText(q)).trim();
|
|
15
|
+
// ── Jot down what we know. Each line is just (context → what follows). ──
|
|
16
|
+
await mind.ingest([
|
|
17
|
+
// One relation, shown three times — a pattern taught purely by example:
|
|
18
|
+
["The Mona Lisa was painted by Leonardo da Vinci.", "Leonardo da Vinci"],
|
|
19
|
+
["The Starry Night was painted by Vincent van Gogh.", "Vincent van Gogh"],
|
|
20
|
+
[
|
|
21
|
+
"The Night Watch was painted by Rembrandt van Rijn.",
|
|
22
|
+
"Rembrandt van Rijn",
|
|
23
|
+
],
|
|
24
|
+
// One stray fact, keyed on a name none of the examples mention:
|
|
25
|
+
["Pablo Picasso", "Pablo Picasso co-founded the Cubist movement"],
|
|
26
|
+
]);
|
|
27
|
+
// 1) GENERALIZE — apply the learned pattern to an unseen sentence and read out
|
|
28
|
+
// the painter. "Pablo Picasso" was never given as an answer; Sema locates it
|
|
29
|
+
// by analogy to the three examples.
|
|
30
|
+
console.log(await ask("The Weeping Woman was painted by Pablo Picasso."));
|
|
31
|
+
// → "Pablo Picasso co-founded the Cubist movement"
|
|
32
|
+
// …and, having found the painter, it KEEPS GOING: the name bridges into the
|
|
33
|
+
// one fact it holds about him. The answer appears in no word of the question.
|
|
34
|
+
// 2) COMPUTE — exact arithmetic, grounded right where the notes go silent.
|
|
35
|
+
console.log(await ask("a museum charges 12*4 for a family ticket"));
|
|
36
|
+
// → "48"
|
|
37
|
+
await mind.store.close();
|
|
38
38
|
}
|
|
39
39
|
main();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Episode {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
context: string;
|
|
3
|
+
continuation: string;
|
|
4
4
|
}
|
|
5
5
|
export type TrainingItem = string | Episode;
|
|
6
6
|
/** Dedup + trim a concept's items: drop empty/degenerate pairs and exact
|
|
@@ -8,10 +8,10 @@ export type TrainingItem = string | Episode;
|
|
|
8
8
|
export declare function refineItems(items: TrainingItem[]): TrainingItem[];
|
|
9
9
|
/** One normalized SmolSent row. */
|
|
10
10
|
export interface SmolSentRow {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
src: string;
|
|
12
|
+
trg: string;
|
|
13
|
+
sl: string;
|
|
14
|
+
tl: string;
|
|
15
15
|
}
|
|
16
16
|
/** Normalize a raw datasets-server row into a SmolSentRow, or null when it lacks
|
|
17
17
|
* both sides or a side is implausibly large (a dump, not a sentence). */
|
|
@@ -22,9 +22,9 @@ export declare function toSmolSentRow(row: unknown): SmolSentRow | null;
|
|
|
22
22
|
export declare function smolSentRowToItems(row: SmolSentRow): TrainingItem[];
|
|
23
23
|
/** One normalized Aya row. */
|
|
24
24
|
export interface AyaRow {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
inputs: string;
|
|
26
|
+
targets: string;
|
|
27
|
+
language: string;
|
|
28
28
|
}
|
|
29
29
|
/** Normalize a raw datasets-server row object into an AyaRow, or null when it
|
|
30
30
|
* lacks a usable prompt/answer or a field is implausibly large (a dump, not a
|
|
@@ -38,16 +38,16 @@ export declare function toAyaRow(row: unknown): AyaRow | null;
|
|
|
38
38
|
export declare function ayaRowToItems(row: AyaRow): TrainingItem[];
|
|
39
39
|
/** A single oasst2 message node (the fields we use; the tree nests via replies). */
|
|
40
40
|
interface OasstNode {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
role?: string;
|
|
42
|
+
text?: string;
|
|
43
|
+
rank?: number | null;
|
|
44
|
+
deleted?: boolean;
|
|
45
|
+
replies?: OasstNode[];
|
|
46
46
|
}
|
|
47
47
|
/** One conversational turn extracted from a tree. */
|
|
48
48
|
export interface OasstTurn {
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
role: string;
|
|
50
|
+
text: string;
|
|
51
51
|
}
|
|
52
52
|
/** Collapse a conversation tree to ONE linear path: at each node, descend into
|
|
53
53
|
* its best-ranked, non-deleted reply (rank 0 preferred; unranked sorts last).
|
|
@@ -72,13 +72,11 @@ export declare function bestOasstPath(root: OasstNode): OasstTurn[];
|
|
|
72
72
|
*
|
|
73
73
|
* Returns [] for a conversation below the multi-turn threshold, so callers can
|
|
74
74
|
* simply skip empties. */
|
|
75
|
-
export declare function oasstConversationToItems(
|
|
76
|
-
turns: OasstTurn[],
|
|
77
|
-
): TrainingItem[];
|
|
75
|
+
export declare function oasstConversationToItems(turns: OasstTurn[]): TrainingItem[];
|
|
78
76
|
/** One normalized General-Knowledge row. */
|
|
79
77
|
export interface GenKnowRow {
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
question: string;
|
|
79
|
+
answer: string;
|
|
82
80
|
}
|
|
83
81
|
/** Normalize a raw datasets-server row into a GenKnowRow, or null when it lacks
|
|
84
82
|
* a usable question/answer or a side is implausibly large (corruption). */
|