Add support for row-dependent sampling from list and weighted-dict columns
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start by reading the column configuration and generator paths named in the issue: config/column_configs.py, config/column_types.py, and engine/column_generators/generators/. Then trace row drop handling in engine/dataset_builders/async_scheduler.py and row offsets in engine/context.py; the issue leaves key design questions open. Done means a built-in column can sample each row's list or weighted dict pool, with defined handling for invalid pools, empty pools, and seeded draws, plus tests for those behaviors.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Priority Level
High (Major improvement)
Is your feature request related to a problem? Please describe.
Data Designer samples from distributions that are fixed in the config (SamplerColumnConfig). Some pipelines instead need each record to sample from its own pool: a list or weighted dict held in another column of the same record, coming from the seed dataset or an earlier column.
| record_id | candidate_pool | example draw |
|---|---|---|
| 1 | ["A", "B", "C"] |
"B" |
| 2 | ["D", "E"] |
"E" |
| 3 | {"F": 0.8, "G": 0.2} |
"F" |
I ran into this while moving pipelines to Data Designer from SDG Hub, an open-source Python framework for synthetic data generation. Two existing synthetic data generation workflows that I and my team use depend on per-record sampling:
- Red-team prompt generation: each seed record is an adversarial harm category with its own pools for eight attributes (demographic, region, language style and so on). Most pools are uniform lists; some are weighted dicts. Each output row draws one value per attribute from its own record's pools.
- MCP tool-use distillation: each seed record is an MCP server with its tool list. Each output row draws 2 of that server's tools, without replacement, to seed a question.
Neither fits Data Designer's config today:
- Sampler columns can't read other columns. They are generated from scratch, and #614 made this explicit for subcategory samplers by rejecting non-sampler parents at config validation.
- Expression columns can pick one element uniformly with Jinja's
randomfilter, but offer no weights, no sampling without replacement and no seeding, and an empty pool drops the row. - Custom columns and column-generator plugins can do it, but each pipeline then needs Python code or an extra package, and a custom column can't ship in a config file run with
data-designer create.
Describe the solution you'd like
Proposing to add a built-in column type, pool-sampler, that draws values from a pool held in another column of the same record. A pool is a list (drawn uniformly) or a dict of value to weight (drawn by weight), and can come from the seed dataset or from an earlier column.
columns:
- name: region
column_type: pool-sampler
source_column: geography_pool # list -> uniform, dict -> weighted
num_samples: 1
return_scalar: true
- name: sampled_tools
column_type: pool-sampler
source_column: tool_list
num_samples: 2 # without replacement by default
dd.PoolSamplerColumnConfig(name="region", source_column="geography_pool", num_samples=1, return_scalar=True)
| Field | Default | Notes |
|---|---|---|
source_column |
required | column holding each record's pool |
num_samples |
1 | at least 1 |
replace |
false |
without replacement, draws min(num_samples, pool size) |
return_scalar |
false |
returns the value instead of a one-element list; only with num_samples: 1 |
seed |
unset | optional int |
Per row:
- A list, array or set pool is drawn uniformly (a set is sorted first). A dict pool is drawn by weight.
- Weights must be finite and non-negative. Keys with weight 0 are dropped. Keys with weight
Nonecount as absent, because parquet and JSONL seeds pad dict keys missing from a record withNone. - An empty pool, a null cell, or a dict with no positive weight gives
Nonewithreturn_scalar, and[]otherwise. The row is kept. - A pool stored as text is parsed as JSON, then as a Python literal (nothing is executed). A column that mixes lists and dicts reaches generators only as text: JSON strings from a JSONL seed, Python reprs from a DataFrame seed.
- A row whose pool is invalid is dropped: a negative, infinite or non-numeric weight, or a value that is not a list, array, set, dict or parseable text. The log gives drop counts by reason, the way expression columns report rows that fail to render.
- With
seedset, each row gets its own generator, keyed on the seed, the column name and the row's absolute index. Draws then don't depend on row-group scheduling orbuffer_size, and preview and create agree. Withoutseed, draws use fresh entropy.
For list and dict pools this matches SDG Hub's SamplerBlock in cell mode: the same weight checks, zero weights dropped, and the same empty-pool output. The differences are the None-weight rule, parsing of text pools, and the handling of invalid pools: SamplerBlock raises on bad weights (failing the flow), returns an empty draw for a scalar and samples a string's characters, while this column drops the row. SamplerBlock also consumes one seeded generator in row order, which a row-group engine can't reproduce, so seeded draws match it in distribution, not draw for draw.
Fit in the engine:
- Config:
PoolSamplerColumnConfig(SingleColumnConfig)withrequired_columns = [source_column], registered inconfig/column_types.pyand exported fromconfig/__init__.py. - Engine: a
ColumnGeneratorFullColumnin a newengine/column_generators/generators/pool_sampler.py, registered inengine/column_generators/registry.pyandengine/column_generators/utils/generator_classification.py. - DAG and skip: as an ordinary single column, it runs after its source column in the dependency DAG and can carry
skip.when.samplercolumns can't do either: they are generated together from scratch, andskipis rejected on them (config/base.py,_validate_skip_scope). - Row drops: the scheduler accepts fewer rows back only from expression columns today (
_task_supports_row_drops). The new type would join that contract, including failing the run when a row group has no valid row.
I have this working as a column-generator plugin, with tests. A plugin can't drop single rows though: only expression columns may return fewer rows, so an invalid pool in a plugin column drops its whole row group. Once this issue is triaged, I'll use the plugin as the starting point for a plan in plans/<issue>/ and a PR. I am proposing a built-in column because the operation is domain-independent, but open to contributing it to DataDesignerPlugins if that fits the project's direction better.
Open questions:
- A separate column type, or a new
sampler_typeundersampler? The latter needs row access inside the sampler engine. - For an empty or null pool:
Nonefor scalar output and[]for list output (asSamplerBlockdoes), or alwaysNone? - For an invalid pool: drop the row (as expression columns do), or fail the run (as
SamplerBlockdoes)? - Seeded draws in multi-shard Slurm runs: key them on a global row index if shards expose one, or limit seeded columns to single-shard runs?
Describe alternatives you've considered
-
A new
sampler_typethat reads from a column. Sampler columns are collapsed into one multi-column generator that builds its frame from scratch, so no sampler type sees row values. Conditions that name a non-sampler column fail with "not found in schema", and #614 rejects non-sampler subcategory parents at config validation. This route needs row access and per-row parameters inside the sampler engine, and the column still couldn't carryskip.when(open question 1). -
Jinja's
randomfilter in an expression column. It picks one element uniformly from a list, but:- it has no weights: with data-designer 1.1.0, a dict pool from a DataFrame seed reaches the template as
(key, weight)pairs, so the filter renders a pair such as"['Western Europe', 0.7]"; - the result is rendered text, cast at most to
int,floatorbool, so k values can't come back as a list; - it uses Python's global
randommodule, so draws can't be seeded; - an empty or null pool drops the row.
More filters (a weighted pick, a k-sample) would add weights. But the output would still be text, draws still couldn't be keyed to the row, and an empty pool would still drop the row.
- it has no weights: with data-designer 1.1.0, a dict pool from a DataFrame seed reaches the template as
-
Pre-sampling in pandas before the run. This works when the pools are in the seed: sample into new seed columns, then run the config. But the sampling then lives outside the config, so the pipeline is no longer one config that
data-designer createcan run. The rows also have to be replicated in pandas first, and pools produced by an earlier column can't be handled. -
A custom column. It works in Python, but a config that uses one can't ship as a file:
generator_functionserializes as the function's name, and loading needs a callable decorated with@custom_column_generator(unless I missed something). -
A column-generator plugin. This is what I use today (see above). Its limits:
- everyone who runs the config has to install the package;
- multi-shard Slurm runs reject plugin column types (
slurm/planning/resolution.py,_SHARDABLE_COLUMN_TYPES; #1113); - it can't drop single rows, so an invalid pool drops its whole row group.
-
A package in DataDesignerPlugins. It would be listed in the default
nvidiacatalog, so users could find and install it easily. It would still face the install step and the Slurm limit that every plugin has but open to this as alternative / staging spot for this functionality.
Agent Investigation
Findings are at main @ 861a0828 (2026-12-03; v1.1.0 is the latest release). Source paths are under packages/data-designer-*/src/data_designer/.
Sampler columns have no row access
SamplerColumnConfig.required_columnsreturns[](config/column_configs.py:92-94).SamplerColumnGeneratoris aFromScratchColumnGeneratorthat uses onlylen(data)(engine/column_generators/generators/samplers.py:29-38). The sampler engine starts fromDataFrame(index=range(num_samples))(engine/sampling_gen/generator.py:118).- Condition columns become sampler-DAG nodes (
engine/sampling_gen/schema.py:65-70), and a node that isn't a sampler raisesColumn '<name>' not found in schema(:139). On 1.1.0, a category sampler conditioned on a seed column fails with exactly that error. - Samplers draw from numpy's global
RandomState(engine/sampling_gen/utils.py:39-40,generator.py:66), andRunConfighas no seed. skipis rejected onsamplerandseed-datasetcolumns (config/base.py:116-124).
Failures and row drops
- Only expression columns may return fewer rows than they received (
engine/dataset_builders/async_scheduler.py:2196-2202). - A non-retryable failure in any other batch generator drops its whole row group (
async_scheduler.py:2099-2104). With my plugin on 1.0.1, I ran 6 rows withbuffer_size=2and one negative weight in row 3: rows 2 and 3 were dropped and 4 rows came back.
Per-row identity for seeding
current_row_group_start_offsetis set for every task (engine/context.py:24-26,async_scheduler.py:1948). For planned row groups it equalsrow_group * buffer_size(engine/dataset_builders/row_group_plan.py:204-209).- Batch generators receive DataFrames that keep slot indices (
engine/dataset_builders/utils/row_group_buffer.py:71-85). SeedDatasetColumnGeneratoralready reads the offset (engine/column_generators/generators/seed_dataset.py:46-49).
Custom columns and plugins
generator_functionserializes as the function's__name__(config/column_configs.py:735-737), and loading requires a callable decorated with@custom_column_generator(:700-706).- Multi-shard Slurm runs accept only the built-in types in
_SHARDABLE_COLUMN_TYPES(slurm/planning/resolution.py:50-62,:358-364; #1113).
What seeds deliver (probe with 1.1.0, pandas 3.1.2 and pyarrow 24.0.0; 1.0.1 gave identical results; no LLM calls)
| Seed source | List pool arrives as | Dict pool arrives as |
|---|---|---|
DataFrameSeedSource |
numpy.ndarray |
list of (key, weight) tuples |
parquet or JSONL LocalFileSeedSource |
numpy.ndarray |
dict with every key seen in any row; keys absent from the row are None |
| a column mixing lists and dicts | parquet: can't be written; JSONL: JSON strings; DataFrame: Python repr strings | same |
{{ pool | random }} with a DataFrame seed:
- list pool: one element per row;
- weighted dict pool: the pair rendered as a string, e.g.
['Western Europe', 0.7]; - empty list and null pool: both rows dropped (
EmptyRenderedExpression=1, TemplateRenderError=1).
With the plugin on 1.0.1, a pool built by an earlier expression column also works: each row drew from its own pool.
Places a new built-in type touches
config/column_types.py:32-44,:82-98and:143-155config/__init__.py:16-30and:142-160engine/column_generators/registry.py:45-57engine/column_generators/utils/generator_classification.py:17-27engine/dataset_builders/async_scheduler.py:2196-2202, for the row-drop contractslurm/planning/resolution.py:50-62andslurm/services/wiring.py:1003-1015, if seeded runs can be made shard-safe- Tests (repo paths):
packages/data-designer-engine/tests/engine/column_generators/test_registry.pyandpackages/data-designer-engine/tests/engine/column_generators/utils/test_generator_classification.py - Docs (repo paths):
fern/versions/latest/pages/concepts/columns.mdxandarchitecture/config.md
Additional context
Some references from / for sdg_hub's version of this feature:
SamplerBlockin cell mode, the behavior this mirrors: https://github.com/Red-Hat-AI-Innovation-Team/sdg_hub/blob/31efcbedf13424ace88a13171fa6be0e8d8be8ad/src/sdg_hub/core/blocks/transform/sampler.py- Red-team prompt generation flow: https://github.com/Red-Hat-AI-Innovation-Team/sdg_hub/blob/31efcbedf13424ace88a13171fa6be0e8d8be8ad/src/sdg_hub/flows/red_team/prompt_generation/flow.yaml
- MCP tool-use distillation flow: https://github.com/Red-Hat-AI-Innovation-Team/sdg_hub/blob/31efcbedf13424ace88a13171fa6be0e8d8be8ad/src/sdg_hub/flows/agentic/mcp_distillation/flow.yaml
- Red-team example notebook, with list and weighted-dict pools per record: https://github.com/Red-Hat-AI-Innovation-Team/sdg_hub/blob/31efcbedf13424ace88a13171fa6be0e8d8be8ad/examples/red_teaming/red_team_prompt_generation.ipynb
Checklist
- I've reviewed existing issues and the documentation
- This is a design proposal, not a "please build this" request
- Ngôn ngữ chính
- Python
- Star
- 2.4k
- Fork
- 258
- Merge trung bình
- 4 ngày 20 phút
- Pull request đã merge (30 ngày)
- 32
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA-NeMo/DataDesigner
-
Judge score profiler samples reasoning with squared category weights, crowding out uncommon scoresĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
NVIDIA-NeMo/DataDesigner#1202 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Local seed path containing a single quote breaks the DuckDB queryCó thể đã có người làm @xubenqiang đã nhận 39 ngày trước. Đang mởbug triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
NVIDIA-NeMo/DataDesigner#1102 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enforce \from future import annotations` via ruff FA102 rule`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởtask
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NVIDIA-NeMo/DataDesigner#760 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NVIDIA-NeMo/DataDesigner#1205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
NVIDIA-NeMo/DataDesigner#1204 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA-NeMo/DataDesigner
Issue tương tự
-
Test: to_hijri() accepts datetime.datetime and uses only the date partCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởgood first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
omarelshamy25x/shamy-hijri#63 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
polish
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresCó thể đã có người làm @AshutoshSingh840 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
UKGovernmentBEIS/control-arena#992 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Maintainer thường phản hồi trong vòng 1 ngày