Model Details
This model is a mixed gguf q2ks format of cerebras/MiniMax-M2-REAP-172B-A10B generated by 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.
Please follow the license of the original model.
How To Use
Llamacpp inference.
./llama-cli --jinja -hf Intel/MiniMax-M2-REAP-172B-A10B-gguf-q2ks-mixed-AutoRound
> Write a quick sort algorithm.
We are going to implement the Quick Sort algorithm.
Quick Sort is a divide and conquer algorithm that works by selecting a 'pivot' element from the array and partitioning the array into two sub-arrays: elements less than the pivot and elements greater than the pivot. Then recursively sort the sub-arrays.
Steps:
1. Choose a pivot (common strategies: first element, last element, middle, random, etc.)
2. Partition the array such that all elements less than the pivot are to the left of the pivot and all greater to the right.
3. Recursively quick sort the left and right sub-arrays until the entire array is sorted.
We'll write a function `quick_sort(arr)` that sorts the array in place.
We'll use the last element as the pivot for simplicity.
Partitioning:
- We traverse the array from the left to the right (except the pivot) and if an element is less than the pivot, we swap it to the left side.
- We maintain an index (say `i`) for the position where the next element (if found) should be placed in the left part.
- Then we put the pivot at the correct position.
Example:
Array: [10, 7, 8, 9, 1, 5]
Pivot: 5 (last element)
We want: [1, 5, 7, 8, 9, 10]
Implementation of partition (with last element as pivot):
- Initialize `i` as the starting index (0).
- For each element from the start to the second last (because last is pivot):
if element < pivot:
swap arr[i] and arr[j]
i = i + 1
- Finally, swap arr[i] and the pivot (which is at the last index).
- Then return i (the pivot index).
Then we call quick_sort on the left part (from 0 to i-1) and the right part (from i+1 to end).
Let's code accordingly.
</think>
Here's a Python implementation of the Quick Sort algorithm with comments:
```python
def quick_sort(arr):
"""
Sorts a list using the Quick Sort algorithm.
Parameters:
arr (list): The list of elements to sort.
Returns:
list: The sorted list (in-place sort, so the original list is modified).
"""
# Base case: if the list has 0 or 1 elements, it's already sorted
if len(arr) <= 1:
return arr
# Recursive case
return _quick_sort_helper(arr, 0, len(arr) - 1)
def _quick_sort_helper(arr, low, high):
"""
Helper function for Quick Sort that sorts a subarray.
Parameters:
arr (list): The list containing the subarray.
low (int): Starting index of the subarray.
high (int): Ending index of the subarray.
"""
if low < high:
# Partition the array into two subarrays around the pivot
pivot_index = _partition(arr, low, high)
# Recursively sort the elements less than pivot
_quick_sort_helper(arr, low, pivot_index - 1)
# Recursively sort the elements greater than pivot
_quick_sort_helper(arr, pivot_index + 1, high)
def _partition(arr, low, high):
"""
Partitions the array around the pivot.
Elements less than pivot go to the left, greater to the right.
Parameters:
arr (list): The list to partition.
low (int): Starting index.
high (int): Ending index (pivot index).
Returns:
int: The index of the pivot after partitioning.
"""
# Choose the last element as pivot
pivot = arr[high]
# Index of the first element in the array
i = low
# Compare each element with the pivot
for j in range(low, high):
# If element is less than pivot, swap it to the left side
if arr[j] <= pivot:
arr[i], arr[j] = arr[j], arr[i]
i += 1
# Move pivot to its correct position
arr[i], arr[high] = arr[high], arr[i]
return i
# Example usage:
if __name__ == "__main__":
test_list = [10, 7, 8, 9, 1, 5, 3]
print("Original list:", test_list)
quick_sort(test_list)
print("Sorted list:", test_list)
```
### How It Works:
1. **Partitioning**:
- The pivot is the last element of the array.
- Elements less than the pivot move to its left, greater to its right.
- The pivot ends up in its correct final position.
2. **Recursive Sorting**:
- The array is divided around the pivot into two subarrays.
- The process repeats on each subarray until the base case (0 or 1 element) is reached.
### Key Points:
- **In-Place Sorting**: Modifies the original list without needing extra space.
- **Efficiency**:
- **Average Time Complexity**: O(n log n)
- **Worst Case**: O(nΒ²) (when pivot is chosen poorly, e.g., last element in a sorted array)
- **Space Complexity**: O(log n) for recursion stack (in the average case).
### Example Output:
```
Original list: [10, 7, 8, 9, 1, 5, 3]
Sorted list: [1, 3, 5, 7, 8, 9, 10]
```
### To Avoid Worst Case (O(nΒ²)):
- Use a random pivot: `pivot = arr[random.randint(low, high)]`
- Or use the median-of-three method for pivot selection.
Generate the model
If you encounter a bug when loading the model, please remove the @check_model_inputs decorator in modeling_minimax_m2.py.
auto_round --model cerebras/MiniMax-M2-REAP-172B-A10B --scheme q2_k_mixed --output_dir tmp_autoround --iters 0
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
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} }
- Downloads last month
- 141
2-bit
Model tree for Intel/MiniMax-M2-REAP-172B-A10B-gguf-q2ks-mixed-AutoRound
Base model
MiniMaxAI/MiniMax-M2