Ope rs code implementation

From pdl-openair/OpenAIR · View interactive version

Ope rs code implementation is an AI agent skill from the GitHub repository pdl-openair/OpenAIR. 当用户想要实现 OPE 核心算法、编写实验代码、或做单元测试时自动触发。常见场景:用户说"帮我实现这个 OPE 估计器"、"写 DR 代码"、"单元测试"。本 skill 完成核心算法实现、单元测试、可复现性配置,不负责批量实验执行与数据验证。

How to use this skill

Skill file

代码实现(L3 — OPE)

实现 OPE 核心算法代码,完成单元测试,保证可复现性。

Method

Step 1:环境准备

Step 2:理解任务需求

读取 design/experiment_design.md,提取与代码实现相关的部分:

Step 3:代码结构设计

Step 4:实现代码

按照设计实现:

深度学习框架选择:

Step 5:编写单元测试

测试覆盖点示例:

- test_ipe_output_shape()           # 输出形状正确(标量)
- test_ipe_value_finite()           # 估计值有限
- test_dr_equals_dm_plus_ips()      # DR = DM + IPS 关系
- test_data_loader_batch()          # batch 生成
- test_trajectory_sampler()         # 轨迹采样

测试覆盖率目标:≥ 80%,框架优先用 pytest。

Step 6:编写真实执行脚本

Step 7:验证可复现性

import random, numpy as np, torch
random.seed(42); np.random.seed(42)
torch.manual_seed(42); torch.cuda.manual_seed_all(42)

Step 8:验收检查

任何一项失败:记录原因到实现报告,不标记任务完成。

Input

Output

按 schemas/ope/specs/implementation.md 模板产出,使用 Write 工具写入 execute/code/implementation.md,结构:

Constraints

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.