Python API¶
The CLI is convenient for complete runs. The Python API exposes the same configuration and orchestration, plus lower-level corpus and task functions. Generated task options describe options read by the configuration wrappers; the function signatures remain authoritative for direct calls.
Load and check configuration¶
from pathlib import Path
from hermes_benchmark.config import load_config
from hermes_benchmark.pipeline import validate_generation_config
config = load_config(Path("config.yaml"))
validate_generation_config(config)
load_config checks typed YAML structure. validate_generation_config checks
supported enabled task names and cross-task service dependencies. Neither
function runs generation or verifies that a remote credential will work.
Generate and validate¶
from pathlib import Path
from hermes_benchmark.config import load_config
from hermes_benchmark.pipeline import generate_benchmark, validate_benchmark
config = load_config(Path("config.yaml"))
generation = generate_benchmark(config, show_progress=True)
validation = validate_benchmark(config)
print(generation.manifest_path)
if not validation.valid:
raise RuntimeError([issue.to_dict() for issue in validation.issues])
generate_benchmark returns a GenerationReport with steps, reuse status,
output directory, and manifest path. validate_benchmark returns a
ValidationReport; inspect valid, issues, warnings, and sample_counts.
Both reports provide to_dict(). force=True reexecutes stages but retains
provider-level caches.
Inspect capacity¶
from pathlib import Path
from hermes_benchmark.config import load_config
from hermes_benchmark.capacity import profile_dump, estimate_task_capacities
config = load_config(Path("config.yaml"))
profile = profile_dump(
config.dump.path,
config.corpus,
page_limit=config.inspection.sample_pages,
tasks=config.tasks,
mode="sample",
)
report = estimate_task_capacities(profile, config.tasks, config.services)
print(report.to_dict())
run_pilot(config) is available from hermes_benchmark.capacity for isolated
pilot construction. A pilot does not exercise provider inference.
Stream Wikipedia articles¶
from hermes_benchmark.wikipedia import iter_articles
for page in iter_articles("dump.xml.bz2", limit=10):
print(page.page_id, page.revision_id, page.title)
The iterator yields WikiPage objects, including source revision IDs when
available. The filtered raw corpus has a different schema and does not preserve
every field of WikiPage; retain the dump for complete provenance.
Generate individual task groups¶
The following wrappers read task and service settings from a GenerationConfig:
Import from hermes_benchmark.tasks |
Inputs already required below output_dir |
|---|---|
generate_paragraph_tasks_from_config |
Enriched corpus |
generate_reranking_from_config |
Raw corpus |
generate_ner_from_config |
Raw corpus; original dump |
generate_classification_from_config |
Matching raw/enriched corpora; original dump |
generate_extractive_qa_from_config |
Raw corpus; original dump |
They return typed statistics with to_dict() and reused. They do not replace
full-pipeline orchestration or automatically update a previous benchmark-level
manifest. Run generate_benchmark afterward for a complete validated run.
Inject providers for controlled runs¶
from hermes_benchmark.pipeline import PipelineProviders, generate_benchmark
providers = PipelineProviders(
embeddings=my_embedding_provider,
knowledge_base=my_entity_type_provider,
classification=my_classification_provider,
question_rewrite=my_question_provider,
)
report = generate_benchmark(config, providers=providers)
my_* variables above represent application-supplied providers. Omit unused
providers or set them to None to use configured clients. Required interfaces:
| Provider | Identity and methods |
|---|---|
| Embeddings | provider_name, model_name, encode(texts, batch_size) returning a numeric matrix |
| Knowledge base | provider_name, resolve(titles, language) returning title → active label or None |
| Classification | provider_name, model_name, classify(articles, labels, language) |
| Question rewriting | provider_name, model_name, rewrite(rows, language) |
| Hybrid QA conflict replacement | Question provider additionally implements validate_answers(rows, language) |
The QA checker response must contain string id, string answer_text, and
boolean is_unambiguous. Built-in Google providers create the answer-check
request from only id, question, and context. Custom providers must preserve
that gold-blind property themselves. Provider identities are part of cache keys:
change the model identifier when changing custom model behavior.