文本推理样例

- 如果执行文本推理时报“cannot allocate memory in static TLS block”错误,处理方法请参见使用第三方库transformers跑模型推理时,报错“cannot allocate memory in static TLS block”章节。
- 执行样例前请使用以下命令配置环境变量。
source /usr/local/Ascend/ascend-toolkit/set_env.sh # CANN source /usr/local/Ascend/nnal/atb/set_env.sh # ATB source /usr/local/Ascend/llm_model/set_env.sh # ATB Models source /usr/local/Ascend/mindie/set_env.sh # MindIE
带后处理性能测试样例
# Engine模式 文本推理 SMPL_PARAM='{\"temperature\":0.5,\"top_k\":10,\"top_p\":0.9,\"typical_p\":0.9,\"seed\":1234,\"repetition_penalty\":1,\"watermark\":true}' benchmark \ --DatasetPath "/{数据集路径}/GSM8K/" \ --DatasetType "gsm8k" \ --ModelName llama2-7b \ --ModelPath "/{模型权重路径}/LLaMA3-8B/" \ --TestType engine \ --Tokenizer True \ --Concurrency 128 \ --MaxOutputLen 512 \ --DoSampling True \ --SamplingParams=$SMPL_PARAM
Engine文本推理模式输出结果如图1所示:
不带后处理性能测试样例
# Engine模式 文本推理 benchmark \ --DatasetPath "/{数据集路径}/CEval" \ --DatasetType "ceval" \ --ModelName "baichuan2_13b" \ --ModelPath "/{模型权重路径}/baichuan2-13b" \ --TestType engine \ --Concurrency 50 \ --MaxOutputLen 512 \ --Tokenizer True
精度测试样例

- 使用CEval或MMLU数据集计算精度时,MaxOutputLen的值不应设置太大,比如设置为20即可。
- MindIE Server的config.json配置文件中maxSeqLen参数的值一般根据数据序列长度设置。
- 对于CEval数据集,maxSeqLen的参考值为3072;
- 对于MMLU数据集,maxSeqLen的参考值为3600,该数据集中有约为1.4w条数据,推理耗时会比较长。
样例如下所示:
benchmark \ --DatasetPath "/{数据集路径}/CEval" \ --DatasetType "ceval" \ --ModelName "baichuan2_13b" \ --ModelPath "/{模型权重路径}/baichuan2-13b" \ --TestType engine \ --Concurrency 1 \ --MaxOutputLen 20 \ --Tokenizer True \ --TestAccuracy True
父主题: Engine推理模式