Expected behavior of describe method #596
Replies: 1 comment 1 reply
-
A quick aside on how output conformance for Genkit works: we take the provided Zod schema, convert it to JSON schema, then augment the prompt with instructions to format output as conforming to the JSON schema. When you compose a Zod schema from multiple subschemas, they are all converged into one large schema with all nested fields. With that context in mind and taking a look at your reported issue, I think there are a few things at play:
In general when you're seeing poor output conformance results a good tactic is to add good examples in the prompt:
^ obviously the above should be tailored for your use case. If you add some diverse examples with correct output, the LLM will oftentimes behave better. Hope that helps! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to understand the expected behavior of Zod's
describe
method when used with Genkit.Judging by the Genkit document, my expectation was that it was a utility to pass additional context to the model; however, the Zod documentation leads me to expect that it's intended to add a
description
field to the schema.I've seen Genkit use
describe
to do the latter, which I initially thought was a bug, so I created this issue; however, I closed it to avoid becoming clutter after I reviewed the Zod documentation.The remaining problem, which you can see in the example in the original issue, is that descriptions from child schema seem to "bubble-up" or "leak" into their parent schema. In my example, instead of a color's
name
,hex
, orrgb
fields receiving the given description, the color itself receives anull
description.This still seems like a bug to me at least, because the behavior is inconsistent either way, but I'm not sure how to properly characterize and report it until I understand the expected behavior.
What's the expected behavior in this case, or is it just user error on my part?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions