-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
HuggingFacePipeline does not use chat template #19933
Comments
Let me see |
any workaround available? |
A workaround is using
Note that until a release of |
Hello, do you have any examples of code that uses both |
I am facing the same problem with quantized variants of Meta Llama 3 8B-Instruct |
Can you please specify? |
I believe I fixed the issue! I detailed pull request will be submitted tomorrow! Everything should work through ChatHuggingFace in my fork |
Checked other resources
Example Code
Hugging Face pipeline now has support for chat templates. This calls the
apply_chat_template()
of the tokenizer. This is a super useful feature which formats the input correctly according to the model. To apply the template one needs to pass a messages list to the pipeline as input (and not a prompt text).Langchain's
HuggingFacePipeline
class is written in a way that only prompt text is passed to the pipeline. We can see this in theHuggingFacePipeline._generate
method. As a result the prompt is constructed using Langchain's default template which is not the same as what the model works best with.Let's build an example.
This sends the following prompt.
The correct prompt, if chat template was applied, would be:
Error Message and Stack Trace (if applicable)
No response
Description
The
HuggingFacePipeline
class should what is necessary to convert theChatPromptTemplate
to a messages list and then pass it to the pipeline. This will cause the pipeline to useapply_chat_template()
of the tokenizer to correctly format the prompt.System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found:
The text was updated successfully, but these errors were encountered: