**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
52
models/sentence-encoder/model.json
Normal file
52
models/sentence-encoder/model.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"format": "graph-model",
|
||||
"generatedBy": "TensorFlow.js v4.22.0",
|
||||
"convertedBy": "Brainy download-model script",
|
||||
"modelTopology": {
|
||||
"class_name": "GraphModel",
|
||||
"config": {
|
||||
"name": "universal-sentence-encoder"
|
||||
}
|
||||
},
|
||||
"userDefinedMetadata": {
|
||||
"signature": {
|
||||
"inputs": {
|
||||
"inputs": {
|
||||
"name": "inputs",
|
||||
"dtype": "string",
|
||||
"shape": [
|
||||
-1
|
||||
]
|
||||
}
|
||||
},
|
||||
"outputs": {
|
||||
"outputs": {
|
||||
"name": "outputs",
|
||||
"dtype": "float32",
|
||||
"shape": [
|
||||
-1,
|
||||
512
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"weightsManifest": [
|
||||
{
|
||||
"paths": [
|
||||
"group1-shard1of1.bin"
|
||||
],
|
||||
"weights": [
|
||||
{
|
||||
"name": "embedding_matrix",
|
||||
"shape": [
|
||||
512,
|
||||
512
|
||||
],
|
||||
"dtype": "float32"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"modelUrl": "https://tfhub.dev/tensorflow/tfjs-model/universal-sentence-encoder/1/default/1"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue