memocandelioglu commited on
Commit
c5bec45
·
verified ·
1 Parent(s): 804ec44

Create kumrucli.py

Browse files
Files changed (1) hide show
  1. kumrucli.py +33 -0
kumrucli.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BU CLIENT UYGULAMASI, MEMOCAN DELİOĞLUNA AİTTİR.
2
+ # KUMRU AI İÇİN YAZILMIŞTIR.
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer
4
+
5
+ print("Kumru AI - 2025 By VNGRS Team")
6
+ print("Client Uygulamasını yazan: Memocan Delioğlu")
7
+ model_name = "vngrs-ai/Kumru-2B"
8
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
9
+ model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
10
+
11
+ def generate_response(query):
12
+ messages = [
13
+ {'role': 'system', 'content': 'Adın Kumru. VNGRS tarafından Türkçe için sıfırdan eğitilmiş bir dil modelisin.'},
14
+ {'role': 'system', 'content': 'Kumru, şu anda seninle bir Linux terminalinden konuşuluyor. Terminal camiasına selamını ilet, biraz samimi ol :)'},
15
+ {'role': 'user', 'content': query}
16
+ ]
17
+ model_inputs = tokenizer.apply_chat_template(messages, return_tensors='pt', add_generation_prompt=True).to(model.device)
18
+ model_outputs = model.generate(model_inputs, max_new_tokens=512, do_sample=True, top_p=0.9, temperature=0.7, repetition_penalty=1.1)
19
+ output_tokens = model_outputs[0].cpu().detach().numpy().tolist()
20
+ generated_tokens = output_tokens[model_inputs[0].shape[0]:]
21
+ response = tokenizer.decode(generated_tokens, skip_special_tokens=True)
22
+ return response
23
+
24
+ print("Kumru AI başlatılıyor... Linux terminaline bağlandı.")
25
+
26
+ initial_query = "Merhaba Kumru, seni şu an Linux üzerinden kullanıyorum."
27
+ initial_response = generate_response(initial_query)
28
+ print("Kumru:", initial_response)
29
+
30
+ while True:
31
+ query = input("Soru sorun >>>")
32
+ response = generate_response(query)
33
+ print(response)