Repository navigation
fix(fine_tuning): fix gliclass's few-shot segment tags and rerun - #37
Merged
Merged
Conversation
gliclass 0.1.22 finds the first example token with argmin instead of argmax in _create_segment_ids, so with examples in the request every token, labels and row included, is tagged as an example. The instruct model few-shot uses reads those tags. recipe.py now replaces that one function; selfcheck.py checks the tags. Rerun on the same rows: few-shot goes from 26.0% to 57.3% on Banking77 and from 15.0% to 16.7% on the parser set, still below zero-shot (67.3%, 30.0%). Zero-shot and fine-tuned are unchanged. Through SIE, the 630 zero-shot and fine-tuned decisions still match within 0.0001; few-shot doesn't, because SIE's adapter copies gliclass's tags as they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README's "shuffled 39.3%" came from an unrecorded shuffle. Ten seeded shuffles (random.Random(0..9)) of the six Banking77 examples score 20.0% to 69.3% (seed 1 is the 39.3%); say that, and that the best order edges past zero-shot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fix - Say the best few-shot order edges past the edge model's zero-shot. - Drop a stock phrase. - Link SIE's segment_ids(), which uses the same argmin, so the claim that SIE copies the bug is checkable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
Self-reviewTwo passes, code and security, since the diff is 77 lines in 3 files. No Critical or Important findings, and the security pass found nothing. Checked:
Suggestions (3, all fixed in 5fe91de):
One change before the review: the README said a shuffled example order scored 39.3%, from a shuffle that wasn't recorded. Ten seeded shuffles ( |
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
gliclass 0.1.22's
_create_segment_ids(gliclass/model.py) finds the first few-shot example token withargmininstead ofargmax. That returns position 0, so whenever a request includes examples, every token (labels and the row too) is tagged as an example. Only models withuse_segment_embeddingsread these tags. The instruct edge model, which few-shot uses, does;gliclass-edge-v3.0doesn't, so zero-shot and fine-tuning are unaffected.recipe.pyreplaces that one function withsegment_ids(), which tags the input as labels (0), the row (1) and examples (2), as gliclass intends.selfcheck.pychecks the tags on hand-written token ids.Results, re-run on the same rows
Few-shot still scores below zero-shot, and on Banking77 it depends heavily on the order of the examples. Ten seeded shuffles of the same six examples score anywhere from 20.0% to 69.3%. Without the prompt it scores 36.7%. Two examples per label score 55.3%, and three per label 28.7%.
Through SIE: the 630 zero-shot and fine-tuned decisions still match the local run within 0.0001. Few-shot doesn't, because SIE's GLiClass adapter copies gliclass's segment tags as they are, bug included. This is worth fixing upstream in SIE.
Tested
I re-ran every number above myself on this branch:
recipe.py, and the order, prompt and example-count probes.selfcheck.py(with the new segment-tag check), ruff, mypy--strictandcheck_tree.pypass.🤖 Generated with Claude Code