-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Token healing (under 40 LOC) #28346
Comments
FYI @gante |
@Ayenem that's a really cool use of Would you be up for adding it to |
I'm glad you appreciate this use of your feature! Hyrum's law at play :) Sounds good, I'll get started on a dev branch. Thanks for the pointer! |
Hi @Ayenem 👋 I noticed you closed your latest PR. Is there anything we can help you with? 🤗 |
Hi @gante thanks for the follow-up! I deleted my branch because it was becoming a mess and it automatically closed this PR. I didn't think about it but it makes sense. I think I'll just open a new PR when my changes are done. I've been working on removing the dependency to pygtrie by adding functionality to HF's Trie. I've implemented it in my repo and it works. I added my changes to I commented out the entire Trie in I'll retry from scratch with a new PR 😅 EDIT: So whenever I add new tests to EDIT 2: EDIT 3: |
Feature request
Token healing rectifies the token boundary bias in greedy tokenization. It does this by trimming and regrowing the prompt to better align with the model's tokenizer, thus enhancing generation quality. The improvement is clearest with completion models.
Token boundary bias is a silent performance killer that doesn't seem very well known. It has clear impact on completion quality, though I'm not sure where it would fit as a transformers feature.
A more thorough explanation of the problem: The Art of Prompt Design: Prompt Boundaries and Token Healing | by Scott Lundberg.
Motivation
Given a completion prompt with a partial url ending with
:
, the model might have seen the expected completion://
as a single token in training. However, the prompt's tail token:
tells it that the next token is not//
, and so it generates a wrong completion. Such errors compound in auto-regressive language models.Your contribution
My implementation (under 40 LOC): https://github.com/Ayenem/TokenHealer/tree/main
The text was updated successfully, but these errors were encountered: