Remove to-int conversion from Novel logprobs

This commit is contained in:
Cohee 2024-11-22 17:46:20 +00:00
parent 6ae120900d
commit 1938e8ac14
1 changed files with 2 additions and 2 deletions

View File

@ -519,14 +519,14 @@ function convertTokenIdLogprobsToText(input) {
const tokenizerId = getTokenizerBestMatch(api); 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 => const tokenIds = Array.from(new Set(input.flatMap(logprobs =>
logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token), logprobs.topLogprobs.map(([token]) => token).concat(logprobs.token),
))); )));
// Submit token IDs to tokenizer to get token text, then build ID->text map // Submit token IDs to tokenizer to get token text, then build ID->text map
// noinspection JSCheckFunctionSignatures - mutates input in-place // 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]])); const tokenIdText = new Map(tokenIds.map((id, i) => [id, chunks[i]]));
// Fixup logprobs data with token text // Fixup logprobs data with token text