-
Notifications
You must be signed in to change notification settings - Fork 213
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
Autocomplete: Fix retrieval hints #2652
Conversation
totalFileContextChars: Math.floor(tokensToChars(0.9 * maxContextTokens)), // keep 10% margin for preamble, etc. | ||
prefixChars: Math.floor(tokensToChars(0.6 * maxContextTokens)), | ||
suffixChars: Math.floor(tokensToChars(0.1 * maxContextTokens)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow this doesn't add up to 100% haha, let me run some more tests to make sure this still works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR descriptions with my findings. This was a fun one!
…into ps/fix-retrieval-hints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find!
I noticed that the context size hints returned values suffixed with
chars
but one of the values was not going through the sametokensToChars
estimation.This value was used by the context mixer and the retrieval strategies. Luckily, the Jaccard similarity strategy was not using that value. However, the context mixer was likely truncating results because of this, so I would suspect this to increase the average context length a bit (which could have a negative impact on performance). However there was another bug that counter-acted this change a bit. The previous
totalFileContextChars
was used to only count the additional code snippets (so excluding prefix and suffix) while the documentation said that this number is inclusive.Also, the actual truncation happens at the prompt level and is unaffected by these hints. These only tell the context retriever how much context it should retrieve.
Some math shows us that the actual difference is not big:
Before:
After:
So yeah, almost the same 😅
However, with the new change, if fewer actual suffix or prefix characters are used, we will retrieve more context to fill up the window (which IMO is a good thing)
Test plan