OpenCompass 评测 InternLM-1.8B 实践-第三期闯关大挑战

1.1 配置基础环境

在资源配置中, 使用10% A100 * 1。

1.2 面向GPU的环境安装

studio-conda -o internlm-base -t opencompass
source activate opencompass
git clone -b 0.2.4 https://github.com/open-compass/opencompass
cd opencompass
pip install -e .

在运行时,发现有不少库都没安装成功,后来重新运行:

pip install -r requirements.txt

1.3 数据准备

解压评测数据集到 data/ 处

cp /share/temp/datasets/OpenCompassData-core-20231110.zip /root/opencompass/
unzip OpenCompassData-core-20231110.zip
1.4 启动评测
python run.py --datasets ceval_gen --hf-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b --tokenizer-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b --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

命令解析

python run.py
--datasets ceval_gen \
--hf-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b \  # HuggingFace 模型路径
--tokenizer-path /share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b \  # 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 16 \  # 生成的最大 token 数
--batch-size 2  \  # 批量大小
--num-gpus 1  # 运行模型所需的 GPU 数量
--debug

mode:opencompass.models.huggingface.HuggingFace_Shanghai_AI_Laboratory_internlm2-chat-1_8b
dataset	              version	            metric	
ceval-computer_network	db9ce2	accuracy	gen	47.37
ceval-operating_system	1c2571	accuracy	gen	47.37
ceval-computer_architecture	a74dad	accuracy	gen	23.81
ceval-college_programming	4ca32a	accuracy	gen	13.51
ceval-college_physics	963fa8	accuracy	gen	42.11
ceval-college_chemistry	e78857	accuracy	gen	33.33
ceval-advanced_mathematics	ce03e2	accuracy	gen	10.53
ceval-probability_and_statistics	65e812	accuracy	gen	38.89
ceval-discrete_mathematics	e894ae	accuracy	gen	25
ceval-electrical_engineer	ae42b9	accuracy	gen	27.03
ceval-metrology_engineer	ee34ea	accuracy	gen	54.17
ceval-high_school_mathematics	1dc5bf	accuracy	gen	16.67
ceval-high_school_physics	adf25f	accuracy	gen	42.11
ceval-high_school_chemistry	2ed27f	accuracy	gen	47.37
ceval-high_school_biology	8e2b9a	accuracy	gen	26.32
ceval-middle_school_mathematics	bee8d5	accuracy	gen	36.84
ceval-middle_school_biology	86817c	accuracy	gen	80.95
ceval-middle_school_physics	8accf6	accuracy	gen	47.37
ceval-middle_school_chemistry	167a15	accuracy	gen	80
ceval-veterinary_medicine	b4e08d	accuracy	gen	43.48
ceval-college_economics	f3f4e6	accuracy	gen	32.73
ceval-business_administration	c1614e	accuracy	gen	36.36
ceval-marxism	cf874c	accuracy	gen	68.42
ceval-mao_zedong_thought	51c7a4	accuracy	gen	70.83
ceval-education_science	591fee	accuracy	gen	55.17
ceval-teacher_qualification	4e4ced	accuracy	gen	59.09
ceval-high_school_politics	5c0de2	accuracy	gen	57.89
ceval-high_school_geography	865461	accuracy	gen	47.37
ceval-middle_school_politics	5be3e7	accuracy	gen	71.43
ceval-middle_school_geography	8a63be	accuracy	gen	75
ceval-modern_chinese_history	fc01af	accuracy	gen	52.17
ceval-ideological_and_moral_cultivation	a2aa4a	accuracy	gen	73.68
ceval-logic	f5b022	accuracy	gen	27.27
ceval-law	a110a1	accuracy	gen	29.17
ceval-chinese_language_and_literature	0f8b68	accuracy	gen	47.83
ceval-art_studies	2a1300	accuracy	gen	42.42
ceval-professional_tour_guide	4e673e	accuracy	gen	51.72
ceval-legal_professional	ce8787	accuracy	gen	34.78
ceval-high_school_chinese	315705	accuracy	gen	42.11
ceval-high_school_history	7eb30a	accuracy	gen	65
ceval-middle_school_history	48ab4a	accuracy	gen	86.36
ceval-civil_servant	87d061	accuracy	gen	42.55
ceval-sports_science	70f27b	accuracy	gen	52.63
ceval-plant_protection	8941f9	accuracy	gen	40.91
ceval-basic_medicine	c409d6	accuracy	gen	68.42
ceval-clinical_medicine	49e82d	accuracy	gen	31.82
ceval-urban_and_rural_planner	95b885	accuracy	gen	47.83
ceval-accountant	2837	accuracy	gen	36.73
ceval-fire_engineer	bc23f5	accuracy	gen	38.71
ceval-environmental_impact_assessment_engineer	c64e2d	accuracy	gen	51.61
ceval-tax_accountant	3a5e3c	accuracy	gen	36.73
ceval-physician	6e277d	accuracy	gen	42.86
ceval-stem	-	naive_average	gen	39.21
ceval-social-science	-	naive_average	gen	57.43
ceval-humanities	-	naive_average	gen	50.23
ceval-other	-	naive_average	gen	44.62
ceval-hard	-	naive_average	gen	32
ceval	-	naive_average	gen	46.19

