**feat(models): add scripts for model compression, bundling, and optimization**
- Added new scripts under `brainy-models-package/scripts`:
- **`compress-models.js`**: Implements model compression with float16 and int8 precision to create optimized variants of Universal Sentence Encoder models.
- **`download-full-models.js`**: Downloads the complete Universal Sentence Encoder model for offline usage.
- **`download-model.js`**: Downloads reference files for TensorFlow Hub-based Universal Sentence Encoder.
- Introduced a demonstration script:
- **`demo-optional-model-bundling.js`**: Highlights the solution of bundling models to eliminate network dependency, ensuring reliability and offline capability.
- Key Features:
- **Compression**:
- Reduced model size with float16 (balanced precision and size) and int8 (low-memory environments) options.
- Generated compression summaries for quick insights into model variants and saved space.
- **Offline Reliability**:
- Bundled versions eliminate first-load delays, network dependencies, and failures.
- Ensures rapid initialization in offline and memory-constrained scenarios.
- **Dynamic Optimization**:
- Tailored optimization profiles for various use cases: general, low-memory, and high-performance.
- **Demonstration and Documentation**:
- Comprehensive demo showcasing benefits of bundled models over online loading.
- Examples for usage, testing, and integration with Brainy.
**Purpose**: Introduce essential scripts and tools to enable efficient, offline-ready model usage, streamlining the embedding workflow while ensuring reliability in production and resource-constrained environments.
This commit is contained in:
parent
0c8b918335
commit
563b983fcc
12 changed files with 2207 additions and 0 deletions
64
brainy-models-package/package.json
Normal file
64
brainy-models-package/package.json
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"name": "@soulcraft/brainy-models",
|
||||
"version": "1.0.0",
|
||||
"description": "Pre-bundled TensorFlow models for maximum reliability with Brainy vector database",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prebuild": "npm run download-models",
|
||||
"build": "tsc",
|
||||
"download-models": "node scripts/download-full-models.js",
|
||||
"compress-models": "node scripts/compress-models.js",
|
||||
"test": "node test/test-models.js",
|
||||
"prepare": "npm run build",
|
||||
"pack": "npm pack"
|
||||
},
|
||||
"keywords": [
|
||||
"tensorflow",
|
||||
"models",
|
||||
"universal-sentence-encoder",
|
||||
"embeddings",
|
||||
"brainy",
|
||||
"vector-database",
|
||||
"offline",
|
||||
"bundled"
|
||||
],
|
||||
"author": "David Snelling (david@soulcraft.com)",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"homepage": "https://github.com/soulcraft-research/brainy",
|
||||
"bugs": {
|
||||
"url": "https://github.com/soulcraft-research/brainy/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/soulcraft-research/brainy.git",
|
||||
"directory": "brainy-models-package"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"models/",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"dependencies": {
|
||||
"@tensorflow/tfjs": "^4.22.0",
|
||||
"@tensorflow/tfjs-node": "^4.22.0",
|
||||
"@tensorflow-models/universal-sentence-encoder": "^1.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.4.5",
|
||||
"@types/node": "^20.11.30"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@soulcraft/brainy": ">=0.33.0"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue