firqaaa commited on
Commit
8a7cf8b
1 Parent(s): 9b66ad8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +46 -0
README.md CHANGED
@@ -12,6 +12,52 @@ base_model: unsloth/gemma-2b-bnb-4bit
12
  pipeline_tag: text-generation
13
  ---
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Uploaded model
16
 
17
  - **Developed by:** firqaaa
 
12
  pipeline_tag: text-generation
13
  ---
14
 
15
+ # How to use
16
+
17
+ ```python
18
+ import warnings
19
+ warnings.filterwarnings("ignore")
20
+
21
+ alpaca_prompt = """Di bawah ini adalah instruksi yang menjelaskan tugas, dipasangkan dengan masukan yang memberikan konteks lebih lanjut. Tulis tanggapan yang melengkapi instruksi dengan tepat.
22
+
23
+ ### Instruksi:
24
+ {}
25
+
26
+ ### Masukan:
27
+ {}
28
+
29
+ ### Tanggapan:
30
+ {}"""
31
+
32
+ max_seq_length = 4096 # Choose any! We auto support RoPE Scaling internally!
33
+ dtype = None # None for auto detection. Float16 for Tesla T4, V100, Bfloat16 for Ampere+
34
+ load_in_4bit = True # Use 4bit quantization to reduce memory usage. Can be False.
35
+
36
+ if True:
37
+ from unsloth import FastLanguageModel
38
+ model, tokenizer = FastLanguageModel.from_pretrained(
39
+ model_name = "indo-gemma-2b-alpaca",
40
+ max_seq_length = max_seq_length,
41
+ dtype = dtype,
42
+ load_in_4bit = load_in_4bit
43
+ )
44
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
45
+
46
+ inputs = tokenizer(
47
+ [
48
+ alpaca_prompt.format(
49
+ "Sebutkan langkah-langkah membuat nasi goreng!",
50
+ "", # input
51
+ "", # output - leave this blank for generation!
52
+ )
53
+ ], return_tensors = "pt"
54
+ ).to("cuda")
55
+
56
+ from transformers import TextStreamer
57
+ text_streamer = TextStreamer(tokenizer)
58
+ _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 256)
59
+ ```
60
+
61
  # Uploaded model
62
 
63
  - **Developed by:** firqaaa