Parameters¶
Task parameters are declared on KgTask.config_spec as Parameter objects. A pipeline catalog supplies the values. The resolved values are part of the candidate fingerprint. See Configuration for the catalog fields and Pipelines for how a plan is built.
Declaration¶
from kgpipe.common.model.configuration import ConfigurationDefinition, Parameter, ParameterType
ConfigurationDefinition(
name="Paris entity matching configuration",
parameters=[
Parameter(
name="entity matching threshold",
datatype=ParameterType.number,
default_value=0.9,
native_keys=["ENTITY_MATCHING_THRESHOLD"],
),
],
)
The YAML key is the normalized name: lowercase, with spaces and hyphens turned into single underscores. entity matching threshold is entity_matching_threshold. native_keys adds further aliases, including the legacy environment-style names.
Binding¶
For each step whose task declares config_spec, values are taken in this order:
default_valueon the parameter- the legacy
configmap (ENTITY_MATCHING_THRESHOLDand the other aliases on the configuration page) - the pipeline
parametersmap, applied to every task that has that parameter parameterson that step
The step value wins. The resolved map is stored on the plan step under the normalized names. A task function that takes config receives the ConfigurationProfile. A function that only takes inputs and outputs ignores the profile; tasks that still read os.environ keep that behavior until they accept config.
A pipeline-level parameter that matches nothing, or a step parameter the task does not declare, fails before execution.
What is not a parameter¶
Choosing which task implementation runs is the tasks list, not a parameter. The port wiring is connect: auto or the explicit inputs / outputs refs. Both are covered by plan.fingerprint together with the parameter values. File paths are not.
Configuration space¶
A configuration space is a pipeline layout plus the tasks that may fill it. The layout is an ordered list of categories. A task covers the categories declared on KgTask.category, unless the space names a different set of slots for that task.
Each searchable parameter has a domain. The domain is Parameter.allowed_values, or a shorter list. Every domain value has to match the parameter's type and stay inside allowed_values, minimum, and maximum. ConfigurationSpace.from_tasks builds this from the live tasks. ConfigurationSpace.from_legacy reads the paper's {task_key: {category, parameter: [values]}} dicts and checks those lists against the same constraints.
enumerate_task_combinations lists the task orders the layout accepts. A task is used for the current category only when that category is one of its slots and none of its slots are already covered. A task that covers several slots satisfies the later ones. sample_candidate draws one accepted order and one value from each domain. The same random.Random seed draws the same candidate.
Search¶
Search runs those assignments. A pipeline-level domain is one catalog: each value is applied to every task that declares the parameter, and each value gets its own workspace. That replaces a copied catalog per entity threshold.
from kgpipe import Pipeline, Search
pipeline = Pipeline.from_yaml(
"pipeline.conf",
"rdf_base",
source="data/source.nt",
seed="data/seed.nt",
result="output/result.nt",
data_dir="output",
)
def score(candidate, outcome):
return float(outcome.plan.steps[0].parameters["entity_matching_threshold"])
result = Search(
pipeline,
parameters={"entity_matching_threshold": [0.5, 0.9, 0.95, 0.99]},
objective=score,
rank="custom",
).run()
print(result.best.parameters, result.best.score, result.report_path)
strategy defaults to exhaustive, which walks the domain in enumeration order. random, implementation_aware, qgns (restricted neighborhood search), hnr, hnr_2, and bayesian are the other supported strategies. budget caps how many assignments run. seed is the random seed. init_budget and init_strategy (random or implementation_aware) start qgns, hnr, hnr_2, and bayesian. y is the number of parameter samples per task combination. k and rho belong to qgns. HNR and HNR-2 keep exploration at 0. pool_size and beta belong to the Bayesian step. rank is recorded on the report. The number comes from objective(candidate, outcome); higher is better. The paper's ranking names are default, flat_hmean, and custom.
The same call from the command line:
kgpipe search pipeline.conf rdf_base \
--parameter entity_matching_threshold=0.5,0.9,0.95,0.99 \
--objective pkg.score:score \
--rank custom \
--input data/source.nt --seed data/seed.nt \
--result output/result.nt --data-dir output
--rng-seed is the search seed. --seed is the knowledge graph. --domain task.parameter=v1,v2 varies one task. --dry-run lists the assignments and does not run them. Adaptive strategies list the whole space on a dry run, because the trajectory depends on scores.
Each trial is a normal pipeline attempt. Its report uses parent_run_id to point at the search. The search report is kind: optimization under <data-dir>/runs/<attempt-id>/. It stores the strategy, the budget, the seed, the rank, the history, the best assignment, and the cache flag for each trial. Candidate files live under <data-dir>/candidates/<config-hash>/. A second search of the same assignment skips tasks whose outputs are already there.
A ConfigurationSpace can be passed instead of parameters when the search also changes which task runs. The pipeline still supplies the files.
The LLM proposer is not part of kgpipe search. It stays in experiments/param-opti and needs KGPipe_SEARCH_LLM_*.
Legacy search snapshots¶
Published parameter-search results are {task_keys, profiles} JSON files. The file name, without .json, is the SHA-256 hex digest of json.dumps(snapshot, sort_keys=True). That digest is the result key. plan.fingerprint identifies the resolved execution plan and does not rename those files.
read_legacy_snapshot loads one file and checks the digest. iter_legacy_result_snapshots reads a directory of those files. It skips *.plan.json, *.eval.json, and results.json. The four published directories are parameter_search/rdf_sampled, parameter_search/text_sampled, parameter_search/rdf, and parameter_search/text. The last two are the exhaustive runs. A local copy lives at data/kgpipe-experiment-results/parameter_search/.
Versioned fixture files are a different wrapper, {version: 1, samples: [snapshot, ...]}. load_legacy_sample_file reads that list. The experiment loaders (load_rdf_sampled_pipeline_configs, and the text, unique, and exhaustive variants) read the same wrapper.
Loading a snapshot does not change it. candidate_from_snapshot keeps the profile names and the binding order, and candidate_snapshot writes the same {task_keys, profiles} object, so the digest stays the same. build_candidate then turns that candidate into a kgpipe.pipeline/v1 pipeline. Rebuilding the pipeline produces the same fingerprint as a fixed catalog with the same tasks, port refs, and parameter values.