<thought> was not being invoked when typing Korean.

#1
by JDNOH - opened

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?

LG AI Research org

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|]
LG AI Research org

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.

LG AI Research org

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.

LG AI Research org
This comment has been hidden (marked as Off-Topic)
LG AI Research org

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.

Sign up or log in to comment