Improve validation in structured generation columns
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with LLMStructuredColumnConfig and the attached test_serialization_pydantic_core_schema notebook, then review how JSON Schema and gsonschema currently validate structured outputs. Compare this with the behavior described in #171, especially Decimal values written to Parquet. Done means a concrete serializable approach preserves the relevant Pydantic validation behavior without relying only on the generated JSON schema.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
We would like to store a Pydantic model inside the LLMStructuredColumnConfig, since it allows us to better validate the output. However, column configs need to be serializable. Because of that, we end up converting that to a JSON schema, and using gsonschema to do the validation.
Unfortunately, validating using the JSON schema is not as good as using the Pydantic model. Recently, for instance, we had an issue where models would generate either "price": "12.34" (converted to string) or "price": 12.34 (converted to float), both of which passed validation (price being a Decimal), and later would have issues writing to Parquet. See #171 for more details.
Describe the solution you'd like
It would be nice to be able to serialize the Pydantic model keeping features such as complex types, validators etc. One possibility would be creating our own serialization.
Describe alternatives you've considered
Alternative solutions include adding more info to the prompt, depending on the type; and standardizing types later, before writing to Parquet.
Additional context
See notebook attached (by @nabinchha) for one possibility on how to ser/de Pydantic models.
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 258
- Avg merge
- 4d 20m
- Merged PRs (30d)
- 32
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA-NeMo/DataDesigner
-
Judge score profiler samples reasoning with squared category weights, crowding out uncommon scoresOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
NVIDIA-NeMo/DataDesigner#1202 ·
Maintainers usually reply within 1 day
-
Local seed path containing a single quote breaks the DuckDB queryPossibly taken @xubenqiang claimed this 39 days ago. Openbug triaged
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
NVIDIA-NeMo/DataDesigner#1102 · 3 comments ·
Maintainers usually reply within 1 day
-
enforce \from future import annotations` via ruff FA102 rule`May be free again A pull request for this issue was closed without being merged. Opentask
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NVIDIA-NeMo/DataDesigner#760 ·
Maintainers usually reply within 1 day
-
NVIDIA-NeMo/DataDesigner#1205 ·
Maintainers usually reply within 1 day
-
NVIDIA-NeMo/DataDesigner#1204 ·
Maintainers usually reply within 1 day
All issues in NVIDIA-NeMo/DataDesigner
Similar issues
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPossibly taken A pull request linked to this issue is open or already merged. Opengood first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
omarelshamy25x/shamy-hijri#63 · 3 comments ·
Maintainers usually reply within 1 day