File size: 4,065 Bytes
635af30
 
 
 
 
 
 
03bb408
635af30
ffac3f2
 
 
 
635af30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
license: cc
datasets:
- jondurbin/truthy-dpo-v0.1
---
# WestLake-7B-laser-truthy-dpo-GGUF

![image/webp](https://cdn-uploads.huggingface.co/production/uploads/6455cc8d679315e4ef16fbec/WESciclQuPty1JR8wz8jS.webp)

## iMatrix

iMatrix quantizations are now available thanks to user [Ji-Ha](https://huggingface.co/Ji-Ha)

## Chat Template

*I am using ooba (text generation web ui) for inference

The GGUF version defaults to alpaca:

11:40:53-940260 INFO     LOADER: llama.cpp                                      
11:40:53-940970 INFO     TRUNCATION LENGTH: 32768                               
11:40:53-941299 INFO     INSTRUCTION TEMPLATE: Alpaca                           
11:40:53-941580 INFO     Loaded the model in 4.55 seconds.                      
```
{%- set ns = namespace(found=false) -%}
{%- for message in messages -%}
    {%- if message['role'] == 'system' -%}
        {%- set ns.found = true -%}
    {%- endif -%}
{%- endfor -%}
{%- if not ns.found -%}
    {{- '' + 'Below is an instruction that describes a task. Write a response that appropriately completes the request.' + '\n\n' -}}
{%- endif %}
{%- for message in messages %}
    {%- if message['role'] == 'system' -%}
        {{- '' + message['content'] + '\n\n' -}}
    {%- else -%}
        {%- if message['role'] == 'user' -%}
            {{-'### Instruction:\n' + message['content'] + '\n\n'-}}
        {%- else -%}
            {{-'### Response:\n' + message['content'] + '\n\n' -}}
        {%- endif -%}
    {%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
    {{-'### Response:\n'-}}
{%- endif -%}
```
And can be manually overridden to chatML successfully:

```
{%- set ns = namespace(found=false) -%}
{%- for message in messages -%}
    {%- if message['role'] == 'system' -%}
        {%- set ns.found = true -%}
    {%- endif -%}
{%- endfor -%}
{%- if not ns.found -%}
    {{- '<|im_start|>system\n' + '' + '<|im_end|>\n' -}}
{%- endif %}
{%- for message in messages %}
    {%- if message['role'] == 'system' -%}
        {{- '<|im_start|>system\n' + message['content'] + '<|im_end|>\n' -}}
    {%- else -%}
        {%- if message['role'] == 'user' -%}
            {{-'<|im_start|>user\n' + message['content'] + '<|im_end|>\n'-}}
        {%- else -%}
            {{-'<|im_start|>assistant\n' + message['content'] + '<|im_end|>\n' -}}
        {%- endif -%}
    {%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
    {{-'<|im_start|>assistant\n'-}}
{%- endif -%}
```

Here is the output of the model when I override the chat template to chatML

<|im_start|>system
<|im_end|>
<|im_start|>user
write me a quicksort algorithm in python<|im_end|>
<|im_start|>assistant
Sure, here's a basic implementation of Quicksort algorithm in Python:
```python
def partition(array, low, high):
    """Sorts elements around pivot"""
    i = (low - 1)   # Index of smaller element
    pivot = array[high]   # Select rightmost element as pivot

    for j in range(low, high):
        if array[j] <= pivot:
            i += 1
            array[i], array[j] = array[j], array[i]

    array[i + 1], array[high] = array[high], array[i + 1]   # Put the pivot where it belongs
    return (i + 1)                              # Return index after pivot point

def quicksort(array, low, high):
    """Implementing Quicksort"""
    if len(array) == 1 or low >= high:        # Base conditions
        return array
    elif low < high:   # Recursive step
        pi = partition(array, low, high)      # Separate smaller and greater elements around pivot point
        quicksort(array, low, pi - 1)         # Sort first half
        quicksort(array, pi + 1, high)        # Sort second half
    return array                             # After recursion ends we have a sorted list
```
To use it:
```python
arr = [45, 23, 76, 89, 32, 65]   # Your unsorted array
print("Original Array:", arr)    # Print original array
quicksort(arr, 0, len(arr)-1)    # Call Quicksort function with given range for sorting the entire array.
print("Sorted Array:", arr)      # Print sorted array
```
<|im_end|>
```