Skip to content
Merged
Show file tree
Hide file tree
Changes from 136 commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
6983b6f
Pin the distillation objective before refactoring
qgallouedec Jul 19, 2026
d443d3b
Pin on-policy and off-policy training end to end
qgallouedec Jul 19, 2026
a8bb14c
Document the num_items_in_batch denominator bug
qgallouedec Jul 19, 2026
98eef79
Move IW-OPD to a dedicated experimental trainer
qgallouedec Jul 19, 2026
b65f8a7
Extract the teacher-server path into ServerDistillationTrainer
qgallouedec Jul 19, 2026
f75cd7e
Remove the local sparse top-1 loss path from the base trainer
qgallouedec Jul 19, 2026
6458636
Remove top-k support from the base generalized JSD loss
qgallouedec Jul 19, 2026
166808b
Validate the teacher by vocab size instead of tokenizer identity
qgallouedec Jul 19, 2026
952b0c3
Deprecate `lmbda` on/off-policy mixing
qgallouedec Jul 19, 2026
55e5973
Point the GKD paper reproduction at GKDTrainer
qgallouedec Jul 19, 2026
0b72a4e
Remove `lmbda` and the off-policy training branch
qgallouedec Jul 19, 2026
2527d3d
style
qgallouedec Jul 20, 2026
1c5bdea
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
f232c18
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
7aab597
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
6efeb9f
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
0a4a3d6
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
5eabac4
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
aa0b5fb
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
e058764
style
qgallouedec Jul 20, 2026
4c65faf
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
3500348
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
de167a9
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
1908e5f
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
5a4f715
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
f270c1f
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
456df91
Fix IW-OPD paper metadata used in the model card
qgallouedec Jul 20, 2026
9ecf348
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
28382eb
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
c4acfb4
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
d95c977
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
f64f96c
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
614bb6b
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
5cd0e91
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
26038dd
Remove stale on/off-policy comments after the off-policy removal
qgallouedec Jul 20, 2026
3515b22
Accept a `prompt` column alongside `messages`
qgallouedec Jul 20, 2026
4e5d06f
Accept a `prompt` column alongside `messages`
qgallouedec Jul 20, 2026
dfbf0e5
style
qgallouedec Jul 20, 2026
89494f2
Relax self-distillation train-loss assertion to tolerate fp noise
qgallouedec Jul 20, 2026
9b5ad81
Fix server-config construction to only copy dataclass init fields
qgallouedec Jul 20, 2026
d616372
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
1341b51
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
33667d3
Merge branch 'main' into 01-pin-distillation-objective
qgallouedec Jul 20, 2026
041e337
Merge branch '01-pin-distillation-objective' into 02-pin-on-and-off-p…
qgallouedec Jul 20, 2026
9e989d1
Merge branch '02-pin-on-and-off-policy-training' into 03-document-num…
qgallouedec Jul 20, 2026
b2c2b73
Merge branch '03-document-num-items-in-batch-bug' into 04-move-iw-opd
qgallouedec Jul 20, 2026
97cb164
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
7db5120
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
2d2d32f
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
e63069d
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
e4764cc
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
800b68b
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
b290c1a
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
cad0c5e
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
c978997
0.5 -> 0.25
qgallouedec Jul 20, 2026
acc70cc
Merge branch 'main' into 01-pin-distillation-objective
qgallouedec Jul 20, 2026
854d89d
Merge branch '01-pin-distillation-objective' into 02-pin-on-and-off-p…
qgallouedec Jul 20, 2026
b9f99f1
Diverge the teacher in the on/off-policy param-update pin
qgallouedec Jul 20, 2026
911b0e5
Merge branch 'main' into 01-pin-distillation-objective
qgallouedec Jul 20, 2026
6e8a528
Merge branch '01-pin-distillation-objective' into 02-pin-on-and-off-p…
qgallouedec Jul 20, 2026
fd67ed4
Merge branch '02-pin-on-and-off-policy-training' into 03-document-num…
qgallouedec Jul 20, 2026
a4831c6
Merge branch '03-document-num-items-in-batch-bug' into 04-move-iw-opd
qgallouedec Jul 20, 2026
222615d
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
15a7f6f
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
34e801a
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
0a79977
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
cff3b68
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
1f8690a
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
4871948
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
8057ca4
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
a0d5328
Merge branch 'main' into 02-pin-on-and-off-policy-training
qgallouedec Jul 20, 2026
f750ddd
Merge branch '02-pin-on-and-off-policy-training' into 03-document-num…
qgallouedec Jul 20, 2026
d0d7de3
Merge branch '03-document-num-items-in-batch-bug' into 04-move-iw-opd
qgallouedec Jul 20, 2026
e8ac1df
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
0b4fa84
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
b4f7d75
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
f7d9dc8
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
5914158
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
b8f85a4
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
1492b20
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
d8892e4
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
26eba3c
remove unused import
qgallouedec Jul 20, 2026
f51acd6
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
0462f03
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
ce31b5d
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
989ae4d
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
15e24cc
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
3cbd70f
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
24b235c
Merge remote-tracking branch 'origin/main' into pr/qgallouedec/6452
qgallouedec Jul 20, 2026
5e05b9d
Rework the num_items_in_batch xfail: applied denominator, on-policy
qgallouedec Jul 20, 2026
23784c3
Use a non-strict xfail for the num_items_in_batch pin
qgallouedec Jul 20, 2026
7615bfe
Merge branch '03-document-num-items-in-batch-bug' into 04-move-iw-opd
qgallouedec Jul 20, 2026
82a2017
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
3eaabc7
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
4d9ac2b
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
e881f07
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
7632074
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
4b3c62a
Merge branch 'main' into 04-move-iw-opd
qgallouedec Jul 20, 2026
685d3f5
Merge branch '04-move-iw-opd' into 05-extract-server-distillation
qgallouedec Jul 20, 2026
7bf9d07
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
40f96ed
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
40ee117
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
821d875
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
9ad8c2a
Merge remote-tracking branch 'origin/main' into pr/qgallouedec/6454
qgallouedec Jul 20, 2026
fc5b481
Merge branch '05-extract-server-distillation' into 06-remove-local-sp…
qgallouedec Jul 20, 2026
6f8c4a7
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
59a804d
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
f23fc4f
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
d3be590
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
ba3aa35
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
a41d5df
Merge remote-tracking branch 'origin/main' into pr/qgallouedec/6455
qgallouedec Jul 20, 2026
f069c1e
Merge branch '06-remove-local-sparse-top1' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
58c13be
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
01b6f67
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
3faa04b
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
1375800
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
43c42f4
Merge remote-tracking branch 'origin/11-remove-lmbda-offpolicy' into …
qgallouedec Jul 20, 2026
1a58484
Merge remote-tracking branch 'origin/main' into 07-remove-topk-from-jsd
qgallouedec Jul 20, 2026
45fdb23
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
0bca659
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
939143d
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
0a08547
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
901b155
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
93f6f55
Drop the loss_top_k usage-tips bullet from the docs
qgallouedec Jul 20, 2026
dc4c01b
Merge branch '07-remove-topk-from-jsd' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
356eaab
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
bca4b35
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
825de01
Merge branch 'main' into 08-teacher-vocab-validation
qgallouedec Jul 20, 2026
6d09aa1
Merge branch '08-teacher-vocab-validation' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
5b99699
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
e185842
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
4365c60
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
94a185d
Merge branch 'main' into 09-deprecate-lmbda
qgallouedec Jul 20, 2026
e9365a6
Merge branch '09-deprecate-lmbda' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
a320f99
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
16ec8c3
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
8567f94
Merge branch 'main' into 10-move-gkd-paper-repro
qgallouedec Jul 20, 2026
9ef74d9
Merge branch '10-move-gkd-paper-repro' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
109333e
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
782f088
Merge branch 'main' into 11-remove-lmbda-offpolicy
qgallouedec Jul 20, 2026
88795b0
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
ddcb836
Drop leftover lmbda=1.0 from the num_items xfail test
qgallouedec Jul 20, 2026
d36d174
Merge branch '11-remove-lmbda-offpolicy' into 12-accept-prompt-column
qgallouedec Jul 20, 2026
71883b9
Merge remote-tracking branch 'origin/main' into 12-accept-prompt-column
qgallouedec Jul 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/source/paper_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1634,21 +1634,21 @@ Papers relating to training a student model with the help of a teacher model.

