提升稳定性

This commit is contained in:
qingxu fu
2023-04-09 18:59:43 +08:00
parent 91d07c329a
commit e6cf5532a9
10 changed files with 387 additions and 111 deletions

View File

@@ -58,11 +58,10 @@ def 全项目切换英文(txt, top_p, temperature, chatbot, history, sys_prompt,
# 第5步Token限制下的截断与处理
MAX_TOKEN = 3000
from transformers import GPT2TokenizerFast
print('加载tokenizer中')
tokenizer = GPT2TokenizerFast.from_pretrained("gpt2")
get_token_fn = lambda txt: len(tokenizer(txt)["input_ids"])
print('加载tokenizer结束')
import tiktoken
from toolbox import get_conf
enc = tiktoken.encoding_for_model(*get_conf('LLM_MODEL'))
def get_token_fn(txt): return len(enc.encode(txt))
# 第6步任务函数