rust-kgdb 0.6.58 → 0.6.60
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/README.md +108 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,7 +99,7 @@ This is what I built. A knowledge graph database with an AI layer that **cannot
|
|
|
99
99
|
|
|
100
100
|
**Two components, one npm package:**
|
|
101
101
|
|
|
102
|
-
###
|
|
102
|
+
### rust-kgdb Core: Embedded Knowledge Graph Database
|
|
103
103
|
|
|
104
104
|
A high-performance RDF/SPARQL database that runs **inside your application**. No server. No Docker. No config.
|
|
105
105
|
|
|
@@ -118,9 +118,18 @@ A high-performance RDF/SPARQL database that runs **inside your application**. No
|
|
|
118
118
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
**Performance (Verified on LUBM benchmark):**
|
|
122
|
+
|
|
123
|
+
| Metric | rust-kgdb | RDFox | Apache Jena | Why It Matters |
|
|
124
|
+
|--------|-----------|-------|-------------|----------------|
|
|
125
|
+
| **Lookup** | 449 ns | 5,000+ ns | 10,000+ ns | Catch fraud before payment clears |
|
|
126
|
+
| **Memory/Triple** | 24 bytes | 32 bytes | 50-60 bytes | Fit more data in memory |
|
|
127
|
+
| **Bulk Insert** | 146K/sec | 200K/sec | 50K/sec | Load million-record datasets fast |
|
|
128
|
+
| **Concurrent Writes** | 132K ops/sec | - | - | Handle enterprise transaction volumes |
|
|
129
|
+
|
|
121
130
|
**Like SQLite - but for knowledge graphs.**
|
|
122
131
|
|
|
123
|
-
###
|
|
132
|
+
### HyperMind: Neuro-Symbolic Agent Framework
|
|
124
133
|
|
|
125
134
|
An AI agent layer that uses **the database to prevent hallucinations**. The LLM plans, the database executes.
|
|
126
135
|
|
|
@@ -139,6 +148,36 @@ An AI agent layer that uses **the database to prevent hallucinations**. The LLM
|
|
|
139
148
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
140
149
|
```
|
|
141
150
|
|
|
151
|
+
**Agent Accuracy (LUBM Benchmark - 14 Queries, 3,272 Triples):**
|
|
152
|
+
|
|
153
|
+
| Framework | Without Schema | With Schema | Notes |
|
|
154
|
+
|-----------|---------------|-------------|-------|
|
|
155
|
+
| **Vanilla LLM** | 0% | - | Hallucinates class names, adds markdown |
|
|
156
|
+
| **LangChain** | 0% | 71.4% | Needs manual schema injection |
|
|
157
|
+
| **DSPy** | 14.3% | 71.4% | Better prompting helps slightly |
|
|
158
|
+
| **HyperMind** | - | 71.4% | Schema integrated by design |
|
|
159
|
+
|
|
160
|
+
*Honest numbers: All frameworks achieve similar accuracy WITH schema. The difference is HyperMind integrates schema handling - you don't manually inject it.*
|
|
161
|
+
|
|
162
|
+
**Memory Retrieval (Agent Recall Benchmark):**
|
|
163
|
+
|
|
164
|
+
| Metric | HyperMind | Typical RAG | Why It Matters |
|
|
165
|
+
|--------|-----------|-------------|----------------|
|
|
166
|
+
| **Recall@10** | 94% at 10K depth | ~70% | Find the right past query |
|
|
167
|
+
| **Search Speed** | 16.7ms / 10K queries | 500ms+ | 30x faster context retrieval |
|
|
168
|
+
| **Idempotent Responses** | Yes (semantic hash) | No | Same question = same answer |
|
|
169
|
+
|
|
170
|
+
**Long-Term Memory: Deep Flashback**
|
|
171
|
+
|
|
172
|
+
Most AI agents forget everything between sessions. HyperMind stores memory in the *same* knowledge graph as your data:
|
|
173
|
+
|
|
174
|
+
- **Episodes** link to **KG entities** via hyper-edges
|
|
175
|
+
- **Embeddings** enable semantic search over past queries
|
|
176
|
+
- **Temporal decay** prioritizes recent, relevant memories
|
|
177
|
+
- **Single SPARQL query** traverses both memory AND knowledge graph
|
|
178
|
+
|
|
179
|
+
When your fraud analyst asks "What did we find about Provider X last month?", the agent doesn't say "I don't remember." It retrieves the exact investigation with full context - 94% recall at 10,000 queries deep.
|
|
180
|
+
|
|
142
181
|
**The insight:** AI writes questions (SPARQL queries). Database finds answers. No hallucination possible.
|
|
143
182
|
|
|
144
183
|
---
|
|
@@ -172,6 +211,73 @@ These aren't arbitrary choices. Each one solves a real problem I encountered bui
|
|
|
172
211
|
|
|
173
212
|
---
|
|
174
213
|
|
|
214
|
+
## Why Our Tool Calling Is Different
|
|
215
|
+
|
|
216
|
+
Traditional AI tool calling (OpenAI Functions, LangChain Tools) has fundamental problems:
|
|
217
|
+
|
|
218
|
+
**The Traditional Approach:**
|
|
219
|
+
```
|
|
220
|
+
LLM generates JSON → Runtime validates schema → Tool executes → Hope it works
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
1. **Schema is decorative.** The LLM sees a JSON schema and tries to match it. No guarantee outputs are correct types.
|
|
224
|
+
2. **Composition is ad-hoc.** Chain Tool A → Tool B? Pray that A's output format happens to match B's input.
|
|
225
|
+
3. **Errors happen at runtime.** You find out a tool chain is broken when a user hits it in production.
|
|
226
|
+
4. **No mathematical guarantees.** "It usually works" is the best you get.
|
|
227
|
+
|
|
228
|
+
**Our Approach: Tools as Typed Morphisms**
|
|
229
|
+
```
|
|
230
|
+
Tools are arrows in a category:
|
|
231
|
+
kg.sparql.query: Query → BindingSet
|
|
232
|
+
kg.motif.find: Pattern → Matches
|
|
233
|
+
kg.embeddings.search: EntityId → SimilarEntities
|
|
234
|
+
|
|
235
|
+
Composition is verified:
|
|
236
|
+
f: A → B
|
|
237
|
+
g: B → C
|
|
238
|
+
g ∘ f: A → C ✓ Compiles only if types match
|
|
239
|
+
|
|
240
|
+
Errors caught at plan time, not runtime.
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**What this means in practice:**
|
|
244
|
+
|
|
245
|
+
| Problem | Traditional | HyperMind |
|
|
246
|
+
|---------|-------------|-----------|
|
|
247
|
+
| **Type mismatch** | Runtime error | Won't compile |
|
|
248
|
+
| **Tool chaining** | Hope it works | Type-checked composition |
|
|
249
|
+
| **Output validation** | Schema validation (partial) | Refinement types (complete) |
|
|
250
|
+
| **Audit trail** | Optional logging | Built-in proof witnesses |
|
|
251
|
+
|
|
252
|
+
**Refinement Types: Beyond Basic Types**
|
|
253
|
+
|
|
254
|
+
We don't just have `string` and `number`. We have:
|
|
255
|
+
- `RiskScore` (number between 0 and 1)
|
|
256
|
+
- `PolicyNumber` (matches regex `^POL-\d{8}$`)
|
|
257
|
+
- `CreditScore` (integer between 300 and 850)
|
|
258
|
+
|
|
259
|
+
The type system *guarantees* a tool that outputs `RiskScore` produces a valid risk score. Not "probably" - mathematically proven.
|
|
260
|
+
|
|
261
|
+
**The Insight:** Category theory isn't academic overhead. It's the same math that makes your database transactions safe (ACID = category theory applied to data). We apply it to tool composition.
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## What You Can Do
|
|
266
|
+
|
|
267
|
+
| Query Type | Use Case | Example |
|
|
268
|
+
|------------|----------|---------|
|
|
269
|
+
| **SPARQL** | Find connected entities | `SELECT ?claim WHERE { ?claim :provider :PROV001 }` |
|
|
270
|
+
| **Datalog** | Recursive fraud detection | `fraud_ring(X,Y) :- knows(X,Y), claims_with(X,P), claims_with(Y,P)` |
|
|
271
|
+
| **Motif** | Network pattern matching | `(a)-[e1]->(b); (b)-[e2]->(a)` finds circular relationships |
|
|
272
|
+
| **GraphFrame** | Social network analysis | `gf.pageRank(0.15, 20)` ranks entities by connection importance |
|
|
273
|
+
| **Pregel** | Shortest paths at scale | `pregelShortestPaths(gf, 'source', 100)` for billion-edge graphs |
|
|
274
|
+
| **Embeddings** | Semantic similarity | `embeddings.findSimilar('CLM001', 10, 0.7)` finds related claims |
|
|
275
|
+
| **Agent** | Natural language interface | `agent.ask("Which providers show fraud patterns?")` |
|
|
276
|
+
|
|
277
|
+
Each of these runs in the same embedded database. No separate systems to maintain.
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
175
281
|
## Quick Start
|
|
176
282
|
|
|
177
283
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rust-kgdb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.60",
|
|
4
4
|
"description": "High-performance RDF/SPARQL database with AI agent framework. GraphDB (449ns lookups, 35x faster than RDFox), GraphFrames analytics (PageRank, motifs), Datalog reasoning, HNSW vector embeddings. HyperMindAgent for schema-aware query generation with audit trails. W3C SPARQL 1.1 compliant. Native performance via Rust + NAPI-RS.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|