**📜 Paper**: https://huggingface.co/papers/2306.13649

Introduces Generalized Knowledge Distillation (GKD), which addresses distribution mismatch in KD for auto-regressive models by training the student on its own generated outputs with teacher feedback, instead of a fixed set of sequences. GKD supports flexible loss functions (e.g. beyond KL when the student cannot match the teacher) and integrates with RL fine-tuning (RLHF). The paper reports results on summarization, translation, arithmetic reasoning, and instruction-tuning. Used in TRL via [`experimental.distillation.DistillationTrainer`] and [`experimental.gkd.GKDTrainer`]. To reproduce the paper's setting, use this configuration:
Introduces Generalized Knowledge Distillation (GKD), which addresses distribution mismatch in KD for auto-regressive models by training the student on its own generated outputs with teacher feedback, instead of a fixed set of sequences. GKD supports flexible loss functions (e.g. beyond KL when the student cannot match the teacher) and integrates with RL fine-tuning (RLHF). The paper reports results on summarization, translation, arithmetic reasoning, and instruction-tuning. Used in TRL via [`experimental.gkd.GKDTrainer`], which exposes the paper's on/off-policy mixing (`lmbda`). [`experimental.distillation.DistillationTrainer`] implements the same generalized-JSD objective for the always-on-policy case. To reproduce the paper's setting, use this configuration:

