-
Notifications
You must be signed in to change notification settings - Fork 270
<think> tags for thinking models #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
feature/enhancement
New feature/request
Comments
Nope, not at the moment! We used to have regex parsers but they were underused so we removed them. |
I had the same question and got something working. For now it's more of a hack, but hopefully this is a starting point to get it working generally. Here is my branch and demo notebook. Notes:
Here's the key section in prompt_manager: elif use_chat_template:
chat_preview = self.model.tokenizer.apply_chat_template(
output, tokenize=False, add_generation_prompt=True
)
tokenized = self.model.tokenizer(chat_preview, return_tensors="pt").to(self.model.device)
prepared_batch = Batch(
input_ids=tokenized["input_ids"],
input_mask=tokenized["attention_mask"],
input_lengths=[len(tokenized["input_ids"][0])],
truncated=[False],
padded=[False],
)
response = self.model._generate(
batch=prepared_batch,
max_new_tokens=2048,
stop_tokens=["</think>"],
)
all_start = chat_preview + response[0].result[0] + "</think>"
return all_start, num_effective_fewshots |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thinking models like DeepSeek-R1 emit thinking tags in the output. Is there a way to filter these out easily? Currently they make it directly into the output and so mess up metrics.
The text was updated successfully, but these errors were encountered: