Improve validation in structured generation columns

未关闭
#182 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
data

调研方向

从 LLMStructuredColumnConfig 和附带的 test_serialization_pydantic_core_schema notebook 开始,然后检查 JSON Schema 和 gsonschema 当前如何验证结构化输出。将其与 #171 中描述的行为进行比较,尤其是写入 Parquet 的 Decimal 值。完成的标准是提出一种具体的、可序列化的方法,在不只依赖生成的 JSON schema 的情况下保留相关的 Pydantic 验证行为。

由索引模型根据 Issue 内容生成。

描述

enhancement needs-discussion

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.

test_serialization_pydantic_core_schema (1).ipynb

主要语言
Python
星标
2.4k
派生
241
平均合并
21 小时 51 分钟
30 天内合并 PR
90

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

NVIDIA-NeMo/DataDesigner 的其他 Issue

查看 NVIDIA-NeMo/DataDesigner 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。