Views
No views yet
1from unsloth import FastLanguageModel
2from unsloth.chat_templates import get_chat_template
3
4# Load model
5model, tokenizer = FastLanguageModel.from_pretrained(
6 "uisikdag/qwen3-14b-turkish-alpaca",
7 max_seq_length=2048,
8 load_in_4bit=True,
9)
10tokenizer = get_chat_template(tokenizer, chat_template="qwen2.5")
11FastLanguageModel.for_inference(model)
12
13# Generate response
14instruction = "Python'da bir sayının asal olup olmadığını kontrol eden bir fonksiyon yaz."
15messages = [{"role": "user", "content": instruction}]
16
17inputs = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
18outputs = model.generate(input_ids=inputs, max_new_tokens=256, temperature=0.7, top_p=0.9, do_sample=True)
19response = tokenizer.decode(outputs[0], skip_special_tokens=True).split("assistant")[-1].strip()
20print(response)1@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}