Skip to content

Commit 3c1f701

Browse files
committed
fix(ruvector-cli): tiny-dancer score command (raw forward) + dep ^0.1.22
Replaces the route subcommand (which used Router.route's 5-feature engineering — a different model contract) with 'score', backed by tiny-dancer's score() raw forward pass that matches trainRouter models. Also fixes the earlier Float32Array issue by removing the Router.route path entirely. Co-Authored-By: claude-flow <ruv@ruv.net>
1 parent 39fb398 commit 3c1f701

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

npm/packages/ruvector/bin/cli.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,22 +1934,21 @@ tinyDancer
19341934
});
19351935

19361936
tinyDancer
1937-
.command('route <model>')
1938-
.description('Route a query through a trained model. --query: JSON embedding array; --candidates: JSON file of [{id, embedding}]')
1939-
.requiredOption('--query <json>', 'Query embedding as a JSON array or @file')
1940-
.requiredOption('--candidates <file>', 'Candidates JSON file: [{ id, embedding }]')
1941-
.option('--threshold <n>', 'Confidence threshold', '0.85')
1937+
.command('score <model>')
1938+
.description('Score a query embedding with a trained model. High = the cheap model is good enough (route cheap)')
1939+
.requiredOption('--query <json>', 'Query embedding as a JSON array or @file (length must match the model input dim)')
1940+
.option('--threshold <n>', 'Decision threshold for cheap-vs-strong', '0.5')
19421941
.action(async (model, options) => {
19431942
const td = loadTinyDancer();
1944-
const queryEmbedding = JSON.parse(options.query.startsWith('@') ? fs.readFileSync(options.query.slice(1), 'utf8') : options.query);
1945-
const candidates = JSON.parse(fs.readFileSync(options.candidates, 'utf8'));
1946-
const router = new td.Router({ modelPath: model, confidenceThreshold: parseFloat(options.threshold) });
1947-
const resp = await router.route({ queryEmbedding, candidates });
1948-
console.log(chalk.cyan('\n Routing decisions (best first):'));
1949-
for (const d of resp.decisions) {
1950-
console.log(` ${chalk.white(d.candidateId)} conf=${d.confidence.toFixed(3)} light=${d.useLightweight} unc=${d.uncertainty.toFixed(3)}`);
1951-
}
1952-
console.log(chalk.gray(` inference ${resp.inferenceTimeUs}µs over ${resp.candidatesProcessed} candidates\n`));
1943+
const embedding = JSON.parse(options.query.startsWith('@') ? fs.readFileSync(options.query.slice(1), 'utf8') : options.query);
1944+
const s = await td.score(model, embedding);
1945+
const threshold = parseFloat(options.threshold);
1946+
console.log(chalk.cyan(`\n score = ${s.toFixed(4)}`));
1947+
console.log(
1948+
s >= threshold
1949+
? chalk.green(' → route to the CHEAP model (good enough)\n')
1950+
: chalk.yellow(' → route to a STRONGER model\n')
1951+
);
19531952
});
19541953

19551954
tinyDancer
@@ -1960,7 +1959,7 @@ tinyDancer
19601959
const td = require('@ruvector/tiny-dancer');
19611960
console.log(chalk.green(`\n @ruvector/tiny-dancer ${td.version()}${td.hello()}`));
19621961
console.log(chalk.gray(' train: npx ruvector tiny-dancer train <draco.json> --out model.safetensors'));
1963-
console.log(chalk.gray(' route: npx ruvector tiny-dancer route <model.safetensors> --query <emb> --candidates <file>\n'));
1962+
console.log(chalk.gray(' score: npx ruvector tiny-dancer score <model.safetensors> --query <embedding.json>\n'));
19641963
} catch {
19651964
console.log(chalk.yellow('\n @ruvector/tiny-dancer not installed. npm install @ruvector/tiny-dancer\n'));
19661965
}

npm/packages/ruvector/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
},
8484
"optionalDependencies": {
8585
"@ruvector/rvf": "^0.1.0",
86-
"@ruvector/tiny-dancer": "^0.1.21"
86+
"@ruvector/tiny-dancer": "^0.1.22"
8787
},
8888
"devDependencies": {
8989
"@types/node": "^20.10.5",

0 commit comments

Comments
 (0)