sourcegraph / cody

Type less, code more: Cody is an AI code assistant that uses advanced search and codebase context to help you write and fix code.
https://cody.dev
Apache License 2.0
2.4k stars 263 forks source link

Autocomplete: figure out why starcoder generates syntactically incorrect if conditions #1983

Open valerybugakov opened 8 months ago

valerybugakov commented 8 months ago

Tested on starcoder-16b. It consistently completes if █ string incorrectly without parentheses around a condition:

if featureFlagProvider.enabled {

This behavior is so consistent that we might want to handle it on the client side manually.

philipp-spiess commented 8 months ago

@valerybugakov Can you log one of the exact prompt this happens? I tried to reproduce it via the Fireworks API playground directly where the issue does not seem to occur 🤔

Screenshot 2023-11-29 at 12 54 17

The prompt I used for this test was only:

<filename>test.ts <fim_prefix>function myFunction(flag: boolean) {   if <fim_suffix>} } <fim_middle>
philipp-spiess commented 8 months ago

(It also works if I remove the space between if and <fim_suffix>

valerybugakov commented 8 months ago

I got an even worse variation of this just now:

Screenshot 2023-11-29 at 20 07 32
valerybugakov commented 8 months ago

Is it a strong Python influence from the training dataset? 🤔

philipp-spiess commented 8 months ago

@valerybugakov Possible, yeah. The prompt is also very short, maybe it doesn't know it's in a TS file example yet 😓

valerybugakov commented 8 months ago

I had the same behavior in bigger TS files. I am going to monitor it and share examples here.

taylorsperry commented 8 months ago

@valerybugakov and @philipp-spiess can you help me understand what the user impact is here?

valerybugakov commented 8 months ago

I set the priority to P2 because this behavior is inconsistent. Sometimes StarCoder generates incorrect syntax for if statements in Javascript and Typescript:

// StarCoder completion
if value && anotherValue {

// Valid syntax
if (value && anotherValue) {
github-actions[bot] commented 6 months ago

This issue is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days.