<thought> was not being invoked when typing Korean.
English input works, but when I input a query sentence in Korean, the response was missing the sentence. Does the Exaone-Deep model only support English?
Hello, @JDNOH ! Thank you for asking.
By default, EXAONE-Deep uses a generation prompt [|assistant|]<thought>\n
to ensure reasoning steps in the generation process.
To help us better understand the issue, could you share the input and the output (if too long, just part of it) from your test case?
!!!!!!!!!!!!!!!!!!!!! INPUT !!!!!!!!!!!!!!!!!!!!!
import time
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
from threading import Thread
model_name = "/downloads/EXAONE-Deep-7.8B"
streaming = True # choose the streaming option
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
messages = [
{"role": "user", "content": "νκ΅ λ²μ€μλ 골νκ³΅μ΄ λͺ κ°λ λ€μ΄κ° μ μλμ?"}
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
)
start_time = time.time()
if streaming:
streamer = TextIteratorStreamer(tokenizer)
thread = Thread(target=model.generate, kwargs=dict(
input_ids=input_ids.to("cuda"),
eos_token_id=tokenizer.eos_token_id,
max_new_tokens=32768,
do_sample=True,
temperature=0.6,
top_p=0.95,
streamer=streamer
))
thread.start()
for text in streamer:
print(text, end="", flush=True)
!!!!!!!!!!!!!!!!!!!!! OUTPUT !!!!!!!!!!!!!!!!!!!!!
[|system|][|endofturn|]
[|user|]νκ΅ λ²μ€μλ 골νκ³΅μ΄ λͺ κ°λ λ€μ΄κ° μ μλμ?
[|assistant|]<thought>
</thought>
νκ΅ λ²μ€μ 골νκ³΅μ΄ λͺ κ°λ λ€μ΄κ° μ μλμ§μ λν μ νν μ«μλ λ²μ€μ ν¬κΈ°μ ννμ λ°λΌ λ€λ₯΄κΈ° λλ¬Έμ λ¨μ μ μΌλ‘ λ§μλ리기 μ΄λ ΅μ΅λλ€. μΌλ°μ μΌλ‘ λ²μ€μ λ΄λΆ 곡κ°μ κ³μ°ν λλ μΉκ°μ© μ’μ 곡κ°κ³Ό μ§μ μ£λ 곡κ°μ κ³ λ €ν΄μΌ ν©λλ€. 골ν곡μ λΉκ΅μ ν° λ¬Όκ±΄μ΄κΈ° λλ¬Έμ, λ²μ€μ μ§μΉΈμ΄λ νΉμ 곡κ°μ λ°λΌ μ΅λ 10~20κ° μ λκ° λ€μ΄κ° μ μμ κ²μΌλ‘ μΆμ λ©λλ€. νμ§λ§ μ΄λ λ²μ€μ ν¬κΈ°μ 골ν곡μ ν¬κΈ°μ λ°λΌ λ¬λΌμ§ μ μμΌλ, ꡬ체μ μΈ λ²μ€ λͺ¨λΈμ΄λ 골ν곡μ ν¬κΈ°λ₯Ό μκ³ μλ€λ©΄ λ μ νν μμΉλ₯Ό μ»μ μ μμ κ²μ
λλ€.[|endofturn|]
Thank you for sharing the example.
I noticed that the tokenizer does not generate <thought>
after [|assistant|]
. This might be related to the chat template configuration in your tokenizer_config.json
file (located at the bottom of the content).
Here's the valid chat template for EXAONE-Deep models:
{% for message in messages %}{% if loop.first and message['role'] != 'system' %}{{ '[|system|][|endofturn|]\\n' }}{% endif %}{% set content = message['content'] %}{% if '</thought>' in content %}{% set content = content.split('</thought>')[-1].lstrip('\\n') %}{% endif %}{{ '[|' + message['role'] + '|]' + content }}{% if not message['role'] == 'user' %}{{ '[|endofturn|]' }}{% endif %}{% if not loop.last %}{{ '\\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '\\n[|assistant|]<thought>\\n' }}{% endif %}
As you can see at the end of the template, the generation prompt \n[|assistant|]<thought>\n
is included to ensure proper reasoning steps.
I haven't noticed that you edit the output for missing <thought>
.
I'll review your example and get back to you once we have more information.
Thank you for waiting, @JDNOH .
As described in Usage Guidelines, when evaluating CSAT Math 2025, a question was followed by the instruction, "Please reason step by step, and put your final answer within \boxed{}." in prompt. We observed that the EXAONE Deep model demonstrated the expected performance. Thus, we recommend adding the instruction to your prompt. However, the optimal prompt may vary depending on the question type.
We would be happy if you found a better prompt for your use cases and shared it with the community.