遇见数据集

AI Code Optimization for Sustainability: Dataset

收藏
Zenodo2026-02-14 更新2026-05-26 收录
官方服务:

资源简介:

AI Code Optimization for Sustainability: Dataset Refactoring Python Code for Energy-Efficiency using Qwen3: Dataset based on HumanEval, MBPP, and Mercury 📄 Read the Paper | HuggingFace Mirror | DOI: 10.5281/zenodo.18377893 | About the author This dataset is a part of a Master thesis research internship investigating the use of LLMs to optimize Python code for energy efficiency. The research was conducted as part of the Greenify My Code (GMC) project at the Netherlands Organisation for Applied Scientific Research (TNO). The code samples were curated from Mercury paper, dataset, Google MBPP (paper, dataset), and OpenAI HumanEval (paper, dataset) datasets. The 1,763 unique Python code samples analyzed before and after refactoring by Qwen3 models using four inference strategies (prompt and interaction style): cot-code-single, cot-code-plan, cot-suggestions-single, and cot-suggestions-plan. The analysis provides the following information (when possible): Functional correctness via provided test suites Static code analysis via Radon, eco-code-analyzer (custom fork used) and custom AST metrics Runtime profiling in a sandboxed environment using pyRAPL to measure energy consumption (µJ) under synthetic stress load (80% using stress-ng): baseline: 10ms (no code execution) warmup: 10ms (running test suite in a loop) profiling: 1s (running test suite in a loop) This analysis uses the following versions of Qwen3 models: 0.6B-Q8-GGUF 1.7B-Q8-GGUF 4B-Q8-GGUF 8B-Q8-GGUF 14B-Q8-GGUF 32B-Q8-GGUF Dataset Structure & Column Descriptions The dataset is structured hierarchically using dot-notation to separate nodes. The message column provides a status message of the entire process (success means that analysis before, refactoring, and analysis after were all successful) 1. Input Sample Metadata Information regarding the source code sample. Column Description input.sample_num Unique index identifier for the sample input.origin Source benchmark (Mercury, MBPP, or HumanEval) input.name Name of the function/task input.code Original Python source code input.test.initialization Test setup code to run before executing tests input.test.assertions List of assertions used for functional verification 2. Analysis These suffixes apply to both the original code (analysis_before) and the refactored code (analysis_after). Static Analysis Column Description analysis_*.static.radon.* Radon metrics analysis_*.static.ast.nodes Total nodes in the Abstract Syntax Tree analysis_*.static.ast.branching_factor total_branches divided by nodes_with_children analysis_*.static.ast.tree_depth Maximum depth of the AST analysis_*.static.eco.score Energy efficiency score (higher is better) analysis_*.static.eco.suggestions List of static analysis suggestions for energy improvement Runtime & Energy Profiling Measured using pyRAPL. Energy values are in Microjoules (µJ). Metrics starting with ... are the same for baseline, warmup, and profiling Column Description analysis_*.runtime.test.status Functional correctness status (passed, failed, error) ...duration_us Phase duration in microseconds ...util_avg_cpu Average CPU utilization ...util_avg_memory Average Memory utilization ...pkg_uj CPU Package Energy ...dram_uj DRAM Energy ...total_uj Total Energy (Package + DRAM) ...total_per_rep_uj Energy per single test execution 3. Greenify/Refactoring Process Details on the model, prompts, and the refactoring process. Columns starting with ... are the same for plan and refactor phases, however plan may be empty if a single-phase strategy is used. Column Description greenify.meta.input_type Context provided: just_code or code_with_suggestions greenify.meta.process_variation Strategy used: single_phase or plan_then_implement (two-step) greenify.meta.model.tag HuggingFace tag of the model ...prompt The prompt sent to the LLM for code generation ...tokens.* Token counts (input/output/total) for the given phase ...duration_seconds Time taken by the LLM to generate output ...rewritten_code LLM output: energy-optimized Python code ...explanation LLM output: self-written description for the reasoning of the applied changes Attribution and Licensing This dataset contains derivative work of the source datasets and is thus licensed under CC BY-NC 4.0.

# 面向可持续性的AI代码优化:数据集 ## 基于Qwen3实现Python代码能效重构:源自HumanEval、MBPP与Mercury的数据集 📄 论文阅读 | HuggingFace 镜像站 | DOI: 10.5281/zenodo.18377893 | 作者信息 本数据集为硕士论文研究实习项目的一部分,该项目探究如何利用大语言模型(Large Language Model)优化Python代码以提升能效。本研究作为荷兰应用科学研究组织(Netherlands Organisation for Applied Scientific Research,TNO)旗下Greenify My Code(GMC)项目的子课题开展。 本数据集的代码样本源自Mercury论文与数据集、Google MBPP(论文与数据集)以及OpenAI HumanEval(论文与数据集)。研究团队针对1763个唯一Python代码样本,使用Qwen3模型结合四种推理策略(提示词与交互风格):cot-code-single、cot-code-plan、cot-suggestions-single及cot-suggestions-plan,分别对重构前后的代码进行分析。在条件允许的情况下,本次分析提供以下维度的信息: - 基于提供的测试套件验证功能正确性 - 通过Radon、eco-code-analyzer(使用自定义分支版本)及自定义抽象语法树(Abstract Syntax Tree,AST)指标进行静态代码分析 - 在沙箱环境中通过pyRAPL开展运行时性能分析,在模拟压力负载(使用stress-ng模拟80%负载)下测量能耗(单位:微焦耳,µJ): - 基线测试:10ms(无代码执行) - 预热阶段:10ms(循环运行测试套件) - 性能分析阶段:1s(循环运行测试套件) 本次分析使用以下Qwen3模型版本:0.6B-Q8-GGUF、1.7B-Q8-GGUF、4B-Q8-GGUF、8B-Q8-GGUF、14B-Q8-GGUF及32B-Q8-GGUF ## 数据集结构与字段说明 本数据集采用点标记法实现层级化节点分隔。`message`字段用于记录全流程状态信息(状态为success代表重构前分析、代码重构及重构后分析全部成功) ### 1. 输入样本元数据 有关源代码样本的相关信息。 | 字段 | 说明 | | --- | --- | | `input.sample_num` | 样本唯一索引标识符 | | `input.origin` | 基准数据集来源(Mercury、MBPP或HumanEval) | | `input.name` | 函数/任务名称 | | `input.code` | 原始Python源代码 | | `input.test.initialization` | 测试执行前的初始化代码 | | `input.test.assertions` | 用于功能验证的断言列表 | ### 2. 分析结果 以下后缀同时适用于原始代码(`analysis_before`)与重构后代码(`analysis_after`)。 #### 静态分析 | 字段 | 说明 | | --- | --- | | `analysis_*.static.radon.*` | Radon指标 | | `analysis_*.static.ast.nodes` | 抽象语法树总节点数 | | `analysis_*.static.ast.branching_factor` | 分支因子(总分支数除以含子节点的节点数) | | `analysis_*.static.ast.tree_depth` | 抽象语法树最大深度 | | `analysis_*.static.eco.score` | 能效评分(分值越高性能越好) | | `analysis_*.static.eco.suggestions` | 用于提升能效的静态分析建议列表 | #### 运行时与能耗性能分析 本次分析通过pyRAPL完成,能耗数值单位为微焦耳(µJ)。以`...`为前缀的指标同时适用于基线测试、预热阶段及性能分析阶段。 | 字段 | 说明 | | --- | --- | | `analysis_*.runtime.test.status` | 功能正确性状态(通过、失败或出错) | | `...duration_us` | 阶段时长(单位:微秒) | | `...util_avg_cpu` | 平均CPU利用率 | | `...util_avg_memory` | 平均内存利用率 | | `...pkg_uj` | CPU封装能耗 | | `...dram_uj` | 动态随机存取存储器(DRAM)能耗 | | `...total_uj` | 总能耗(CPU封装+DRAM) | | `...total_per_rep_uj` | 单次测试执行能耗 | ### 3. 代码重构与绿色优化流程 本部分包含模型、提示词及代码重构流程的详细信息。以`...`为前缀的字段同时适用于规划阶段与重构阶段,若采用单阶段策略则规划阶段字段可能为空。 | 字段 | 说明 | | --- | --- | | `greenify.meta.input_type` | 输入上下文类型(仅代码或带建议的代码) | | `greenify.meta.process_variation` | 所用策略(单阶段或先规划再实现的两阶段策略) | | `greenify.meta.model.tag` | 模型的HuggingFace标签 | | `...prompt` | 发送给大语言模型用于代码生成的提示词 | | `...tokens.*` | 对应阶段的Token计数(输入/输出/总Token数) | | `...duration_seconds` | 大语言模型生成输出所用时长(单位:秒) | | `...rewritten_code` | 大语言模型输出的经能效优化的Python代码 | | `...explanation` | 大语言模型输出的针对所应用优化的推理过程说明 | ## 归属与许可 本数据集包含源数据集的衍生作品,因此采用CC BY-NC 4.0许可协议进行授权。

提供机构:
Zenodo
创建时间:
2026-01-30
二维码
社区交流群
二维码
科研交流群
商业服务