Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/draco/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
249 changes: 249 additions & 0 deletions src/draco/README.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions src/draco/adapter_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[
{
"adapter_name": "draco",
"adapter_builders": [
"Jianing Yin (jianingyin@alumni.upenn.edu)"
],
"original_benchmark": [
{
"split": "full",
"size": 100,
"harness": "None",
"supported_agents": ["None"],
"adaptable": true,
"notes": "100 deep-research queries with 3,934 weighted expert criteria. Upstream ships the dataset and a grader library (paper-instruments/rubric, LLM judge, Gemini-3-Pro in the paper); responses were produced by deep research APIs and Claude with server-side tools, outside any harness."
}
],
"harbor_adapter": [
{
"split": "full",
"adapted_benchmark_size": 100,
"parity_benchmark_size": null,
"parity_sampling_rate": null,
"registry_benchmark_size": 100,
"added_agents": ["None"],
"parity_matching_agents": [],
"parity_unmatching_agents": ["None"],
"parity_costs": null,
"notes": "Parity pending: plan to be agreed with the Harbor team. Verifier calls the official grader library with its default judge prompt; reward is the clamped normalized score."
}
]
}
]
28 changes: 28 additions & 0 deletions src/draco/parity_experiment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"adapter_name": "draco",
"agent": "<agent>@<version>",
"model": "<model>",
"date": "YYYY-MM-DD",
"adapted_benchmark_size": 100,
"parity_benchmark_size": null,
"number_of_runs": null,
"notes": "Parity not yet run; plan (agent, model, judge, runs) to be agreed with the Harbor team.",
"original_parity_repo": "https://github.com/paper-instruments/rubric",
"adapter_pr": [
"https://github.com/harbor-framework/adapters/pull/63"
],
"dataset_pr": [],
"parity_pr": [],
"metrics": [
{
"benchmark_name": "DRACO",
"metric": "normalized_score",
"original": "<mean +/- sample_SEM, e.g. 45.2% +/- 1.3%>",
"harbor": "<mean +/- sample_SEM, e.g. 44.8% +/- 1.1%>",
"original_runs": [],
"harbor_runs": []
}
]
}
]
22 changes: 22 additions & 0 deletions src/draco/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[project]
name = "harbor-draco-adapter"
version = "0.1.0"
description = "Harbor adapter for DRACO (Perplexity deep research benchmark with expert rubrics)"
readme = "README.md"
authors = [
{ name = "Jianing Yin", email = "jianingyin@alumni.upenn.edu" }
]
requires-python = ">=3.13"
dependencies = [
"huggingface_hub>=0.30",
]

[project.scripts]
draco = "draco.main:main"

[build-system]
requires = ["uv_build>=0.11.21,<0.12.0"]
build-backend = "uv_build"

[tool.uv.build-backend]
module-name = "draco"
27 changes: 27 additions & 0 deletions src/draco/run_draco.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
jobs_dir: jobs
n_attempts: 1
timeout_multiplier: 1.0
orchestrator:
type: local
n_concurrent_trials: 4
quiet: false
environment:
type: docker
# type: daytona
force_build: true
delete: true
# env:
# DAYTONA_API_KEY: ${DAYTONA_API_KEY}
# The verifier calls an LLM judge. Export the key for the judge provider
# (GEMINI_API_KEY for the default gemini/gemini-3-pro-preview) and optionally
# JUDGE_MODEL / JUDGE_API_BASE / JUDGE_API_KEY before running.
agents:
- name: oracle
# - name: claude-code
# model_name: anthropic/claude-haiku-4-5-20251001
# - name: codex
# model_name: openai/gpt-5-mini
datasets:
- path: datasets/draco
artifacts:
- /app/report.md
1 change: 1 addition & 0 deletions src/draco/src/draco/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__all__ = []
186 changes: 186 additions & 0 deletions src/draco/src/draco/adapter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
"""
DRACO adapter: converts perplexity-ai/draco into Harbor tasks.

DRACO pairs 100 deep-research queries with expert-written rubrics (3,934
weighted criteria across four axes). The agent writes a Markdown report to
/app/report.md; the verifier grades it criterion-by-criterion with an LLM judge
using the official grader library and reports the normalized rubric score.

Paper: https://arxiv.org/abs/2602.11685
Dataset: https://huggingface.co/datasets/perplexity-ai/draco
Grader: https://github.com/paper-instruments/rubric
"""

