Skip to content

Commit e8ee64b

Browse files
handshapeabetlen
andauthored
feat: add Jinja2 loop controls to chat templates (abetlen#2018)
* Add support for jinja break for Cohere * docs: reference transformers chat template extensions --------- Co-authored-by: Andrei <abetlen@gmail.com>
1 parent fdf38b3 commit e8ee64b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- feat: add Jinja2 loop controls to chat templates by @handshape in #2018
1011
- fix: avoid cleanup errors for partially initialized `LlamaModel` objects by @usernames122 in #2173
1112
- fix: suppress stdout and stderr in Jupyter notebooks by @Anai-Guo in #2181
1213
- feat: enable arm64 musl builds by @acon96 in #2221

llama_cpp/llama_chat_format.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,12 @@ def __init__(
223223
loader=jinja2.BaseLoader(),
224224
trim_blocks=True,
225225
lstrip_blocks=True,
226-
extensions=[Jinja2ChatFormatter.IgnoreGenerationTags],
226+
# Keep this aligned with Transformers' chat-template Jinja extensions.
227+
# https://github.com/huggingface/transformers/blob/39603d0e5cdb6f00e8d473d7fcbb01032d709181/src/transformers/utils/chat_template_utils.py#L489-L490
228+
extensions=[
229+
Jinja2ChatFormatter.IgnoreGenerationTags,
230+
jinja2.ext.loopcontrols,
231+
],
227232
).from_string(self.template)
228233

229234
@staticmethod

0 commit comments

Comments
 (0)