From 1938e8ac141c53846eae23a4e8d2d7093049dd1e Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 22 Nov 2024 17:46:20 +0000 Subject: [PATCH] Remove to-int conversion from Novel logprobs --- public/scripts/logprobs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/scripts/logprobs.js b/public/scripts/logprobs.js index fa7ff0d15..17c0584a3 100644 --- a/public/scripts/logprobs.js +++ b/public/scripts/logprobs.js @@ -519,14 +519,14 @@ function convertTokenIdLogprobsToText(input) { const tokenizerId = getTokenizerBestMatch(api); - // Flatten unique token IDs across all logprobs + /** @type {any[]} Flatten unique token IDs across all logprobs */ const tokenIds = Array.from(new Set(input.flatMap(logprobs => logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token), ))); // Submit token IDs to tokenizer to get token text, then build ID->text map // noinspection JSCheckFunctionSignatures - mutates input in-place - const { chunks } = decodeTextTokens(tokenizerId, tokenIds.map(parseInt)); + const { chunks } = decodeTextTokens(tokenizerId, tokenIds); const tokenIdText = new Map(tokenIds.map((id, i) => [id, chunks[i]])); // Fixup logprobs data with token text