-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
- Loading branch information
Showing
11 changed files
with
689 additions
and
184 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
trl == 0.8.6 | ||
peft == 0.6.2 | ||
trl == 0.9.6 | ||
peft == 0.12.0 | ||
datasets == 2.19.2 | ||
tyro | ||
evaluate | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from .models.modeling_base import adapt_PreTrainedModelWrapper_to_gaudi | ||
from .models.modeling_sd_base import GaudiDefaultDDPOStableDiffusionPipeline | ||
from .trainer.ddpo_trainer import GaudiDDPOTrainer | ||
from .trainer.dpo_config import GaudiDPOConfig | ||
from .trainer.dpo_trainer import GaudiDPOTrainer | ||
from .trainer.ppo_config import GaudiPPOConfig | ||
from .trainer.ppo_trainer import GaudiPPOTrainer | ||
from .trainer.reward_trainer import GaudiRewardTrainer, RewardDataCollatorWithPadding | ||
from .trainer.sft_config import GaudiSFTConfig | ||
from .trainer.sft_trainer import GaudiSFTTrainer |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2022 The HuggingFace Team. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from dataclasses import dataclass | ||
from typing import Dict, Literal, Optional | ||
|
||
from trl.trainer.dpo_config import FDivergenceType | ||
|
||
from ... import GaudiTrainingArguments | ||
|
||
|
||
@dataclass | ||
class GaudiDPOConfig(GaudiTrainingArguments): | ||
r""" | ||
Initialize GaudiDPOConfig. | ||
Adapted from https://github.com/huggingface/trl/blob/v0.9.6/trl/trainer/dpo_config.py#L33 | ||
- inherit from GaudiTrainingArguments | ||
""" | ||
|
||
beta: float = 0.1 | ||
label_smoothing: float = 0 | ||
loss_type: Literal[ | ||
"sigmoid", "hinge", "ipo", "bco_pair", "sppo_hard", "nca_pair", "robust", "aot", "aot_pair", "exo_pair" | ||
] = "sigmoid" | ||
label_pad_token_id: int = -100 | ||
padding_value: Optional[int] = None | ||
truncation_mode: str = "keep_end" | ||
max_length: Optional[int] = None | ||
max_prompt_length: Optional[int] = None | ||
max_target_length: Optional[int] = None | ||
is_encoder_decoder: Optional[bool] = None | ||
disable_dropout: bool = True | ||
generate_during_eval: bool = False | ||
precompute_ref_log_probs: bool = False | ||
dataset_num_proc: Optional[int] = None | ||
model_init_kwargs: Optional[Dict] = None | ||
ref_model_init_kwargs: Optional[Dict] = None | ||
model_adapter_name: Optional[str] = None | ||
ref_adapter_name: Optional[str] = None | ||
reference_free: bool = False | ||
force_use_ref_model: bool = False | ||
f_divergence_type: Optional[FDivergenceType] = FDivergenceType.REVERSE_KL | ||
f_alpha_divergence_coef: Optional[float] = 1.0 | ||
sync_ref_model: bool = False | ||
ref_model_mixup_alpha: float = 0.9 | ||
ref_model_sync_steps: int = 64 | ||
rpo_alpha: Optional[float] = None | ||
|
||
def __post_init__(self): | ||
if self.loss_type == "kto_pair": | ||
raise ValueError("Support for kto_pair has been removed in DPOTrainer. Please use KTOTrainer.") | ||
return super().__post_init__() |
Oops, something went wrong.