perf: pre-compute type embeddings at build time (zero runtime cost)
Major optimization - all type embeddings now built into package: Build-time generation: - Created scripts/buildTypeEmbeddings.ts to generate all type embeddings - Generates embeddings for 31 NounTypes + 40 VerbTypes at build time - Stores as base64-encoded binary data in embeddedTypeEmbeddings.ts - Added check script to rebuild only when needed Updated all consumers: - NeuralEntityExtractor: loads pre-computed embeddings (instant) - BrainyTypes: loads pre-computed embeddings (instant init) - NaturalLanguageProcessor: loads pre-computed embeddings (instant init) Build process: - Added npm run build:types to generate embeddings - Added npm run build:types:if-needed for conditional rebuild - Integrated into main build pipeline - Auto-rebuilds only when types or build script change Benefits: - Zero runtime cost - embeddings loaded instantly - Survives all container restarts - All 71 types always available (31 nouns + 40 verbs) - ~100KB memory overhead for permanent performance gain - Eliminates 5-10 second initialization delay This completes the type embedding optimization started in v3.32.5
This commit is contained in:
parent
87eb60d527
commit
0d649b8a79
9 changed files with 643 additions and 111 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@soulcraft/brainy",
|
||||
"version": "3.32.5",
|
||||
"version": "3.33.0",
|
||||
"description": "Universal Knowledge Protocol™ - World's first Triple Intelligence database unifying vector, graph, and document search in one API. 31 nouns × 40 verbs for infinite expressiveness.",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
|
|
@ -55,7 +55,10 @@
|
|||
"node": "22.x"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:patterns:if-needed && tsc && tsc -p tsconfig.cli.json",
|
||||
"build": "npm run build:types:if-needed && npm run build:patterns:if-needed && tsc && tsc -p tsconfig.cli.json",
|
||||
"build:types": "tsx scripts/buildTypeEmbeddings.ts",
|
||||
"build:types:if-needed": "node scripts/check-type-embeddings.cjs || npm run build:types",
|
||||
"build:types:force": "npm run build:types",
|
||||
"build:patterns": "tsx scripts/buildEmbeddedPatterns.ts",
|
||||
"build:patterns:if-needed": "node scripts/check-patterns.cjs || npm run build:patterns",
|
||||
"build:patterns:force": "npm run build:patterns",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue