AI能效评估工具

ecoai-efficiency 是一个用于测量和评估人工智能模型能源效率的工具,通过统一的绿色效率分数(GES)标准,帮助用户优化模型性能并减少碳足迹。

  • by ecoailab
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 ecoailab/energy-mcp-server

使用说明

生态效率

GES:绿色效率得分 --每瓦特智能。

生态效率 使用统一的指标衡量AI的能源效率。

GES = Accuracy (%) / Energy (kWh per 1000 inferences)
from ai_efficiency import measure

score = measure(your_model, test_data)
print(score)
# → Efficiency: 47,000 (accuracy per kWh)
# → Grade: A
# → Carbon: 0.8g CO2 per 1000 queries

为什么?

  • 监管机构来了。 欧盟人工智能法案将要求能源披露。
  • 投资者在问。 ESG基金想要人工智能的碳足迹。
  • 成本正在爆炸。 GPU账单很重要。效率=节省的钱。

没有标准的方法来衡量人工智能的效率。现在有了。

安装

pip install ecoai-efficiency

快速开始

测量任何模型

from ai_efficiency import measure

# Works with any model that has a predict() or __call__() method
score = measure(
    model=your_model,
    test_data=X_test,
    n_samples=1000
)

print(f"Efficiency Score: {score.efficiency:,.0f}")
print(f"Energy per 1K queries: {score.kwh_per_1k:.4f} kWh")
print(f"Carbon per 1K queries: {score.co2_per_1k:.2f}g CO2")
print(f"Grade: {score.grade}")

比较型号

from ai_efficiency import compare

results = compare([model_a, model_b, model_c], test_data)

# Output:
# Model     | Accuracy | kWh/1K  | Efficiency | Grade
# ----------|----------|---------|------------|------
# model_a   | 94.2%    | 0.0100  | 9,420      | B
# model_b   | 91.8%    | 0.0008  | 114,750    | A+
# model_c   | 96.1%    | 0.0450  | 2,136      | C

生成报告

from ai_efficiency import report

r = report(model, test_data)
r.save("efficiency_report.pdf")  # For regulators, investors
r.save("efficiency_report.json") # For CI/CD pipelines

绿色效率评分(GES)

                    Accuracy (or Quality Metric)
GES = ──────────────────────────────────────────────
       Energy Consumption (kWh per 1000 inferences)

越高越好。使用0.001千瓦时的模型准确率为95%,得分为95000。

成绩

阈值来自74个模型基准人群(NeurIPS 2026 D&B):

等级 GES分数 百分位数 含义
A+ ≥3265200 前10% 卓越的效率
A ≥1306469 前25% 非常高效
B ≥512892 前50% 高于中位数
C ≥187135 前75% 低于中位数
D <187135 底部25% 需要优化

碳计算

我们使用区域电网碳强度:

from ai_efficiency import measure

# Specify your region for accurate carbon calculation
score = measure(model, data, region="KR")  # South Korea: 450g CO2/kWh
score = measure(model, data, region="EU")  # Europe avg: 250g CO2/kWh
score = measure(model, data, region="US-CA")  # California: 200g CO2/kWh

实时碳强度

获取实时电网碳数据(需要 电力地图 API密钥):

from ai_efficiency import get_carbon_intensity

# Set API key (or use ELECTRICITY_MAPS_API_KEY env var)
intensity = get_carbon_intensity("KR", real_time=True, api_key="your-key")
print(f"Current grid intensity: {intensity} gCO2/kWh")

云提供商碳因素

from ai_efficiency import get_cloud_carbon_factor

# AWS, GCP, Azure carbon factors
aws_carbon = get_cloud_carbon_factor("aws", "us-east-1")  # 379 gCO2/kWh
gcp_carbon = get_cloud_carbon_factor("gcp", "us-west1")   # 92 gCO2/kWh (low!)

SCI for AI(绿色软件基金会)

生成符合以下要求的报告 人工智能SCI 标准:

from ai_efficiency import sci_report

sci = sci_report(model, test_data, region="KR")
print(sci)
# → SCI Score: 0.0234 gCO2eq/1000 inferences
# → E (Energy): 0.000052 kWh
# → I (Carbon Intensity): 450 gCO2eq/kWh
# → M (Embodied): 0.0001 gCO2eq

# Export SCI-compliant report
print(sci.to_sci_report(model_name="MyModel"))

学术论文指标

使用LaTeX导出生成纸质指标:

from ai_efficiency import measure_academic

metrics = measure_academic(
    model, test_data, test_labels,
    region="KR",
    flops_per_sample=1.2e9  # Optional: FLOPs if known
)

# LaTeX table for papers
print(metrics.to_latex_table())

# Markdown for README
print(metrics.to_markdown_table())

# Full metrics
print(f"GES: {metrics.ges:,.0f}")           # Green Efficiency Score
print(f"Energy/FLOP: {metrics.energy_per_flop:.2e}")  # If FLOPs provided

比较模型(学术)

from ai_efficiency import compare_academic

latex_table = compare_academic(
    [model_a, model_b],
    ["BERT-base", "DistilBERT"],
    test_data, test_labels
)
# → Generates LaTeX table sorted by efficiency

支持的模型

  • PyTorch:任何 nn.Module
  • TensorFlow/Keras:任何型号 predict()
  • Scikit学习:任何估算值
  • 拥抱脸:变压器、扩散器
  • OpenAI/人类学:基于API的模型(估计)
  • 自定义:任何可调用 .predict() 或 __call__()

CLI工具

# Measure a saved model
ecoai-efficiency measure model.pt --data test.csv

# Compare multiple models
ecoai-efficiency compare model_a.pt model_b.pt --data test.csv

# Generate compliance report
ecoai-efficiency report model.pt --data test.csv --output report.pdf

CI/CD集成

# .github/workflows/efficiency.yml
- name: Check AI Efficiency
  run: |
    pip install ecoai-efficiency
    ecoai-efficiency check model.pt --min-grade B --fail-below C

研究

该项目基于韩巴特国立大学EcoAI实验室的研究:

  • 具有能源意识的机器学习
  • 人工智能系统的碳足迹
  • 高效推理优化

贡献

我们需要帮助:

  • GPU功率测量精度
  • 更多硬件配置文件(TPU、苹果硅)
  • 云提供商集成(AWS、GCP、Azure)
  • 区域碳强度数据

看 贡献.md.

路线图

  • [x] 基本测量(CPU)
  • [x] GPU功率测量(NVIDIA)
  • [x] 实时碳强度(电力地图API)
  • [x] 云提供商碳因素(AWS、GCP、Azure)
  • [x] 人工智能合规SCI(绿色软件基金会)
  • [x] LaTeX导出的学术指标
  • [x] 碳含量计算
  • []过程级功率测量
  • []优化建议
  • []API认证

引用

如果您在研究中使用ecoai效率,请引用:

@inproceedings{lee2026ges,
  title = {GES: A Unified Metric and Benchmark for AI Energy Efficiency},
  author = {Lee, Sangkeum},
  booktitle = {NeurIPS 2026 Datasets and Benchmarks Track},
  year = {2026},
  url = {https://github.com/ecoailab/ecoai-efficiency}
}
@software{ecoai_efficiency,
  title = {ecoai-efficiency: Green Efficiency Score for AI},
  author = {EcoAI Lab, Hanbat National University},
  year = {2025},
  version = {1.0.0},
  url = {https://github.com/ecoailab/ecoai-efficiency}
}

许可证

麻省理工学院

团队

汉巴特国立大学生态人工智能实验室


“最环保的人工智能是用更少的资源做更多的事情。”