Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversational dataset support for KTOTrainer #2248

Merged
merged 19 commits into from
Oct 24, 2024
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
add num_items_in_batch=None
qgallouedec committed Oct 18, 2024
commit ada53cfa157bae50154d1c26d3d5f5a5e98803ea
1 change: 1 addition & 0 deletions trl/trainer/bco_trainer.py
Original file line number Diff line number Diff line change
@@ -1260,6 +1260,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
if not self.use_dpo_data_collator:
warnings.warn(
1 change: 1 addition & 0 deletions trl/trainer/cpo_trainer.py
Original file line number Diff line number Diff line change
@@ -828,6 +828,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
if not self.use_dpo_data_collator:
warnings.warn(
1 change: 1 addition & 0 deletions trl/trainer/dpo_trainer.py
Original file line number Diff line number Diff line change
@@ -1547,6 +1547,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
compute_loss_context_manager = amp.autocast("cuda") if self._peft_has_been_casted_to_bf16 else nullcontext()
with compute_loss_context_manager:
2 changes: 1 addition & 1 deletion trl/trainer/gkd_trainer.py
Original file line number Diff line number Diff line change
@@ -215,7 +215,7 @@ def generalized_jsd_loss(
else:
return jsd

def compute_loss(self, model, inputs, return_outputs=False):
def compute_loss(self, model, inputs, return_outputs=False, num_items_in_batch=None):
# compute student output
outputs_student = model(
input_ids=inputs["input_ids"],
1 change: 1 addition & 0 deletions trl/trainer/kto_trainer.py
Original file line number Diff line number Diff line change
@@ -1234,6 +1234,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
if not self.use_dpo_data_collator:
warnings.warn(
1 change: 1 addition & 0 deletions trl/trainer/orpo_trainer.py
Original file line number Diff line number Diff line change
@@ -844,6 +844,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
if not self.use_dpo_data_collator:
warnings.warn(
1 change: 1 addition & 0 deletions trl/trainer/reward_trainer.py
Original file line number Diff line number Diff line change
@@ -266,6 +266,7 @@ def compute_loss(
model: Union[PreTrainedModel, nn.Module],
inputs: Dict[str, Union[torch.Tensor, Any]],
return_outputs=False,
num_items_in_batch=None,
) -> Union[torch.Tensor, Tuple[torch.Tensor, Dict[str, torch.Tensor]]]:
if not self.use_reward_data_collator:
warnings.warn(