Skip to content

Commit 3bff178

Browse files
author
sd109
committed
Implement workaround for models with missing chat templates
1 parent 025be44 commit 3bff178

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

chart/templates/_helpers.tpl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,19 @@ Create the name of the service account to use
7676
{{- default "default" .Values.serviceAccount.name }}
7777
{{- end }}
7878
{{- end }}
79+
80+
{{/*
81+
Workaround for models which don't yet contain chat templates in their HuggingFace repos.
82+
If a chat template is provided in the Helm values then this is used, otherwise we omit the
83+
chat template for all models apart from a list of known cases where the upstream repo is
84+
not responsive to adding a chat template to their repo.
85+
*/}}
86+
{{- define "azimuth-llm.chatTemplate" -}}
87+
{{- if .Values.huggingface.chatTemplate }}
88+
- --chat-template
89+
- {{ quote .Values.huggingface.chatTemplate }}
90+
{{- else if contains "WizardCoder" .Values.huggingface.model }}
91+
- --chat-template
92+
- {{ quote "{% for message in messages %}{% if message['role'] == 'system' %}{% endif %}{% if message['role'] == 'user' %}{{ '### Instruction:\n' }}{% endif %}{% if message['role'] == 'assistant' %}{{ '### Response:\n' }}{% endif %}{{ message['content'].strip() }}{% if not loop.last %}{{ '\n\n' }}{% endif %}{% if message['role'] == 'user' and loop.last %}{{ '### Response:\n' }}{% endif %}{% endfor %}" }}
93+
{{- end -}}
94+
{{- end }}

chart/templates/api/deployment.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ spec:
2828
args:
2929
- --model
3030
- {{ .Values.huggingface.model }}
31-
{{- if .Values.huggingface.chatTemplate }}
32-
- --chat-template
33-
- {{ quote .Values.huggingface.chatTemplate }}
34-
{{- end -}}
31+
{{- include "azimuth-llm.chatTemplate" . | nindent 10 }}
3532
{{- if .Values.api.extraArgs -}}
3633
{{- .Values.api.extraArgs | toYaml | nindent 10 }}
3734
{{- end -}}

0 commit comments

Comments
 (0)