From 596732a98199de543f5c660c612b84adc18969a4 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 17 Feb 2023 12:35:30 -0300 Subject: [PATCH] The soft prompt length must be considered here too --- server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server.py b/server.py index 145f2ae1..181a3c9d 100644 --- a/server.py +++ b/server.py @@ -505,11 +505,17 @@ def clean_chat_message(text): return text def generate_chat_prompt(text, tokens, name1, name2, context, chat_prompt_size, impersonate=False): + global soft_prompt, soft_prompt_tensor + text = clean_chat_message(text) rows = [f"{context.strip()}\n"] i = len(history['internal'])-1 count = 0 + + if soft_prompt: + chat_prompt_size -= soft_prompt_tensor.shape[1] max_length = min(get_max_prompt_length(tokens), chat_prompt_size) + while i >= 0 and len(encode(''.join(rows), tokens)[0]) < max_length: rows.insert(1, f"{name2}: {history['internal'][i][1].strip()}\n") count += 1