jaeyong2's picture
Update README.md
42403d0 verified
|
raw
history blame
1.42 kB
metadata
library_name: transformers
tags: []

reasoning example : input

from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "jaeyong2/Midm-2.0-Reason-SFT"

# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype="auto",
    device_map="auto"
)


prompt = "2의 제곱근은 뭐야?"

# message for inference
messages = [
    {"role": "system", 
     "content": "Mi:dm(믿:음)은 KT에서 개발한 AI 기반 어시스턴트이다."},
    {"role": "user", "content": prompt}
]

input_ids = tokenizer.apply_chat_template(
    messages,
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt"
)

output = model.generate(
    input_ids.to("cuda"),
    eos_token_id=tokenizer.eos_token_id,
    max_new_tokens=1024,
    do_sample=False,
)
print(tokenizer.decode(output[0]))

reasoing example result

<think>
2의 제곱근에 대해 설명드리겠습니다.

2의 제곱근은 2를 곱한 수를 의미합니다. 즉, 어떤 수 x가 2의 제곱근이라는 것은 x × x = 2를 만족하는 수 x를 말합니다.

수학적으로 표현하면 다음과 같습니다:
x² = 2
x = √2

따라서 2의 제곱근은 √2입니다.

참고로 √2는 무리수이며, 약분하면 1.4142...가 됩니다.
</think>

2의 제곱근은 √2입니다.