From 8dba6b2a5d74da81407d4e8a7924c72c7a2157e9 Mon Sep 17 00:00:00 2001 From: thinksoso Date: Wed, 12 Apr 2023 20:43:41 +0800 Subject: [PATCH] add test --- .gitignore | 3 ++- infer.py | 5 +++-- scripts/test.sh | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 scripts/test.sh diff --git a/.gitignore b/.gitignore index 132750f..850112c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ lora-** *ckpt wandb todo.txt -.vscode/ \ No newline at end of file +.vscode/ +*tmp* \ No newline at end of file diff --git a/infer.py b/infer.py index 89bd5fe..0f2ff21 100644 --- a/infer.py +++ b/infer.py @@ -31,7 +31,7 @@ def main( instruct_dir: str = "", use_lora: bool = True, lora_weights: str = "tloen/alpaca-lora-7b", - # The prompt template to use, will default to alpaca. + # The prompt template to use, will default to med_template. prompt_template: str = "med_template", ): prompter = Prompter(prompt_template) @@ -111,9 +111,10 @@ def main( infer_from_json(instruct_dir) else: for instruction in [ - "一位50岁女性出现不适、厌油腻、肝囊肿等症状,检查后发现为胆囊癌,并且病情十分严重,应该如何进行治疗?", + "我感冒了,怎么治疗", "一个患有肝衰竭综合征的病人,除了常见的临床表现外,还有哪些特殊的体征?", "急性阑尾炎和缺血性心脏病的多发群体有何不同?", + "小李最近出现了心动过速的症状,伴有轻度胸痛。体检发现P-R间期延长,伴有T波低平和ST段异常", ]: print("Instruction:", instruction) print("Response:", evaluate(instruction)) diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 0000000..c7747c9 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +# If inferring with the llama model, set 'use_lora' to 'False' and 'prompt_template' to 'ori_template'. +# If inferring with the default alpaca model, set 'use_lora' to 'True', 'lora_weights' to 'tloen/alpaca-lora-7b', and 'prompt_template' to 'alpaca'. +# If inferring with the llama-med model, download the LORA weights and set 'lora_weights' to './lora-llama-med' (or the exact directory of LORA weights) and 'prompt_template' to 'med_template'. + +BASE_MODEL="decapoda-research/llama-7b-hf" +# 原始llama +o_cmd="python infer.py \ + --base_model ${BASE_MODEL} \ + --use_lora False \ + --prompt_template 'ori_template'" + +# Alpaca +a_cmd="python infer.py \ + --base_model ${BASE_MODEL} \ + --use_lora True \ + --lora_weights "tloen/alpaca-lora-7b" \ + --prompt_template 'alpaca'" + +# llama-med +m_cmd="python infer.py \ + --base_model ${BASE_MODEL} \ + --use_lora True \ + --lora_weights "lora-llama-med" \ + --prompt_template 'med_template'" + +echo "ori" +eval $o_cmd > infer_result/o_tmp.txt +echo "alpaca" +eval $a_cmd > infer_result/a_tmp.txt +echo "med" +eval $m_cmd > infer_result/m_tmp.txt \ No newline at end of file