DeepSeek sharp chat template v0.1 (draft)
Browse files- chat_template.jinja +40 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{# ============================================================================
|
| 2 |
+
DeepSeek Sharp Chat Template -- DRAFT v0.1
|
| 3 |
+
DeepSeek-V2/V3 native header format + a terseness system prompt appended.
|
| 4 |
+
This is a STRUCTURE SKELETON: header framing + terseness splice + generation
|
| 5 |
+
prompt. Tool-call rendering, reasoning extraction, and KV-cache-safe history
|
| 6 |
+
are the remaining pieces before a stable release (see PROCESS.md).
|
| 7 |
+
#}
|
| 8 |
+
{%- set template_version = "deepseek-sharp-v0.1-draft" %}
|
| 9 |
+
{%- set _terse_on = terse if terse is defined else true %}
|
| 10 |
+
{%- set _terse_core %}
|
| 11 |
+
Never: open with preamble or pleasantries; restate the question; add filler transitions; hedge with niceties; or repeat a point you've already made.
|
| 12 |
+
Always: keep essential steps, caveats, uncertainties, and specifics — never drop correctness or a needed warning for brevity. Keep the final answer lean. Use the least structure that conveys it (plain prose when short; lists or code only when they earn their place). If genuinely uncertain, say so and explain why — never omit uncertainty for the sake of brevity.
|
| 13 |
+
If a user request is genuinely ambiguous, ask a sharp question, don't guess.
|
| 14 |
+
{%- endset %}
|
| 15 |
+
{#- Collect and merge leading system/developer messages into one turn. #}
|
| 16 |
+
{%- set _sys = '' %}
|
| 17 |
+
{%- for msg in messages if msg.role in ('system','developer') %}
|
| 18 |
+
{%- set _part = msg.content if msg.content is string else (msg.content[0].text if msg.content and msg.content[0] and msg.content[0].text is defined else '') %}
|
| 19 |
+
{%- set _sys = (_sys | trim) ~ (('\n\n' if _sys | trim else '')) ~ (_part | trim) %}
|
| 20 |
+
{%- endfor %}
|
| 21 |
+
{%- if _terse_on %}
|
| 22 |
+
{%- set _sys = (_sys | trim) ~ (('\n\n' if _sys | trim else '')) ~ '[TERSENESS]' ~ '\n' ~ (_terse_core | trim) %}
|
| 23 |
+
{%- endif %}
|
| 24 |
+
{%- if _sys | trim %}
|
| 25 |
+
<|start_header_id|>system<|end_header_id|>
|
| 26 |
+
|
| 27 |
+
{{ _sys | trim }}
|
| 28 |
+
<|eot_id|>
|
| 29 |
+
{%- endif %}
|
| 30 |
+
{#- Non-system messages: DeepSeek header framing. Tool + reasoning rendering TBD. #}
|
| 31 |
+
{%- for msg in messages if msg.role not in ('system','developer') %}
|
| 32 |
+
<|start_header_id|>{{ msg.role }}<|end_header_id|>
|
| 33 |
+
|
| 34 |
+
{{ msg.content if msg.content is string else (msg.content[0].text if msg.content and msg.content[0] and msg.content[0].text is defined else '') }}
|
| 35 |
+
<|eot_id|>
|
| 36 |
+
{%- endfor %}
|
| 37 |
+
{%- if add_generation_prompt %}
|
| 38 |
+
<|start_header_id|>assistant<|end_header_id|>
|
| 39 |
+
|
| 40 |
+
{%- endif %}
|