```python
from trl.experimental.distillation import DistillationConfig
from trl.experimental.gkd import GKDConfig

# XSum summarization task (Table A.1 of the paper)
training_args = DistillationConfig(
training_args = GKDConfig(
lmbda=0.5, # λ student data fraction (Section 3 of the paper)
beta=0.5, # β Generalized JSD interpolation, 0=KL, 1=reverse KL (Section 3 of the paper)
temperature=1.0, # student training temperature (Appendix A of the paper)
max_steps=40000, # training steps (Table A.1 of the paper)
learning_rate=3e-4, # learning rate (Table A.1 of the paper)
per_device_train_batch_size=32, # batch size (Table A.1 of the paper)
warmup_steps=2000, # warm-up steps (Table A.1 of the paper)
max_completion_length=64, # max output tokens (Table A.1 of the paper)
max_new_tokens=64, # max output tokens (Table A.1 of the paper)
)
```

Expand Down
34 changes: 24 additions & 10 deletions tests/experimental/test_distillation_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ def _make_args(self, **kwargs):
"disable_tqdm": True,
"use_cpu": True,
"bf16": False,
"lmbda": 0.0,
"max_length": 128,
"max_completion_length": 32,
"model_init_kwargs": {"dtype": "float32", "device_map": None},
Expand Down Expand Up @@ -254,17 +253,11 @@ def test_distillation_trainer_train_runs_with_local_teacher(self):
assert train_result.metrics["train_loss"] >= -1e-4
assert "model.safetensors" in os.listdir(self.tmp_dir + "/checkpoint-2")

@pytest.mark.parametrize("lmbda", [0.0, 1.0])
def test_train_updates_params_on_and_off_policy(self, lmbda):
"""Pin both policy modes end to end before `lmbda` is removed.

`lmbda=0.0` trains on the dataset's own completions, `lmbda=1.0` on completions the student generates. The
trainer is scheduled to become always-on-policy, so the off-policy case is pinned here to make its removal a
deliberate deletion rather than a silent one.
"""
def test_train_updates_params(self):
"""Training is always on-policy: the student generates completions, the teacher scores them, params move."""
# Higher lr than the default: gradients are tiny on this model and the default lr can stall the update, which
# would make the assertion below vacuous.
trainer = self._make_local_trainer(lmbda=lmbda, max_steps=2, learning_rate=0.1)
trainer = self._make_local_trainer(max_steps=2, learning_rate=0.1)

# Diverge the teacher from the student so the divergence (and thus the gradient) is well above fp noise; with
# matched weights it would be ~0 and the update below could pass on noise alone.
Expand All @@ -281,6 +274,27 @@ def test_train_updates_params_on_and_off_policy(self, lmbda):
for name, param in previous_params.items():
assert not torch.equal(param, trainer.model.get_parameter(name)), f"Parameter {name} has not changed."

