3 ms·
Didn't explore much, but it seems alpaca-lora has better results for coding tasks. One example I've used was: "Implement quicksort in python.". This is the resu
by tarruda 4y ago
Didn't explore much, but it seems alpaca-lora has better results for coding tasks. One example I've used was: "Implement quicksort in python.". This is the result with Code alpaca:
def quicksort(arr):
if len(arr) < 2:
return arr
else:
pivot = arr[len(arr) / 2]
left_index = 0
right_index = len(arr) - 1
while left_index <= right_index:
while arr[left_index] < pivot:
left_index += 1
while arr[right_index] > pivot:
right_index -= 1
if left_index <= right_index:
temp = arr[left_index]
arr[left_index] = arr[right_index]
arr[right_index] = temp
left_index += 1
right_index -= 1
return quicksort(arr[:left_index]) + [arr[left_index]] + quicksort(arr[right_index + 1:])
Alpaca lora result:
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[0]
left = [arr[i] for i in range(1, len(arr)) if arr[i] < pivot]
right = [arr[i] for i in range(1, len(arr)) if arr[i] > pivot]
return quicksort(left) + [pivot] + quicksort(right)
Shorter and much cleaner, not to mention it works (code alpaca version is broken). Also it matches what ChatGPT generates for me.
- sahil_chaudhary 4y agoInteresting, in my experiments alpaca-lora performed worse but definitely possible that isn't the case generally.
- grph123dot 4y agoThe Alpaca lora result is incorrect since, for example, if all elements in array are the same the result in just an array with one element.
- xiphias2 4y agoYou are correct also it's not quicksort as it's not in place array, but needs a lot of memory management