brainy/tests
David Snelling f898f0ce7b feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime
BREAKING CHANGE: Complete migration from TensorFlow.js to Transformers.js for embedding generation

This is a major architectural change that replaces TensorFlow.js (USE model) with Transformers.js (all-MiniLM-L6-v2) for significantly improved performance and reduced complexity.

Key Changes:
- Replace TensorFlow.js Universal Sentence Encoder with Transformers.js all-MiniLM-L6-v2
- Reduce model size from 525MB to 87MB (83% reduction)
- Reduce embedding dimensions from 512 to 384 (faster distance calculations)
- Remove TensorFlow.js Float32Array patching (caused ONNX conflicts)
- Implement smart bundled model detection for offline operation
- Add explicit model download script for Docker deployments
- Remove complex environment variables in favor of simple configuration
- Update all distance functions to use optimized pure JavaScript
- Remove TensorFlow-specific utilities and type definitions

Performance Improvements:
- Model loading: 5x faster (87MB vs 525MB)
- Memory usage: 75% reduction (~200-400MB vs ~1.5GB)
- Distance calculations: Faster pure JS vs GPU overhead for small vectors
- Cold start performance: Significantly improved

Files Changed:
- Updated package.json: New dependencies, simplified scripts
- Rewrote src/utils/embedding.ts: Complete Transformers.js implementation
- Updated src/utils/distance.ts: Optimized JavaScript distance functions
- Simplified src/setup.ts: Removed TensorFlow-specific patching
- Simplified src/utils/textEncoding.ts: Only Node.js TextEncoder/Decoder patches
- Deleted src/utils/robustModelLoader.ts: TensorFlow-specific loader
- Deleted src/types/tensorflowTypes.ts: TensorFlow type definitions
- Added scripts/download-models.cjs: Docker-compatible model downloader
- Added comprehensive documentation: README.md, OFFLINE_MODELS.md, analysis docs

Testing:
- All 19 tests passing
- Removed test mocking in favor of real implementation testing
- Updated test environment for Transformers.js compatibility
- Performance tests validate improved efficiency

This migration resolves production issues with Docker egress limitations and provides a more robust, performant foundation for vector operations.
2025-08-05 19:29:59 -07:00
..
mocks feat(tests): add robust mock implementations and expand test coverage for S3 and OPFS storage 2025-07-21 13:42:10 -07:00
api-integration.test.ts **test(storage-adapter-coverage): improve search result validation and consistency in assertions** 2025-08-01 18:31:05 -07:00
auto-configuration.test.ts feat(pagination): implement cursor-based pagination and enhance search caching 2025-08-04 14:25:05 -07:00
core.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
custom-models-path.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
database-operations.test.ts **docs: remove outdated statistics-related documentation and add standards** 2025-07-28 16:00:05 -07:00
dimension-standardization.test.ts **docs: remove outdated statistics-related documentation and add standards** 2025-07-28 16:00:05 -07:00
distributed-caching.test.ts feat(pagination): implement cursor-based pagination and enhance search caching 2025-08-04 14:25:05 -07:00
distributed.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
edge-cases.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
environment.browser.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
environment.node.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
error-handling.test.ts **docs: remove outdated statistics-related documentation and add standards** 2025-07-28 16:00:05 -07:00
json-search-test.js **feat(search): enhance JSON document search with field-level filtering and prioritization** 2025-08-01 08:27:39 -07:00
model-loading-priority.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
multi-environment.test.ts **feat(scripts): add automated release workflow script** 2025-07-31 13:40:28 -07:00
opfs-storage.test.ts **feat(core, storage, tests): enhance verb construction with timestamps and metadata** 2025-07-25 09:44:10 -07:00
package-install.test.ts refactor: simplify build system and improve model loading flexibility 2025-08-05 16:09:30 -07:00
package-size-breakdown.test.ts feat(tests): replace old test scripts with updated test suite for storage and reporting 2025-07-21 12:47:20 -07:00
package-size-limit.test.ts fix: include all JavaScript modules in npm package 2025-08-05 16:20:36 -07:00
pagination.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
performance-improvements.test.ts feat(pagination): implement cursor-based pagination and enhance search caching 2025-08-04 14:25:05 -07:00
performance.test.ts **docs: remove outdated statistics-related documentation and add standards** 2025-07-28 16:00:05 -07:00
s3-storage.test.ts **test(storage): add tests for S3 change log functionality** 2025-07-31 10:22:47 -07:00
setup.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
specialized-scenarios.test.ts **fix(storage): improve restoration and deletion logic in storage adapter** 2025-07-31 14:03:51 -07:00
statistics-storage.test.ts **feat(tests, docs, storage): add statistics storage tests and enhance documentation** 2025-07-24 16:24:02 -07:00
statistics.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
storage-adapter-coverage.test.ts **test(storage-adapter-coverage): improve search result validation and consistency in assertions** 2025-08-01 18:31:05 -07:00
storage-adapters.test.ts refactor: simplify build system and improve model loading flexibility 2025-08-05 16:09:30 -07:00
tensorflow-patch.test.ts **test(tests): add comprehensive test suite for Brainy functionality** 2025-07-15 11:56:16 -07:00
test-matrix.md **docs: remove outdated statistics-related documentation and add standards** 2025-07-28 16:00:05 -07:00
type-utils.test.ts **feat(utils): add type utility functions and examples for runtime type management** 2025-07-31 14:24:16 -07:00
vector-operations.test.ts feat\!: migrate from TensorFlow.js to Transformers.js with ONNX Runtime 2025-08-05 19:29:59 -07:00
verify-custom-models.js refactor: simplify build system and improve model loading flexibility 2025-08-05 16:09:30 -07:00
verify-model-loading.js refactor: simplify build system and improve model loading flexibility 2025-08-05 16:09:30 -07:00
verify-model-priority-simple.js refactor: simplify build system and improve model loading flexibility 2025-08-05 16:09:30 -07:00