@pytest.mark.xfail(
strict=True,
reason="Prompt-only datasets carry no dataset-completion tokens, so num_items_in_batch (counted from the raw "
"dataloader labels before on-policy generation replaces them) is 0 and the loss is sum / 0 = NaN. Un-xfail "
"when the num_items_in_batch denominator is fixed (plan 5.6).",
)
def test_train_runs_with_prompt_only_dataset(self):
"""The forward-looking prompt-only format should train end to end once the loss denominator is fixed."""
dataset = load_dataset("trl-internal-testing/zen", "conversational_prompt_only", split="train")
trainer = DistillationTrainer(
model=self.model_id,
teacher_model=self.model_id,
args=self._make_args(max_steps=1, learning_rate=0.1),
train_dataset=dataset,
processing_class=self.tokenizer,
)

trainer.train()

assert all(torch.isfinite(param).all() for param in trainer.model.parameters())
Comment thread
cursor[bot] marked this conversation as resolved.

@pytest.mark.xfail(
reason="On-policy, num_items_in_batch is computed by transformers from the raw dataloader labels before "
"generation replaces the completions, and _RepeatBatchDataLoader repeats one generation batch across the "
Expand Down
1 change: 0 additions & 1 deletion tests/experimental/test_server_distillation_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def _run_one_step(self, bs, ga, monkeypatch):
teacher_model_server_url="http://fake-teacher.invalid:8000",
loss_top_k=1,
beta=1.0,
lmbda=0.0,
loss_add_tail=True,
save_strategy="no",
report_to="none",
Expand Down
21 changes: 0 additions & 21 deletions trl/experimental/distillation/distillation_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import warnings
from dataclasses import dataclass, field
from typing import Any

Expand Down Expand Up @@ -50,9 +49,6 @@ class DistillationConfig(_BaseConfig):
temperature (`float`, *optional*, defaults to `1.0`):
Temperature for sampling during generation and for computing the distillation loss. Higher values produce
softer probability distributions.
lmbda (`float`, *optional*, defaults to `1.0`):
Probability of using on-policy (student-generated) data for each gradient accumulation slice. A value of
`0.0` means fully off-policy (dataset completions only), `1.0` means fully on-policy.
beta (`float`, *optional*, defaults to `1.0`):
Interpolation coefficient for the Generalized Jensen-Shannon Divergence loss. When `0.0`, the loss is the
forward KL divergence. When `1.0`, the loss is the reverse KL divergence. When `0.5`, it is the standard
Expand Down Expand Up @@ -165,13 +161,6 @@ class DistillationConfig(_BaseConfig):
"help": "Temperature for sampling and loss computation. Higher values produce softer distributions."
},
)
lmbda: float = field(
default=1.0,
metadata={
"help": "Probability of using on-policy (student-generated) data per gradient accumulation slice. "
"0.0 = fully off-policy, 1.0 = fully on-policy."
},
)
beta: float = field(
default=1.0,
metadata={
Expand Down Expand Up @@ -314,8 +303,6 @@ class DistillationConfig(_BaseConfig):
def __post_init__(self):
super().__post_init__()

if self.lmbda < 0.0 or self.lmbda > 1.0:
raise ValueError(f"lmbda must be in [0.0, 1.0], got {self.lmbda}.")
if self.beta < 0.0 or self.beta > 1.0:
raise ValueError(f"beta must be in [0.0, 1.0], got {self.beta}.")

Expand All @@ -342,11 +329,3 @@ def __post_init__(self):
f"gradient_accumulation_steps. Got {self.generation_batch_size} * {self.num_generations} != "
f"{self.per_device_train_batch_size} * {self.gradient_accumulation_steps}."
)

if self.num_generations > 1 and self.lmbda < 1.0:
warnings.warn(
f"num_generations={self.num_generations} with lmbda={self.lmbda} means off-policy batches include "
f"{self.num_generations} copies of each sample. Consider lmbda=1.0 when num_generations > 1.",
UserWarning,
stacklevel=2,
)
Loading
Loading