I'm glad to see projects like this.
I had a look at the demo (https://huggingface.co/spaces/TabbyML/tabby) and wasn't too impressed with the generated code for the default sample prompt (binary search) -- it recurses infinitely if the item is missing. It would be interesting to compare with Copilot's output. No idea how one would go about fixing this (other than manually add a correct binary search implementation to the training data, which feels like cheating).
Request to https://tabbyml-tabby.hf.space/v1/completions:
{
"language": "python",
"prompt": "def binarySearch(arr, left, right, x):\n mid = (left +"
}
Response:
{
"id": "cmpl-...",
"created": 1680867355,
"choices": [
{
"index": 0,
"text": " right) >> 1\n if x < arr[mid]:\n return binarySearch(arr, left, mid - 1, x)\n elif x > arr[mid]:\n return binarySearch(arr, mid + 1, right, x)\n else:\n return mid"
}
]
}
Formatted code:
def binarySearch(arr, left, right, x):
mid = (left + right) >> 1
if x < arr[mid]:
return binarySearch(arr, left, mid - 1, x)
elif x > arr[mid]:
return binarySearch(arr, mid + 1, right, x)
else:
return mid
Manually written test cases:
arr = [1, 3, 5, 7]
print(binarySearch(arr, 0, len(arr), 5)) # 2 (correct)
print(binarySearch(arr, 0, len(arr), 4)) # RecursionError
Runnable demo:
https://tio.run/##lY/BCoJAEIbvPsUPXVw0yCyCKG@9QB3Fg@maC7bKuI...