n1ck-guo's picture
Update README.md
32d09e7 verified
---
base_model:
- openai/gpt-oss-20b
---
## Model Details
This model is a gguf q2ks format of [openai/gpt-oss-20b](https://huggingface.co/openai/gpt-oss-20b) generated by [intel/auto-round](https://github.com/intel/auto-round) algorithm.
Please follow the license of the original model.
## How To Use
Llamacpp inference
~~~bash
llama-cli -hf Intel/gpt-oss-20b-gguf-q2ks-AutoRound
~~~
~~~bash
> Write a quick sort algorithm.
<|channel|>analysis<|message|>The user says: "Write a quick sort algorithm." They didn't specify language. Usually, we can answer with a generic explanation, maybe pseudocode. The user says "Write a quick sort algorithm." We should respond with a quick sort algorithm. Possibly in Python? Or a typical quick sort implementation. The user didn't specify the language. They might want a quicksort implementation. We can answer in Python. We can also explain the algorithm.
We should answer concisely but thorough. The user: "Write a quick sort algorithm." So we can just give code.
Thus the best solution: Provide quicksort algorithm in Python. Possibly iterative? But we can provide recursive quicksort.
We should mention the typical quicksort: pick pivot, partition, sort left, sort right.
We'll produce a quicksort function. Provide an implementation.
We can show both in-place quicksort and functional quicksort. The question didn't ask for any particular style, so just give a quicksort algorithm. So just provide code and explanation.
We can answer in a short format:
```
def quicksort(arr):
if len(arr)<=1:
return arr
pivot=arr[len(arr)//2]
left=[x for x in arr if x<pivot]
middle=[x for x in arr if x==pivot]
right=[x for x in arr if x>pivot]
return quicksort(left)+middle+quicksort(right)
```
Alternatively in-place:
```
def quicksort_inplace(arr, low, high):
if low<high:
pi = partition(arr, low, high)
quicksort_inplace(arr, low, pi-1)
quicksort_inplace(arr, pi+1, high)
```
We can provide partition:
```
def partition(arr, low, high):
pivot = arr[high]
i = low-1
for j in range(low, high):
if arr[j] < pivot:
i += 1
arr[i], arr[j] = arr[j], arr[i]
arr[i+1], arr[high] = arr[high], arr[i+1]
return i+1
```
Also mention complexity: average O(n log n), worst O(n^2).
We can provide the code. The user likely wants code. Provide a quicksort algorithm in Python or Java, etc.
We can provide in Python, as it's commonly used.
Let's produce a quicksort algorithm in Python. We'll explain the algorithm in a short explanation.
Ok.<|start|>assistant<|channel|>final<|message|>Here is a simple **quick‑sort** implementation in Python (recursive, in‑place).
It works for any sequence that supports random access and comparison.
```python
def quicksort_inplace(a, low=0, high=None):
"""
Sorts the list `a` in‑place using the quick‑sort algorithm.
:param a: list to sort
:param low: first index to sort (default 0)
:param high: last index to sort (default None, meaning the last element)
"""
if high is None:
high = len(a) - 1
if low < high:
p = partition(a, low, high) # pivot position after partition
quicksort_inplace(a, low, p - 1) # left sub‑array
quicksort_inplace(a, p + 1, high) # right sub‑array
def partition(a, low, high):
"""
Partitions the sub‑array a[low:high+1] around a pivot.
Elements less than the pivot are moved to the left of the pivot,
elements greater or equal to the right.
Returns the final index of the pivot.
"""
pivot = a[high] # choose the right‑most element as pivot
i = low - 1 # last element that is less than pivot
for j in range(low, high):
if a[j] < pivot:
i += 1
a[i], a[j] = a[j], a[i] # swap
# place pivot after the last smaller element
a[i + 1], a[high] = a[high], a[i + 1]
return i + 1
```
**How it works**
1. **Pivot**: In this example the right‑most element is used as the pivot.
2. **Partition**: All elements `< pivot` are moved to the left side; all `>= pivot` stay on the right.
3. **Recursion**: After partitioning, we sort the left sub‑array (`low` … `p-1`) and the right sub‑array (`p+1` … `high`).
4. **In‑place**: The algorithm sorts the original list without allocating additional memory for the sub‑arrays.
**Complexities**
- **Average‑case**: `O(n log n)` – when partitions are roughly balanced.
- **Worst‑case**: `O(n²)` – when partitions are highly unbalanced (e.g., already sorted input with the last element as pivot).
This can be mitigated by picking a random pivot or the median‑of‑three pivot.
You can run it on a list:
```python
data = [3, 6, 8, 10, 1, 2, 1]
quicksort_inplace(data)
print(data) # -> [1, 1, 2, 3, 6, 8, 10]
```
Feel free to adapt the code (e.g., use a random pivot or a different partition scheme) for your specific needs.
~~~
### Generate the model
#### Requirement
pip install git+https://github.com/intel/auto-round.git@hengguo/gguf_update_0806
Here is the sample command to reproduce the model
```bash
auto_round --format gguf:q2_k_s --iters 0 --nsamples 512 --model openai/gpt-oss-20b --output_dir tmp_autoround
```
## Ethical Considerations and Limitations
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.
Therefore, before deploying any applications of the model, developers should perform safety testing.
## Caveats and Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
Here are a couple of useful links to learn more about Intel's AI software:
- Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
## Disclaimer
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.
## Cite
@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} }
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)