GGUF
conversational
n1ck-guo commited on
Commit
7840e91
·
verified ·
1 Parent(s): a000cba

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +152 -0
README.md ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - Qwen/Qwen3-Coder-30B-A3B-Instruct
4
+ datasets:
5
+ - codeparrot/github-code-clean
6
+ ---
7
+
8
+ ## Model Details
9
+
10
+ This model is a mixed gguf q2ks format of [Qwen/Qwen3-Coder-30B-A3B-Instruct](https://huggingface.co/Qwen/Qwen/Qwen3-Coder-30B-A3B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm. Embedding layer and lm-head layer are fallback to 8 bits and non expert layers are fallback to 4 bits. Please refer to Section `Generate the model` for more details.
11
+
12
+ Please follow the license of the original model.
13
+
14
+ ## How To Use
15
+
16
+ Llamacpp inference
17
+
18
+ ~~~bash
19
+ /llama-cli -hf Intel/Qwen3-Coder-30B-A3B-Instruct-gguf-q2ks-mixed-AutoRound
20
+ ~~~
21
+
22
+ ~~~bash
23
+ > Write a quick sort algorithm.
24
+ Here's a quick sort algorithm implementation in Python:
25
+
26
+ ```python
27
+ def quicksort(arr):
28
+ """
29
+ Sort an array using the quicksort algorithm.
30
+
31
+ Args:
32
+ arr: List to be sorted
33
+
34
+ Returns:
35
+ Sorted list
36
+ """
37
+ if len(arr) <= 1:
38
+ return arr
39
+
40
+ pivot = arr[len(arr) // 2]
41
+ left = [x for x in arr if x < pivot]
42
+ middle = [x for x in arr if x == pivot]
43
+ right = [x for x in arr if x > pivot]
44
+
45
+ return quicksort(left) + middle + quicksort(right)
46
+
47
+ # Alternative in-place version (more memory efficient)
48
+ def quicksort_inplace(arr, low=0, high=None):
49
+ """
50
+ Sort an array in-place using quicksort.
51
+
52
+ Args:
53
+ arr: List to be sorted
54
+ low: Starting index
55
+ high: Ending index
56
+ """
57
+ if high is None:
58
+ high = len(arr) - 1
59
+
60
+ if low < high:
61
+ pivot_index = partition(arr, low, high)
62
+ quicksort_inplace(arr, low, pivot_index - 1)
63
+ quicksort_inplace(arr, pivot_index + 1, high)
64
+
65
+ def partition(arr, low, high):
66
+ """
67
+ Partition function for in-place quicksort.
68
+ """
69
+ pivot = arr[high]
70
+ i = low - 1
71
+
72
+ for j in range(low, high):
73
+ if arr[j] <= pivot:
74
+ i += 1
75
+ arr[i], arr[j] = arr[j], arr[i]
76
+
77
+ arr[i + 1], arr[high] = arr[high], arr[i + 1]
78
+ return i + 1
79
+
80
+ # Example usage:
81
+ if __name__ == "__main__":
82
+ # Test the simple version
83
+ test_arr = [64, 34, 25, 12, 22, 11, 90]
84
+ print("Original:", test_arr)
85
+ print("Sorted:", quicksort(test_arr))
86
+
87
+ # Test the in-place version
88
+ test_arr2 = [64, 34, 25, 12, 22, 11, 90]
89
+ quicksort_inplace(test_arr2)
90
+ print("In-place sorted:", test_arr2)
91
+ ```
92
+
93
+ **Time Complexity:** O(n log n) average case, O(n²) worst case
94
+ **Space Complexity:** O(log n) for recursive calls
95
+
96
+ The first version creates new arrays during each recursion, making it easier to understand but using more memory. The second version sorts in-place, which is more memory efficient.
97
+
98
+ ~~~
99
+
100
+
101
+
102
+ ### Generate the model
103
+
104
+ Here is the sample command to reproduce the model
105
+
106
+ ```python
107
+ import torch
108
+ from transformers import AutoModelForCausalLM, AutoTokenizer
109
+ from auto_round import AutoRound
110
+
111
+ model_name = "Qwen/Qwen3-Coder-30B-A3B-Instruct"
112
+
113
+ model = AutoModelForCausalLM.from_pretrained(model_name,
114
+ device_map="auto", torch_dtype="auto")
115
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
116
+ layer_config = {}
117
+ for n, m in model.named_modules():
118
+ if n == "lm_head" or isinstance(m,torch.nn.Embedding):
119
+ layer_config[n] = {"bits": 8}
120
+ elif isinstance(m, torch.nn.Linear) and (not "expert" in n or "shared_experts" in n) and n != "lm_head":
121
+ layer_config[n] = {"bits": 4}
122
+
123
+ autoround = AutoRound(model, tokenizer, iters=0, layer_config=layer_config, nsamples=512, dataset="github-code-clean")
124
+ autoround.quantize_and_save("tmp_autoround", format="gguf:q2_k_s")
125
+
126
+ ```
127
+
128
+
129
+
130
+ ## Ethical Considerations and Limitations
131
+
132
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
133
+
134
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
135
+
136
+ ## Caveats and Recommendations
137
+
138
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
139
+
140
+ Here are a couple of useful links to learn more about Intel's AI software:
141
+
142
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
143
+
144
+ ## Disclaimer
145
+
146
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
147
+
148
+ ## Cite
149
+
150
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
151
+
152
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)