gnumanth commited on
Commit
174a6cc
1 Parent(s): aa1372d

chore: more details

Browse files
Files changed (1) hide show
  1. README.md +70 -0
README.md CHANGED
@@ -13,3 +13,73 @@ base_model: unsloth/gemma-7b-bnb-4bit
13
 
14
  # gemma-alpacha
15
  > yahma/alpaca-cleaned finetuned with gemma-7b-bnb-4bit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # gemma-alpacha
15
  > yahma/alpaca-cleaned finetuned with gemma-7b-bnb-4bit
16
+
17
+ # Usage
18
+
19
+ ```sh
20
+ pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
21
+ ```
22
+
23
+
24
+ ```py
25
+ from unsloth import FastLanguageModel
26
+ import torch
27
+
28
+ model, tokenizer = FastLanguageModel.from_pretrained(
29
+ model_name = "gnumanth/gemma-unsloth-alpaca",
30
+ max_seq_length = 2048,
31
+ dtype = None,
32
+ load_in_4bit = True,
33
+ )
34
+ ```
35
+
36
+
37
+ ```py
38
+ alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
39
+
40
+ ### Instruction:
41
+ {}
42
+
43
+ ### Input:
44
+ {}
45
+
46
+ ### Response:
47
+ {}"""
48
+ ```
49
+
50
+ ```py
51
+ FastLanguageModel.for_inference(model) # Enable native 2x faster inference
52
+ inputs = tokenizer(
53
+ [
54
+ alpaca_prompt.format(
55
+ "Give me a python code for quicksort", # instruction
56
+ "1,-1,0,8,9,-2,2", # input
57
+ "", # output - leave this blank for generation!
58
+ )
59
+ ], return_tensors = "pt").to("cuda")
60
+
61
+ from transformers import TextStreamer
62
+ text_streamer = TextStreamer(tokenizer)
63
+ _ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)
64
+ ```
65
+
66
+ ```sh
67
+ <bos>Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
68
+
69
+ ### Instruction:
70
+ Give me a python code for quicksort
71
+
72
+ ### Input:
73
+ 1,-1,0,8,9,-2,2
74
+
75
+ ### Response:
76
+ def quicksort(arr):
77
+ if len(arr) <= 1:
78
+ return arr
79
+ pivot = arr[0]
80
+ left = [i for i in arr[1:] if i < pivot]
81
+ right = [i for i in arr[1:] if i >= pivot]
82
+ return quicksort(left) + [pivot] + quicksort(right)<eos>
83
+ ```
84
+
85
+ [Hemanth HMM](https://h3amnth.com) | (Built with [unsloth](https://unsloth.ai))