feat: migrate embeddings to Candle WASM + remove semantic type inference
Major architectural changes: 1. EMBEDDINGS ENGINE (ONNX → Candle WASM): - Replace ONNX Runtime with Rust Candle compiled to WASM - Embedded model in WASM binary (no external downloads) - Quantized Q8 precision with <50MB memory footprint - Zero-download, offline-first operation - Same embedding quality (all-MiniLM-L6-v2) 2. REMOVE SEMANTIC TYPE INFERENCE: - Delete embeddedKeywordEmbeddings.ts (14MB of pre-computed embeddings) - Remove typeAwareQueryPlanner.ts and semanticTypeInference.ts - Remove VerbExactMatchSignal (uses keyword embeddings) - Update SmartRelationshipExtractor to 3 signals (55%/30%/15% weights) API CHANGES (requires v7.0.0): - Removed: inferTypes(), inferNouns(), inferVerbs(), inferIntent() - Removed: getSemanticTypeInference(), SemanticTypeInference class - Removed: TypeInference, SemanticTypeInferenceOptions types Users can still use natural language queries in find() - they just need to specify type explicitly for type-optimized searches. PACKAGE SIZE IMPACT: - Compressed: 90.1 MB → 86.2 MB (-4.3%) - Uncompressed: 114.4 MB → 100.3 MB (-12%) - ~448K lines of code removed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
81cd16e41b
commit
da7d2ed29d
60 changed files with 3887 additions and 448557 deletions
|
|
@ -1600,31 +1600,6 @@ export class Brainy<T = any> implements BrainyInterface<T> {
|
|||
const params: FindParams<T> =
|
||||
typeof query === 'string' ? await this.parseNaturalQuery(query) : query
|
||||
|
||||
// Phase 3: Automatic type inference for 40% latency reduction
|
||||
if (params.query && !params.type && this.index instanceof TypeAwareHNSWIndex) {
|
||||
// Import Phase 3 components dynamically
|
||||
const { getQueryPlanner } = await import('./query/typeAwareQueryPlanner.js')
|
||||
const planner = getQueryPlanner()
|
||||
const plan = await planner.planQuery(params.query)
|
||||
|
||||
// Use inferred types if confidence is sufficient
|
||||
if (plan.confidence > 0.6) {
|
||||
params.type = plan.targetTypes.length === 1
|
||||
? plan.targetTypes[0]
|
||||
: plan.targetTypes
|
||||
|
||||
// Log for analytics (production-friendly)
|
||||
if (this.config.verbose) {
|
||||
console.log(
|
||||
`[Phase 3] Inferred types: ${plan.routing} ` +
|
||||
`(${plan.targetTypes.length} types, ` +
|
||||
`${(plan.confidence * 100).toFixed(0)}% confidence, ` +
|
||||
`${plan.estimatedSpeedup.toFixed(1)}x estimated speedup)`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Zero-config validation - only enforces universal truths
|
||||
const { validateFindParams, recordQueryPerformance } = await import('./utils/paramValidation.js')
|
||||
validateFindParams(params)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue