Skip to content

Keep unprompted same-dataset training text unchanged - #1628

Open
Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/optional-training-instructions-20261112
Open

Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/optional-training-instructions-20261112

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

Same-dataset training always formats the query instruction even when query_instruction_for_retrieval is left at its default None. With the default format, a query becomes None<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 --check passes.

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant