protocols¶
Responsibility¶
typing.Protocolcontracts each plugin kind satisfies structurally, plus runtime-checkable capability protocols the pipeline tests withisinstanceinstead of probing attributes (Capability protocol).
Public surface¶
GenerativeBackend:model_id,async generate(snapshot, generation: GenerationConfig) -> GenerationResult;GenerationResultpromisestext.Capabilities:
SupportsKvCache(kv_cache_hits,kv_cache_reused_tokens,set_kv_cache_enabled(enabled, max_entries)),SupportsLogprobs(returns_logprobs; thetransformersandapibackends),SupportsAclose(async aclose()),FittableValueFunction(fit(corpus)),RequiresEmbeddings(needs_embeddings),RequiresLogprobs(needs_logprobs).EstimatorStrategy:name,bind_snapshot,sample_masks(player_set, budget_fraction, include_minimal_masks, seed),estimate_attributions(masks, payoffs, aggregator)(Estimator);TwoPhaseEstimator:begin_allocation(masks, payoffs),sample_allocation_masks().EstimandAggregator:estimand,coalition_weight(size, n),aggregate(masks, payoffs)(Estimand).ValueFunction:name,score(base, candidate)(Value function).AbsencePolicy:name,apply(snapshot, players, mask)(Absence policy);PlayerPartitioner:name,partition(snapshot) -> PlayerSetwith spans (Partition).Normalizer,AttributionRenderer,EmbeddingProvider.protocols/plugin.py:PluginOptions(pydantic model withextra="forbid", strict types, frozen; the base class accepts no keys) andDeclaresPluginOptions(a plugin class with anoptions_modelclass variable) (Plugin options).
Data flow¶
Invariants¶
A plugin that satisfies the protocols works without subclassing; capabilities are optional and detected with
isinstance.The orchestrator has no estimator-name switch: every estimator exposes
estimate_attributions, and two-phase estimators are found byTwoPhaseEstimator.
Known issues¶
None open.