llm
llm
¶
OpenAI-compatible LLM discovery for PII plans and sampler mappings.
Classes:
| Name | Description |
|---|---|
LLMPlanEnhancer |
Discover plans and sampler mappings through bounded structured requests. |
DependencyOptions = dict[str, dict[EntityType, list[str]]]
module-attribute
¶
Target column -> source entity type -> permitted source columns, in candidate order.
LLMPlanEnhancer(config, *, settings=None, transport=None, sleep=time.sleep)
¶
Bases: PlanEnhancer
Discover plans and sampler mappings through bounded structured requests.
Pass one classifies every column's entity type and optional pattern. NSS then derives replacement membership and all permitted dependency candidates deterministically, and pass two only selects useful candidate IDs. Invalid optional patterns get focused repair requests. A separate request maps dependency values to sampler values on demand.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LLMConfig
|
Persisted LLM behavior. |
required |
settings
|
InferenceSettings | None
|
Endpoint, model, key, and request settings; defaults to
|
None
|
transport
|
LLMTransport | None
|
Structured-response transport; defaults to an
|
None
|
sleep
|
Callable[[float], None]
|
Function used to wait between transient retries. |
sleep
|
Attributes:
| Name | Type | Description |
|---|---|---|
settings |
Resolved inference settings. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If the inference settings are invalid. |
Methods:
| Name | Description |
|---|---|
enhance |
Return a semantically classified, deterministically assembled plan. |
discover_data_to_sampler_value_mapping |
Map conditioner-column values without a sampler match to values from one sampler catalog. |
Source code in src/nemo_safe_synthesizer/pii_replacer/planning/llm.py
enhance(discovery_input, baseline)
¶
Return a semantically classified, deterministically assembled plan.
baseline is not sent to the model. The heuristic discoverer returns an empty plan, and a hint that always
says nothing reads as a negative signal, so prompts carry no heuristic classifications or dependency choices.
Source code in src/nemo_safe_synthesizer/pii_replacer/planning/llm.py
discover_data_to_sampler_value_mapping(dataframe, plan, catalog)
¶
Map conditioner-column values without a sampler match to values from one sampler catalog.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Data whose conditioner-column values need sampler values. |
required |
plan
|
PiiReplacementPlan
|
Replacement plan naming the conditioner columns. |
required |
catalog
|
SamplerValueCatalog
|
Sampler values available for each conditioner entity type. |
required |
Returns:
| Type | Description |
|---|---|
DataToSamplerValueMapping
|
Per-column mappings from each dataset value that has no |
DataToSamplerValueMapping
|
case-insensitive sampler match to one or more sampler values. A |
DataToSamplerValueMapping
|
value that fits no narrower set maps to every supplied value, so |
DataToSamplerValueMapping
|
sampling is not narrowed. Returns an empty dict when every value |
DataToSamplerValueMapping
|
already matches. |
DataToSamplerValueMapping
|
For example, with the catalog |
DataToSamplerValueMapping
|
|
DataToSamplerValueMapping
|
a |
DataToSamplerValueMapping
|
|
DataToSamplerValueMapping
|
is omitted because it already matches. |
Raises:
| Type | Description |
|---|---|
ParameterError
|
If the mapping request exceeds its size bounds. |