intertnlm实训营第六次作业

作业

基础作业

  • 使用 OpenCompass 评测 InternLM2-Chat-7B 模型在 C-Eval 数据集上的性能

使用下边的命令

python run.py --datasets ceval_gen --hf-path /share/temp/model_repos/internlm2-chat-7b/ --tokenizer-path /share/temp/model_repos/internlm2-chat-7b/ --tokenizer-kwargs padding_side='left' truncation='left' trust_remote_code=True --model-kwargs trust_remote_code=True device_map='auto' --max-seq-len 1024 --max-out-len 16 --batch-size 2 --num-gpus 1 --debug

刚开始的时候,用的是max-seq-len=2048,bs = 2,开始冒红,猜测是显存问题,调小了就好了

进阶作业

configs目录下创建文件eval_internlm2_chat.py

from mmengine.config import read_base
from opencompass.models.turbomind import TurboMindModel

with read_base():
    # choose a list of datasets
    from .datasets.ceval.ceval_gen_5f30c7 import ceval_datasets


datasets = [*ceval_datasets]

internlm_meta_template = dict(round=[
    dict(role='HUMAN', begin='<|User|>:', end='\n'),
    dict(role='BOT', begin='<|Bot|>:', end='<eoa>\n', generate=True),
],
                              eos_token_id=103028)

# config for internlm2-chat-7b
internlm2_chat_7b = dict(
    type=TurboMindModel,
    abbr='internlm2-chat-7b',
    path='/root/internlm2-chat-7b-4bit-quant',
    engine_config=dict(session_len=2048,
                       max_batch_size=32,
                       rope_scaling_factor=1.0),
    gen_config=dict(top_k=1,
                    top_p=0.8,
                    temperature=1.0,
                    max_new_tokens=100),
    max_out_len=100,
    max_seq_len=1024,
    batch_size=2,
    concurrency=32,
    meta_template=internlm_meta_template,
    run_cfg=dict(num_gpus=1, num_procs=1),
)

models = [internlm2_chat_7b]

使用下面的命令对模型量化并运行

# 进行量化并转为turbomind格式
lmdeploy lite auto_awq /root/share/model_repos/internlm2-chat-7b --work-dir internlm2-chat-7b-4bit
# 模型转换
lmdeploy convert internlm2-chat-7b ./internlm2-chat-7b-4bit/ --model-format awq --group-size 128  --dst-path internlm2-chat-7b-4bit-quant
# 运行脚本
python run.py configs/eval_test.py -w outputs/lmdeploy_turbomind/internlm2-7b-chat --debug

原本的

量化前后效果还是不错的,看到大佬们说的,觉得很有道理。量化后的效果好,可能是因为加入了噪声,从而增加了鲁棒性,因此效果更好了。

posted @ 2024-01-24 16:35  艾特玖  阅读(17)  评论(0编辑  收藏  举报