Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- **`EvaluationPipeline` takes the run's inputs only as `settings=EvaluationSettings(...)`.** The Python API no longer accepts the fields as keyword or positional arguments: `EvaluationPipeline(product="lib", output_dir=out, description="d")` now raises `TypeError`, and the same run is `EvaluationPipeline(settings=EvaluationSettings(product="lib", output_dir=out, description="d"))`. The `EvaluationSettings` fields, their defaults and the refusal for a run with neither `repo` nor `description` are unchanged; the CLI (`evaluate`, `benchmark run`, `orchestrate`) is unchanged. Scripts that build the pipeline directly move their arguments into `EvaluationSettings(...)`.
2 changes: 1 addition & 1 deletion dokimi/docs/methodology.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Every writer (`eval questions generate`, `eval questions refine`, the `evaluate`
| `metadata` as a list | `{"items": [...]}` (v2 declares `metadata` an object; the list is kept, not dropped) |
| `null` in a key v1 does not declare and v2 types (`model`, `total_questions`, `persona_id`, `source_type`, `topics`, ...) | key dropped, without a notice. A `null` inside a typed value (`"topics": [null]`) is not dropped and is refused |

A set that needed any of these, or that is not valid under the version it declares (e.g. a set stamped `questions.v1` whose records use `question`, which `eval questions refine` wrote before v2), is logged once: `read <path> in legacy questions format (...); using it as questions.v2`. Reading these shapes is meant to be retired later; fix the file by hand to stop the notice (`question` for `text` or `question_text`, an `id` on each record, `metadata` as an object, and `schema_version` set to `questions.v2` or removed). No command rewrites a set unchanged: `eval questions refine` is not a re-save, it normalizes fields, drops trivial and duplicate questions and changes the `question_set_hash`, so do not use it on a curated set. A set that is still not valid v2 after reading (a record with an empty question, a field of the wrong type) fails before any model call, with each failing record and the fix named. The run then writes its own v2 copy to `<output-dir>/questions/<product>.json` with the `question_set_hash`. A `--questions` file that is not UTF-8 or not JSON (an empty file included) stops `evaluate` at start-up, before any output directory exists, with `Error: --questions <path>: <reason>` and exit 2, when the run will read it; a re-run that reuses the cached `<output-dir>/questions/<product>.json` never reads it, so a file that is empty, not JSON or not UTF-8 does not stop it (a missing path or a directory still does). `evaluate` has no `--questions-from`; through the Python API (`EvaluationPipeline(questions_from=<path>)`) an unparseable file raises `InputError` with the message `--questions-from <path>: <reason>`, while `benchmark run` and `benchmark preflight` keep their own `questions source invalid` message. A `--questions-from` file is never written. A `--questions` file is written only through the Python API (`EvaluationPipeline(custom_questions_path=<output-dir>/questions/<product>.json, force_regen=True)`), when the merge added a record to it; that file keeps each record's `source_type`, while any other custom or golden set is tagged `manual`. The cached file is the run's own and is rewritten as v2. No CLI command can reach this path: `evaluate` takes `--questions` but not `--force`, and `benchmark run` and `benchmark batch` take `--force` but not `--questions`. For sets already valid as v1 or v2, ids and `question_set_hash` do not change on the way through. `data export --kind questions` exports any of these in the v2 shape and records the source version (or `legacy`) in the dataset card.
A set that needed any of these, or that is not valid under the version it declares (e.g. a set stamped `questions.v1` whose records use `question`, which `eval questions refine` wrote before v2), is logged once: `read <path> in legacy questions format (...); using it as questions.v2`. Reading these shapes is meant to be retired later; fix the file by hand to stop the notice (`question` for `text` or `question_text`, an `id` on each record, `metadata` as an object, and `schema_version` set to `questions.v2` or removed). No command rewrites a set unchanged: `eval questions refine` is not a re-save, it normalizes fields, drops trivial and duplicate questions and changes the `question_set_hash`, so do not use it on a curated set. A set that is still not valid v2 after reading (a record with an empty question, a field of the wrong type) fails before any model call, with each failing record and the fix named. The run then writes its own v2 copy to `<output-dir>/questions/<product>.json` with the `question_set_hash`. A `--questions` file that is not UTF-8 or not JSON (an empty file included) stops `evaluate` at start-up, before any output directory exists, with `Error: --questions <path>: <reason>` and exit 2, when the run will read it; a re-run that reuses the cached `<output-dir>/questions/<product>.json` never reads it, so a file that is empty, not JSON or not UTF-8 does not stop it (a missing path or a directory still does). `evaluate` has no `--questions-from`; through the Python API (`EvaluationPipeline(settings=EvaluationSettings(questions_from=<path>))`) an unparseable file raises `InputError` with the message `--questions-from <path>: <reason>`, while `benchmark run` and `benchmark preflight` keep their own `questions source invalid` message. A `--questions-from` file is never written. A `--questions` file is written only through the Python API (`EvaluationPipeline(settings=EvaluationSettings(custom_questions_path=<output-dir>/questions/<product>.json, force_regen=True))`), when the merge added a record to it; that file keeps each record's `source_type`, while any other custom or golden set is tagged `manual`. The cached file is the run's own and is rewritten as v2. No CLI command can reach this path: `evaluate` takes `--questions` but not `--force`, and `benchmark run` and `benchmark batch` take `--force` but not `--questions`. For sets already valid as v1 or v2, ids and `question_set_hash` do not change on the way through. `data export --kind questions` exports any of these in the v2 shape and records the source version (or `legacy`) in the dataset card.

`expected_topics` carries two different kinds of content depending on the source, and evaluation treats them differently. Persona-generated sets store short keyword labels ("version check", "import test"). Curated golden sets store verified answer statements, often with citations in `metadata` (`must_cite`, `github_issue`, `verified_by`). Only the latter are usable as judge ground truth — see [Grounded Judging](#grounded-judging).

Expand Down
6 changes: 3 additions & 3 deletions dokimi/dokimi/commands/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _refuse_judge_sampling(args: argparse.Namespace) -> None:
def _run_single_library(entry, output_dir: str, model: str, provider: str, judge_model: str, judge_provider: str = DEFAULT_JUDGE_PROVIDER, doc_source_override=None, max_tokens_per_question: int = DEFAULT_MAX_TOKENS_PER_QUESTION, force_regen: bool = False, concurrency: int = DEFAULT_CONCURRENCY, questions_from=None, questions_root=None, judge_temperature=None, judge_placeholder=False, registry=None) -> dict:
"""Run full evaluation pipeline for one ProductEntry. Returns result dict."""
from dokimi.commands.arms import pipeline_checkpoint
from dokimi.orchestrator import EvaluationPipeline
from dokimi.orchestrator import EvaluationPipeline, EvaluationSettings
from pathlib import Path as _Path

doc_source = doc_source_override or (entry.doc_sources[0] if entry.doc_sources else "context7")
Expand All @@ -72,7 +72,7 @@ def _run_single_library(entry, output_dir: str, model: str, provider: str, judge
context=f"benchmark:{entry.key}",
)

pipeline = EvaluationPipeline(
pipeline = EvaluationPipeline(settings=EvaluationSettings(
product=entry.name,
repo=entry.repo,
description=entry.description,
Expand All @@ -94,7 +94,7 @@ def _run_single_library(entry, output_dir: str, model: str, provider: str, judge
registry=registry,
questions_root=_Path(questions_root) if questions_root else None,
checkpoint=pipeline_checkpoint, # the answered questions, until the answers file is saved (#1004)
)
))
result = pipeline.run(concurrency=concurrency)
return {"library": entry.key, "name": entry.name, "status": "ok", "result": result}

Expand Down
6 changes: 3 additions & 3 deletions dokimi/dokimi/commands/orchestrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def cmd_evaluate(args: argparse.Namespace) -> None:
"""Run full evaluation pipeline (orchestrator)."""
from dokimi.commands.arms import pipeline_checkpoint
from dokimi.mcp.factory import require_local_doc_source
from dokimi.orchestrator import EvaluationPipeline
from dokimi.orchestrator import EvaluationPipeline, EvaluationSettings

if not getattr(args, "repo", None) and not getattr(args, "description", None):
raise InputError("either --repo or --description must be provided.")
Expand Down Expand Up @@ -65,7 +65,7 @@ def cmd_evaluate(args: argparse.Namespace) -> None:
require_local_doc_source(getattr(args, "doc_source", "context7"))
# Create pipeline; it checks --questions and creates the output directories
try:
pipeline = EvaluationPipeline(
pipeline = EvaluationPipeline(settings=EvaluationSettings(
product=args.product,
repo=getattr(args, "repo", None),
description=getattr(args, "description", None),
Expand All @@ -87,7 +87,7 @@ def cmd_evaluate(args: argparse.Namespace) -> None:
doc_source=getattr(args, "doc_source", "context7"),
context7_id=getattr(args, "context7_id", None),
checkpoint=pipeline_checkpoint, # the answered questions, until the answers file is saved (#1004)
)
))
except OSError as exc: # a missing --questions file, an unusable --out-dir
raise InputError(str(exc)) from exc

Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/orchestrator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"""Pipeline orchestration module."""

from .pipeline import EvaluationPipeline
from .pipeline_settings import EvaluationSettings

__all__ = ["EvaluationPipeline"]
__all__ = ["EvaluationPipeline", "EvaluationSettings"]

Check warning on line 9 in dokimi/dokimi/orchestrator/__init__.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-element `["EvaluationPipeline", "EvaluationSettings"]` -> `["EvaluationSettings"]`

Check warning on line 9 in dokimi/dokimi/orchestrator/__init__.py

View workflow job for this annotation

GitHub Actions / Mutation of changed lines

mutant survived: drop-element `["EvaluationPipeline", "EvaluationSettings"]` -> `["EvaluationPipeline"]`
140 changes: 36 additions & 104 deletions dokimi/dokimi/orchestrator/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
from dokimi.artifacts import save_artifact
from dokimi.atomic_write import write_bytes_in_place_or_atomic
from dokimi.process_io import text_file_bytes
from dokimi.defaults import (DEFAULT_ANSWER_MODEL, DEFAULT_ANSWER_PROVIDER, DEFAULT_JUDGE_MODEL, DEFAULT_JUDGE_PROVIDER,
DEFAULT_RETRIEVAL_TOP_K)
from dokimi.eval.stats import paired_summary
from dokimi.mcp.factory import create_doc_source_client, require_local_doc_source, resolve_library_id_for_product
from dokimi.orchestrator.arm_answering import Checkpoint, PipelineArms
from dokimi.files import InputError, read_json_input, refuse_device
from dokimi.digest import key_bytes

from dokimi.orchestrator.pipeline_settings import EvaluationSettings
from dokimi.orchestrator.question_source import warn_unpinned_questions
from dokimi.orchestrator.question_sets import (
compute_question_set_hash, load_questions_payload, resolve_questions_from_path)
Expand Down Expand Up @@ -98,118 +97,51 @@ class EvaluationPipeline:
6. Generate report
"""

def __init__(
self,
product: str,
output_dir: Path,
repo: Optional[str] = None,
description: Optional[str] = None,
custom_questions_path: Optional[Path] = None,
model: str = DEFAULT_ANSWER_MODEL,
provider: str = DEFAULT_ANSWER_PROVIDER,
judge_model: str = DEFAULT_JUDGE_MODEL,
judge_provider: str = DEFAULT_JUDGE_PROVIDER,
judge_temperature: Optional[float] = None,
personas_count: int = 5,
questions_per_topic: int = 2,
top_k: int = DEFAULT_RETRIEVAL_TOP_K,
rerank_threshold: float = 0.3,
debug_retrieval: bool = False,
doc_source: str = "context7",
context7_id: Optional[str] = None,
max_tokens_per_question: int = 4000,
force_regen: bool = False,
questions_from: Optional[Path] = None,
product_key: Optional[str] = None,
questions_root: Optional[Path] = None,
registry: Optional[Any] = None,
judge_placeholder: bool = False,
checkpoint: Optional[Callable[[Path], Checkpoint]] = None,
):
def __init__(self, settings: EvaluationSettings):
"""
Initialize pipeline.
Initialize pipeline from the run's inputs.

Args:
product: Product name (e.g., "oneDNN")
output_dir: Base directory for outputs
repo: GitHub repo (e.g., "oneapi-src/oneDNN"). Optional — when
omitted, ``description`` must be provided so the LLM can
generate personas without GitHub data.
description: Plain-text description of the product. Used as the
sole signal for persona generation when ``repo`` is not given.
Also useful to supplement GitHub data.
custom_questions_path: Optional path to manual questions JSON
model: LLM model for generation/answering
provider: Provider for generation/answering
judge_model: LLM model for evaluation
judge_provider: Provider for evaluation
judge_temperature: Optional judge sampling temperature; unset leaves
the provider default
personas_count: Target number of personas
questions_per_topic: Questions per topic per persona
top_k: Docs to retrieve before reranking
rerank_threshold: Min relevance score
debug_retrieval: Include retrieval metadata
doc_source: Documentation source descriptor — 'context7' (default),
'local:<path>', or 'url:<url>'
context7_id: Explicit Context7 library ID (e.g., 'intel/mkl-dnn').
Overrides the auto-resolved ID when doc_source is 'context7'.
questions_from: Reuse an existing question set (file, or a run
directory holding questions/<product_key>.json).
product_key: Registry key used for output file names and golden
question-set lookup (defaults to ``product``).
questions_root: Directory holding golden question sets named
``<product_key>_golden.json``, for example a checkout of the
evaluation-content repository. When given and the file is
present it is the run's whole question set and generation is
skipped; when it is absent a warning is logged and questions are
generated. Without this argument (and without
``custom_questions_path``) the run has no golden set.
registry: ProductRegistry used to find the declared context7_id
(default: the bundled products.yaml)
judge_placeholder: No effect, warned: since method version 4 the
context arm answers a question with no document found with the
plain prompt, and that answer is judged (#228 step 4c)
checkpoint: Makes the file the answered questions are kept in until
the answers file is saved, from the answers path
(``commands.arms.pipeline_checkpoint``); none by default
The fields are described on :class:`EvaluationSettings`.
"""
if not repo and not description:
if not isinstance(settings, EvaluationSettings):
raise TypeError(f"EvaluationPipeline.__init__() settings must be an EvaluationSettings, "
f"not {type(settings).__name__}")
if not settings.repo and not settings.description:
raise ValueError(
"Either 'repo' or 'description' must be provided. "
"Supply 'repo' for GitHub-based persona discovery, or "
"'description' for products without a public repository."
)

self.product = product
self.product_key = product_key or product
self.repo = repo
self.description = description
self.output_dir = Path(output_dir)

self.questions_root = Path(questions_root) if questions_root else None
self._resolve_question_source(custom_questions_path, questions_from, force_regen)

self.model = model
self.provider = provider
self.judge_model = judge_model
self.judge_provider = judge_provider
self.judge_temperature = judge_temperature
_warn_judge_placeholder(judge_placeholder)

self.personas_count = personas_count
self.questions_per_topic = questions_per_topic
self.top_k = top_k
self.rerank_threshold = rerank_threshold
self.debug_retrieval = debug_retrieval
self.doc_source = doc_source
self.context7_id = context7_id
self.product = settings.product
self.product_key = settings.product_key or settings.product
self.repo = settings.repo
self.description = settings.description
self.output_dir = Path(settings.output_dir)

self.questions_root = Path(settings.questions_root) if settings.questions_root else None
self._resolve_question_source(settings.custom_questions_path, settings.questions_from, settings.force_regen)

self.model = settings.model
self.provider = settings.provider
self.judge_model = settings.judge_model
self.judge_provider = settings.judge_provider
self.judge_temperature = settings.judge_temperature
_warn_judge_placeholder(settings.judge_placeholder)

self.personas_count = settings.personas_count
self.questions_per_topic = settings.questions_per_topic
self.top_k = settings.top_k
self.rerank_threshold = settings.rerank_threshold
self.debug_retrieval = settings.debug_retrieval
self.doc_source = settings.doc_source
self.context7_id = settings.context7_id
# Product registry for the library id (defaults to the bundled products.yaml).
self.registry = registry
self.max_tokens_per_question = max_tokens_per_question
self.force_regen = force_regen
self.registry = settings.registry
self.max_tokens_per_question = settings.max_tokens_per_question
self.force_regen = settings.force_regen

self._resolve_external_questions(questions_from)
self._resolve_external_questions(settings.questions_from)

# Output paths
self.personas_path = self.output_dir / "personas" / f"{self.product_key}.json"
Expand All @@ -221,7 +153,7 @@ def __init__(
# Create output dirs
for path in [self.personas_path, self.questions_path, self.answers_path, self.eval_path, self.report_path]:
path.parent.mkdir(parents=True, exist_ok=True)
self.checkpoint = _open_checkpoint(checkpoint, self.answers_path)
self.checkpoint = _open_checkpoint(settings.checkpoint, self.answers_path)

def _resolve_question_source(self, custom_questions_path: Optional[Path], questions_from: Optional[Path],
force_regen: bool) -> None:
Expand Down
Loading
Loading