GGUF
conversational
n1ck-guo commited on
Commit
3d812d0
·
verified ·
1 Parent(s): 96122df

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +153 -0
README.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - zai-org/GLM-4.5
4
+ datasets:
5
+ - codeparrot/github-code-clean
6
+ ---
7
+
8
+ ## Model Details
9
+
10
+ This model is a mixed gguf q2ks format of [zai-org/GLM-4.5](https://huggingface.co/zai-org/GLM-4.5) 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/GLM-4.5-gguf-q2ks-mixed-AutoRound
20
+ ~~~
21
+
22
+ ~~~bash
23
+ > Write a quick sort algorithm.
24
+ Of course! Here's a quick sort algorithm written in Python. Quick sort is a highly efficient sorting algorithm and is a divide-and-conquer algorithm.
25
+
26
+ ### The Algorithm
27
+ The algorithm picks a 'pivot' element from the array and partitions the other elements into two sub-arrays: those less than the pivot and those greater than the pivot. The process is then repeated recursively for the sub-arrays until the entire list is sorted.
28
+
29
+ ### Python Implementation
30
+
31
+ ```python
32
+ def quick_sort(arr):
33
+ """
34
+ Sorts an array in ascending order using the Quick Sort algorithm.
35
+ This is an in-place sort using the Lomuto partition scheme.
36
+ """
37
+ # Helper function to perform the partitioning
38
+ def _partition(low, high):
39
+ # We'll use the last element as the pivot
40
+ pivot = arr[high]
41
+ i = low - 1 # Index of smaller element
42
+
43
+ for j in range(low, high):
44
+ # If current element is smaller than or equal to pivot
45
+ if arr[j] <= pivot:
46
+ i += 1
47
+ arr[i], arr[j] = arr[j], arr[i] # Swap
48
+
49
+ # Place the pivot in its correct position
50
+ arr[i + 1], arr[high] = arr[high], arr[i + 1]
51
+ return i + 1 # Return the pivot index
52
+
53
+ # Main recursive function
54
+ def _sort(low, high):
55
+ if low < high:
56
+ # pi is the partitioning index, arr[pi] is now at its correct place
57
+ pi = _partition(low, high)
58
+
59
+ # Recursively sort elements before and after the partition
60
+ _sort(low, pi - 1)
61
+ _sort(pi + 1, high)
62
+
63
+ # Start the sorting process
64
+ _sort(0, len(arr) - 1)
65
+ return arr
66
+
67
+ # Example usage:
68
+ my_list = [10, 7, 8, 9, 1, 5]
69
+ print(f"Original list: {my_list}")
70
+
71
+ sorted_list = quick_sort(my_list)
72
+ print(f"Sorted list: {sorted_list}")
73
+
74
+ # Output:
75
+ # Original list: [10, 7, 8, 9, 1, 5]
76
+ # Sorted list: [1, 5, 7, 8, 9, 10]
77
+ ```
78
+
79
+ ### Explanation:
80
+
81
+ 1. **`quick_sort(arr)`**: This is the main function that users call. It sets up the recursive sorting process.
82
+ 2. **`_partition(low, high)`**: This is a helper function that does the core work of the algorithm.
83
+ * **Pivot Selection**: It selects the last element of the current sub-array (`arr[high]`) as the pivot.
84
+ * **Partitioning**: It iterates through the sub-array (from `low` to `high-1`). Any element found that is less than or equal to the pivot is swapped to the left side of the sub-array. The index `i` keeps track of the boundary between elements less than the pivot and elements greater than the pivot.
85
+ * **Final Swap**: After the loop, the pivot itself is swapped into its final, correct position (at index `i + 1`), and this new index is returned.
86
+ 3. **`_sort(low, high)`**: This is the recursive helper function.
87
+ * **Base Case**: The recursion stops when `low >= high`, meaning the sub-array has 0 or 1 element and is already considered sorted.
88
+ * **Recursive Step**: It first calls `_partition` to get the pivot's correct position (`pi`). Then, it makes two recursive calls to sort the elements to the left of the pivot (`_sort(low, pi - 1)`) and the elements to the right of the pivot (`_sort(pi + 1, high)`).
89
+
90
+ ### Key Points:
91
+ * **Time Complexity**:
92
+ * **Best and Average Case**: O(n log n). This occurs when the pivot consistently divides the array into roughly equal halves.
93
+ * **Worst Case**: O(n²). This can happen if the pivot is consistently the smallest or largest element (e.g., if the array is already sorted and you always pick the last element as the pivot). This can be mitigated by choosing a better pivot strategy (e.g., "median-of-three").
94
+ * **Space Complexity**: O(log n) on average for the recursion stack depth. O(n) in the worst case.
95
+ * **In-Place**: This implementation is an "in-place" sort, meaning it modifies the original array directly and does not require significant extra memory for creating new arrays (unlike, for example, a naive merge sort implementation). This makes it very memory-efficient.
96
+
97
+ I can provide an implementation in another language (like JavaScript, C++, or Java) or explain a different partitioning scheme (like Hoare's) if you'd like!
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 = "zai-org/GLM-4.5"
112
+
113
+ model = AutoModelForCausalLM.from_pretrained(model_name,
114
+ device_map="cpu", 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)
124
+ autoround.quantize_and_save("tmp_autoround", format="gguf:q2_k_s")
125
+
126
+
127
+ ```
128
+
129
+
130
+
131
+ ## Ethical Considerations and Limitations
132
+
133
+ 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.
134
+
135
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
136
+
137
+ ## Caveats and Recommendations
138
+
139
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
140
+
141
+ Here are a couple of useful links to learn more about Intel's AI software:
142
+
143
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
144
+
145
+ ## Disclaimer
146
+
147
+ 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.
148
+
149
+ ## Cite
150
+
151
+ @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} }
152
+
153
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)