Skip to content

parameters

parameters

Classes:

Name Description
SafeSynthesizerParameters

Main configuration class for the Safe Synthesizer pipeline.

SafeSynthesizerParameters pydantic-model

Bases: Parameters

Main configuration class for the Safe Synthesizer pipeline.

This is the top-level configuration class that orchestrates all aspects of synthetic data generation including training, generation, privacy, evaluation, and data handling. It provides validation to ensure parameter compatibility.

Fields:

Validators:

  • _normalize_unknown_field_policy
  • _validate_and_resolve_data_params
  • check_timeseries_group_column

data pydantic-field

Configuration controlling how input data is grouped and split for training and evaluation.

evaluation pydantic-field

Parameters for evaluating the quality of generated synthetic data.

training pydantic-field

Hyperparameters for model training such as learning rate, batch size, and LoRA adapter settings.

generation pydantic-field

Parameters governing synthetic data generation including temperature, top-p, and number of records to produce.

privacy pydantic-field

Differential-privacy hyperparameters. When None, differential privacy is disabled entirely.

time_series pydantic-field

Configuration for time-series mode. Time-series pipeline is currently experimental.

replace_pii pydantic-field

PII replacement configuration. When None, PII replacement is skipped.

preflight pydantic-field

Preflight validation overrides, including checks to skip via disabled_checks.

emit_telemetry pydantic-field

Whether to emit anonymous Safe Synthesizer telemetry events. Defaults from NEMO_TELEMETRY_ENABLED when unset.

unknown_fields = DEFAULT_UNKNOWN_FIELDS pydantic-field

How unknown configuration keys are handled recursively. Use 'ignore' only for compatibility with stale configurations and notebooks or mismatched client and service versions.

from_params(**kwargs) classmethod

Construct parameters from resolved keyword names.

Names may be top-level fields, canonical dotted paths, unique bare names, or supported legacy aliases. Ambiguous bare names raise an error that lists the canonical dotted alternatives.

Parameters:

Name Type Description Default
**kwargs object

Values keyed by a supported parameter name.

{}

Returns:

Type Description
'SafeSynthesizerParameters'

A validated configuration with unspecified fields defaulted.

Example

from nemo_safe_synthesizer.config import SafeSynthesizerParameters SafeSynthesizerParameters.from_params(num_records=2000)

Source code in src/nemo_safe_synthesizer/config/parameters.py
@classmethod
@override
def from_params(cls, **kwargs: object) -> "SafeSynthesizerParameters":
    """Construct parameters from resolved keyword names.

    Names may be top-level fields, canonical dotted paths, unique bare
    names, or supported legacy aliases. Ambiguous bare names raise an error
    that lists the canonical dotted alternatives.

    Args:
        **kwargs: Values keyed by a supported parameter name.

    Returns:
        A validated configuration with unspecified fields defaulted.

    Example:
        >>> from nemo_safe_synthesizer.config import SafeSynthesizerParameters
        >>> SafeSynthesizerParameters.from_params(num_records=2000)
    """
    schema = ParameterSchema.from_model(cls)
    assignments: list[PatchAssignment] = []
    resolved_paths: set[ParameterPath] = set()
    for name, value in kwargs.items():
        if (path := schema.require(name)) in resolved_paths:
            raise ParameterError(f"Duplicate parameter path {str(path)!r}.")
        resolved_paths.add(path)
        assignments.append(PatchAssignment(path, value, f"parameter {name!r}", 0))

    return CompiledConfigPatch.from_paths(cls, assignments).apply()

from_config_source(source=None, **kwargs) classmethod

Normalize a source using its effective unknown-field policy.

Source code in src/nemo_safe_synthesizer/config/parameters.py
@classmethod
@override
def from_config_source(
    cls,
    source: Parameters | Mapping[str, object] | None = None,
    **kwargs: object,
) -> Self:
    """Normalize a source using its effective unknown-field policy."""
    if "unknown_fields" in kwargs:
        unknown_field_behavior = validate_unknown_fields(kwargs["unknown_fields"])
    else:
        unknown_field_behavior = cls._unknown_fields_from_input(source)
    return cast(
        Self,
        super().from_config_source(
            source,
            unknown_field_behavior=unknown_field_behavior,
            **kwargs,
        ),
    )

from_config_patch(patch) classmethod

Validate a sparse top-level config patch as a full configuration.

