@soulcraft/brainy 5.4.0 ā 5.6.0
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/CHANGELOG.md +45 -0
- package/README.md +4 -3
- package/dist/augmentations/display/fieldPatterns.js +3 -3
- package/dist/augmentations/display/intelligentComputation.d.ts +1 -1
- package/dist/augmentations/display/intelligentComputation.js +1 -3
- package/dist/augmentations/typeMatching/brainyTypes.d.ts +1 -1
- package/dist/augmentations/typeMatching/brainyTypes.js +7 -9
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +1 -1
- package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +1 -1
- package/dist/augmentations/universalDisplayAugmentation.d.ts +1 -1
- package/dist/augmentations/universalDisplayAugmentation.js +1 -1
- package/dist/brainy.js +2 -2
- package/dist/cli/commands/types.js +2 -2
- package/dist/cortex/neuralImport.js +0 -1
- package/dist/hnsw/typeAwareHNSWIndex.d.ts +3 -3
- package/dist/hnsw/typeAwareHNSWIndex.js +5 -5
- package/dist/importers/SmartExcelImporter.js +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/neural/embeddedKeywordEmbeddings.d.ts +1 -1
- package/dist/neural/embeddedKeywordEmbeddings.js +56 -56
- package/dist/neural/embeddedTypeEmbeddings.d.ts +3 -3
- package/dist/neural/embeddedTypeEmbeddings.js +14 -14
- package/dist/neural/entityExtractor.js +2 -2
- package/dist/neural/relationshipConfidence.js +1 -1
- package/dist/neural/signals/VerbContextSignal.js +6 -6
- package/dist/neural/signals/VerbExactMatchSignal.js +9 -9
- package/dist/neural/signals/VerbPatternSignal.js +5 -5
- package/dist/query/typeAwareQueryPlanner.d.ts +7 -7
- package/dist/query/typeAwareQueryPlanner.js +9 -10
- package/dist/storage/baseStorage.d.ts +48 -1
- package/dist/storage/baseStorage.js +237 -19
- package/dist/types/graphTypes.d.ts +588 -230
- package/dist/types/graphTypes.js +683 -248
- package/dist/types/typeMigration.d.ts +95 -0
- package/dist/types/typeMigration.js +141 -0
- package/dist/utils/intelligentTypeMapper.js +2 -2
- package/dist/utils/metadataIndex.js +6 -6
- package/package.json +2 -2
- package/dist/importManager.d.ts +0 -78
- package/dist/importManager.js +0 -267
- package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +0 -300
- package/dist/storage/adapters/typeAwareStorageAdapter.js +0 -1012
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,51 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.5.0](https://github.com/soulcraftlabs/brainy/compare/v5.4.0...v5.5.0) (2025-11-06)
|
|
6
|
+
|
|
7
|
+
### šÆ Stage 3 CANONICAL Taxonomy - Complete Coverage
|
|
8
|
+
|
|
9
|
+
**169 types** (42 nouns + 127 verbs) representing **96-97% of all human knowledge**
|
|
10
|
+
|
|
11
|
+
### ⨠New Features
|
|
12
|
+
|
|
13
|
+
* **Expanded Type System**: 169 types (from 71 types in v5.x)
|
|
14
|
+
- **42 noun types** (was 31): Added `organism`, `substance` + 11 others
|
|
15
|
+
- **127 verb types** (was 40): Added `affects`, `learns`, `destroys` + 84 others
|
|
16
|
+
- Coverage: Natural Sciences (96%), Formal Sciences (98%), Social Sciences (97%), Humanities (96%)
|
|
17
|
+
- Timeless design: Stable for 20+ years without changes
|
|
18
|
+
|
|
19
|
+
* **New Noun Types**:
|
|
20
|
+
- `organism`: Living biological entities (animals, plants, bacteria, fungi)
|
|
21
|
+
- `substance`: Physical materials and matter (water, iron, chemicals, DNA)
|
|
22
|
+
- Plus 11 additional types from Stage 3 taxonomy
|
|
23
|
+
|
|
24
|
+
* **New Verb Types**:
|
|
25
|
+
- `destroys`: Lifecycle termination and destruction relationship
|
|
26
|
+
- `affects`: Patient/experiencer relationship (who/what experiences action)
|
|
27
|
+
- `learns`: Cognitive acquisition and learning process
|
|
28
|
+
- Plus 84 additional verbs across 24 semantic categories
|
|
29
|
+
|
|
30
|
+
### š§ Breaking Changes (Minor Impact)
|
|
31
|
+
|
|
32
|
+
* **Removed Types** (migration recommended):
|
|
33
|
+
- `user` ā migrate to `person`
|
|
34
|
+
- `topic` ā migrate to `concept`
|
|
35
|
+
- `content` ā migrate to `informationContent` or `document`
|
|
36
|
+
- `createdBy`, `belongsTo`, `supervises`, `succeeds` ā use inverse relationships
|
|
37
|
+
|
|
38
|
+
### š Performance
|
|
39
|
+
|
|
40
|
+
* **Memory optimization**: 676 bytes for 169 types (99.2% reduction vs Maps)
|
|
41
|
+
* **Type embeddings**: 338KB embedded, zero runtime computation
|
|
42
|
+
* **Build time**: Type embeddings pre-computed, instant availability
|
|
43
|
+
|
|
44
|
+
### š Documentation
|
|
45
|
+
|
|
46
|
+
* Added `docs/STAGE3-CANONICAL-TAXONOMY.md` - Complete type reference
|
|
47
|
+
* Updated all type descriptions and embeddings
|
|
48
|
+
* Full semantic coverage across all knowledge domains
|
|
49
|
+
|
|
5
50
|
### [5.4.0](https://github.com/soulcraftlabs/brainy/compare/v5.3.6...v5.4.0) (2025-11-05)
|
|
6
51
|
|
|
7
52
|
- fix: resolve HNSW race condition and verb weight extraction (v5.4.0) (1fc54f0)
|
package/README.md
CHANGED
|
@@ -183,12 +183,13 @@ Most systems force you to choose:
|
|
|
183
183
|
|
|
184
184
|
**Why this matters:** Your data isn't just vectors or just documents or just graphs. It's all three at once. A research paper is semantically similar to other papers (vector), written by an author (graph), and published in 2023 (document). **Brainy is the only system that understands this.**
|
|
185
185
|
|
|
186
|
-
### šÆ **
|
|
186
|
+
### šÆ **42 Noun Types Ć 127 Verb Types = Universal Protocol**
|
|
187
187
|
|
|
188
188
|
Model **any domain** with mathematical completeness:
|
|
189
189
|
|
|
190
190
|
```
|
|
191
|
-
|
|
191
|
+
42 Nouns Ć 127 Verbs Ć ā Metadata = 5,334+ base combinations
|
|
192
|
+
Stage 3 CANONICAL: 96-97% coverage of all human knowledge
|
|
192
193
|
```
|
|
193
194
|
|
|
194
195
|
**Real-world expressiveness:**
|
|
@@ -545,7 +546,7 @@ Understand how the same code scales from prototype to billions of entities:
|
|
|
545
546
|
**[š Cloud Deployment Guide ā](docs/deployment/CLOUD_DEPLOYMENT_GUIDE.md)**
|
|
546
547
|
|
|
547
548
|
### šÆ The Universal Type System
|
|
548
|
-
Explore the mathematical foundation:
|
|
549
|
+
Explore the mathematical foundation: 42 nouns Ć 127 verbs = Stage 3 CANONICAL taxonomy:
|
|
549
550
|
|
|
550
551
|
**[š Noun-Verb Taxonomy ā](docs/architecture/noun-verb-taxonomy.md)**
|
|
551
552
|
|
|
@@ -20,7 +20,7 @@ export const UNIVERSAL_FIELD_PATTERNS = [
|
|
|
20
20
|
fields: ['firstName', 'lastName', 'fullName', 'realName'],
|
|
21
21
|
displayField: 'title',
|
|
22
22
|
confidence: 0.9,
|
|
23
|
-
applicableTypes: [NounType.Person
|
|
23
|
+
applicableTypes: [NounType.Person],
|
|
24
24
|
transform: (value, context) => {
|
|
25
25
|
const { metadata } = context;
|
|
26
26
|
if (metadata.firstName && metadata.lastName) {
|
|
@@ -68,7 +68,7 @@ export const UNIVERSAL_FIELD_PATTERNS = [
|
|
|
68
68
|
fields: ['bio', 'biography', 'profile', 'about'],
|
|
69
69
|
displayField: 'description',
|
|
70
70
|
confidence: 0.85,
|
|
71
|
-
applicableTypes: [NounType.Person
|
|
71
|
+
applicableTypes: [NounType.Person]
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
fields: ['content', 'text', 'body', 'message'],
|
|
@@ -100,7 +100,7 @@ export const UNIVERSAL_FIELD_PATTERNS = [
|
|
|
100
100
|
fields: ['role', 'position', 'jobTitle', 'occupation'],
|
|
101
101
|
displayField: 'type',
|
|
102
102
|
confidence: 0.8,
|
|
103
|
-
applicableTypes: [NounType.Person
|
|
103
|
+
applicableTypes: [NounType.Person],
|
|
104
104
|
transform: (value) => String(value || 'Person')
|
|
105
105
|
},
|
|
106
106
|
{
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - BrainyTypes for semantic type detection
|
|
6
6
|
* - Neural Import patterns for field analysis
|
|
7
7
|
* - JSON processing utilities for field extraction
|
|
8
|
-
* - Existing NounType/VerbType taxonomy (
|
|
8
|
+
* - Existing NounType/VerbType taxonomy (42+127 types)
|
|
9
9
|
*/
|
|
10
10
|
import type { ComputedDisplayFields, DisplayConfig } from './types.js';
|
|
11
11
|
import type { GraphVerb } from '../../coreTypes.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - BrainyTypes for semantic type detection
|
|
6
6
|
* - Neural Import patterns for field analysis
|
|
7
7
|
* - JSON processing utilities for field extraction
|
|
8
|
-
* - Existing NounType/VerbType taxonomy (
|
|
8
|
+
* - Existing NounType/VerbType taxonomy (42+127 types)
|
|
9
9
|
*/
|
|
10
10
|
import { getBrainyTypes } from '../typeMatching/brainyTypes.js';
|
|
11
11
|
import { getFieldPatterns, getPriorityFields } from './fieldPatterns.js';
|
|
@@ -371,12 +371,10 @@ export class IntelligentComputationEngine {
|
|
|
371
371
|
[VerbType.WorksWith]: 'works with',
|
|
372
372
|
[VerbType.MemberOf]: 'is member of',
|
|
373
373
|
[VerbType.ReportsTo]: 'reports to',
|
|
374
|
-
[VerbType.CreatedBy]: 'created by',
|
|
375
374
|
[VerbType.Owns]: 'owns',
|
|
376
375
|
[VerbType.LocatedAt]: 'located at',
|
|
377
376
|
[VerbType.Likes]: 'likes',
|
|
378
377
|
[VerbType.Follows]: 'follows',
|
|
379
|
-
[VerbType.Supervises]: 'supervises'
|
|
380
378
|
};
|
|
381
379
|
return verbPhrases[verbType] || 'related to';
|
|
382
380
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* BrainyTypes - Intelligent type detection using semantic embeddings
|
|
3
3
|
*
|
|
4
4
|
* This module uses our existing TransformerEmbedding and similarity functions
|
|
5
|
-
* to intelligently match data to our
|
|
5
|
+
* to intelligently match data to our 42 noun types and 127 verb types.
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - Semantic similarity matching using embeddings
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* BrainyTypes - Intelligent type detection using semantic embeddings
|
|
3
3
|
*
|
|
4
4
|
* This module uses our existing TransformerEmbedding and similarity functions
|
|
5
|
-
* to intelligently match data to our
|
|
5
|
+
* to intelligently match data to our 42 noun types and 127 verb types.
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
8
|
* - Semantic similarity matching using embeddings
|
|
@@ -19,33 +19,35 @@ import { getNounTypeEmbeddings, getVerbTypeEmbeddings } from '../../neural/embed
|
|
|
19
19
|
* These descriptions are used to generate embeddings for each type
|
|
20
20
|
*/
|
|
21
21
|
const NOUN_TYPE_DESCRIPTIONS = {
|
|
22
|
-
// Core Entity Types
|
|
22
|
+
// Core Entity Types (7)
|
|
23
23
|
[NounType.Person]: 'person human individual user employee customer citizen member author creator agent actor participant',
|
|
24
24
|
[NounType.Organization]: 'organization company business corporation institution agency department team group committee board',
|
|
25
25
|
[NounType.Location]: 'location place address city country region area zone coordinate position site venue building',
|
|
26
26
|
[NounType.Thing]: 'thing object item product device equipment tool instrument asset artifact material physical tangible',
|
|
27
27
|
[NounType.Concept]: 'concept idea theory principle philosophy belief value abstract intangible notion thought',
|
|
28
28
|
[NounType.Event]: 'event occurrence incident activity happening meeting conference celebration milestone timestamp date',
|
|
29
|
+
[NounType.Agent]: 'agent AI bot automated system automation software assistant service daemon daemon worker processor',
|
|
30
|
+
// Biological Types (1) - Stage 3
|
|
31
|
+
[NounType.Organism]: 'organism animal plant bacteria fungi species living biological life creature being microorganism',
|
|
32
|
+
// Material Types (1) - Stage 3
|
|
33
|
+
[NounType.Substance]: 'substance material matter chemical element compound liquid gas solid molecule atom material',
|
|
29
34
|
// Digital/Content Types
|
|
30
35
|
[NounType.Document]: 'document file report article paper text pdf word contract agreement record documentation',
|
|
31
36
|
[NounType.Media]: 'media image photo video audio music podcast multimedia graphic visualization animation',
|
|
32
37
|
[NounType.File]: 'file digital data binary code script program software archive package bundle',
|
|
33
38
|
[NounType.Message]: 'message email chat communication notification alert announcement broadcast transmission',
|
|
34
|
-
[NounType.Content]: 'content information data text material resource publication post blog webpage',
|
|
35
39
|
// Collection Types
|
|
36
40
|
[NounType.Collection]: 'collection group set list array category folder directory catalog inventory database',
|
|
37
41
|
[NounType.Dataset]: 'dataset data table spreadsheet database records statistics metrics measurements analysis',
|
|
38
42
|
// Business/Application Types
|
|
39
43
|
[NounType.Product]: 'product item merchandise offering service feature application software solution package',
|
|
40
44
|
[NounType.Service]: 'service offering subscription support maintenance utility function capability',
|
|
41
|
-
[NounType.User]: 'user account profile member subscriber customer client participant identity credentials',
|
|
42
45
|
[NounType.Task]: 'task action todo item job assignment duty responsibility activity step procedure',
|
|
43
46
|
[NounType.Project]: 'project initiative program campaign effort endeavor plan scheme venture undertaking',
|
|
44
47
|
// Descriptive Types
|
|
45
48
|
[NounType.Process]: 'process workflow procedure method algorithm sequence pipeline operation routine protocol',
|
|
46
49
|
[NounType.State]: 'state status condition phase stage mode situation circumstance configuration setting',
|
|
47
50
|
[NounType.Role]: 'role position title function responsibility duty job capacity designation authority',
|
|
48
|
-
[NounType.Topic]: 'topic subject theme category tag keyword area domain field discipline specialty',
|
|
49
51
|
[NounType.Language]: 'language dialect locale tongue vernacular communication speech linguistics vocabulary',
|
|
50
52
|
[NounType.Currency]: 'currency money dollar euro pound yen bitcoin payment financial monetary unit',
|
|
51
53
|
[NounType.Measurement]: 'measurement metric quantity value amount size dimension weight height volume distance',
|
|
@@ -68,7 +70,6 @@ const VERB_TYPE_DESCRIPTIONS = {
|
|
|
68
70
|
[VerbType.References]: 'references cites mentions points links refers quotes sources',
|
|
69
71
|
// Temporal/Causal Types
|
|
70
72
|
[VerbType.Precedes]: 'precedes before earlier prior previous antecedent preliminary foregoing',
|
|
71
|
-
[VerbType.Succeeds]: 'succeeds follows after later subsequent next ensuing succeeding',
|
|
72
73
|
[VerbType.Causes]: 'causes triggers induces produces generates results influences affects',
|
|
73
74
|
[VerbType.DependsOn]: 'depends requires needs relies necessitates contingent prerequisite',
|
|
74
75
|
[VerbType.Requires]: 'requires needs demands necessitates mandates obliges compels entails',
|
|
@@ -81,8 +82,6 @@ const VERB_TYPE_DESCRIPTIONS = {
|
|
|
81
82
|
// Ownership/Attribution Types
|
|
82
83
|
[VerbType.Owns]: 'owns possesses holds controls manages administers governs maintains',
|
|
83
84
|
[VerbType.AttributedTo]: 'attributed credited assigned ascribed authored written composed',
|
|
84
|
-
[VerbType.CreatedBy]: 'created made produced generated built developed authored written',
|
|
85
|
-
[VerbType.BelongsTo]: 'belongs property possession part member affiliate associated owned',
|
|
86
85
|
// Social/Organizational Types
|
|
87
86
|
[VerbType.MemberOf]: 'member participant affiliate associate belongs joined enrolled registered',
|
|
88
87
|
[VerbType.WorksWith]: 'works collaborates cooperates partners teams assists helps supports',
|
|
@@ -90,7 +89,6 @@ const VERB_TYPE_DESCRIPTIONS = {
|
|
|
90
89
|
[VerbType.Follows]: 'follows subscribes tracks monitors watches observes trails pursues',
|
|
91
90
|
[VerbType.Likes]: 'likes enjoys appreciates favors prefers admires values endorses',
|
|
92
91
|
[VerbType.ReportsTo]: 'reports answers subordinate accountable responsible supervised managed',
|
|
93
|
-
[VerbType.Supervises]: 'supervises manages oversees directs leads controls guides administers',
|
|
94
92
|
[VerbType.Mentors]: 'mentors teaches guides coaches instructs trains advises counsels',
|
|
95
93
|
[VerbType.Communicates]: 'communicates talks speaks messages contacts interacts corresponds exchanges',
|
|
96
94
|
// Descriptive/Functional Types
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* IntelligentTypeMatcher - Wrapper around BrainyTypes for testing
|
|
3
3
|
*
|
|
4
4
|
* Provides intelligent type detection using semantic embeddings
|
|
5
|
-
* for matching data to our
|
|
5
|
+
* for matching data to our 42 noun types and 127 verb types.
|
|
6
6
|
*/
|
|
7
7
|
import { NounType, VerbType } from '../../types/graphTypes.js';
|
|
8
8
|
export interface TypeMatchOptions {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* IntelligentTypeMatcher - Wrapper around BrainyTypes for testing
|
|
3
3
|
*
|
|
4
4
|
* Provides intelligent type detection using semantic embeddings
|
|
5
|
-
* for matching data to our
|
|
5
|
+
* for matching data to our 42 noun types and 127 verb types.
|
|
6
6
|
*/
|
|
7
7
|
import { VerbType } from '../../types/graphTypes.js';
|
|
8
8
|
import { getBrainyTypes } from './brainyTypes.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Features:
|
|
7
7
|
* - ā
Leverages existing BrainyTypes for semantic type detection
|
|
8
|
-
* - ā
Complete icon coverage for all
|
|
8
|
+
* - ā
Complete icon coverage for all 42 NounTypes + 127 VerbTypes
|
|
9
9
|
* - ā
Zero performance impact with lazy computation and intelligent caching
|
|
10
10
|
* - ā
Perfect isolation - can be disabled, replaced, or configured
|
|
11
11
|
* - ā
Clean developer experience with zero conflicts
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Features:
|
|
7
7
|
* - ā
Leverages existing BrainyTypes for semantic type detection
|
|
8
|
-
* - ā
Complete icon coverage for all
|
|
8
|
+
* - ā
Complete icon coverage for all 42 NounTypes + 127 VerbTypes
|
|
9
9
|
* - ā
Zero performance impact with lazy computation and intelligent caching
|
|
10
10
|
* - ā
Perfect isolation - can be disabled, replaced, or configured
|
|
11
11
|
* - ā
Clean developer experience with zero conflicts
|
package/dist/brainy.js
CHANGED
|
@@ -2758,7 +2758,7 @@ export class Brainy {
|
|
|
2758
2758
|
*/
|
|
2759
2759
|
async extractConcepts(text, options) {
|
|
2760
2760
|
const entities = await this.extract(text, {
|
|
2761
|
-
types: [NounType.Concept, NounType.
|
|
2761
|
+
types: [NounType.Concept, NounType.Concept],
|
|
2762
2762
|
confidence: options?.confidence || 0.7,
|
|
2763
2763
|
neuralMatching: true
|
|
2764
2764
|
});
|
|
@@ -3282,7 +3282,7 @@ export class Brainy {
|
|
|
3282
3282
|
return Object.fromEntries(this.metadataIndex.getAllEntityCounts());
|
|
3283
3283
|
},
|
|
3284
3284
|
// Phase 1b: O(1) count by type enum (Uint32Array-based, more efficient)
|
|
3285
|
-
// Uses fixed-size type tracking:
|
|
3285
|
+
// Uses fixed-size type tracking: 676 bytes vs ~35KB with Maps (98.1% reduction)
|
|
3286
3286
|
byTypeEnum: (type) => {
|
|
3287
3287
|
return this.metadataIndex.getEntityCountByTypeEnum(type);
|
|
3288
3288
|
},
|
|
@@ -26,7 +26,7 @@ export async function types(options) {
|
|
|
26
26
|
}
|
|
27
27
|
// Display nouns
|
|
28
28
|
if (showNouns) {
|
|
29
|
-
console.log(chalk.bold.cyan('\nš Noun Types (
|
|
29
|
+
console.log(chalk.bold.cyan('\nš Noun Types (42):\n'));
|
|
30
30
|
const nounChunks = [];
|
|
31
31
|
for (let i = 0; i < BrainyTypes.nouns.length; i += 3) {
|
|
32
32
|
nounChunks.push(BrainyTypes.nouns.slice(i, i + 3));
|
|
@@ -37,7 +37,7 @@ export async function types(options) {
|
|
|
37
37
|
}
|
|
38
38
|
// Display verbs
|
|
39
39
|
if (showVerbs) {
|
|
40
|
-
console.log(chalk.bold.cyan('\nš Verb Types (
|
|
40
|
+
console.log(chalk.bold.cyan('\nš Verb Types (127):\n'));
|
|
41
41
|
const verbChunks = [];
|
|
42
42
|
for (let i = 0; i < BrainyTypes.verbs.length; i += 3) {
|
|
43
43
|
verbChunks.push(BrainyTypes.verbs.slice(i, i + 3));
|
|
@@ -479,7 +479,6 @@ export class NeuralImport {
|
|
|
479
479
|
[VerbType.WorksWith]: 0.7, // Specific
|
|
480
480
|
[VerbType.Mentors]: 0.9, // Very specific
|
|
481
481
|
[VerbType.ReportsTo]: 0.9, // Very specific
|
|
482
|
-
[VerbType.Supervises]: 0.9 // Very specific
|
|
483
482
|
};
|
|
484
483
|
return specificityScores[verbType] || 0.5;
|
|
485
484
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Storage: Already type-first from Phase 1a
|
|
8
8
|
*
|
|
9
9
|
* Architecture:
|
|
10
|
-
* - One HNSWIndex per NounType (
|
|
10
|
+
* - One HNSWIndex per NounType (42 total)
|
|
11
11
|
* - Lazy initialization (indexes created on first use)
|
|
12
12
|
* - Type routing for optimal performance
|
|
13
13
|
* - Falls back to multi-type search when type unknown
|
|
@@ -101,7 +101,7 @@ export declare class TypeAwareHNSWIndex {
|
|
|
101
101
|
* **All-types search** (fallback):
|
|
102
102
|
* ```typescript
|
|
103
103
|
* await index.search(queryVector, 10)
|
|
104
|
-
* // Searches all
|
|
104
|
+
* // Searches all 42 graphs (slower but comprehensive)
|
|
105
105
|
* ```
|
|
106
106
|
*
|
|
107
107
|
* @param queryVector Query vector
|
|
@@ -192,7 +192,7 @@ export declare class TypeAwareHNSWIndex {
|
|
|
192
192
|
* Rebuild HNSW indexes from storage (type-aware)
|
|
193
193
|
*
|
|
194
194
|
* CRITICAL: This implementation uses type-filtered pagination to avoid
|
|
195
|
-
* loading ALL entities for each type (which would be
|
|
195
|
+
* loading ALL entities for each type (which would be 42 billion reads @ 1B scale).
|
|
196
196
|
*
|
|
197
197
|
* Can rebuild all types or specific types.
|
|
198
198
|
* Much faster than rebuilding a monolithic index.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Storage: Already type-first from Phase 1a
|
|
8
8
|
*
|
|
9
9
|
* Architecture:
|
|
10
|
-
* - One HNSWIndex per NounType (
|
|
10
|
+
* - One HNSWIndex per NounType (42 total)
|
|
11
11
|
* - Lazy initialization (indexes created on first use)
|
|
12
12
|
* - Type routing for optimal performance
|
|
13
13
|
* - Falls back to multi-type search when type unknown
|
|
@@ -84,7 +84,7 @@ export class TypeAwareHNSWIndex {
|
|
|
84
84
|
// Validate type is a valid NounType
|
|
85
85
|
const typeIndex = TypeUtils.getNounIndex(type);
|
|
86
86
|
if (typeIndex === undefined || typeIndex === null || typeIndex < 0) {
|
|
87
|
-
throw new Error(`Invalid NounType: ${type}. Must be one of the
|
|
87
|
+
throw new Error(`Invalid NounType: ${type}. Must be one of the 42 defined types.`);
|
|
88
88
|
}
|
|
89
89
|
if (!this.indexes.has(type)) {
|
|
90
90
|
prodLog.info(`Creating HNSW index for type: ${type}`);
|
|
@@ -137,7 +137,7 @@ export class TypeAwareHNSWIndex {
|
|
|
137
137
|
* **All-types search** (fallback):
|
|
138
138
|
* ```typescript
|
|
139
139
|
* await index.search(queryVector, 10)
|
|
140
|
-
* // Searches all
|
|
140
|
+
* // Searches all 42 graphs (slower but comprehensive)
|
|
141
141
|
* ```
|
|
142
142
|
*
|
|
143
143
|
* @param queryVector Query vector
|
|
@@ -302,7 +302,7 @@ export class TypeAwareHNSWIndex {
|
|
|
302
302
|
* Rebuild HNSW indexes from storage (type-aware)
|
|
303
303
|
*
|
|
304
304
|
* CRITICAL: This implementation uses type-filtered pagination to avoid
|
|
305
|
-
* loading ALL entities for each type (which would be
|
|
305
|
+
* loading ALL entities for each type (which would be 42 billion reads @ 1B scale).
|
|
306
306
|
*
|
|
307
307
|
* Can rebuild all types or specific types.
|
|
308
308
|
* Much faster than rebuilding a monolithic index.
|
|
@@ -341,7 +341,7 @@ export class TypeAwareHNSWIndex {
|
|
|
341
341
|
`(${(vectorMemory / 1024 / 1024).toFixed(1)}MB > ${(availableCache / 1024 / 1024).toFixed(1)}MB cache) - loading on-demand`);
|
|
342
342
|
}
|
|
343
343
|
// Load ALL nouns ONCE and route to correct type indexes
|
|
344
|
-
// This is O(N) instead of O(
|
|
344
|
+
// This is O(N) instead of O(42*N) from the previous parallel approach
|
|
345
345
|
let cursor = undefined;
|
|
346
346
|
let hasMore = true;
|
|
347
347
|
let totalLoaded = 0;
|
|
@@ -41,7 +41,7 @@ export class SmartExcelImporter {
|
|
|
41
41
|
enableRelationshipInference: true,
|
|
42
42
|
// CONCEPT EXTRACTION PRODUCTION-READY (v3.33.0+):
|
|
43
43
|
// Type embeddings are now pre-computed at build time - zero runtime cost!
|
|
44
|
-
// All
|
|
44
|
+
// All 42 noun types + 127 verb types instantly available
|
|
45
45
|
//
|
|
46
46
|
// Performance profile:
|
|
47
47
|
// - Type embeddings: INSTANT (pre-computed at build time, ~100KB in-memory)
|
|
@@ -231,7 +231,7 @@ export class SmartExcelImporter {
|
|
|
231
231
|
const relationshipColumnPatterns = [
|
|
232
232
|
{ pattern: /^(location|home|lives in|resides|dwelling|place)$/i, defaultType: VerbType.LocatedAt },
|
|
233
233
|
{ pattern: /^(owner|owned by|belongs to|possessed by|wielder)$/i, defaultType: VerbType.PartOf },
|
|
234
|
-
{ pattern: /^(created by|made by|invented by|authored by|creator|author)$/i, defaultType: VerbType.
|
|
234
|
+
{ pattern: /^(created by|made by|invented by|authored by|creator|author)$/i, defaultType: VerbType.Creates },
|
|
235
235
|
{ pattern: /^(uses|utilizes|requires|needs|employs|tool|weapon|item)$/i, defaultType: VerbType.Uses },
|
|
236
236
|
{ pattern: /^(member of|part of|within|inside|group|organization)$/i, defaultType: VerbType.PartOf },
|
|
237
237
|
{ pattern: /^(knows|friend|associate|colleague|ally|companion)$/i, defaultType: VerbType.FriendOf },
|
package/dist/index.d.ts
CHANGED
|
@@ -51,9 +51,9 @@ export type { Vector, VectorDocument, SearchResult, DistanceFunction, EmbeddingF
|
|
|
51
51
|
import type { AugmentationResponse, BrainyAugmentation, BaseAugmentation, AugmentationContext } from './types/augmentations.js';
|
|
52
52
|
export { AugmentationManager, type AugmentationInfo } from './augmentationManager.js';
|
|
53
53
|
export type { AugmentationResponse, BrainyAugmentation, BaseAugmentation, AugmentationContext };
|
|
54
|
-
import type { GraphNoun, GraphVerb, EmbeddedGraphVerb, Person, Location, Thing, Event,
|
|
54
|
+
import type { GraphNoun, GraphVerb, EmbeddedGraphVerb, Person, Organization, Location, Thing, Concept, Event, Agent, Organism, Substance, Quality, TimeInterval, Function, Proposition, Document, Media, File, Message, Collection, Dataset, Product, Service, Task, Project, Process, State, Role, Language, Currency, Measurement, Hypothesis, Experiment, Contract, Regulation, Interface, Resource, Custom, SocialGroup, Institution, Norm, InformationContent, InformationBearer, Relationship } from './types/graphTypes.js';
|
|
55
55
|
import { NounType, VerbType } from './types/graphTypes.js';
|
|
56
|
-
export type { GraphNoun, GraphVerb, EmbeddedGraphVerb, Person, Location, Thing, Event,
|
|
56
|
+
export type { GraphNoun, GraphVerb, EmbeddedGraphVerb, Person, Organization, Location, Thing, Concept, Event, Agent, Organism, Substance, Quality, TimeInterval, Function, Proposition, Document, Media, File, Message, Collection, Dataset, Product, Service, Task, Project, Process, State, Role, Language, Currency, Measurement, Hypothesis, Experiment, Contract, Regulation, Interface, Resource, Custom, SocialGroup, Institution, Norm, InformationContent, InformationBearer, Relationship };
|
|
57
57
|
import { getNounTypes, getVerbTypes, getNounTypeMap, getVerbTypeMap } from './utils/typeUtils.js';
|
|
58
58
|
import { BrainyTypes, TypeSuggestion, suggestType } from './utils/brainyTypes.js';
|
|
59
59
|
import { inferTypes, inferNouns, inferVerbs, inferIntent, getSemanticTypeInference, SemanticTypeInference, type TypeInference, type SemanticTypeInferenceOptions } from './query/semanticTypeInference.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pre-computed Keyword Embeddings for Unified Semantic Type Inference
|
|
3
3
|
*
|
|
4
4
|
* Generated by: scripts/buildKeywordEmbeddings.ts
|
|
5
|
-
* Generated on: 2025-
|
|
5
|
+
* Generated on: 2025-11-06T17:59:17.355Z
|
|
6
6
|
* Total keywords: 1050 (716 nouns + 334 verbs)
|
|
7
7
|
* Canonical: 919, Synonyms: 131
|
|
8
8
|
* Embedding dimension: 384
|