brainy/src/embeddings/candle-wasm/Cargo.toml
David Snelling da7d2ed29d 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>
2026-01-06 12:52:34 -08:00

55 lines
1.5 KiB
TOML

[package]
name = "candle-embeddings"
version = "0.1.0"
edition = "2021"
description = "WASM-based sentence embeddings using Candle and all-MiniLM-L6-v2"
license = "MIT"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
# Candle ML framework
candle-core = "0.8"
candle-nn = "0.8"
candle-transformers = "0.8"
# HuggingFace tokenizer with WASM support
# Use unstable_wasm feature which provides fancy-regex instead of onig
tokenizers = { version = "0.20", default-features = false, features = ["unstable_wasm"] }
# WASM bindings
wasm-bindgen = "0.2"
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
web-sys = { version = "0.3", features = ["console"] }
# Serialization for model loading
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Error handling
anyhow = "1.0"
# Async
futures = "0.3"
# WASM compatibility - force getrandom with js/wasm_js features
# getrandom 0.2 (from tokenizers->rand) needs "js" feature
# getrandom 0.3 (from candle->rand 0.9) needs "wasm_js" feature + rustflags
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom_02 = { package = "getrandom", version = "0.2", features = ["js"] }
getrandom = { version = "0.3", features = ["wasm_js"] }
[dev-dependencies]
wasm-bindgen-test = "0.3"
[profile.release]
opt-level = "z" # Optimize for size
lto = true # Link-time optimization
codegen-units = 1 # Single codegen unit for better optimization
panic = "abort" # Abort on panic (smaller binary)
[features]
default = []
simd = [] # Enable SIMD when browser support is available