diff --git a/brainy-models-package/README.md b/brainy-models-package/README.md index 09f5f113..ddf763cd 100644 --- a/brainy-models-package/README.md +++ b/brainy-models-package/README.md @@ -1,12 +1,21 @@ -# @soulcraft/brainy-models +
+Brainy Logo +

-Pre-bundled TensorFlow models for maximum reliability with Brainy vector database. +[![License](https://img.shields.io/badge/license-MIT-green.svg)](../LICENSE) +[![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/) +[![TypeScript](https://img.shields.io/badge/TypeScript-5.4.5-blue.svg)](https://www.typescriptlang.org/) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](../CONTRIBUTING.md) -## Overview +**Pre-bundled TensorFlow models for maximum reliability with Brainy vector database** + +
+ +## ✨ Overview This package provides offline access to the Universal Sentence Encoder model, eliminating network dependencies and ensuring consistent performance. It's designed as an optional companion to the main `@soulcraft/brainy` package for applications requiring maximum reliability. -## Features +### šŸš€ Key Features - šŸ”’ **Maximum Reliability**: Fully offline model loading with zero network dependencies - šŸ“¦ **Pre-bundled Models**: Complete Universal Sentence Encoder model (~25MB) included @@ -15,7 +24,7 @@ This package provides offline access to the Universal Sentence Encoder model, el - šŸ› ļø **Easy Integration**: Drop-in replacement for online model loading - šŸ“Š **Comprehensive Metrics**: Detailed model information and performance statistics -## Installation +## šŸ”§ Installation ```bash npm install @soulcraft/brainy-models @@ -26,7 +35,7 @@ npm install @soulcraft/brainy-models - Node.js >= 18.0.0 - `@soulcraft/brainy` >= 0.33.0 -## Quick Start +## šŸ Quick Start ### Basic Usage @@ -88,7 +97,7 @@ await encoder.load() const embeddings = await encoder.embedToArrays(['Sample text']) ``` -## API Reference +## šŸ“š API Reference ### BundledUniversalSentenceEncoder @@ -221,7 +230,7 @@ const models = utils.listAvailableModels() console.log('Available models:', models) ``` -## Model Variants +## šŸŽÆ Model Variants The package includes multiple model variants optimized for different use cases: @@ -243,7 +252,7 @@ The package includes multiple model variants optimized for different use cases: - **Memory**: Low - **Speed**: Medium -## Scripts +## āš™ļø Scripts The package includes several utility scripts: @@ -271,7 +280,7 @@ Verify model functionality: npm test ``` -## Development +## šŸ”Ø Development ### Building the Package @@ -291,7 +300,7 @@ npm test npm run pack ``` -## Comparison with Online Loading +## āš–ļø Comparison with Online Loading | Feature | Online Loading | Bundled Models | |---------|----------------|----------------| @@ -302,7 +311,7 @@ npm run pack | **Network required** | Yes (first time) | No | | **Offline support** | Limited | Complete | -## Use Cases +## šŸ’” Use Cases ### When to Use Bundled Models @@ -319,7 +328,7 @@ npm run pack - āœ… Environments with reliable internet connectivity - āœ… Applications that rarely use embeddings -## Troubleshooting +## šŸ”§ Troubleshooting ### Model Not Found Error @@ -351,15 +360,15 @@ For optimal performance: 2. **Speed-critical**: Use original float32 models 3. **Balanced**: Use float16 compressed models -## License +## šŸ“„ License MIT -## Contributing +## šŸ¤ Contributing Contributions are welcome! Please see the main [Brainy repository](https://github.com/soulcraft-research/brainy) for contribution guidelines. -## Support +## šŸ’¬ Support For issues and questions: - [GitHub Issues](https://github.com/soulcraft-research/brainy/issues) diff --git a/brainy-models-package/models/universal-sentence-encoder/metadata.json b/brainy-models-package/models/universal-sentence-encoder/metadata.json index fa7c9b44..0f0af299 100644 --- a/brainy-models-package/models/universal-sentence-encoder/metadata.json +++ b/brainy-models-package/models/universal-sentence-encoder/metadata.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "Complete Universal Sentence Encoder model bundled for offline use", "dimensions": 512, - "downloadDate": "2025-08-01T23:20:17.338Z", + "downloadDate": "2025-08-02T00:28:52.947Z", "source": "tensorflow-models/universal-sentence-encoder", "approach": "full-bundle", "modelUrl": "https://storage.googleapis.com/tfjs-models/savedmodel/universal_sentence_encoder", diff --git a/brainy-models-package/models/universal-sentence-encoder/model.json b/brainy-models-package/models/universal-sentence-encoder/model.json index 17527857..04950b6f 100644 --- a/brainy-models-package/models/universal-sentence-encoder/model.json +++ b/brainy-models-package/models/universal-sentence-encoder/model.json @@ -7178,5 +7178,6 @@ } ] } - ] + ], + "format": "tfjs-graph-model" } \ No newline at end of file diff --git a/brainy-models-package/scripts/download-full-models.js b/brainy-models-package/scripts/download-full-models.js index 51b603f8..1a81a601 100644 --- a/brainy-models-package/scripts/download-full-models.js +++ b/brainy-models-package/scripts/download-full-models.js @@ -138,6 +138,13 @@ async function downloadFullModel() { // Read the model.json to get the weights manifest const modelJson = JSON.parse(fs.readFileSync(modelJsonPath, 'utf8')) + // Add the required "format" field for TensorFlow.js compatibility + if (!modelJson.format) { + modelJson.format = 'tfjs-graph-model' + fs.writeFileSync(modelJsonPath, JSON.stringify(modelJson, null, 2)) + console.log('āœ… Added "format" field to model.json for TensorFlow.js compatibility') + } + // Download all weight files if (modelJson.weightsManifest) { for (const manifest of modelJson.weightsManifest) { diff --git a/brainy-models-package/scripts/release-workflow.js b/brainy-models-package/scripts/release-workflow.js index 7bc2f115..b4b2a273 100644 --- a/brainy-models-package/scripts/release-workflow.js +++ b/brainy-models-package/scripts/release-workflow.js @@ -54,7 +54,9 @@ function executeStep(command, description, cwd = packageDir) { return true } catch (error) { // eslint-disable-next-line no-console - console.error(`āŒ Error during ${description.toLowerCase()}: ${error.message}`) + console.error( + `āŒ Error during ${description.toLowerCase()}: ${error.message}` + ) return false } } @@ -62,7 +64,9 @@ function executeStep(command, description, cwd = packageDir) { // Main workflow async function runReleaseWorkflow() { // eslint-disable-next-line no-console - console.log(`\n=== Starting @soulcraft/brainy-models-package Release Workflow (${versionType}) ===\n`) + console.log( + `\n=== Starting @soulcraft/brainy-models-package Release Workflow (${versionType}) ===\n` + ) // Step 1: Build the project if (!executeStep('npm run build', 'Building brainy-models-package')) { @@ -73,45 +77,56 @@ async function runReleaseWorkflow() { // Step 2: Run tests to ensure everything is working if (!executeStep('npm test', 'Running tests')) { // eslint-disable-next-line no-console - console.warn('āš ļø Tests failed. This might indicate issues with the release.') - + console.warn( + 'āš ļø Tests failed. This might indicate issues with the release.' + ) + // Ask the user if they want to continue despite test failures // eslint-disable-next-line no-console - console.log('\nāš ļø Do you want to continue with the release process despite test failures? (y/N)') - + console.log( + '\nāš ļø Do you want to continue with the release process despite test failures? (y/N)' + ) + const rl = readline.createInterface({ input: process.stdin, output: process.stdout }) - - const response = await new Promise(resolve => { - rl.question('', answer => { + + const response = await new Promise((resolve) => { + rl.question('', (answer) => { rl.close() resolve(answer.toLowerCase()) }) }) - + if (response !== 'y' && response !== 'yes') { // eslint-disable-next-line no-console console.error('Release process aborted due to test failures.') // eslint-disable-next-line no-process-exit process.exit(1) } - + // eslint-disable-next-line no-console console.log('Continuing with release process despite test failures...') } // Step 3: Update version and generate changelog - if (!executeStep(`npm run release:${versionType}`, `Updating version (${versionType}) and generating changelog`)) { + if ( + !executeStep( + `npm run release:${versionType}`, + `Updating version (${versionType}) and generating changelog` + ) + ) { // eslint-disable-next-line no-process-exit process.exit(1) } // Step 4: Create GitHub release - if (!executeStep('npm run github-release', 'Creating GitHub release')) { + if (!executeStep('npm run _github-release', 'Creating GitHub release')) { // eslint-disable-next-line no-console - console.log('Warning: GitHub release creation failed, but continuing with deployment...') + console.log( + 'Warning: GitHub release creation failed, but continuing with deployment...' + ) } // Step 5: Publish to NPM @@ -126,7 +141,9 @@ async function runReleaseWorkflow() { const newVersion = packageJson.version // eslint-disable-next-line no-console - console.log(`\nšŸŽ‰ @soulcraft/brainy-models-package v${newVersion} release completed successfully! šŸŽ‰\n`) + console.log( + `\nšŸŽ‰ @soulcraft/brainy-models-package v${newVersion} release completed successfully! šŸŽ‰\n` + ) // eslint-disable-next-line no-console console.log('Summary of actions:') // eslint-disable-next-line no-console @@ -140,11 +157,13 @@ async function runReleaseWorkflow() { // eslint-disable-next-line no-console console.log(`- Package published to NPM as @soulcraft/brainy-models-package`) // eslint-disable-next-line no-console - console.log('\nThank you for using the brainy-models-package release workflow!\n') + console.log( + '\nThank you for using the brainy-models-package release workflow!\n' + ) } // Run the workflow -runReleaseWorkflow().catch(error => { +runReleaseWorkflow().catch((error) => { // eslint-disable-next-line no-console console.error('Unexpected error during release workflow:', error) // eslint-disable-next-line no-process-exit