-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TGI
(Text Generation Inference) Endpoint Inference and TGI JSON Grammar Generation
#502
base: main
Are you sure you want to change the base?
Conversation
TGI
(Text Generation Inference) Endpoint InferenceTGI
(Text Generation Inference) Endpoint Inference and TGI JSON Grammar Generation
Updated the PR to add support for JSON Grammar Constrained Generation for TGI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR ! Few thing i'm not sure to get / understand
@@ -491,6 +492,7 @@ def _process_batch_logprob( | |||
context=request.context if rolling else request.context + request.choice, | |||
stop_tokens=[], | |||
max_tokens=1, | |||
grammar=request.generation_grammar, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the grammar in the request here while it is defined in the generation config ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generated_text = self.client.generate( | ||
prompt=context, | ||
do_sample=generation_config.do_sample or False, | ||
max_new_tokens=generation_config.max_new_tokens, | ||
best_of=generation_config.best_of, | ||
repetition_penalty=generation_config.repetition_penalty, | ||
return_full_text=generation_config.return_full_text or False, | ||
seed=generation_config.seed, | ||
stop_sequences=generation_config.stop, | ||
temperature=generation_config.temperature, | ||
top_k=generation_config.top_k, | ||
top_p=generation_config.top_p, | ||
truncate=generation_config.truncate, | ||
typical_p=generation_config.typical_p, | ||
watermark=generation_config.watermark or False, | ||
decoder_input_details=generation_config.decoder_input_details, | ||
grammar=generation_config.grammar, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, this is the interface text-generation==0.7.0
is exposing now which is different since I have upgraded it from 0.6.0
in this PR.
Did you mean, is there a cleaner way to do this?
UP! I encountered a similar issue where the bug prevented us from using the TGI endpoint. The key issues I found are:
|
Exactly @naufalso , this is already solved in this PR! |
Description
While implementing a custom task using
lighteval
, I needed to use constrained grammar generation with TGI and it seems that TGI integration is not up-to-date and not working.Fixes for TGI Endpoint Inference
/info
route of TGI3.0.1
doesn't always return required fields such asmodel_dtype
, so it was set toNone
by default if not found:AsyncClient
from TGI has agenerate
function that expects multiple parameters and not a structure.do_sample
,return_full_text
andwatermark
parameters asFalse
by default since they come fromhuggingface_hub
which accepts aNone
default parameters but TGI doesn't accept them_async_process_request
anyway and maybe this should be fixed in another PR. Same foradapter_id
for LoRA heads.ModelClient
's usage has been fixed to use theconfig: TGIModelConfig
by default instead of named parametersFixes for TGI JSON Grammar Generation
text_generation
to0.7.0
Environment
Command
Dependencies
model_config_path
argument for TGItgi.yaml
:Test Results
It works as can be seen from the logs.
TGI Logs with JSON Grammar Generation
Lighteval Logs
Note: I have anonymized parts of the logs