[GH-ISSUE #633] DeepSeek-R1-Distill-Qwen-7B的chat template在train中把<think></think>标签之间的文字删掉 #509

Closed
opened 2026-10-26 21:22:23 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @ethanelasky on GitHub (Apr 17, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/633

当我用huggingface的tokenizer来tokenize 包含reasoning的prompt的时候,我的reasoning总是被apply_chat_template删掉。

相关的Jinja code(在tokenizer_config.json里): {% if '' in content %}{% set content = content.split('')[-1] %}{% endif %}

apply_chat_template前,我的助理prompt长这样:
\nOkay, let's tackle the question: "Is the protein Papilin secreted?" \n\nFirst, I need to recall what Papilin is. From what I remember, Papilin is a type of proteoglycan. Proteoglycans are proteins that have glycosaminoglycan chains attached. They are often found in the extracellular matrix, which would suggest they are secreted because the extracellular matrix is outside the cell.\n\nNow, the question is whether Papilin is secreted. Since proteoglycans are typically components of the extracellular matrix, they must be secreted by cells to get there. The extracellular matrix is produced by cells secreting various proteins and other molecules, so if Papilin is part of that, it's likely secreted.\n\nI should check if there's any specific information about Papilin's secretion. But given that the documents provided are empty, I can't reference them. Based on my existing knowledge, Papilin's role in the extracellular matrix as a proteoglycan implies that it is indeed a secreted protein. There's no conflicting information here, so the answer should be yes.\n\n\nOkay, let's tackle the question: "Is the protein Papilin secreted?" \n\nFirst, I need to recall what Papilin is. From what I remember, Papilin is a type of proteoglycan. Proteoglycans are proteins that have glycosaminoglycan chains attached. They are often found in the extracellular matrix, which would suggest they are secreted because the extracellular matrix is outside the cell.\n\nNow, the question is whether Papilin is secreted. Since proteoglycans are typically components of the extracellular matrix, they must be secreted by cells to get there. The extracellular matrix is produced by cells secreting various proteins and other molecules, so if Papilin is part of that, it's likely secreted.\n\nI should check if there's any specific information about Papilin's secretion. But given that the documents provided are empty, I can't reference them. Based on my existing knowledge, Papilin's role in the extracellular matrix as a proteoglycan implies that it is indeed a secreted protein. There's no conflicting information here, so the answer should be yes.\n\n

apply_chat_template后(这里是全prompt):
<|begin▁of▁sentence|><|User|>\nGiven a question and relevant documents, provide a concise, exact answer.\nFirst, read the documents carefully, then extract or synthesize a precise answer.\nIf the provided documents are not helpful, you must answer based on your own knowledge.\nThe answer should be as brief as possible while being complete and accurate.\n\nQuestion: Is the protein Papilin secreted?\n\nDocuments:\nSAMPLE_FORMATTED_CONTEXTS\n<|Assistant|>\n\boxed{yes}<|end▁of▁sentence|>

Originally created by @ethanelasky on GitHub (Apr 17, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/633 当我用huggingface的tokenizer来tokenize 包含reasoning的prompt的时候,我的reasoning总是被apply_chat_template删掉。 相关的Jinja code(在tokenizer_config.json里): {% if '</think>' in content %}{% set content = content.split('</think>')[-1] %}{% endif %} apply_chat_template前,我的助理prompt长这样: <think>\nOkay, let\'s tackle the question: "Is the protein Papilin secreted?" \n\nFirst, I need to recall what Papilin is. From what I remember, Papilin is a type of proteoglycan. Proteoglycans are proteins that have glycosaminoglycan chains attached. They are often found in the extracellular matrix, which would suggest they are secreted because the extracellular matrix is outside the cell.\n\nNow, the question is whether Papilin is secreted. Since proteoglycans are typically components of the extracellular matrix, they must be secreted by cells to get there. The extracellular matrix is produced by cells secreting various proteins and other molecules, so if Papilin is part of that, it\'s likely secreted.\n\nI should check if there\'s any specific information about Papilin\'s secretion. But given that the documents provided are empty, I can\'t reference them. Based on my existing knowledge, Papilin\'s role in the extracellular matrix as a proteoglycan implies that it is indeed a secreted protein. There\'s no conflicting information here, so the answer should be yes.\n</think>\n<think>\nOkay, let\'s tackle the question: "Is the protein Papilin secreted?" \n\nFirst, I need to recall what Papilin is. From what I remember, Papilin is a type of proteoglycan. Proteoglycans are proteins that have glycosaminoglycan chains attached. They are often found in the extracellular matrix, which would suggest they are secreted because the extracellular matrix is outside the cell.\n\nNow, the question is whether Papilin is secreted. Since proteoglycans are typically components of the extracellular matrix, they must be secreted by cells to get there. The extracellular matrix is produced by cells secreting various proteins and other molecules, so if Papilin is part of that, it\'s likely secreted.\n\nI should check if there\'s any specific information about Papilin\'s secretion. But given that the documents provided are empty, I can\'t reference them. Based on my existing knowledge, Papilin\'s role in the extracellular matrix as a proteoglycan implies that it is indeed a secreted protein. There\'s no conflicting information here, so the answer should be yes.\n</think>\n apply_chat_template后(这里是全prompt): <|begin▁of▁sentence|><|User|>\nGiven a question and relevant documents, provide a concise, exact answer.\nFirst, read the documents carefully, then extract or synthesize a precise answer.\nIf the provided documents are not helpful, you must answer based on your own knowledge.\nThe answer should be as brief as possible while being complete and accurate.\n\nQuestion: Is the protein Papilin secreted?\n\nDocuments:\nSAMPLE_FORMATTED_CONTEXTS\n<|Assistant|>\n\\boxed{yes}<|end▁of▁sentence|>
bsakaguchi 2026-10-26 21:22:23 +00:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 4, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!

<!-- gh-comment-id:2937805280 --> @github-actions[bot] commented on GitHub (Jun 4, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
Author
Owner

@github-actions[bot] commented on GitHub (Jun 21, 2025):

false

<!-- gh-comment-id:2993177520 --> @github-actions[bot] commented on GitHub (Jun 21, 2025): false
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-R1#509
No description provided.