Skip to content

Commit 8ae14c2

Browse files
committed
olmo thinker template final
1 parent bac9393 commit 8ae14c2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

open_instruct/dataset_transformation.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,46 @@ def visualize_token_role(tokens: list[int], masks: list[int], tokenizer: PreTrai
398398
"{% endif %}"
399399
"{% endfor %}"
400400
),
401+
"olmo_thinker_no_think": (
402+
"{% set has_system = messages|selectattr('role', 'equalto', 'system')|list|length > 0 %}"
403+
"{% if not has_system %}"
404+
"{{ '<|im_start|>system\nYou are Olmo, a helpful AI assistant built by Ai2. Your date cutoff is December 2024, and your model weights are available at https://huggingface.co/allenai.<|im_end|>\n' }}"
405+
"{% endif %}"
406+
"{% for message in messages %}"
407+
"{% if message['role'] == 'system' %}"
408+
"{{ '<|im_start|>system\n' + message['content'] }}"
409+
"{% if message.get('functions', none) is not none %}"
410+
"{{ ' <functions>' + message['functions'] + '</functions><|im_end|>\n' }}"
411+
"{% else %}"
412+
"{{ ' You do not currently have access to any functions. <functions></functions><|im_end|>\n' }}"
413+
"{% endif %}"
414+
"{% elif message['role'] == 'user' %}"
415+
"{% if message.get('functions', none) is not none %}"
416+
"{{ '<|im_start|>user\n' + message['content'] + '\n' + '<functions>' + message['functions'] + '</functions><|im_end|>\n' }}"
417+
"{% else %}"
418+
"{{ '<|im_start|>user\n' + message['content'] + '<|im_end|>\n' }}"
419+
"{% endif %}"
420+
"{% elif message['role'] == 'assistant' %}"
421+
"{{ '<|im_start|>assistant\n' }}"
422+
"{% if message.get('content', none) is not none %}"
423+
"{{ message['content'] }}"
424+
"{% endif %}"
425+
"{% if message.get('function_calls', none) is not none %}"
426+
"{{ '<function_calls>' + message['function_calls'] + '</function_calls>' }}"
427+
"{% endif %}"
428+
"{% if not loop.last %}"
429+
"{{ '<|im_end|>' + '\n' }}"
430+
"{% else %}"
431+
"{{ eos_token }}"
432+
"{% endif %}"
433+
"{% elif message['role'] == 'environment' %}"
434+
"{{ '<|im_start|>environment\n' + message['content'] + '<|im_end|>\n' }}"
435+
"{% endif %}"
436+
"{% if loop.last and add_generation_prompt %}"
437+
"{{ '<|im_start|>assistant\n' }}"
438+
"{% endif %}"
439+
"{% endfor %}"
440+
),
401441
"olmo_thinker_r1_style": (
402442
"A conversation between user and assistant. "
403443
"The user asks a question, and the assistant solves it. "

0 commit comments

Comments
 (0)