A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 17, 04:15 UTC
Add chat templates for ChatGLM (#3418)
Dinghow Yang committed
Mar 15, 2024 at 14:19 UTC
253a98078a21a014c263bea9f99ae9234a263670
2 files changed
+36
examples/template_chatglm.jinja
new
+18
@@ -0,0 +1,18 @@
1
+{%- set counter = namespace(index=0) -%}
2
+{%- for message in messages -%}
3
+ {%- if message['role'] == 'user' -%}
4
+ {{- '[Round ' + counter.index|string + ']\n问:' + message['content'] -}}
5
+ {%- set counter.index = counter.index + 1 -%}
6
+ {%- endif -%}
7
+ {%- if message['role'] == 'assistant' -%}
8
+ {{- '\n答:' + message['content'] -}}
9
+ {%- if (loop.last and add_generation_prompt) or not loop.last -%}
10
+ {{- '\n' -}}
11
+ {%- endif -%}
12
+ {%- endif -%}
13
+{%- endfor -%}
14
+
15
+
16
+{%- if add_generation_prompt and messages[-1]['role'] != 'assistant' -%}
17
+ {{- '\n答:' -}}
18
+{%- endif -%}
\ No newline at end of file
examples/template_chatglm2.jinja
new
+18
@@ -0,0 +1,18 @@
1
+{%- set counter = namespace(index=1) -%}
2
+{%- for message in messages -%}
3
+ {%- if message['role'] == 'user' -%}
4
+ {{- '[Round ' + counter.index|string + ']\n\n问:' + message['content'] -}}
5
+ {%- set counter.index = counter.index + 1 -%}
6
+ {%- endif -%}
7
+ {%- if message['role'] == 'assistant' -%}
8
+ {{- '\n\n答:' + message['content'] -}}
9
+ {%- if (loop.last and add_generation_prompt) or not loop.last -%}
10
+ {{- '\n\n' -}}
11
+ {%- endif -%}
12
+ {%- endif -%}
13
+{%- endfor -%}
14
+
15
+
16
+{%- if add_generation_prompt and messages[-1]['role'] != 'assistant' -%}
17
+ {{- '\n\n答:' -}}
18
+{%- endif -%}
\ No newline at end of file