Views
No views yet
| Developers | Baran Bingöl (Hugging Face: barandinho) |
| Base Model | microsoft/phi-4 |
| Architecture | 14B parameters, dense decoder-only Transformer |
| Training Data | 55K Turkish instruction samples |
| Context Length | 16K tokens |
| License | MIT (License Link) |
phi-4 is best suited for prompts using the chat format as follows:1<|im_start|>system<|im_sep|>
2Sen yardımsever bir yapay zekasın.<|im_end|>
3<|im_start|>user<|im_sep|>
4Kuantum hesaplama neden önemlidir?<|im_end|>
5<|im_start|>assistant<|im_sep|>transformers1import os
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, pipeline
3import torch
4
5model_name = "barandinho/phi4-turkish-instruct"
6
7quant_config = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_use_double_quant=True)
8
9os.makedirs("offload", exist_ok=True)
10
11tokenizer = AutoTokenizer.from_pretrained(model_name)
12model = AutoModelForCausalLM.from_pretrained(
13 model_name,
14 device_map="auto",
15 torch_dtype=torch.float16,
16 quantization_config=quant_config,
17 offload_folder="offload"
18)
19
20messages = [
21 {"role": "system", "content": "Sen yardımsever bir yapay zekasın."},
22 {"role": "user", "content": "Kuantum hesaplama neden önemlidir, basit terimlerle açıklayabilir misin?"},
23]
24
25pipe = pipeline(
26 "text-generation",
27 model=model,
28 tokenizer=tokenizer
29)
30
31generation_args = {
32 "max_new_tokens": 500,
33 "return_full_text": False,
34 "temperature": 0.0,
35 "do_sample": False,
36}
37
38output = pipe(messages, **generation_args)
39print(output[0]['generated_text'])