import hashlib
import json
import logging
import shutil
from pathlib import Path

logger = logging.getLogger(__name__)

TEMPLATE_DIR = Path(__file__).parent / "task-template"

HF_REPO_ID = "perplexity-ai/draco"
HF_FILENAME = "test.jsonl"
# Pinned dataset revision so generated tasks are reproducible.
HF_REVISION = "ce076749809027649ebd331bcb70f42bf720d387"


def load_records(data_file: Path | None = None) -> list[dict]:
"""Load benchmark records from a local JSONL file or the pinned HF revision."""
if data_file is None:
from huggingface_hub import hf_hub_download

data_file = Path(
hf_hub_download(
HF_REPO_ID, HF_FILENAME, repo_type="dataset", revision=HF_REVISION
)
)
with open(data_file, encoding="utf-8") as f:
return [json.loads(line) for line in f if line.strip()]


def _toml_str(value: str) -> str:
# JSON string escaping is a valid TOML basic string.
return json.dumps(value, ensure_ascii=False)


def _slug(value: str) -> str:
return "-".join(
"".join(c if c.isalnum() else " " for c in value.lower()).split()
)


def _criteria(rubric: dict) -> list[dict]:
return [c for section in rubric["sections"] for c in section["criteria"]]


def rubric_derived_report(record: dict, rubric: dict) -> str:
"""Fallback oracle report built from the task's positive-weight criteria.

DRACO has no reference reports. This document restates every positive
criterion under its rubric axis, which exercises the full judge pipeline end
to end. It is a pipeline check, not a real research report; pass
--oracle-reports-dir to stage genuine reports.
"""
lines = [
"# Research Report",
"",
"## Request",
"",
record["problem"].strip(),
"",
]
for section in rubric["sections"]:
criteria = [c["requirement"].strip() for c in section["criteria"] if c["weight"] > 0]
if criteria:
lines += [f"## {section['title']}", ""]
lines += [f"- {criterion}" for criterion in criteria]
lines.append("")
return "\n".join(lines)


class DracoAdapter:
NAME = "draco"

def __init__(
self,
output_dir: Path,
limit: int | None = None,
overwrite: bool = False,
task_ids: list[str] | None = None,
data_file: Path | None = None,
oracle_reports_dir: Path | None = None,
**kwargs,
):
self.output_dir = Path(output_dir)
self.limit = limit
self.overwrite = overwrite
self.task_ids = task_ids
self.data_file = data_file
self.oracle_reports_dir = oracle_reports_dir

def _oracle_report(self, record: dict, rubric: dict) -> str:
if self.oracle_reports_dir is not None:
path = self.oracle_reports_dir / f"{record['id']}.md"
if path.exists():
return path.read_text(encoding="utf-8")
logger.warning(
f"No oracle report at {path}; using rubric-derived fallback"
)
return rubric_derived_report(record, rubric)

def _prepare_task(self, record: dict, task_dir: Path) -> None:
task_id = record["id"]
rubric = json.loads(record["answer"])
criteria = _criteria(rubric)
shutil.copytree(TEMPLATE_DIR, task_dir, dirs_exist_ok=True)

task_toml = (TEMPLATE_DIR / "task.toml").read_text()
replacements = {
"{task_id}": task_id,
"{keywords}": _toml_str(_slug(record["domain"])),
'"{domain}"': _toml_str(record["domain"]),
'"{rubric_id}"': _toml_str(rubric["id"]),
"{n_criteria}": str(len(criteria)),
"{n_negative_criteria}": str(sum(c["weight"] < 0 for c in criteria)),
}
for placeholder, value in replacements.items():
task_toml = task_toml.replace(placeholder, value)
(task_dir / "task.toml").write_text(task_toml)

