Update README.md
Browse files
README.md
CHANGED
@@ -20,3 +20,104 @@ tags:
|
|
20 |
This mistral 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 mistral 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 |
+
|
25 |
+
# README
|
26 |
+
|
27 |
+
This is a test model on a the following
|
28 |
+
- a private dataset
|
29 |
+
- slight customization on alpaca chat template
|
30 |
+
- Works with Ollama create but requires customization to Modelfile
|
31 |
+
- One reason for this was wanted to try doing Q2_K and see if it was actually good(?) -> Exceeds Expectation!!
|
32 |
+
- My examples will be based on unslot.Q2_K.GGUF file, however other quantization should work as well
|
33 |
+
|
34 |
+
# HOW TO USE
|
35 |
+
|
36 |
+
The whole point of conversion for me was I wanted to be able to to use it through Ollama or (other local options)
|
37 |
+
For Ollama, it required to be a GGUF file. Once you have this it is pretty straight forward
|
38 |
+
|
39 |
+
If you want to try it first, the Q2_K version of this is available in Ollama => deeokay/minimistral
|
40 |
+
|
41 |
+
```python
|
42 |
+
ollama pull deeokay/minimistral
|
43 |
+
```
|
44 |
+
|
45 |
+
|
46 |
+
# Quick Start:
|
47 |
+
- You must already have Ollama running in your setting
|
48 |
+
- Download the unsloth.Q2_K.gguf model from Files
|
49 |
+
- In the same directory create a file call "Modelfile"
|
50 |
+
- Inside the "Modelfile" type
|
51 |
+
|
52 |
+
```python
|
53 |
+
FROM ./mistrial_unsloth.Q2_K.gguf
|
54 |
+
|
55 |
+
PARAMETER stop <|STOP|>
|
56 |
+
PARAMETER stop "<|STOP|>"
|
57 |
+
PARAMETER stop <|END_RESPONSE|>
|
58 |
+
PARAMETER stop "<|END_RESPONSE|>"
|
59 |
+
PARAMETER temperature 0.4
|
60 |
+
|
61 |
+
TEMPLATE """<|BEGIN_QUERY|>
|
62 |
+
{{.Prompt}}
|
63 |
+
<|END_QUERY|>
|
64 |
+
<|BEGIN_RESPONSE|>
|
65 |
+
"""
|
66 |
+
|
67 |
+
SYSTEM """You are an AI assistant. Respond to the user's query between the BEGIN_QUERY and END_QUERY tokens. Use the appropriate BEGIN_ and END_ tokens for different types of content in your response.""""""
|
68 |
+
```
|
69 |
+
- Save a go back to the folder (folder where model + Modelfile exisit)
|
70 |
+
- Now in terminal make sure you are in the same location of the folder and type in the following command
|
71 |
+
|
72 |
+
```python
|
73 |
+
ollama create mycustomai # "mycustomai" <- you can name it anything u want
|
74 |
+
```
|
75 |
+
|
76 |
+
After than you should be able to use this model to chat!
|
77 |
+
This GGUF is based on unsloth/mistral-7b-instruct-v0.3-bnb-4bit by Unslot,
|
78 |
+
|
79 |
+
|
80 |
+
# NOTE: DISCLAIMER
|
81 |
+
|
82 |
+
Please note this is not for the purpose of production, but result of Fine Tuning through self learning
|
83 |
+
This is my Fine Tuning pass through with personalized customized dataset.
|
84 |
+
Please feel free to customize the Modelfile, and if you do get a better response than mine, please share!!
|
85 |
+
|
86 |
+
If would like to know how I started creating my dataset, you can check this link
|
87 |
+
[Crafting GPT2 for Personalized AI-Preparing Data the Long Way (Part1)](https://medium.com/@deeokay/the-soul-in-the-machine-crafting-gpt2-for-personalized-ai-9d38be3f635f)
|
88 |
+
|
89 |
+
As the data was getting created with custom GPT2 special tokens, I had to convert that to the a Alpaca Template.
|
90 |
+
However I got creative again.. the training data has the following Template:
|
91 |
+
|
92 |
+
```python
|
93 |
+
special_tokens_dict = {
|
94 |
+
'eos_token': '<|STOP|>',
|
95 |
+
'bos_token': '<|STOP|>',
|
96 |
+
'pad_token': '<|PAD|>',
|
97 |
+
'additional_special_tokens': ['<|BEGIN_QUERY|>', '<|BEGIN_QUERY|>',
|
98 |
+
'<|BEGIN_ANALYSIS|>', '<|END_ANALYSIS|>',
|
99 |
+
'<|BEGIN_RESPONSE|>', '<|END_RESPONSE|>',
|
100 |
+
'<|BEGIN_SENTIMENT|>', '<|END_SENTIMENT|>',
|
101 |
+
'<|BEGIN_CLASSIFICATION|>', '<|END_CLASSIFICATION|>',]
|
102 |
+
}
|
103 |
+
|
104 |
+
tokenizer.add_special_tokens(special_tokens_dict)
|
105 |
+
model.resize_token_embeddings(len(tokenizer))
|
106 |
+
|
107 |
+
tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids('<|STOP|>')
|
108 |
+
tokenizer.bos_token_id = tokenizer.convert_tokens_to_ids('<|STOP|>')
|
109 |
+
tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids('<|PAD|>')
|
110 |
+
|
111 |
+
```
|
112 |
+
|
113 |
+
The data is in the following format:
|
114 |
+
|
115 |
+
```python
|
116 |
+
def combine_text(user_prompt, analysis, sentiment, new_response, classification):
|
117 |
+
user_q = f"<|STOP|><|BEGIN_QUERY|>{user_prompt}<|END_QUERY|>"
|
118 |
+
analysis = f"<|BEGIN_ANALYSIS|>{analysis}<|END_ANALYSIS|>"
|
119 |
+
new_response = f"<|BEGIN_RESPONSE|>{new_response}<|END_RESPONSE|>"
|
120 |
+
classification = f"<|BEGIN_CLASSIFICATION|>{classification}<|END_CLASSIFICATION|>"
|
121 |
+
sentiment = f"<|BEGIN_SENTIMENT|>Sentiment: {sentiment}<|END_SENTIMENT|><|STOP|>"
|
122 |
+
return user_q + analysis + new_response + classification + sentiment
|
123 |
+
```
|