<think>好的,用户想了解如何调用ModelScope中的AMChat_internlm2-math-plus-1.8b模型的API,需要教程、示例代码和文档。首先,我需要回忆一下ModelScope平台的基本使用流程,通常调用模型API需要安装SDK,获取API Token,然后根据文档编写代码。 接下来,我需要检查用户提供的引用内容,看看是否有相关的信息。引用[1]提到了OFA文生SQL模型,引用[2]是ARM数学库的使用,引用[3]是关于OpenCompass评测实践。看起来这些引用可能没有直接关联,但需要确认是否有隐藏的相关信息。例如,引用[1]中的团队代码仓库可能有相关示例,但不确定。引用[3]提到可能需要额外步骤安装依赖,这可能对用户有帮助。 用户的问题是关于API调用的,所以应该分步骤回答。首先安装必要的库,比如modelscope的Python SDK。然后获取API Token,这通常在ModelScope的个人设置中。接下来是示例代码,可能需要导入pipeline,并指定模型名称。需要注意模型名称是否正确,比如AMChat_internlm2-math-plus-1.8b可能需要全名,比如'AI-ModelScope/AMChat_internlm2-math-plus-1.8b'。 另外,需要提醒用户注意模型输入输出的格式,比如数学问题可能需要特定的prompt结构。可能还需要处理输入输出的参数,比如max_length等。文档链接可能需要指向ModelScope的模型卡片页面,比如https://modelscope.cn/models/AI-ModelScope/AMChat_internlm2-math-plus-1.8b。 同时,用户可能遇到的问题包括安装依赖、网络连接、Token权限等,需要给出常见问题解决建议。例如,安装开发版本或检查网络设置。 最后,生成相关问题时要围绕模型调用、参数调整、数学任务处理、本地部署等扩展方向。确保问题对用户深入学习有帮助。</think>### ModelScope AMChat_internlm2-math-plus-1.8b API 使用步骤 #### 1. 环境准备 - 安装ModelScope SDK: ```bash pip install modelscope ``` 若需最新功能可安装开发版: ```bash pip install "modelscope[llm]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html ``` #### 2. 获取API凭证 - 登录[ModelScope官网](https://modelscope.cn),在个人中心「AccessToken」页面创建Token[^3] #### 3. 基础调用代码示例 ```python from modelscope import AutoModelForCausalLM, AutoTokenizer model_id = 'AI-ModelScope/AMChat_internlm2-math-plus-1.8b' tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained(model_id, device_map='auto', trust_remote_code=True) prompt = "解方程:$x^2 + 5x + 6 = 0$" inputs = tokenizer(prompt, return_tensors='pt').to('cuda') outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` #### 4. 高级参数说明 - `temperature`:控制生成随机性(0-1- `top_p`:核采样概率阈值 - `repetition_penalty`:重复惩罚因子 #### 5. 官方文档参考 完整API文档参见:[AMChat_internlm2-math-plus-1.8b模型卡片](https://modelscope.cn/models/AI-ModelScope/AMChat_internlm2-math-plus-1.8b)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值