instruction = (TEMPLATE_DIR / "instruction.md").read_text()
instruction = instruction.replace("{problem}", record["problem"].strip())
(task_dir / "instruction.md").write_text(instruction)

# The judge sees the query alongside each criterion, as in the paper.
(task_dir / "tests" / "task.json").write_text(
json.dumps(
{
"id": task_id,
"domain": record["domain"],
"problem": record["problem"],
"rubric": rubric,
},
indent=2,
ensure_ascii=False,
)
)
oracle_report = self._oracle_report(record, rubric)
(task_dir / "solution" / "report.md").write_text(oracle_report, encoding="utf-8")
# Lets ORACLE_MODE accept only the staged oracle report.
(task_dir / "tests" / "oracle_report.sha256").write_text(
hashlib.sha256(oracle_report.encode("utf-8")).hexdigest() + "\n"
)

def run(self) -> tuple[int, int]:
records = load_records(self.data_file)
records.sort(key=lambda r: r["id"])

if self.task_ids:
wanted = set(self.task_ids)
missing = wanted - {r["id"] for r in records}
if missing:
logger.warning(f"Unknown task IDs: {sorted(missing)}")
records = [r for r in records if r["id"] in wanted]
if self.limit is not None:
records = records[: max(0, self.limit)]

self.output_dir.mkdir(parents=True, exist_ok=True)
generated = skipped = 0
for record in records:
task_dir = self.output_dir / record["id"]
if task_dir.exists():
if not self.overwrite:
skipped += 1
continue
shutil.rmtree(task_dir)
self._prepare_task(record, task_dir)
generated += 1

logger.info(
f"Generated {generated} tasks in {self.output_dir}"
+ (f" (skipped {skipped} existing)" if skipped else "")
)
return generated, skipped
73 changes: 73 additions & 0 deletions src/draco/src/draco/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
"""
Generate DRACO tasks in Harbor format.

Usage:
uv run draco --output-dir ../../datasets/draco
"""

import argparse
import logging
from pathlib import Path

from .adapter import DracoAdapter

# Default output dir: <repo>/datasets/<adapter_id>
DEFAULT_OUTPUT_DIR = Path(__file__).resolve().parents[4] / "datasets" / "draco"


def main() -> None:
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")

parser = argparse.ArgumentParser()
parser.add_argument(
"--output-dir",
type=Path,
default=DEFAULT_OUTPUT_DIR,
help="Directory to write generated tasks",
)
parser.add_argument(
"--limit",
type=int,
default=None,
help="Generate only the first N tasks (sorted by id)",
)
parser.add_argument(
"--overwrite",
action="store_true",
help="Overwrite existing tasks",
)
parser.add_argument(
"--task-ids",
nargs="+",
default=None,
help="Only generate these task IDs (upstream id values)",
)
parser.add_argument(
"--data-file",
type=Path,
default=None,
help="Local test.jsonl (default: download the pinned HF revision)",
)
parser.add_argument(
"--oracle-reports-dir",
type=Path,
default=None,
help="Directory of <id>.md reports to stage as oracle solutions "
"(default: rubric-derived fallback reports)",
)
args = parser.parse_args()

adapter = DracoAdapter(
args.output_dir,
overwrite=args.overwrite,
limit=args.limit,
task_ids=args.task_ids,
data_file=args.data_file,
oracle_reports_dir=args.oracle_reports_dir,
)

adapter.run()


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions src/draco/src/draco/task-template/environment/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.12-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates \
&& rm -rf /var/lib/apt/lists/*
9 changes: 9 additions & 0 deletions src/draco/src/draco/task-template/instruction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{problem}

---

Research the request above and write your final answer as a single, self-contained Markdown report at `/app/report.md`.

- You have internet access; use it to gather and verify information.
- Only the contents of `/app/report.md` will be evaluated.
- Do not ask for clarification or human help; complete the task autonomously.
Loading