atasoglu commited on
Commit
bada9fb
·
verified ·
1 Parent(s): 164d17f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -20,3 +20,49 @@ tags:
20
  This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  This gemma2 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
+
24
+ # Usage
25
+
26
+ ```py
27
+ from unsloth import FastLanguageModel
28
+ import torch
29
+ max_seq_length = 2048 # Choose any! We auto support RoPE Scaling internally!
30
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
31
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
32
+
33
+ model, tokenizer = FastLanguageModel.from_pretrained(
34
+ model_name = "atasoglu/gemma-2-2b-tr",
35
+ max_seq_length = max_seq_length,
36
+ dtype = dtype,
37
+ load_in_4bit = load_in_4bit,
38
+ )
39
+
40
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
41
+
42
+ alpaca_prompt = """Aşağıda verilen talimat ve giriş ifadelerine uygun bir cevap yaz.
43
+
44
+ ### Talimat:
45
+ Aşağıdaki programlama dillerinden hangisi yapay zeka çalışmak için daha uygundur?
46
+ Sebebini açıkla.
47
+
48
+ ### Giriş:
49
+ Python, C++, Java, Rust
50
+
51
+ ### Cevap:
52
+ """
53
+ inputs = tokenizer(alpaca_prompt, return_tensors="pt").to("cuda")
54
+ outputs = model.generate(
55
+ **inputs,
56
+ max_new_tokens=128,
57
+ do_sample=True,
58
+ temperature=0.2,
59
+ repetition_penalty=1.15,
60
+ top_k=20,
61
+ top_p=0.7,
62
+ )
63
+
64
+ generated_tokens = outputs[:, inputs.input_ids.shape[1]:]
65
+ response = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
66
+ print(response)
67
+ # Output: ['C++ veya Python en iyi seçenektir çünkü bu iki dilde çok sayıda yapay zeka araçları vardır. Bu araçlar, veri analizi, öğrenme algoritmaları ve karar verme süreçlerini kolaylaştırır. Ayrıca, her ikisinin de güçlü bir kütüphanesi olması da önemlidir.']
68
+ ```