提示格式
根據使用的語言模型不同,使用不同的格式來下指令可以得到更好的結果,akasha目前提供 gpt, llama, chat_gpt, chat_mistral, chat_gemini, auto 等格式
若選擇 auto會根據模型類別來決定提示格式
gpt
1 2 3 4
|
prompt_format = System: {system_prompt} \n\n {history_messages} \n\n Human: {prompt}
|
llama
1 2 3 4
|
prompt_format = [INST] <<SYS>> {system_prompt} \n\n <<SYS>> {history_messages} \n\n {prompt} [\INST]
|
chat_gpt
1 2 3 4 5 6 7 8 9 10
|
prompt_format = [{"role":"system", "content": {system_prompt} }, {"role":"user", "content": {history msg1}}, {"role":"assistant", "content": {history msg2}}, . . . {"role":"user", "content": {prompt}}]
|
chat_mistral
1 2 3 4 5 6 7 8 9 10 11
|
prompt_format = [{"role":"user", "content": "start conversation" }, {"role":"assistant", "content": {system_prompt}}, {"role":"user", "content": {history msg1}}, {"role":"assistant", "content": {history msg2}}, . . . {"role":"user", "content": {prompt}}]
|
chat_gemini
1 2 3 4 5 6 7 8 9
| prompt_format =[{"role":"model", "parts": [{system_prompt}]}, {"role":"user", "parts": [{history msg1}]}, {"role":"model", "parts": [{history msg2}]}, . . . {"role":"user", "parts": [{prompt}]}]
|
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| import akasha sys_prompt = "請用中文回答" prompt = "五軸是甚麼?" qa = akasha.RAG( verbose=False, search_type="svm", model="openai:gpt-3.5-turbo", prompt_format_type="chat_gpt")
response = qa( data_source="docs/mic/", prompt=prompt, system_prompt=sys_prompt, )
|
Example2
1 2 3 4 5 6 7 8 9 10 11 12
| import akasha import akasha.helper as ah from akasha.utils.prompts.gen_prompt import format_sys_prompt
sys_prompt = "請用中文回答" prompt_format = "chat_gpt" prompt = "五軸是甚麼?" input_text = format_sys_prompt(sys_prompt,prompt,prompt_format) model_obj = akasha.handle_model("openai:gpt-3.5-turbo",False,0.0)
response = ah.call_model(model_obj, input_text)
|