File size: 1,779 Bytes
5567b0e
 
 
 
 
 
 
 
 
 
 
 
 
aa1372d
 
174a6cc
 
 
 
 
 
 
 
 
 
2dfaf8c
174a6cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
language:
- en
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- gemma
- trl
base_model: unsloth/gemma-7b-bnb-4bit
---

# gemma-alpacha
> yahma/alpaca-cleaned finetuned with gemma-7b-bnb-4bit

# Usage

```sh
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
```


```py
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained("gnumanth/gemma-unsloth-alpaca")
```


```py
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.

### Instruction:
{}

### Input:
{}

### Response:
{}"""
```

```py
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
inputs = tokenizer(
[
    alpaca_prompt.format(
        "Give me a python code for quicksort", # instruction
        "1,-1,0,8,9,-2,2", # input
        "", # output - leave this blank for generation!
    )
], return_tensors = "pt").to("cuda")

from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer = text_streamer, max_new_tokens = 128)
```

```sh
<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.

### Instruction:
Give me a python code for quicksort

### Input:
1,-1,0,8,9,-2,2

### Response:
def quicksort(arr):
    if len(arr) <= 1:
        return arr
    pivot = arr[0]
    left = [i for i in arr[1:] if i < pivot]
    right = [i for i in arr[1:] if i >= pivot]
    return quicksort(left) + [pivot] + quicksort(right)<eos>
```

[Hemanth HMM](https://h3amnth.com) | (Built with [unsloth](https://unsloth.ai))