使用opencompass在Humaneval+上对比Qwen2-7B和AlchemistCoder-DS-6.7B

AlchemistCoder

AlchemistCoder 是InternLM的代码生成模型
对比一下类似参数,近期评价很好的Qwen2-7B
在这里插入图片描述

下载模型

分别下载到本地(使用hf-mirror)

huggingface-cli download --resume-download internlm/AlchemistCoder-DS-6.7B --local-dir /root/models/AlchemistCoder-DS-6.7B/

huggingface-cli download --resume-download Qwen/Qwen2-7B-Instruct --local-dir /root/models/Qwen2-7B-Instruct/

运行评测

python run.py
--datasets humaneval_plus_gen \
--hf-path /root/models/AlchemistCoder-DS-6.7B \  # HuggingFace 模型路径
--tokenizer-path /root/models/AlchemistCoder-DS-6.7B \  # HuggingFace tokenizer 路径(如果与模型路径相同,可以省略)
--tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True \  # 构建 tokenizer 的参数
--model-kwargs device_map='auto' trust_remote_code=True \  # 构建模型的参数
--max-seq-len 1024 \  # 模型可以接受的最大序列长度
--max-out-len 1024 \  # 生成的最大 token 数
--batch-size 2  \  # 批量大小
--num-gpus 1  \ # 运行模型所需的 GPU 数量
--debug
python run.py  \
--datasets humaneval_plus_gen  \ 
--hf-path /root/models/Qwen2-7B-Instruct  \
--tokenizer-path /root/models/Qwen2-7B-Instruct  \
--tokenizer-kwargs  trust_remote_code=True padding_side='left' truncation=''left'    \
--model-kwargs device_map='auto' trust_remote_code=True torch_dtype='auto'   \ 
--max-seq-len 1024 \ 
--max-out-len 1024 \ 
--batch-size 2  \  
--num-gpus 1  \ 
--debug 

报错

  File "/root/opencompass/opencompass/datasets/humaneval.py", line 71, in __init__
    raise ImportError(
ImportError: Please install evalplus use following steps:
git clone --recurse-submodules git@github.com:open-compass/human-eval.git
cd human-eval
pip install -e .
pip install -e evalplus

如果直接pip install parallel也会报错如下

File "/root/.conda/envs/opencompass/lib/python3.10/site-packages/evalplus/evaluate.py", line 128, in evaluate
    if flags.parallel is None:
AttributeError: 'dict' object has no attribute 'parallel'

后使用源码安装(git clone --recurse-submodules git@github.com:open-compass/human-eval.git 会报错)

git clone  https://github.com/open-compass/evalplus.git
cd evalplus
pip install -e .

替换了版本

Successfully built evalplus
Installing collected packages: evalplus
  Attempting uninstall: evalplus
    Found existing installation: evalplus 0.2.1
    Uninstalling evalplus-0.2.1:
      Successfully uninstalled evalplus-0.2.1
Successfully installed evalplus-0.1.0.dev598

batch size参数设置

batch sizetime
21637.15s
10526.18s
2024G显存不足

结果

AlchemistCoder-DS-6.7BQwen2-7B-Instruct
45.7335.36

两个模型的得分都低于主页上的分数
Qwen2-7B-Instruct一开始是0,部分预测内容如下
在这里插入图片描述需要修改
opencompass/opencompass/models/huggingface.py

# self.model.generation_config.do_sample = False

然后可以正常跑完

### 不同大小的Qwen2模型性能对比 对于 Qwen2-7B Qwen2-2.5B 模型,在多个方面存在显著差异,这些差异影响了各自的表现能力。 #### 性能表现 较大的 Qwen2-7B 模型通常具有更好的泛化能力更高的准确性。这是因为更大的参数量允许网络学习到更复杂的模式并更好地捕捉数据中的细微差别[^1]。相比之下,较小的 Qwen2-2.5B 虽然在资源消耗上更为经济高效,但在处理复杂任务时可能不如较大版本那么出色。 #### 训练效率与推理速度 由于拥有较少的参数数量,Qwen2-2.5B 在训练过程中所需的计算资源相对较低,并且可以更快完成一轮迭代;同样地,在实际应用环境中执行预测操作也会更加迅速。然而,这种优势是以牺牲一定的精度为代价换取而来。 #### 应用场景适应性 如果应用场景对实时响应有较高要求,则可以选择轻量化版即 Qwen2-2.5B 来满足需求;而对于那些追求极致效果而不受限于硬件条件的任务来说,采用高容量配置如 Qwen2-7B 将会是一个明智的选择。 ```python import time def compare_model_performance(model_2_5b, model_7b): start_time = time.time() result_2_5b = model_2_5b.predict() # 假设 predict 方法用于获取模型输出 end_time_2_5b = time.time() result_7b = model_7b.predict() end_time_7b = time.time() inference_time_2_5b = end_time_2_5b - start_time inference_time_7b = end_time_7b - end_time_2_5b print(f"Inference Time (2.5B): {inference_time_2_5b:.4f} seconds") print(f"Inference Time (7B): {inference_time_7b:.4f} seconds") # 示例调用函数来展示两个模型之间的推断时间区别 compare_model_performance(Model2_5B(), Model7B()) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值