I'm glad to see projects like this.<p>I had a look at the demo (<a href="https://huggingface.co/spaces/TabbyML/tabby" rel="nofollow">https://huggingface.co/spaces/TabbyML/tabby</a>) 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).<p>Request to <a href="https://tabbyml-tabby.hf.space/v1/completions" rel="nofollow">https://tabbyml-tabby.hf.space/v1/completions</a>:<p><pre><code> {
"language": "python",
"prompt": "def binarySearch(arr, left, right, x):\n mid = (left +"
}
</code></pre>
Response:<p><pre><code> {
"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"
}
]
}
</code></pre>
Formatted code:<p><pre><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
</code></pre>
Manually written test cases:<p><pre><code> arr = [1, 3, 5, 7]
print(binarySearch(arr, 0, len(arr), 5)) # 2 (correct)
print(binarySearch(arr, 0, len(arr), 4)) # RecursionError
</code></pre>
Runnable demo:<p><a href="https://tio.run/##lY/BCoJAEIbvPsUPXVw0yCyCKG@9QB3Fg@maC7bKuII@vc1qdJGg5rIL83/fzDSDKWsdjmMuC9yVTmm4yZSy0k2JfFSyMD5IPUp@enF0wPVUOc5wbQ/e3BSIIgRTVxXocQLjMQeTGbFF0nSkvw6x1jUCO2ZCZDWZon9M1uFZx2fjt6qVC5qzjsMUnxIzEfrY@zgkTkNKG3fp3thFtf0LjgqBFbZws5pIZkb8hu0m7CqzjlpV6wtRTeP4Ag" rel="nofollow">https://tio.run/##lY/BCoJAEIbvPsUPXVw0yCyCKG@9QB3Fg@maC7bKuI...</a>