Pipeline configuration¶
Explain pipeline configuration schema.
- class nlp_shap.pipeline.config.BackendConfig(*, kind: str, model_id: str, api_host: str | None = None)[source]¶
Bases:
BaseModelBackend selection and connection parameters.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nlp_shap.pipeline.config.GenerationConfig(*, max_new_tokens: int = 128, temperature: float = 0.0, top_k: int = 1, precompute_base: bool = True)[source]¶
Bases:
BaseModelGeneration parameters for the base and coalition evaluations.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nlp_shap.pipeline.config.BudgetConfig(*, fraction: Annotated[float, Gt(gt=0.0), Le(le=1.0)] = 1.0)[source]¶
Bases:
BaseModelEstimator budget controls replacing standard/limited split configs.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nlp_shap.pipeline.config.ArchiveConfig(*, path: str = './runs/{run_id}', flush_every: Annotated[int, Ge(ge=1)] = 50)[source]¶
Bases:
BaseModelRun archive persistence options.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nlp_shap.pipeline.config.DedupConfig(*, enabled: Literal['auto', 'on', 'off'] = 'auto')[source]¶
Bases:
BaseModelCoalition deduplication options.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- enabled: Literal['auto', 'on', 'off']¶
Deduplication mode for repeated coalition evaluations.
- class nlp_shap.pipeline.config.KvCacheConfig(*, enabled: bool = True)[source]¶
Bases:
BaseModelPrefix cache options for supported backends.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class nlp_shap.pipeline.config.ExplanationConfig(*, use_v2: bool = True, estimand: Estimand = Estimand.SHAPLEY, estimator: str = 'neyman_cc', value_fn: str = 'tfidf_cosine', normalizer: str = 'identity', players: str = 'tokens', absence_policy: str = 'delete', budget: BudgetConfig = BudgetConfig(fraction=1.0), include_minimal_masks: bool = False, max_inflight: Annotated[int, Ge(ge=1)] = 2, archive: ArchiveConfig = ArchiveConfig(path='./runs/{run_id}', flush_every=50), dedup: DedupConfig = DedupConfig(enabled='auto'), kv_cache: KvCacheConfig = KvCacheConfig(enabled=True), embedding_mode: EmbeddingMode = EmbeddingMode.STATIC, seed: int = 42)[source]¶
Bases:
BaseModelExplanation algorithm and runtime controls.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- budget: BudgetConfig¶
Estimator budget controls.
- archive: ArchiveConfig¶
Run archive persistence settings.
- dedup: DedupConfig¶
Coalition deduplication settings.
- kv_cache: KvCacheConfig¶
Prefix cache settings for supported backends.
- embedding_mode: EmbeddingMode¶
Embedding mode used by embedding-based value functions.
- class nlp_shap.pipeline.config.ExplainConfig(*, backend: BackendConfig, generation: GenerationConfig = GenerationConfig(max_new_tokens=128, temperature=0.0, top_k=1, precompute_base=True), explanation: ExplanationConfig = ExplanationConfig(use_v2=True, estimand=<Estimand.SHAPLEY: 'shapley'>, estimator='neyman_cc', value_fn='tfidf_cosine', normalizer='identity', players='tokens', absence_policy='delete', budget=BudgetConfig(fraction=1.0), include_minimal_masks=False, max_inflight=2, archive=ArchiveConfig(path='./runs/{run_id}', flush_every=50), dedup=DedupConfig(enabled='auto'), kv_cache=KvCacheConfig(enabled=True), embedding_mode=<EmbeddingMode.STATIC: 'static'>, seed=42))[source]¶
Bases:
BaseModelTop-level explain pipeline configuration.
- model_config = {'extra': 'forbid', 'frozen': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- backend: BackendConfig¶
Backend selection and connection parameters.
- generation: GenerationConfig¶
Generation parameters for base and coalition evaluations.
- explanation: ExplanationConfig¶
Explanation algorithm and runtime controls.
- nlp_shap.pipeline.config.explain_config_from_yaml(text: str) ExplainConfig[source]¶
Parse YAML text into a validated
ExplainConfig.
- nlp_shap.pipeline.config.explain_config_to_yaml(config: ExplainConfig) str[source]¶
Serialize a config to YAML with stable key ordering within sections.
Explain pipeline result types.
- class nlp_shap.pipeline.result.ExplainResult(estimand: Estimand, values: tuple[float, ...])[source]¶
Bases:
objectAttribution output for a single explain run.
Run archive manifest schema stubs.
- class nlp_shap.pipeline.manifest.RunManifestPayload[source]¶
Bases:
TypedDictJSON-compatible manifest payload persisted with a run archive.
- class nlp_shap.pipeline.manifest.RunManifest(estimand: Estimand, run_id: str)[source]¶
Bases:
objectTop-level metadata persisted alongside a run archive.
- to_dict() RunManifestPayload[source]¶
Serialize manifest fields to JSON-compatible primitives.
- nlp_shap.pipeline.manifest.parse_manifest(payload: RunManifestPayload) RunManifest[source]¶
Parse a typed manifest payload into a run manifest.