| 1 | --- |
| 2 | title: "How Autocomplete Works in Continue" |
| 3 | sidebarTitle: "How Autocomplete Works" |
| 4 | description: "Understand how Continue's autocomplete works, including timing optimization, context retrieval from your codebase, and filtering to improve AI code suggestions." |
| 5 | --- |
| 6 | |
| 7 | ## Timing Optimization for Autocomplete |
| 8 | |
| 9 | In order to display suggestions quickly, without sending too many requests, we do the following: |
| 10 | |
| 11 | - Debouncing: If you are typing quickly, we won't make a request on each keystroke. Instead, we wait until you have finished. |
| 12 | - Caching: If your cursor is in a position that we've already generated a completion for, this completion is reused. For example, if you backspace, we'll be able to immediately show the suggestion you saw before. |
| 13 | |
| 14 | ## Context Retrieval from Your Codebase |
| 15 | |
| 16 | Continue uses a number of retrieval methods to find relevant snippets from your codebase to include in the prompt. |
| 17 | |
| 18 | ## Filtering and Post-Processing AI Suggestions |
| 19 | |
| 20 | Language models aren't perfect, but can be made much closer by adjusting their output. We do extensive post-processing on responses before displaying a suggestion, including: |
| 21 | |
| 22 | - Removing special tokens |
| 23 | - Stopping early when regenerating code to avoid long, irrelevant output |
| 24 | - Fixing indentation for proper formatting |
| 25 | - Occasionally discarding low-quality responses, such as those with excessive repetition |
| 26 | |
| 27 | You can learn more about how it works in the [Autocomplete deep dive](/customization/models#autocomplete). |
| 28 | |
| 29 | <Info> |
| 30 | **Looking for AI that predicts your next changes or additions?** Check out |
| 31 | [Next Edit](/features/autocomplete/next-edit), an experimental feature that |
| 32 | proactively suggests code changes before you even start typing, going beyond |
| 33 | traditional autocomplete to anticipate entire code modifications. |
| 34 | </Info> |