From a345a2acd2df85910669a84a81926296b632a36c Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:16:55 -0300 Subject: [PATCH] Add a tokenizer placeholder --- modules/text_generation.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/text_generation.py b/modules/text_generation.py index 6537512..bd018c0 100644 --- a/modules/text_generation.py +++ b/modules/text_generation.py @@ -21,8 +21,11 @@ def get_max_prompt_length(tokens): return max_length def encode(prompt, tokens_to_generate=0, add_special_tokens=True): + + # These models do not have explicit tokenizers for now, so + # we return an estimate on the number of tokens if shared.is_RWKV or shared.is_LLaMA: - return prompt + return np.zeros((1, len(prompt)//5)) input_ids = shared.tokenizer.encode(str(prompt), return_tensors='pt', truncation=True, max_length=get_max_prompt_length(tokens_to_generate), add_special_tokens=add_special_tokens) if shared.args.cpu: