Views
No views yet

!pip install -U accelerate bitsandbytes1import torch
2from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
3from transformers import BitsAndBytesConfig
4import time
5
6model_name = "ytu-ce-cosmos/Turkish-Llama-8b-v0.1"
7
8bnb_config = BitsAndBytesConfig(
9 load_in_8bit=True,
10 bnb_8bit_compute_dtype=torch.bfloat16,
11 load_in_8bit_fp32_cpu_offload=True,
12 device_map = 'auto'
13)
14
15tokenizer = AutoTokenizer.from_pretrained(model_name)
16model = AutoModelForCausalLM.from_pretrained(
17 model_name,
18 device_map="auto",
19 torch_dtype=torch.bfloat16,
20 quantization_config=bnb_config,
21)1text_generator = pipeline(
2 "text-generation",
3 model=model,
4 tokenizer=tokenizer,
5 device_map="auto",
6 temperature=0.3,
7 repetition_penalty=1.1,
8 top_p=0.9,
9 max_length=610,
10 do_sample=True,
11 return_full_text=False,
12 min_new_tokens=32
13)1text = """Yapay zeka hakkında 3 tespit yaz.\n"""
2
3r = text_generator(text)
4
5print(r[0]['generated_text'])
6
7"""
81. Yapay Zeka (AI), makinelerin insan benzeri bilişsel işlevleri gerçekleştirmesini sağlayan bir teknoloji alanıdır.
9
102. Yapay zekanın geliştirilmesi ve uygulanması, sağlık hizmetlerinden eğlenceye kadar çeşitli sektörlerde çok sayıda fırsat sunmaktadır.
11
123. Yapay zeka teknolojisinin potansiyel faydaları önemli olsa da mahremiyet, işten çıkarma ve etik hususlar gibi konularla ilgili endişeler de var.
13"""1@inproceedings{kesgin2024optimizing,
2 title={Optimizing Large Language Models for Turkish: New Methodologies in Corpus Selection and Training},
3 author={Kesgin, H Toprak and Yuce, M Kaan and Dogan, Eren and Uzun, M Egemen and Uz, Atahan and {\.I}nce, Elif and Erdem, Yusuf and Shbib, Osama and Zeer, Ahmed and Amasyali, M Fatih},
4 booktitle={2024 Innovations in Intelligent Systems and Applications Conference (ASYU)},
5 pages={1--6},
6 year={2024},
7 organization={IEEE}
8}