-
Notifications
You must be signed in to change notification settings - Fork 645
Open
Description
A v0 would be allowing users to instantiate the logits processor with the tool call tokens and pass it to the generator. Note that this would only work with models that use simple tokens for tool calling (Llama has a more complex pattern that we can handle later).
model = ...
logits_processor = FunctionCallingLogitsProcessor("<tool_call>", "</tool_call>", Union[User, Customer])
generator = Generator(model, processor=logits_processor)The implementation is simple:
- While
<tool_call>has not been observed,__call__is a pass-through. - After
<tool_call>has been observed, mask the logits to follow a given JSON Schema. - Once the JSON generation has completed, force the generation of
</tool_call> - Then let the model generate freely,
__call__is a pass-through.
If there are several possible function calls, the type for (2) would be a Union of the different JSON Schemas.
torchss
Metadata
Metadata
Assignees
Labels
No labels