benchmark \ --DatasetPath "/{数据集路径}/GSM8K/" \ --DatasetType gsm8k \ --ModelName {Lora模型ID} \ --ModelPath "/{模型权重路径}/llama_7b" \ --TestType vllm_client \ --Http https://{ipAddress}:{port} \ --ManagementHttp https://{managementIpAddress}:{managementPort} \ --Tokenizer True \ --TestAccuracy True \ --DoSampling False
benchmark \ --DatasetPath "/{数据集路径}/GSM8K/" \ --DatasetType gsm8k \ --ModelName llama_7b \ --ModelPath "/{模型权重路径}/llama_7b" \ --TestType vllm_client \ --Http https://{ipAddress}:{port} \ --ManagementHttp https://{managementIpAddress}:{managementPort} \ --Tokenizer True \ --TestAccuracy True \ --DoSampling False \ --LoraDataMappingFile {Lora模型与推理数据映射文件路径}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | import json import random def create_json(file_path): # 可选模型名称列表 choices = ["BaseModel", "LoraAdapter1", "LoraAdapter2"] with open(file_path, 'w', encoding='utf-8') as file: # 根据模型名称随机选择BaseModel或Lora模型对1000条数据进行推理(用户根据需要自行配置映射逻辑) for i in range(1000): current_choice_idx = random.randint(0, len(choices) - 1) if current_choice_idx==0: # BaseModel无需指定与数据的映射关系,未指定映射的数据默认使用BaseModel continue # 每一行保存一组数据与Lora模型ID的映射关系 data = json.dumps({str(i): choices[current_choice_idx]}) file.write(data + "\n") if __name__ == "__main__": create_json("lora_mapping.json") |
执行以上脚本后生成配置文件(文件名以lora_mapping.json为例):
python generate_lora_mapping_file.py
lora_mapping.json配置文件内容示例如下:
{"0": "LoraAdapter1"} {"1": "LoraAdapter2"} {"6": "LoraAdapter1"} {"7": "LoraAdapter2"} {"8": "LoraAdapter1"} {"9": "LoraAdapter2"} {"10": "LoraAdapter1"} {"11": "LoraAdapter1"} {"13": "LoraAdapter2"}