feat: replace dtype with clearer precision parameter for model selection

- Changed confusing 'dtype' to 'precision' for model variant selection
- Fixed Q8 quantized model loading in transformers.js pipeline
- Added proper model file detection for q8 vs fp32 models
- Updated all references across codebase to use new parameter
- Maintains backward compatibility while providing clearer API
This commit is contained in:
David Snelling 2025-08-29 13:22:13 -07:00
parent 32df3ee6ae
commit 2a080aca55
5 changed files with 52 additions and 19 deletions

View file

@ -113,7 +113,7 @@ export class LightweightEmbedder {
console.log('⚠️ Loading ONNX model for complex text...')
const { TransformerEmbedding } = await import('../utils/embedding.js')
this.onnxEmbedder = new TransformerEmbedding({
dtype: 'fp32',
precision: 'fp32',
verbose: false
})
await this.onnxEmbedder.init()

View file

@ -139,7 +139,7 @@ export class UniversalMemoryManager {
this.embeddingFunction = new TransformerEmbedding({
verbose: false,
dtype: 'fp32',
precision: 'fp32',
localFilesOnly: process.env.BRAINY_ALLOW_REMOTE_MODELS !== 'true'
})

View file

@ -16,7 +16,7 @@ async function initModel(): Promise<void> {
if (!model) {
model = new TransformerEmbedding({
verbose: false,
dtype: 'fp32',
precision: 'fp32',
localFilesOnly: process.env.BRAINY_ALLOW_REMOTE_MODELS !== 'true'
})
await model.init()