update config templates

This commit is contained in:
imClumsyPanda 2023-11-30 23:20:39 +08:00
parent 072e0a2a32
commit 89b07ba55d
3 changed files with 123 additions and 133 deletions

View File

@ -106,7 +106,7 @@ kbs_config = {
# TextSplitter配置项如果你不明白其中的含义就不要修改。 # TextSplitter配置项如果你不明白其中的含义就不要修改。
text_splitter_dict = { text_splitter_dict = {
"ChineseRecursiveTextSplitter": { "ChineseRecursiveTextSplitter": {
"source": "huggingface", ## 选择tiktoken则使用openai的方法 "source": "huggingface", # 选择tiktoken则使用openai的方法
"tokenizer_name_or_path": "", "tokenizer_name_or_path": "",
}, },
"SpacyTextSplitter": { "SpacyTextSplitter": {

View File

@ -115,7 +115,7 @@ ONLINE_LLM_MODEL = {
# 昆仑万维天工 API https://model-platform.tiangong.cn/ # 昆仑万维天工 API https://model-platform.tiangong.cn/
"tiangong-api": { "tiangong-api": {
"version":"SkyChat-MegaVerse", "version": "SkyChat-MegaVerse",
"api_key": "", "api_key": "",
"secret_key": "", "secret_key": "",
"provider": "TianGongWorker", "provider": "TianGongWorker",
@ -166,9 +166,9 @@ MODEL_PATH = {
"chatglm3-6b-base": "THUDM/chatglm3-6b-base", "chatglm3-6b-base": "THUDM/chatglm3-6b-base",
"Qwen-1_8B": "Qwen/Qwen-1_8B", "Qwen-1_8B": "Qwen/Qwen-1_8B",
"Qwen-1_8B-Chat":"Qwen/Qwen-1_8B-Chat", "Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat",
"Qwen-1_8B-Chat-Int8":"Qwen/Qwen-1_8B-Chat-Int8", "Qwen-1_8B-Chat-Int8": "Qwen/Qwen-1_8B-Chat-Int8",
"Qwen-1_8B-Chat-Int4":"Qwen/Qwen-1_8B-Chat-Int4", "Qwen-1_8B-Chat-Int4": "Qwen/Qwen-1_8B-Chat-Int4",
"Qwen-7B": "Qwen/Qwen-7B", "Qwen-7B": "Qwen/Qwen-7B",
"Qwen-7B-Chat": "Qwen/Qwen-7B-Chat", "Qwen-7B-Chat": "Qwen/Qwen-7B-Chat",
@ -180,8 +180,8 @@ MODEL_PATH = {
"Qwen-72B": "Qwen/Qwen-72B", "Qwen-72B": "Qwen/Qwen-72B",
"Qwen-72B-Chat": "Qwen/Qwen-72B-Chat", "Qwen-72B-Chat": "Qwen/Qwen-72B-Chat",
"Qwen-72B-Chat-Int8":"Qwen/Qwen-72B-Chat-Int8" "Qwen-72B-Chat-Int8": "Qwen/Qwen-72B-Chat-Int8",
"Qwen-72B-Chat-Int4":"Qwen/Qwen-72B-Chat-Int4" "Qwen-72B-Chat-Int4": "Qwen/Qwen-72B-Chat-Int4",
"baichuan2-13b": "baichuan-inc/Baichuan2-13B-Chat", "baichuan2-13b": "baichuan-inc/Baichuan2-13B-Chat",
"baichuan2-7b": "baichuan-inc/Baichuan2-7B-Chat", "baichuan2-7b": "baichuan-inc/Baichuan2-7B-Chat",
@ -254,11 +254,11 @@ VLLM_MODEL_DICT = {
"BlueLM-7B-Chat-32k": "vivo-ai/BlueLM-7B-Chat-32k", "BlueLM-7B-Chat-32k": "vivo-ai/BlueLM-7B-Chat-32k",
# 注意bloom系列的tokenizer与model是分离的因此虽然vllm支持但与fschat框架不兼容 # 注意bloom系列的tokenizer与model是分离的因此虽然vllm支持但与fschat框架不兼容
# "bloom":"bigscience/bloom", # "bloom": "bigscience/bloom",
# "bloomz":"bigscience/bloomz", # "bloomz": "bigscience/bloomz",
# "bloomz-560m":"bigscience/bloomz-560m", # "bloomz-560m": "bigscience/bloomz-560m",
# "bloomz-7b1":"bigscience/bloomz-7b1", # "bloomz-7b1": "bigscience/bloomz-7b1",
# "bloomz-1b7":"bigscience/bloomz-1b7", # "bloomz-1b7": "bigscience/bloomz-1b7",
"internlm-7b": "internlm/internlm-7b", "internlm-7b": "internlm/internlm-7b",
"internlm-chat-7b": "internlm/internlm-chat-7b", "internlm-chat-7b": "internlm/internlm-chat-7b",
@ -286,9 +286,9 @@ VLLM_MODEL_DICT = {
"opt-iml-max-30b": "facebook/opt-iml-max-30b", "opt-iml-max-30b": "facebook/opt-iml-max-30b",
"Qwen-1_8B": "Qwen/Qwen-1_8B", "Qwen-1_8B": "Qwen/Qwen-1_8B",
"Qwen-1_8B-Chat":"Qwen/Qwen-1_8B-Chat", "Qwen-1_8B-Chat": "Qwen/Qwen-1_8B-Chat",
"Qwen-1_8B-Chat-Int8":"Qwen/Qwen-1_8B-Chat-Int8", "Qwen-1_8B-Chat-Int8": "Qwen/Qwen-1_8B-Chat-Int8",
"Qwen-1_8B-Chat-Int4":"Qwen/Qwen-1_8B-Chat-Int4", "Qwen-1_8B-Chat-Int4": "Qwen/Qwen-1_8B-Chat-Int4",
"Qwen-7B": "Qwen/Qwen-7B", "Qwen-7B": "Qwen/Qwen-7B",
"Qwen-7B-Chat": "Qwen/Qwen-7B-Chat", "Qwen-7B-Chat": "Qwen/Qwen-7B-Chat",
@ -300,8 +300,8 @@ VLLM_MODEL_DICT = {
"Qwen-72B": "Qwen/Qwen-72B", "Qwen-72B": "Qwen/Qwen-72B",
"Qwen-72B-Chat": "Qwen/Qwen-72B-Chat", "Qwen-72B-Chat": "Qwen/Qwen-72B-Chat",
"Qwen-72B-Chat-Int8":"Qwen/Qwen-72B-Chat-Int8" "Qwen-72B-Chat-Int8": "Qwen/Qwen-72B-Chat-Int8",
"Qwen-72B-Chat-Int4":"Qwen/Qwen-72B-Chat-Int4" "Qwen-72B-Chat-Int4": "Qwen/Qwen-72B-Chat-Int4",
"agentlm-7b": "THUDM/agentlm-7b", "agentlm-7b": "THUDM/agentlm-7b",
"agentlm-13b": "THUDM/agentlm-13b", "agentlm-13b": "THUDM/agentlm-13b",

View File

@ -16,122 +16,112 @@
# - input: 用户输入内容 # - input: 用户输入内容
# - agent_scratchpad: Agent的思维记录 # - agent_scratchpad: Agent的思维记录
PROMPT_TEMPLATES = {} PROMPT_TEMPLATES = {
"llm_chat": {
"default":
'{{ input }}',
PROMPT_TEMPLATES["llm_chat"] = { "with_history":
"default": "{{ input }}", 'The following is a friendly conversation between a human and an AI. '
"with_history": 'The AI is talkative and provides lots of specific details from its context. '
"""The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know. 'If the AI does not know the answer to a question, it truthfully says it does not know.\n\n'
'Current conversation:\n'
'{history}\n'
'Human: {input}\n'
'AI:',
Current conversation: "py":
{history} '你是一个聪明的代码助手请你给我写出简单的py代码。 \n'
Human: {input} '{{ input }}',
AI:""", },
"py":
"""
你是一个聪明的代码助手请你给我写出简单的py代码。 \n "knowledge_base_chat": {
{{ input }} "default":
""", '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,'
} '不允许在答案中添加编造成分,答案请使用中文。 </指令>\n'
'<已知信息>{{ context }}</已知信息>\n'
PROMPT_TEMPLATES["knowledge_base_chat"] = { '<问题>{{ question }}</问题>\n',
"default":
""" "text":
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。 </指令> '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
<已知信息>{{ context }}</已知信息>、 '<已知信息>{{ context }}</已知信息>\n'
<问题>{{ question }}</问题> '<问题>{{ question }}</问题>\n',
""",
"text": "Empty": # 搜不到知识库的时候使用
""" '请你回答我的问题:\n'
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令> '{{ question }}\n\n',
<已知信息>{{ context }}</已知信息>、 },
<问题>{{ question }}</问题>
""",
"Empty": # 搜不到知识库的时候使用 "search_engine_chat": {
""" "default":
请你回答我的问题: '<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。'
{{ question }} '如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令>\n'
\n '<已知信息>{{ context }}</已知信息>\n'
""", '<问题>{{ question }}</问题>\n',
}
PROMPT_TEMPLATES["search_engine_chat"] = { "search":
"default": '<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令>\n'
""" '<已知信息>{{ context }}</已知信息>\n'
<指令>这是我搜索到的互联网信息,请你根据这些信息进行提取并有调理,简洁的回答问题。如果无法从中得到答案,请说 “无法搜索到能回答问题的内容”。 </指令> '<问题>{{ question }}</问题>\n',
<已知信息>{{ context }}</已知信息> },
<问题>{{ question }}</问题>
""",
"search": "agent_chat": {
""" "default":
<指令>根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,答案请使用中文。 </指令> 'Answer the following questions as best you can. If it is in order, you can use some tools appropriately. '
<已知信息>{{ context }}</已知信息>、 'You have access to the following tools:\n\n'
<问题>{{ question }}</问题> '{tools}\n\n'
""", 'Use the following format:\n'
} 'Question: the input question you must answer1\n'
PROMPT_TEMPLATES["agent_chat"] = { 'Thought: you should always think about what to do and what tools to use.\n'
"default": 'Action: the action to take, should be one of [{tool_names}]\n'
""" 'Action Input: the input to the action\n'
Answer the following questions as best you can. If it is in order, you can use some tools appropriately.You have access to the following tools: 'Observation: the result of the action\n'
'... (this Thought/Action/Action Input/Observation can be repeated zero or more times)\n'
{tools} 'Thought: I now know the final answer\n'
'Final Answer: the final answer to the original input question\n'
Use the following format: 'Begin!\n\n'
Question: the input question you must answer1 'history: {history}\n\n'
Thought: you should always think about what to do and what tools to use. 'Question: {input}\n\n'
Action: the action to take, should be one of [{tool_names}] 'Thought: {agent_scratchpad}\n',
Action Input: the input to the action
Observation: the result of the action "ChatGLM3":
... (this Thought/Action/Action Input/Observation can be repeated zero or more times) 'You can answer using the tools, or answer directly using your knowledge without using the tools. '
Thought: I now know the final answer 'Respond to the human as helpfully and accurately as possible.\n'
Final Answer: the final answer to the original input question 'You have access to the following tools:\n'
Begin! '{tools}\n'
'Use a json blob to specify a tool by providing an action key (tool name) '
history: {history} 'and an action_input key (tool input).\n'
'Valid "action" values: "Final Answer" or [{tool_names}]'
Question: {input} 'Provide only ONE action per $JSON_BLOB, as shown:\n\n'
'```\n'
Thought: {agent_scratchpad} '{{{{\n'
""", ' "action": $TOOL_NAME,\n'
' "action_input": $INPUT\n'
"ChatGLM3": '}}}}\n'
""" '```\n\n'
You can answer using the tools, or answer directly using your knowledge without using the tools.Respond to the human as helpfully and accurately as possible. 'Follow this format:\n\n'
You have access to the following tools: 'Question: input question to answer\n'
{tools} 'Thought: consider previous and subsequent steps\n'
Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input). 'Action:\n'
Valid "action" values: "Final Answer" or [{tool_names}] '```\n'
Provide only ONE action per $JSON_BLOB, as shown: '$JSON_BLOB\n'
'```\n'
``` 'Observation: action result\n'
{{{{ '... (repeat Thought/Action/Observation N times)\n'
"action": $TOOL_NAME, 'Thought: I know what to respond\n'
"action_input": $INPUT 'Action:\n'
}}}} '```\n'
``` '{{{{\n'
' "action": "Final Answer",\n'
Follow this format: ' "action_input": "Final response to human"\n'
'}}}}\n'
Question: input question to answer 'Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. '
Thought: consider previous and subsequent steps 'Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\n'
Action: 'history: {history}\n\n'
``` 'Question: {input}\n\n'
$JSON_BLOB 'Thought: {agent_scratchpad}',
``` }
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{{{{
"action": "Final Answer",
"action_input": "Final response to human"
}}}}
Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.
history: {history}
Question: {input}
Thought: {agent_scratchpad}
""",
} }