@hviana/sema
v0.2.3
Published
Sema: a non-parametric, instance-based reasoning system.
Readme
███████╗ ███████╗ ███╗ ███╗ █████╗
██╔════╝ ██╔════╝ ████╗ ████║ ██╔══██╗
███████╗ █████╗ ██╔████╔██║ ███████║
╚════██║ ██╔══╝ ██║╚██╔╝██║ ██╔══██║
███████║ ███████╗ ██║ ╚═╝ ██║ ██║ ██║
╚══════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝The mind without weights.
A reasoning engine grounded in a vector-symbolic architecture and instance-based memory — not in billions of trained parameters.
No weights. No gradients. No training loop. No neural network. No GPU.
Deterministic · Auditable · CPU-only
— ⬡ — ⬡ — ⬡ —
[!IMPORTANT] © Sema is not a large language model. Today's LLMs compress the world into opaque floating-point weights and answer by sampling from them. Sema does the opposite: it keeps your knowledge as knowledge — content-addressed, inspectable, exact — and reasons over it on demand. The store is the model. What it knows, you can read. Why it answered, you can trace.
Formally, Sema is a non-parametric, instance-based reasoning system: a Vector Symbolic Architecture (Plate 1995; Kanerva 2009) over a content-addressable memory, with inference by weighted automated deduction (Knuth 1977; Felzenszwalb & McAllester 2007). Each term is grounded in HOW_IT_WORKS.md.
✦ Retrieval and reasoning, one search
Two questions, asked of every query — and Sema answers both in a single pass:
| | The question it asks | | :--------------- | :--------------------------------------------------- | | 🔎 Retrieval | "What do I already know that bears on this?" | | 🧠 Deduction | "What can I conclude or decide from what I found?" |
┌──────────────────────────────────────────────┐
Your question │"The Weeping Woman was painted by Picasso." │
└──────────────────────┬───────────────────────┘
▼
🔎 Retrieve resonate the query against the memory
· "… painted by … → the painter" (a learned pattern)
· "Picasso → co-founded the Cubist movement"
▼
🧠 Deduce connect · derive · compose
· lift the painter from a sentence never seen
· follow that name onward to what it implies
▼
✅ Answer "Pablo Picasso co-founded the Cubist movement"
(a fact that appears in no word of the question)Retrieval and reasoning are not two bolted-together stages — they are one search over one memory, which is why the answer can be something no single stored fact contains. Watch it happen below.
✦ Why Sema
🧩 Symbolic, not statistical
Knowledge is stored as a content-addressed graph, not smeared across a weight matrix. Every fact is an edge you can point at. Nothing is hallucinated out of a probability distribution.
🔀 Retrieval and reasoning, unified
Retrieval and reasoning are one mechanism, not a brittle pipeline of bolted- together components. A query enters the graph where it resonates and a single lightest-derivation search composes the answer.
🔍 Fully auditable
Every answer is a derivation over explicit facts. No black box. Trace any output back to the exact deposits that produced it — a hard requirement for regulated, high-stakes, and safety-critical deployments.
♻️ Deterministic & reproducible
Same seed + same bytes → identical result, every time. No temperature, no sampling, no drift between runs. Reproducibility is a property of the architecture, not a flag you toggle.
⚡ Instant training
Training is depositing — one pass, no epochs, no gradient descent, no fine-tuning jobs. Teach it a fact and it knows the fact. Now.
🔒 Total data sovereignty
Runs entirely on your hardware. No API calls, no telemetry, no weights to leak. Everything a trained mind knows lives in a few files on your disk.
[!TIP] No GPU. No cluster. No cloud bill. Sema runs on an ordinary CPU with a tiny memory footprint, because it never multiplies a weight matrix — it walks a graph. The economics of deploying intelligence change completely.
✦ See it think
Give Sema four plain notes — the way you'd jot them down — then ask things no note answers. From three worked examples it learns the shape of "X was painted by Y", lifts the painter out of a sentence it has never seen, and — in the same pass — reasons onward to a separate fact about that painter. The reply contains no word from the question: it is retrieval, generalization, and reasoning composing as a single act.
// demo.ts — one short session that drives the WHOLE pipeline from one memory.
//
// We give Sema a handful of plain notes, then ask things that no single note
// answers. The headline query is the third one: from three worked examples Sema
// learns the shape of "X was painted by Y", lifts the painter out of a sentence
// it has NEVER seen, and then — in the same pass — reasons forward to a separate
// fact about that painter. The reply contains no word from the question. That is
// retrieval, generalization, and reasoning composing as a single act, with every
// step traceable back to the notes behind it.
import { Mind } from "../src/index.js";
import { SQliteStore } from "../src/store-sqlite.js";
async function main(): Promise<void> {
const mind = new Mind({ store: new SQliteStore({ path: ":memory:" }) });
const ask = async (q: string) => (await mind.respondText(q)).trim();
// ── Jot down what we know. Each line is just (context → what follows). ──
await mind.ingest([
// One relation, shown three times — a pattern taught purely by example:
["The Mona Lisa was painted by Leonardo da Vinci.", "Leonardo da Vinci"],
["The Starry Night was painted by Vincent van Gogh.", "Vincent van Gogh"],
[
"The Night Watch was painted by Rembrandt van Rijn.",
"Rembrandt van Rijn",
],
// One stray fact, keyed on a name none of the examples mention:
["Pablo Picasso", "Pablo Picasso co-founded the Cubist movement"],
]);
// 1) GENERALIZE — apply the learned pattern to an unseen sentence and read out
// the painter. "Pablo Picasso" was never given as an answer; Sema locates it
// by analogy to the three examples.
console.log(await ask("The Weeping Woman was painted by Pablo Picasso."));
// → "Pablo Picasso co-founded the Cubist movement"
// …and, having found the painter, it KEEPS GOING: the name bridges into the
// one fact it holds about him. The answer appears in no word of the question.
// 2) COMPUTE — exact arithmetic, grounded right where the notes go silent.
console.log(await ask("a museum charges 12*4 for a family ticket"));
// → "48"
await mind.store.close();
}
main();Pablo Picasso co-founded the Cubist movement
48[!NOTE] This is example/demo.ts, verbatim — run it yourself with
npm run demo. Look closely at the first answer: the question names a painting Sema was never shown and asks nothing explicit, yet the reply is a fact about Picasso that appears nowhere in the question. Sema generalized "painted by" from three examples to recognize Pablo Picasso as the answer slot, then followed that name to the one thing it knows about him — retrieval, an analogy, and a reasoning hop, in one query. The second answer is exact, not a plausible-looking guess. Every step traces back to the four notes above.
✦ Engineered from three solved problems
Sema is composed of three self-contained, independently documented engines. They are fully decoupled — Sema reaches them only through interfaces.
| Engine | What it solves | Result |
| :--------------- | :----------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| 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 |
| 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 |
| 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 |
✦ Learn more
| Document | What's inside | | :------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- | | 📘 HOW_IT_WORKS.md | The full theory: vector symbolic architectures, the Merkle DAG, distributional halos, weighted deduction — concepts, diagrams, and extensive pseudocode. | | 🛠️ AGENTS.md | The development manual: repo layout, build/test, internals, invariants, and recipes for extending the system. | | ⚖️ LICENSE.md | PolyForm Noncommercial License 1.0.0. | | 💼 COMMERCIAL-LICENSE.md | Commercial licensing terms and contact. | | 🤗 Trained examples | Pre-trained memory files you can download and use directly. |
⚖️ Licensing & compliance — please read
[!WARNING] Sema is the product of serious, sustained research — and it is protected. It is released under the PolyForm Noncommercial License 1.0.0. Personal study, academic research, experimentation, and use by noncommercial organizations are welcome and explicitly permitted.
[!CAUTION] Commercial use requires a separate paid license. This includes — but is not limited to — use by a company; use to provide paid services or serve clients; use inside a SaaS, hosted product, or any revenue-generating platform; and use to reduce business costs or support business operations.
Operating Sema commercially (artifacts and algorithmic logic) without a license is a violation of its terms. See COMMERCIAL-LICENSE.md to obtain one, and TRADEMARKS.md — the Sema name, logos, and brand are not covered by the source license.
Respecting these terms funds the research that makes work like this possible. If Sema creates value for your business, license it — and help keep independent, weight-free AI research alive.
© Sema Author — Henrique Viana (creator).
Academic purpose:
Commercial licensing:
[email protected], [email protected]
© Sema Supporters — Marcelo Oliveira dos Reis · Rogerio Nascimento
— ⬡ — ⬡ — ⬡ —
