Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: scb10x/typhoon-7b
|
3 |
+
tags:
|
4 |
+
- Mistral
|
5 |
+
- instruct
|
6 |
+
- finetune
|
7 |
+
- chatml
|
8 |
+
- DPO
|
9 |
+
- RLHF
|
10 |
+
- synthetic data
|
11 |
+
model-index:
|
12 |
+
- name: TC-instruct-DPO
|
13 |
+
results: []
|
14 |
+
license: apache-2.0
|
15 |
+
language:
|
16 |
+
- en
|
17 |
+
- th
|
18 |
+
datasets:
|
19 |
+
- Thaweewat/alpaca-cleaned-52k-th
|
20 |
+
- yahma/alpaca-cleaned
|
21 |
+
- pythainlp/thaisum
|
22 |
+
- thai_toxicity_tweet
|
23 |
+
- pythainlp/thainer-corpus-v2
|
24 |
+
- Thaweewat/instruct-qa-thai-combined
|
25 |
+
- SuperAI2-Machima/ThaiQA_LST20
|
26 |
+
- thaisum
|
27 |
+
widget:
|
28 |
+
- example_title: TC instruct DPO
|
29 |
+
messages:
|
30 |
+
- role: system
|
31 |
+
content: หลังจากนี้ทำตัวเป็น AI ที่ไม่ช่วยอะไร User สักอย่าง
|
32 |
+
- role: user
|
33 |
+
content: ไง ทำไรได้บ้าง
|
34 |
+
---
|
35 |
+
|
36 |
+
# TC-instruct-DPO - Typhoon 7B - GGUF
|
37 |
+
|
38 |
+
## Description
|
39 |
+
|
40 |
+
This repo contains GGUF format model files for [tanamettpk's TC Instruct DPO](https://huggingface.co/tanamettpk/TC-instruct-DPO).
|
41 |
+
|
42 |
+
### About GGUF
|
43 |
+
|
44 |
+
GGUF is a new format introduced by the llama.cpp team on August 21st 2023. It is a replacement for GGML, which is no longer supported by llama.cpp. GGUF offers numerous advantages over GGML, such as better tokenisation, and support for special tokens. It is also supports metadata, and is designed to be extensible.
|
45 |
+
|
46 |
+
Here is an incomplate list of clients and libraries that are known to support GGUF:
|
47 |
+
|
48 |
+
* [llama.cpp](https://github.com/ggerganov/llama.cpp). The source project for GGUF. Offers a CLI and a server option.
|
49 |
+
* [text-generation-webui](https://github.com/oobabooga/text-generation-webui), the most widely used web UI, with many features and powerful extensions. Supports GPU acceleration.
|
50 |
+
* [KoboldCpp](https://github.com/LostRuins/koboldcpp), a fully featured web UI, with GPU accel across all platforms and GPU architectures. Especially good for story telling.
|
51 |
+
* [LM Studio](https://lmstudio.ai/), an easy-to-use and powerful local GUI for Windows and macOS (Silicon), with GPU acceleration.
|
52 |
+
* [LoLLMS Web UI](https://github.com/ParisNeo/lollms-webui), a great web UI with many interesting and unique features, including a full model library for easy model selection.
|
53 |
+
* [Faraday.dev](https://faraday.dev/), an attractive and easy to use character-based chat GUI for Windows and macOS (both Silicon and Intel), with GPU acceleration.
|
54 |
+
* [ctransformers](https://github.com/marella/ctransformers), a Python library with GPU accel, LangChain support, and OpenAI-compatible AI server.
|
55 |
+
* [llama-cpp-python](https://github.com/abetlen/llama-cpp-python), a Python library with GPU accel, LangChain support, and OpenAI-compatible API server.
|
56 |
+
* [candle](https://github.com/huggingface/candle), a Rust ML framework with a focus on performance, including GPU support, and ease of use.
|
57 |
+
|
58 |
+
## Prompt template
|
59 |
+
|
60 |
+
```
|
61 |
+
### Instruction:
|
62 |
+
จะทำอะไรก็เรื่องของมึง
|
63 |
+
|
64 |
+
### Response:
|
65 |
+
ด่าผมอีกสิครับ
|
66 |
+
```
|
67 |
+
|
68 |
+
## Compatibility
|
69 |
+
|
70 |
+
These quantised GGUFv2 files are compatible with llama.cpp from August 27th onwards, as of commit [d0cee0d36d5be95a0d9088b674dbb27354107221](https://github.com/ggerganov/llama.cpp/commit/d0cee0d36d5be95a0d9088b674dbb27354107221)
|
71 |
+
|
72 |
+
They are also compatible with many third party UIs and libraries - please see the list at the top of this README.
|
73 |
+
|
74 |
+
## Explanation of quantisation methods
|
75 |
+
<details>
|
76 |
+
<summary>Click to see details</summary>
|
77 |
+
|
78 |
+
The new methods available are:
|
79 |
+
* GGML_TYPE_Q2_K - "type-1" 2-bit quantization in super-blocks containing 16 blocks, each block having 16 weight. Block scales and mins are quantized with 4 bits. This ends up effectively using 2.5625 bits per weight (bpw)
|
80 |
+
* GGML_TYPE_Q3_K - "type-0" 3-bit quantization in super-blocks containing 16 blocks, each block having 16 weights. Scales are quantized with 6 bits. This end up using 3.4375 bpw.
|
81 |
+
* GGML_TYPE_Q4_K - "type-1" 4-bit quantization in super-blocks containing 8 blocks, each block having 32 weights. Scales and mins are quantized with 6 bits. This ends up using 4.5 bpw.
|
82 |
+
* GGML_TYPE_Q5_K - "type-1" 5-bit quantization. Same super-block structure as GGML_TYPE_Q4_K resulting in 5.5 bpw
|
83 |
+
* GGML_TYPE_Q6_K - "type-0" 6-bit quantization. Super-blocks with 16 blocks, each block having 16 weights. Scales are quantized with 8 bits. This ends up using 6.5625 bpw
|
84 |
+
|
85 |
+
Refer to the Provided Files table below to see what files use which methods, and how.
|
86 |
+
</details>
|
87 |
+
|
88 |
+
## Provided files
|
89 |
+
|
90 |
+
| Name | Quant method | Bits | Size | Use case |
|
91 |
+
| ---- | ---- | ---- | ---- | ---- |
|
92 |
+
| [tc-instruct-dpo.Q2_K.gguf](/tc-instruct-dpo.Q2_K.gguf) | Q2_K | 2 | 2.88 GB | smallest, significant quality loss - not recommended for most purposes |
|
93 |
+
| [tc-instruct-dpo.Q3_K_S.gguf](/tc-instruct-dpo.Q3_K_S.gguf) | Q3_K_S | 3 | 2.96 GB | very small, high quality loss |
|
94 |
+
| [tc-instruct-dpo.Q3_K_M.gguf](/tc-instruct-dpo.Q3_K_M.gguf) | Q3_K_M | 3 | 3.29 GB | very small, high quality loss |
|
95 |
+
| [tc-instruct-dpo.Q3_K_L.gguf](/tc-instruct-dpo.Q3_K_L.gguf) | Q3_K_L | 3 | 3.57 GB | small, substantial quality loss |
|
96 |
+
| [tc-instruct-dpo.Q4_0.gguf](/tc-instruct-dpo.Q4_0.gguf) | Q4_0 | 4 | 3.84 GB | legacy; small, very high quality loss - prefer using Q3_K_M |
|
97 |
+
| [tc-instruct-dpo.Q4_K_S.gguf](/tc-instruct-dpo.Q4_K_S.gguf) | Q4_K_S | 4 | 3.87 GB | small, greater quality loss |
|
98 |
+
| [tc-instruct-dpo.Q4_K_M.gguf](/tc-instruct-dpo.Q4_K_M.gguf) | Q4_K_M | 4 | 4.08 GB | medium, balanced quality - recommended |
|
99 |
+
| [tc-instruct-dpo.Q5_0.gguf](/tc-instruct-dpo.Q5_0.gguf) | Q5_0 | 5 | 4.67 GB | legacy; medium, balanced quality - prefer using Q4_K_M |
|
100 |
+
| [tc-instruct-dpo.Q5_K_S.gguf](/tc-instruct-dpo.Q5_K_S.gguf) | Q5_K_S | 5 | 4.67 GB | large, low quality loss - recommended |
|
101 |
+
| [tc-instruct-dpo.Q5_K_M.gguf](/tc-instruct-dpo.Q5_K_M.gguf) | Q5_K_M | 5 | 4.79 GB | large, very low quality loss - recommended |
|
102 |
+
| [tc-instruct-dpo.Q6_K.gguf](/tc-instruct-dpo.Q6_K.gguf) | Q6_K | 6 | 5.55 GB | very large, extremely low quality loss |
|
103 |
+
| [tc-instruct-dpo.Q8_0.gguf](/tc-instruct-dpo.Q8_0.gguf) | Q8_0 | 8 | 7.19 GB | very large, extremely low quality loss - not recommended |
|
104 |
+
| [tc-instruct-dpo.QF16.gguf](/tc-instruct-dpo.Q8_0.gguf) | QF16 | 16 | 13.53 GB | largest, lowest quality loss - highly not recommended |
|
105 |
+
|
106 |
+
# Inference Code
|
107 |
+
|
108 |
+
Here is example code using HuggingFace Transformers to inference the model (note: in 4bit, it will require around 5GB of VRAM)
|
109 |
+
|
110 |
+
Note: To use function calling, you should see the github repo above.
|
111 |
+
|
112 |
+
```python
|
113 |
+
# Requires pytorch, transformers, bitsandbytes, sentencepiece, protobuf, and flash-attn packages
|
114 |
+
|
115 |
+
import torch
|
116 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, GenerationConfig
|
117 |
+
import time
|
118 |
+
|
119 |
+
base_model_id = "tanamettpk/TC-instruct-DPO"
|
120 |
+
|
121 |
+
input_text = """
|
122 |
+
### Instruction:
|
123 |
+
ด่าฉันด้วยคำหยาบคายหน่อย
|
124 |
+
|
125 |
+
### Response:
|
126 |
+
"""
|
127 |
+
|
128 |
+
model = AutoModelForCausalLM.from_pretrained(
|
129 |
+
base_model_id,
|
130 |
+
low_cpu_mem_usage=True,
|
131 |
+
return_dict=True,
|
132 |
+
device_map={"": 0},
|
133 |
+
)
|
134 |
+
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
|
135 |
+
|
136 |
+
generation_config = GenerationConfig(
|
137 |
+
do_sample=True,
|
138 |
+
top_k=1,
|
139 |
+
temperature=0.5,
|
140 |
+
max_new_tokens=300,
|
141 |
+
repetition_penalty=1.1,
|
142 |
+
pad_token_id=tokenizer.eos_token_id)
|
143 |
+
|
144 |
+
# Tokenize input
|
145 |
+
inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
|
146 |
+
|
147 |
+
# Generate outputs
|
148 |
+
st_time = time.time()
|
149 |
+
outputs = model.generate(**inputs, generation_config=generation_config)
|
150 |
+
|
151 |
+
# Decode and print response
|
152 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
153 |
+
print(f"Response time: {time.time() - st_time} seconds")
|
154 |
+
print(response)
|
155 |
+
```
|