Skip to content

Commit 2e8aaa4

Browse files
authored
[allowing system role for deep seek renderer] (#139)
1 parent 7728f5a commit 2e8aaa4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tinker_cookbook/renderers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,16 @@ class DeepSeekV3Renderer(Renderer):
627627
Format like this (no newlines between messages):
628628
<|begin_of_sentence|><|User|>What can you help me with?<|Assistant|><think>Thinking...</think>I can help you with...<|end_of_centence|>
629629
For no-think, just use <|Assistant|></think>
630+
Deepseek renderer does not support the system role out of the box. You can set system_role_as_user to True to automatically convert the system role to the user role.
630631
"""
631632

633+
def __init__(self, tokenizer: Tokenizer, system_role_as_user: bool = False):
634+
super().__init__(tokenizer)
635+
self.system_role_as_user = system_role_as_user
636+
632637
def _render_message(self, message: Message) -> tuple[list[int], list[int], list[int]]:
633638
assert message.get("thinking") is None, "TODO: support CoT in DsV3 renderer"
634-
if message["role"] == "user":
639+
if message["role"] == "user" or (self.system_role_as_user and message["role"] == "system"):
635640
role_token = self._get_special_token("User")
636641
elif message["role"] == "assistant":
637642
role_token = self._get_special_token("Assistant")

0 commit comments

Comments
 (0)