diff --git a/CHANGELOG.md b/CHANGELOG.md index a0eb9da889..ba3f748f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- feat: add Jinja2 loop controls to chat templates by @handshape in #2018 - fix: avoid cleanup errors for partially initialized `LlamaModel` objects by @usernames122 in #2173 - fix: suppress stdout and stderr in Jupyter notebooks by @Anai-Guo in #2181 - feat: enable arm64 musl builds by @acon96 in #2221 diff --git a/llama_cpp/llama_chat_format.py b/llama_cpp/llama_chat_format.py index f24b89f3ef..ed51b728cf 100644 --- a/llama_cpp/llama_chat_format.py +++ b/llama_cpp/llama_chat_format.py @@ -223,7 +223,12 @@ def __init__( loader=jinja2.BaseLoader(), trim_blocks=True, lstrip_blocks=True, - extensions=[Jinja2ChatFormatter.IgnoreGenerationTags], + # Keep this aligned with Transformers' chat-template Jinja extensions. + # https://github.com/huggingface/transformers/blob/39603d0e5cdb6f00e8d473d7fcbb01032d709181/src/transformers/utils/chat_template_utils.py#L489-L490 + extensions=[ + Jinja2ChatFormatter.IgnoreGenerationTags, + jinja2.ext.loopcontrols, + ], ).from_string(self.template) @staticmethod