Turkish Reasoning Model based on
DeepSeek-R1-0528-Qwen3-8B.
This model has undergone SFT (with
OpenTurkishDiverseReasoning dataset) and GRPO training stages for creating better Turkish reasoning traces.
For a detailed Turkish technical blog checkout
this link
1from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
2
3MODEL_ID = "barandinho/TDM-8b-v0.1"
4
5model = AutoModelForCausalLM.from_pretrained(
6 MODEL_ID,
7 torch_dtype="auto",
8 device_map="auto"
9)
10tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
11
12SYSTEM_PROMPT = """Sen TÜDÜM (TÜrkçe Düşünen Üretken Model) isimli yardımsever bir yapay zeka modelisin.
13Türkçe cevap ver ve cevabını tamamla."""
14
15messages = [
16 {"role": "system", "content": SYSTEM_PROMPT},
17 {"role": "user", "content": "lollapalooza kelimesinde kaç tane l harfi vardır?"}
18]
19
20streamer = TextStreamer(tokenizer, skip_prompt=True)
21
22text = tokenizer.apply_chat_template(
23 messages,
24 tokenize=False,
25 add_generation_prompt=True,
26 )
27
28model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
29
30# NOTE: If you are not using TextStreamer, you can decode created_ids with tokenizer and print out the result.
31# Keep in mind that it could take long to see the results without streamer.
32generated_ids = model.generate(
33 **model_inputs,
34 max_new_tokens=16384,
35 temperature=0.6,
36 top_p=0.95,
37 do_sample=True,
38 streamer=streamer
39 )
1<think>
2Kullanıcı "lollapalooza" kelimesinde kaç tane "l" harfi olduğunu soruyor. Önce kelimeyi yazıp harflerini saymalıyım.
3
4Kelime: l-o-l-l-a-p-a-l-o-o-z-a
5
6Şimdi her harfi kontrol edelim:
7- İlk harf: l → bir l
8- İkinci harf: o → değil
9- Üçüncü harf: l → ikinci l
10- Dördüncü harf: l → üçüncü l
11- Beşinci harf: a → değil
12- Altıncı harf: p → değil
13- Yedinci harf: a → değil
14- Sekizinci harf: l → dördüncü l
15- Dokuzuncu harf: o → değil
16- Onuncu harf: o → değil
17- On birinci harf: z → değil
18- On ikinci harf: a → değil
19
20Yani l harfleri: 1. pozisyonda, 3. pozisyonda, 4. pozisyonda, 8. pozisyonda.
21Toplam 4 tane.
22
23Daha kolay bir yöntem: kelimeyi yazıp l'leri işaretleyerek sayabilirim.
24l o l l a p a l o o z a
25İlk l, üçüncü l, dördüncü l, sekizinci l → 4 tane.
26
27Kelimeyi bilgisayarda saydıramam ama mantıken zaten 4. Şimdi cevap 4.
28Kullanıcıya cevap olarak 4 demeliyim.
29
30Düşünce sürecimde zaten hesapladım, şimdi özet kısmına geçeyim.
31Özet: "lollapalooza" kelimesinde 4 tane "l" harfi vardır.
32</think>
33
34"lollapalooza" kelimesinde toplam 4 tane "l" harfi bulunmaktadır.
You should strip out thinking parts for multi-turn conversation. A simple while loop that provides this is like below :
1import re
2from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
3
4MODEL_ID = "barandinho/TDM-8b-v0.1"
5
6model = AutoModelForCausalLM.from_pretrained(
7 MODEL_ID,
8 torch_dtype="auto",
9 device_map="auto"
10)
11tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
12
13SYSTEM_PROMPT = """Sen TÜDÜM (TÜrkçe Düşünen Üretken Model) isimli yardımsever bir yapay zeka modelisin.
14Türkçe cevap ver ve cevabını tamamla."""
15
16messages = [{"role": "system", "content": SYSTEM_PROMPT}]
17
18print("Çıkmak için 'q' yazınız.")
19print("-" * 40)
20
21while True:
22
23 user_input = input("\nSen: ").strip()
24
25 if user_input.lower() == 'q':
26 break
27
28 if not user_input:
29 continue
30
31 messages.append({"role": "user", "content": user_input})
32
33 # apply chat template and generate response.
34 text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
35 model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
36
37 print("TÜDÜM: ", end="", flush=True)
38 generated_ids = model.generate(
39 **model_inputs,
40 max_new_tokens=16384,
41 temperature=0.6,
42 top_p=0.95,
43 do_sample=True,
44 streamer=streamer
45 )
46
47 # get assistant response
48 input_length = model_inputs.input_ids.shape[1]
49 assistant_tokens = generated_ids[0][input_length:]
50 raw_response = tokenizer.decode(assistant_tokens, skip_special_tokens=True)
51
52 # critical : clean thinking parts for multi-turn conversation.
53 clean_response = re.sub(r'<think>.*?</think>', '', raw_response, flags=re.DOTALL).strip()
54 clean_response = re.sub(r'<|.*?|>', '', clean_response).strip()
55
56 messages.append({"role": "assistant", "content": clean_response})
You can use LM Studio (or any other local llm client) to run this model on your own computer locally via
GGUF version of this model