Replies: 3 comments 2 replies
-
I think the |
Beta Was this translation helpful? Give feedback.
-
How is that so? There would be a unified user interface. |
Beta Was this translation helpful? Give feedback.
-
I may have misunderstood a part of it. Would your proposition include getting rid of the custom types I thought that the big advantage of going through an intermediary So, thinking more about it, I agree with your proposition and think it's what makes the most sense. The only potential challenge I can see is properly conveying information on what types can be used for local models and what they do. The |
Beta Was this translation helpful? Give feedback.
-
With v1 users will be able to specify the output structure of the text generated by LLMs using Python types, as if they were annotating the corresponding function. Non exhaustively:
Internally we have three different ways to constrain the output type:
So we need to internally map Python types to these different ways. I think this is where the distinction between
APIGenerator
andLocalGenerator
comes in handy.APIGenerator
We currently create
Chocie
,JsonSchema
objects that we then pass to the respective model classes. I think this is an antipattern, which can be seen in theGeminiTypeAdapter
class:where a much cleaner version, which does not require to introduce intermediate code, would be:
I thus suggest that, for API model providers, we just forward the output type passed by the user and handle the conversion in the respective
XTypeAdapter
classes.LocalGenerator
Here we need to distinguish what should be handled with regex-based and CFG-based structured generation, then build the respective logits processors. For instance:
And then handle conversion in
to_regex
:etc.
Note: We probably want the model instance to be responsible for building the logits processor, since different models can have different backends (NumPy, Torch, MLX, JAX, etc.).
Beta Was this translation helpful? Give feedback.
All reactions