Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preamble leak for anthropic #1274

Merged
merged 2 commits into from
Oct 3, 2023
Merged

fix: preamble leak for anthropic #1274

merged 2 commits into from
Oct 3, 2023

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Oct 2, 2023

Close #1291

Fix issues that cause the preamble to leak for anthropic by enclosing the code with backticks to make sure Claude instant knows where the code ends, instead of having the code snippets end with a new line or unfinished code/comment, which would confuse Claude and lead it to think the code was not completed so they should continue the completion from the end of the code snippet instead of the code inside the tags.

Before

Screenshot 2023-10-02 at 3 27 09 PM

After

Screenshot 2023-10-02 at 3 28 30 PM

Test plan

  1. build Cody from this branch
  2. Go to line 213 of vscode/webviews/Chat.tsx in your editor
  3. Instead of seeing Human: as a suggestion, Cody should not suggest anything that starts with Human here (or anywhere)
  4. You should still get suggestions from Cody in other appropriate places

Copy link
Member

@valerybugakov valerybugakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks logical and solves the issue we found, but I wonder if it affects the output unexpectedly (like when we found out that Claude doesn't like trailing spaces). Did you have a chance to run this change against our completions dataset?

@philipp-spiess
Copy link
Contributor

Agree with Valery. I’m a bit concerned too about shipping this so shortly before the release. Maybe as a quick fix we can add a filter for completions that start with Human: from Anthropic and then we can land this after the release and test it a bit more?

Unrelated but instead of \n<--End of code--> did you ever try to wrap everything in an xml tag like so?

<code>${infillPrefix}${OPENING_CODE_TAG}${CLOSING_CODE_TAG}${infillSuffix}</code>`

@abeatrix
Copy link
Contributor Author

abeatrix commented Oct 3, 2023

Agree with Valery. I’m a bit concerned too about shipping this so shortly before the release. Maybe as a quick fix we can add a filter for completions that start with Human: from Anthropic and then we can land this after the release and test it a bit more?

Unrelated but instead of \n<--End of code--> did you ever try to wrap everything in an xml tag like so?

<code>${infillPrefix}${OPENING_CODE_TAG}${CLOSING_CODE_TAG}${infillSuffix}</code>`

I tried that at the beginning but couldn't get it to work, I'm planning to spend some more time later to see if we can improve the prompt later, but for now I am enclosing the prompt with backticks like we do in Chat. I run the test suite and it seems like adding the {infillBlock} between the XML tags works better, but since this is LLM I think the output is going to be slightly different anyway. Let me know if you think we should remove the ${infillBlock} from the Human prompt and just enclose the code with backticks for now. This at least would solve the issue where Claude doesn't know if the code snippet has ended or not 😄

@abeatrix
Copy link
Contributor Author

abeatrix commented Oct 3, 2023

as discussed with @philipp-spiess on slack, we will merge this fix and make additional changes in patches if required.

@abeatrix abeatrix merged commit 9602794 into main Oct 3, 2023
12 checks passed
@abeatrix abeatrix deleted the bee/fix-preamble-leak branch October 3, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete: preamble leak bug
4 participants