Repository navigation
Fix distillation spans dropped beside punctuation - #406
Merged
Merged
Conversation
Pseudo-label alignment used str.split, which keeps commas and periods on the word. Spans predicted on the model's own tokens then matched no word and were left out of the fine-tune set. Co-authored-by: Cursor <cursoragent@cursor.com>
Collaborator
|
Hi @GPT-AGI , thanks for fixing it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
compress_prompt_embeddings(..., distill=True)turns character spans from inference into word indexes withstr.split(). That keeps punctuation on the word (Honolulu,,Hawaii.). Inference tokenizes with the model word splitter, which separates the comma and the period, so the predicted spans match neither split word and are omitted from the fine-tune set.The usage docs generate those pseudo-labels from sentences such as "Barack Obama was born in Honolulu, Hawaii."
What changed
Word boundaries now come from
data_processor.words_splitter, the same splitter inference uses. A span is kept when its stripped character range lands on those token bounds.predict_entitiesoutput is unchanged. Only the training examples built fordistill=Truechange, and only their word tokenization.How verified
Python 3.12, from the clone:
2 passed. Ruff reported no issues. The same sentence now yields
ner == [(2, 2, "location"), (4, 4, "location")]on tokens["Born", "in", "Honolulu", ",", "Hawaii", "."].