Replace toxicity model with multi-label classifier

This commit is contained in:
Jordan Wages 2026-08-26 17:00:49 -05:00
commit 1568c787f8
24 changed files with 2581129 additions and 119717 deletions

View file

@ -11,11 +11,11 @@ describe("InferenceQueue", () => {
let calls = 0;
const queue = new InferenceQueue(async (requests) => {
calls += 1;
return requests.map((item) => ({ requestId: item.requestId, id: item.id, textHash: "hash", label: "toxic" as const, probability: .9, navigationId: item.navigationId }));
return requests.map((item) => ({ requestId: item.requestId, id: item.id, textHash: "hash", scores: { toxicity: .9, severe_toxicity: 0, obscene: 0, threat: 0, insult: 0, identity_attack: 0, sexual_explicit: 0 }, navigationId: item.navigationId }));
}, undefined, 10, 8, 0);
const first = await queue.enqueue(request("a", 0));
const second = await queue.enqueue({ ...request("b", 0), text: "text a" });
expect(first.probability).toBe(.9);
expect(first.scores.toxicity).toBe(.9);
expect(second.requestId).toBe("b");
expect(calls).toBe(1);
expect(queue.cacheSize).toBe(1);