[ PROMPT_NODE_22376 ]
evaluating-code-models
[ SKILL_DOCUMENTATION ]
# BigCode Evaluation Harness - 代码模型基准测试
## 快速开始
BigCode Evaluation Harness 可在 15 个以上的基准测试中评估代码生成模型,包括 HumanEval、MBPP 和 MultiPL-E(18 种语言)。
**安装**:
bash
git clone https://github.com/bigcode-project/bigcode-evaluation-harness.git
cd bigcode-evaluation-harness
pip install -e .
accelerate config
**在 HumanEval 上评估**:
bash
accelerate launch main.py
--model bigcode/starcoder2-7b
--tasks humaneval
--max_length_generation 512
--temperature 0.2
--n_samples 20
--batch_size 10
--allow_code_execution
--save_generations
**查看可用任务**:
bash
python -c "from bigcode_eval.tasks import ALL_TASKS; print(ALL_TASKS)"
## 常见工作流
### 工作流 1:标准代码基准评估
在核心代码基准(HumanEval, MBPP, HumanEval+)上评估模型。
**检查清单**:
代码基准评估:
- [ ] 第 1 步:选择基准测试套件
- [ ] 第 2 步:配置模型和生成参数
- [ ] 第 3 步:运行带代码执行的评估
- [ ] 第 4 步:分析 pass@k 结果
**第 1 步:选择基准测试套件**
**Python 代码生成**(最常用):
- **HumanEval**: 164 个手写问题,函数补全
- **HumanEval+**: 相同的 164 个问题,但测试用例多 80 倍(更严格)
- **MBPP**: 500 个众包问题,入门级难度
- **MBPP+**: 399 个精选问题,测试用例多 35 倍
**多语言**(18 种语言):
- **MultiPL-E**: 将 HumanEval/MBPP 翻译为 C++, Java, JavaScript, Go, Rust 等。
**高级**:
- **APPS**: 10,000 个问题(入门/面试/竞赛)
- **DS-1000**: 7 个库中的 1,000 个数据科学问题
**第 2 步:配置模型和生成参数**
bash
# 标准 HuggingFace 模型
accelerate launch main.py
--model bigcode/starcoder2-7b
--tasks humaneval
--max_length_generation 512
--temperature 0.2
--do_sample True
--n_samples 200
--batch_size 50
--allow_code_execution
# 量化模型 (4-bit)
accelerate launch main.py
--model codellama/CodeLlama-34b-hf
--tasks humaneval
--load_in_4bit
--max_length_generation 512
--allow_code_execution
# 自定义/私有模型
accelerate launch main.py
--model /path/to/my-code-model
--tasks humaneval
--trust_remote_code
--use_auth_token
--allow_code_execution
**第 3 步:运行评估**
bash
# 使用 pass@k 估计进行完整评估 (k=1,10,100)
accelerate launch m