@remnic/bench 9.3.577 → 9.3.579
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +69 -53
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22580,70 +22580,50 @@ function versioningConfig(overrides) {
|
|
|
22580
22580
|
// src/benchmarks/remnic/retrieval-personalization/runner.ts
|
|
22581
22581
|
import { randomUUID as randomUUID15 } from "crypto";
|
|
22582
22582
|
|
|
22583
|
-
// src/benchmarks/remnic/retrieval-shared.ts
|
|
22584
|
-
function prefixAggregates(prefix, aggregates) {
|
|
22585
|
-
const prefixed = {};
|
|
22586
|
-
for (const [metric, aggregate] of Object.entries(aggregates)) {
|
|
22587
|
-
prefixed[`${prefix}.${metric}`] = aggregate;
|
|
22588
|
-
}
|
|
22589
|
-
return prefixed;
|
|
22590
|
-
}
|
|
22591
|
-
function pairIdFromTaskId(taskId) {
|
|
22592
|
-
return taskId.replace(/^(clean|dirty):/, "");
|
|
22593
|
-
}
|
|
22594
|
-
function buildTieredAggregates(tasks) {
|
|
22595
|
-
const cleanTasks = tasks.filter((task) => task.details?.tier === "clean");
|
|
22596
|
-
const dirtyTasks = tasks.filter((task) => task.details?.tier === "dirty");
|
|
22597
|
-
const dirtyTasksByPairId = new Map(
|
|
22598
|
-
dirtyTasks.map((task) => [pairIdFromTaskId(task.taskId), task])
|
|
22599
|
-
);
|
|
22600
|
-
const pairedDeltas = cleanTasks.flatMap((task) => {
|
|
22601
|
-
const dirtyTask = dirtyTasksByPairId.get(pairIdFromTaskId(task.taskId));
|
|
22602
|
-
if (!dirtyTask) return [];
|
|
22603
|
-
const metricNames = /* @__PURE__ */ new Set([
|
|
22604
|
-
...Object.keys(task.scores),
|
|
22605
|
-
...Object.keys(dirtyTask.scores)
|
|
22606
|
-
]);
|
|
22607
|
-
const deltaScores = {};
|
|
22608
|
-
for (const metricName of metricNames) {
|
|
22609
|
-
deltaScores[metricName] = (task.scores[metricName] ?? 0) - (dirtyTask.scores[metricName] ?? 0);
|
|
22610
|
-
}
|
|
22611
|
-
return [deltaScores];
|
|
22612
|
-
});
|
|
22613
|
-
return {
|
|
22614
|
-
...prefixAggregates("clean", aggregateTaskScores(cleanTasks.map((task) => task.scores))),
|
|
22615
|
-
...prefixAggregates("dirty", aggregateTaskScores(dirtyTasks.map((task) => task.scores))),
|
|
22616
|
-
...prefixAggregates("dirty_penalty", aggregateTaskScores(pairedDeltas))
|
|
22617
|
-
};
|
|
22618
|
-
}
|
|
22619
|
-
|
|
22620
22583
|
// src/benchmarks/remnic/retrieval-page-ids.ts
|
|
22621
|
-
function extractRankedPageIds(recallText, pages) {
|
|
22622
|
-
const pageIdByLowercase = new Map(
|
|
22623
|
-
|
|
22624
|
-
);
|
|
22625
|
-
return collectPageIdMarkers(recallText).sort((left, right) => {
|
|
22584
|
+
function extractRankedPageIds(recallText, pages, options = {}) {
|
|
22585
|
+
const pageIdByLowercase = new Map(pages.map((page) => [page.id.toLowerCase(), page.id]));
|
|
22586
|
+
const rankedPageIds = collectPageIdMarkers(recallText).sort((left, right) => {
|
|
22626
22587
|
if (left.index !== right.index) {
|
|
22627
22588
|
return left.index - right.index;
|
|
22628
22589
|
}
|
|
22629
22590
|
return left.id.localeCompare(right.id);
|
|
22630
22591
|
}).map((match) => resolvePageId(match.id, pageIdByLowercase));
|
|
22592
|
+
const seenKnown = /* @__PURE__ */ new Map();
|
|
22593
|
+
const out = [];
|
|
22594
|
+
for (const pageId of rankedPageIds) {
|
|
22595
|
+
if (!pageId.known) {
|
|
22596
|
+
out.push(pageId.id);
|
|
22597
|
+
continue;
|
|
22598
|
+
}
|
|
22599
|
+
const seenCount = seenKnown.get(pageId.id) ?? 0;
|
|
22600
|
+
seenKnown.set(pageId.id, seenCount + 1);
|
|
22601
|
+
if (seenCount === 0) {
|
|
22602
|
+
out.push(pageId.id);
|
|
22603
|
+
} else if (options.preserveDuplicateRankSlots) {
|
|
22604
|
+
out.push(formatDuplicatePageIdSlot(pageId.id, seenCount + 1));
|
|
22605
|
+
}
|
|
22606
|
+
}
|
|
22607
|
+
return out;
|
|
22631
22608
|
}
|
|
22632
22609
|
function resolvePageId(markerId, pageIdByLowercase) {
|
|
22633
22610
|
const normalizedMarkerId = stripLeadingFormattingDelimiters(markerId).toLowerCase();
|
|
22634
22611
|
const exact = pageIdByLowercase.get(normalizedMarkerId);
|
|
22635
22612
|
if (exact !== void 0) {
|
|
22636
|
-
return exact;
|
|
22613
|
+
return { id: exact, known: true };
|
|
22637
22614
|
}
|
|
22638
22615
|
let candidate = normalizedMarkerId;
|
|
22639
22616
|
while (candidate.length > 0 && isTrailingFormattingDelimiter(candidate.charCodeAt(candidate.length - 1), { includePeriod: true })) {
|
|
22640
22617
|
candidate = candidate.slice(0, -1);
|
|
22641
22618
|
const known = pageIdByLowercase.get(candidate);
|
|
22642
22619
|
if (known !== void 0) {
|
|
22643
|
-
return known;
|
|
22620
|
+
return { id: known, known: true };
|
|
22644
22621
|
}
|
|
22645
22622
|
}
|
|
22646
|
-
return stripTrailingFormattingDelimiters(normalizedMarkerId);
|
|
22623
|
+
return { id: stripTrailingFormattingDelimiters(normalizedMarkerId), known: false };
|
|
22624
|
+
}
|
|
22625
|
+
function formatDuplicatePageIdSlot(pageId, ordinal) {
|
|
22626
|
+
return `__duplicate_page_id_slot__:${ordinal}:${pageId}`;
|
|
22647
22627
|
}
|
|
22648
22628
|
function collectPageIdMarkers(recallText) {
|
|
22649
22629
|
const out = [];
|
|
@@ -22734,6 +22714,43 @@ function buildSchemaTierMessages(pages) {
|
|
|
22734
22714
|
}));
|
|
22735
22715
|
}
|
|
22736
22716
|
|
|
22717
|
+
// src/benchmarks/remnic/retrieval-shared.ts
|
|
22718
|
+
function prefixAggregates(prefix, aggregates) {
|
|
22719
|
+
const prefixed = {};
|
|
22720
|
+
for (const [metric, aggregate] of Object.entries(aggregates)) {
|
|
22721
|
+
prefixed[`${prefix}.${metric}`] = aggregate;
|
|
22722
|
+
}
|
|
22723
|
+
return prefixed;
|
|
22724
|
+
}
|
|
22725
|
+
function pairIdFromTaskId(taskId) {
|
|
22726
|
+
return taskId.replace(/^(clean|dirty):/, "");
|
|
22727
|
+
}
|
|
22728
|
+
function buildTieredAggregates(tasks) {
|
|
22729
|
+
const cleanTasks = tasks.filter((task) => task.details?.tier === "clean");
|
|
22730
|
+
const dirtyTasks = tasks.filter((task) => task.details?.tier === "dirty");
|
|
22731
|
+
const dirtyTasksByPairId = new Map(
|
|
22732
|
+
dirtyTasks.map((task) => [pairIdFromTaskId(task.taskId), task])
|
|
22733
|
+
);
|
|
22734
|
+
const pairedDeltas = cleanTasks.flatMap((task) => {
|
|
22735
|
+
const dirtyTask = dirtyTasksByPairId.get(pairIdFromTaskId(task.taskId));
|
|
22736
|
+
if (!dirtyTask) return [];
|
|
22737
|
+
const metricNames = /* @__PURE__ */ new Set([
|
|
22738
|
+
...Object.keys(task.scores),
|
|
22739
|
+
...Object.keys(dirtyTask.scores)
|
|
22740
|
+
]);
|
|
22741
|
+
const deltaScores = {};
|
|
22742
|
+
for (const metricName of metricNames) {
|
|
22743
|
+
deltaScores[metricName] = (task.scores[metricName] ?? 0) - (dirtyTask.scores[metricName] ?? 0);
|
|
22744
|
+
}
|
|
22745
|
+
return [deltaScores];
|
|
22746
|
+
});
|
|
22747
|
+
return {
|
|
22748
|
+
...prefixAggregates("clean", aggregateTaskScores(cleanTasks.map((task) => task.scores))),
|
|
22749
|
+
...prefixAggregates("dirty", aggregateTaskScores(dirtyTasks.map((task) => task.scores))),
|
|
22750
|
+
...prefixAggregates("dirty_penalty", aggregateTaskScores(pairedDeltas))
|
|
22751
|
+
};
|
|
22752
|
+
}
|
|
22753
|
+
|
|
22737
22754
|
// src/fixtures/schema-tiers/index.ts
|
|
22738
22755
|
var DEFAULT_SCHEMA_TIER_SEED = 448;
|
|
22739
22756
|
var CLEAN_PAGES = [
|
|
@@ -23215,7 +23232,9 @@ async function runRetrievalPersonalizationBenchmark(options) {
|
|
|
23215
23232
|
await options.system.drain?.();
|
|
23216
23233
|
const recallText = await options.system.recall(sessionId, sample.query, 12e3);
|
|
23217
23234
|
const latencyMs = Math.round(performance.now() - startedAt);
|
|
23218
|
-
const rankedPageIds = extractRankedPageIds(recallText, sample.pages
|
|
23235
|
+
const rankedPageIds = extractRankedPageIds(recallText, sample.pages, {
|
|
23236
|
+
preserveDuplicateRankSlots: true
|
|
23237
|
+
});
|
|
23219
23238
|
const topRetrievedPageIds = rankedPageIds.slice(0, 5);
|
|
23220
23239
|
const expectedJson = JSON.stringify(sample.expectedPageIds);
|
|
23221
23240
|
const actualJson = JSON.stringify(topRetrievedPageIds);
|
|
@@ -23356,14 +23375,11 @@ async function runRetrievalTemporalBenchmark(options) {
|
|
|
23356
23375
|
await options.system.reset(sessionId);
|
|
23357
23376
|
await options.system.store(sessionId, buildSchemaTierMessages(sample.pages));
|
|
23358
23377
|
await options.system.drain?.();
|
|
23359
|
-
const recallText = await options.system.recall(
|
|
23360
|
-
sessionId,
|
|
23361
|
-
sample.query,
|
|
23362
|
-
12e3,
|
|
23363
|
-
{ asOf: sample.window.end }
|
|
23364
|
-
);
|
|
23378
|
+
const recallText = await options.system.recall(sessionId, sample.query, 12e3, { asOf: sample.window.end });
|
|
23365
23379
|
const latencyMs = Math.round(performance.now() - startedAt);
|
|
23366
|
-
const retrievedPageIds = extractRankedPageIds(recallText, sample.pages
|
|
23380
|
+
const retrievedPageIds = extractRankedPageIds(recallText, sample.pages, {
|
|
23381
|
+
preserveDuplicateRankSlots: true
|
|
23382
|
+
});
|
|
23367
23383
|
const topRetrievedPageIds = retrievedPageIds.slice(0, 5);
|
|
23368
23384
|
const matchedPageIds = matchingPageIds(retrievedPageIds, sample);
|
|
23369
23385
|
const expectedJson = JSON.stringify({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remnic/bench",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.579",
|
|
4
4
|
"description": "Retrieval latency ladder benchmarks + CI regression gates for @remnic/core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"hyparquet": "^1.25.7",
|
|
36
36
|
"yaml": "^2.4.2",
|
|
37
|
-
"@remnic/core": "^9.3.
|
|
37
|
+
"@remnic/core": "^9.3.579"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"tsup": "^8.5.1",
|