Source code in src/nemo_safe_synthesizer/config/parameters.py
@classmethod
def from_config_patch(cls, patch: ConfigPatch) -> Self:
    """Validate a sparse top-level config patch as a full configuration."""
    normalized = ParameterSchema.from_model(cls).normalize_aliases(patch)
    unknown_fields = cls._unknown_fields_from_input(normalized)
    return CompiledConfigPatch.from_mapping(
        cls, normalized, origin="config patch", precedence=0, unknown_fields=unknown_fields
    ).apply()

with_config_patch(patch)

Apply a sparse top-level config patch and revalidate the result.

Only fields explicitly set on self are carried into the merge before applying patch. This preserves file/CLI precedence while keeping default values implicit for future exclude_unset dumps.

Source code in src/nemo_safe_synthesizer/config/parameters.py
def with_config_patch(self, patch: ConfigPatch) -> Self:
    """Apply a sparse top-level config patch and revalidate the result.

    Only fields explicitly set on ``self`` are carried into the merge before
    applying ``patch``. This preserves file/CLI precedence while keeping
    default values implicit for future ``exclude_unset`` dumps.
    """
    model_type = type(self)
    base = CompiledConfigPatch.from_mapping(
        model_type,
        self.model_dump(exclude_unset=True),
        origin="base config",
        precedence=0,
        unknown_fields="reject",
    )
    normalized = ParameterSchema.from_model(model_type).normalize_aliases(patch)
    unknown_fields = (
        validate_unknown_fields(normalized["unknown_fields"])
        if "unknown_fields" in normalized
        else self.unknown_fields
    )
    override = CompiledConfigPatch.from_mapping(
        model_type,
        normalized,
        origin="config patch",
        precedence=1,
        unknown_fields=unknown_fields,
    )
    return base.combine(override).apply()

with_runtime_overrides(runtime)

Apply supported resume-time overrides onto a copy of self.

self is the saved training-run config. Only explicitly-set generation and evaluation fields from runtime are merged in, plus emit_telemetry and unknown_fields when the caller set them. Training, data, privacy, and other sections are preserved so training provenance survives a generate-only resume.

Parameters:

Name Type Description Default
runtime SafeSynthesizerParameters

Config carrying resume-time CLI/SDK overrides. Typically sparse -- only the fields the caller set are applied.

required

Returns:

Type Description
'SafeSynthesizerParameters'

A new SafeSynthesizerParameters with overrides applied. The

'SafeSynthesizerParameters'

result is fully independent of self: sections that are not

'SafeSynthesizerParameters'

overridden are deep-copied, so later mutation of either object does

'SafeSynthesizerParameters'

not affect the other.

Source code in src/nemo_safe_synthesizer/config/parameters.py
def with_runtime_overrides(self, runtime: SafeSynthesizerParameters) -> "SafeSynthesizerParameters":
    """Apply supported resume-time overrides onto a copy of self.

    ``self`` is the saved training-run config. Only explicitly-set
    ``generation`` and ``evaluation`` fields from ``runtime`` are merged in,
    plus ``emit_telemetry`` and ``unknown_fields`` when the caller set them.
    Training, data, privacy, and other sections are preserved so training
    provenance survives a generate-only resume.

    Args:
        runtime: Config carrying resume-time CLI/SDK overrides. Typically
            sparse -- only the fields the caller set are applied.

    Returns:
        A new ``SafeSynthesizerParameters`` with overrides applied. The
        result is fully independent of ``self``: sections that are not
        overridden are deep-copied, so later mutation of either object does
        not affect the other.
    """
    updates: dict[str, object] = {}

    def _add_section(name: str, section: Parameters) -> None:
        if (materialized := section.explicit_patch().materialize()) or name in runtime.model_fields_set:
            updates[name] = materialized

    _add_section("generation", runtime.generation)
    _add_section("evaluation", runtime.evaluation)
    if "emit_telemetry" in runtime.model_fields_set:
        updates["emit_telemetry"] = runtime.emit_telemetry
    if "unknown_fields" in runtime.model_fields_set:
        updates["unknown_fields"] = runtime.unknown_fields
    patch = CompiledConfigPatch.from_mapping(
        type(self),
        updates,
        origin="runtime override",
        precedence=1,
        unknown_fields="reject",
    )
    return self.apply_patch(patch)