-
Notifications
You must be signed in to change notification settings - Fork 359
Fix TGI
(Text Generation Inference) Endpoint Inference and TGI JSON Grammar Generation
#502
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
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
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! |
+1 is this going to be merged @NathanHB ? Would really like to use lighteval with locally hosted TGI, but I'm seeing the same |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
hey ! Thanks for the PR it seems good to merge, just need to fix the tests |
add: dep in extra
@NathanHB Apologies for the delay, I missed you approval comment! I've fixed the unit tests in two files that simply needed the new I've also noticed that the I've tried both without and with
|
Hello @NathanHB , just checking if there's any news on this PR? Lmk if I need to provide any support |
hey ! Sorry for the late review. I just retook a look and there's been a refacto of the codebase, this does not seems to affect your code that much but you would need to rename the |
Hey, no worries @NathanHB ! I've adapted the code to use |
thanks ! Last thing, can you provide a config in which you use the grammar arg ? I will test locally to make sure everything is fine on this side |
…he usage of constrained grammar generation using TGI
@NathanHB I have actually noticed that my Also, all tests pass. Furthermore, I have also created an example usage of a custom task that uses a publicly available dataset ( How to run the exampleHere's how to run it from the root of the
Logs from the example runTGI LogsWhile running the
|
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.
Hey ! Thanks for the detailed message, I rechecked and still would change / remove a few things, otherwise much clearer PR :)
examples/custom_tasks_templates/custom_task_classification_grammar_task.py
Outdated
Show resolved
Hide resolved
examples/custom_tasks_templates/custom_task_classification_grammar_task.py
Outdated
Show resolved
Hide resolved
examples/custom_tasks_templates/custom_task_classification_grammar_task.py
Show resolved
Hide resolved
Thank you for the reviews @NathanHB , I've applied everything! I've also improved a unit test for TGI caching by mocking the HTTP request for the |
… Grammar Generation (#502) * fix: Lighteval communication with TGI * fix: JSON grammar constrained generation * fix: unit tests + add: dep in extra * fix: request var => doc var after refactor * fix: update test to support the new grammar field * fix: TGI endpoint with the new refactor * update: TGI model config in examples with the latest parameters * add: example custom task on a classification dataset to demonstrate the usage of constrained grammar generation using TGI * add: format example task * fix: unit test * add: adapt the in the yaml config to use similarly to the other endpoints * clean: moved new task to community_tasks * fix: format * clean: delete unused grammar field * del: grammar * add: copyright at the top * del: langcodes dep isn't needed anymore * add: use load from file directly in the main endpoint * del: newlines * add: mock HTTP request for info to TGI server --------- Co-authored-by: Nathan Habib <30601243+NathanHB@users.noreply.github.com>
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