Repository navigation
Conversation
This branch has not been deployed
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.
Problem
Same-dataset training always formats the query instruction even when
query_instruction_for_retrievalis left at its defaultNone. With the default format, a query becomesNone<query text>. Symmetric STS/clustering passages receive the same unintended prefix, and the ICL dataset repeats the behavior before tokenization. This introduces training text that is absent from the unprompted inference path.The defect was found through code inspection and reproduced using the normal dataset constructors, local JSONL training data and a real local tokenizer.
Change
Only format a resolved instruction when it is not
None, for both base and ICL same-dataset training. Preserve explicit empty-string instructions, configured formats, per-row overrides, passage instructions on retrieval tasks and the ICL suffix/truncation behavior.Validation
PYTHONPATH=. python -m pytest tests/test_finetune_optional_instructions.py tests/test_finetune_trainer_compat.py -q --tb=short: 28 passed.The 24 new cases produce 6 failures and 18 passes on unchanged master, then all pass with this patch. They cover the base and ICL datasets, retrieval/STS/clustering data, absent/global/per-row/empty instructions, queries and passages, and teacher-score/negative-group controls. No mocked package imports or pretrained downloads are used. The four existing trainer compatibility tests also pass. The new test file passes Ruff check and formatting;
git diff --checkpasses.Validation used Python 3.12.14, PyTorch 2.15.0+cpu, Transformers 4.57.1 and Datasets 5.0.1. This verifies dataset text preparation; it does not claim retrieval-quality or GPU-training gains.