CursorJacob JacksonProblem & solution
Character Prefix Conditioning
Summary
The post poses a problem in code completion: generating a language-model completion that begins with the characters already typed by the user. Because modern models process token sequences rather than characters, naively tokenizing the input can produce the wrong result when the cursor falls inside a token. It introduces character prefix conditioning, defined as sampling tokens from an autoregressive distribution while constraining their decoded character string to start with the given prefix. The challenge is to construct an efficient autoregressive algorithm for this conditional distribution while minimizing calls to the original language model; the post requests either an algorithm description or an implementation.
Context
Code completion should begin with the user's typed characters, but language models operate on token sequences. Naive tokenization gives incorrect results when the cursor does not align with a token boundary.
Takeaways
Character prefix conditioning samples a token sequence conditional on a prefix of characters rather than a prefix of tokens.
The sampled token sequence must decode to a character string beginning with the user's supplied prefix.
The requested algorithm should sample autoregressively while minimizing calls to the original language model.
Source and freshness
- Source
- cursor.com
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.