Non-streaming logprobs for Aphrodite
This commit is contained in:
parent
d140b8d5be
commit
d5bf9fc28c
|
@ -4489,6 +4489,7 @@ function parseAndSaveLogprobs(data, continueFrom) {
|
||||||
case textgen_types.LLAMACPP: {
|
case textgen_types.LLAMACPP: {
|
||||||
logprobs = data?.completion_probabilities?.map(x => parseTextgenLogprobs(x.content, [x])) || null;
|
logprobs = data?.completion_probabilities?.map(x => parseTextgenLogprobs(x.content, [x])) || null;
|
||||||
} break;
|
} break;
|
||||||
|
case textgen_types.APHRODITE:
|
||||||
case textgen_types.TABBY: {
|
case textgen_types.TABBY: {
|
||||||
logprobs = parseTabbyLogprobs(data) || null;
|
logprobs = parseTabbyLogprobs(data) || null;
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -153,8 +153,9 @@ function renderTopLogprobs() {
|
||||||
let matched = false;
|
let matched = false;
|
||||||
for (const [token, probability, log] of candidates) {
|
for (const [token, probability, log] of candidates) {
|
||||||
const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>');
|
const container = $('<button class="flex-container flexFlowColumn logprobs_top_candidate"></button>');
|
||||||
|
const tokenNormalized = String(token).replace(/^▁/g, ' ');
|
||||||
|
|
||||||
if (token === selectedToken) {
|
if (token === selectedToken || tokenNormalized === selectedToken) {
|
||||||
matched = true;
|
matched = true;
|
||||||
container.addClass('selected');
|
container.addClass('selected');
|
||||||
}
|
}
|
||||||
|
@ -222,7 +223,7 @@ function onAlternativeClicked(tokenLogprobs, alternative) {
|
||||||
const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs);
|
const replaceIndex = messageLogprobs.findIndex(x => x === tokenLogprobs);
|
||||||
|
|
||||||
const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token);
|
const tokens = messageLogprobs.slice(0, replaceIndex + 1).map(({ token }) => token);
|
||||||
tokens[replaceIndex] = alternative;
|
tokens[replaceIndex] = String(alternative).replace(/^▁/g, ' ');
|
||||||
|
|
||||||
const prefix = continueFrom || '';
|
const prefix = continueFrom || '';
|
||||||
const prompt = prefix + tokens.join('');
|
const prompt = prefix + tokens.join('');
|
||||||
|
@ -335,7 +336,7 @@ function createSwipe(messageId, prompt) {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function toVisibleWhitespace(input) {
|
function toVisibleWhitespace(input) {
|
||||||
return input.replace(/ /g, '·').replace(/\n/g, '↵');
|
return input.replace(/ /g, '·').replace(/▁/g, '·').replace(/\n/g, '↵');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -354,6 +355,9 @@ function withVirtualWhitespace(text, span) {
|
||||||
if (text.match(/\s$/)) {
|
if (text.match(/\s$/)) {
|
||||||
result.push($(document.createTextNode('\u200b')));
|
result.push($(document.createTextNode('\u200b')));
|
||||||
}
|
}
|
||||||
|
if (text.match(/^▁/)) {
|
||||||
|
result.unshift(document.createTextNode('\u200b'));
|
||||||
|
}
|
||||||
// line breaks are trickier. we don't currently handle consecutive line
|
// line breaks are trickier. we don't currently handle consecutive line
|
||||||
// breaks or line breaks occuring in between non-whitespace characters, but
|
// breaks or line breaks occuring in between non-whitespace characters, but
|
||||||
// tokenizers generally don't produce those anyway.
|
// tokenizers generally don't produce those anyway.
|
||||||
|
|
Loading…
Reference in New Issue