# Reward Modeling

[![](https://img.shields.io/badge/All_models-Reward_Trainer-blue)](https://huggingface.co/models?other=reward-trainer,trl)

TRL supports custom reward modeling for anyone to perform reward modeling on their dataset and model.

Check out a complete flexible example at [`examples/scripts/reward_modeling.py`](https://github.com/huggingface/trl/tree/main/examples/scripts/reward_modeling.py).

## Expected dataset type

The [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer) requires a [*implicit prompt* preference dataset](dataset_formats#preference). It means that the dataset should only contain the columns `"chosen"` and `"rejected"` (and not `"prompt"`).
The [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer) supports both [conversational](dataset_formats#conversational) and [standard](dataset_formats#standard) dataset format. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset.

You can also use a pretokenized dataset, in which case the dataset should contain the following columns: `input_ids_chosen`, `attention_mask_chosen`, `input_ids_rejected` and `attention_mask_rejected`.

## Using the `RewardTrainer`

After preparing your dataset, you can use the [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer) in the same way as the `Trainer` class from 🤗 Transformers.
You should pass an `AutoModelForSequenceClassification` model to the [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer), along with a [RewardConfig](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardConfig) which configures the hyperparameters of the training.

### Leveraging 🤗 PEFT to train a reward model

Just pass a `peft_config` in the keyword arguments of [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer), and the trainer should automatically take care of converting the model into a PEFT model!

```python
from peft import LoraConfig, TaskType
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from trl import RewardTrainer, RewardConfig

model = AutoModelForSequenceClassification.from_pretrained("gpt2")
peft_config = LoraConfig(
    task_type=TaskType.SEQ_CLS,
    inference_mode=False,
    r=8,
    lora_alpha=32,
    lora_dropout=0.1,
)

...

trainer = RewardTrainer(
    model=model,
    args=training_args,
    processing_class=tokenizer,
    train_dataset=dataset,
    peft_config=peft_config,
)

trainer.train()

```

### Adding a margin to the loss

As in the [Llama 2 paper](https://huggingface.co/papers/2307.09288), you can add a margin to the loss by adding a `margin` column to the dataset. The reward collator will automatically pass it through and the loss will be computed accordingly.

```python
def add_margin(row):
    # Assume you have a score_chosen and score_rejected columns that you want to use to compute the margin
    return {'margin': row['score_chosen'] - row['score_rejected']}

dataset = dataset.map(add_margin)
```

### Centering rewards

In many scenarios, it's preferable to ensure that a reward model's output is mean zero. This is often done by first calculating the model's average score and then subtracting it.

[[Eisenstein et al., 2023]](https://huggingface.co/papers/2312.09244) proposed an auxiliary loss function designed to directly learn a centered reward model. This auxiliary loss minimizes the squared sum of the rewards, encouraging the model to naturally produce mean-zero outputs:

$$\Big( R(p, r_1) + R(p, r_2) \Big)^2 $$

This auxiliary loss is combined with the main loss function, weighted by the parameter `center_rewards_coefficient` in the `[RewardConfig]`. By default, this feature is deactivated (`center_rewards_coefficient = None`).

```python
training_args = RewardConfig(
    center_rewards_coefficient=0.01,
    ...
)
```

For reference results, please refer PR [#1932](https://github.com/huggingface/trl/pull/1932).

## RewardTrainer[[trl.RewardTrainer]]

<div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8">


<docstring><name>class trl.RewardTrainer</name><anchor>trl.RewardTrainer</anchor><source>https://github.com/huggingface/trl/blob/v0.23.1/trl/trainer/reward_trainer.py#L86</source><parameters>[{"name": "model", "val": ": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module, NoneType] = None"}, {"name": "args", "val": ": typing.Optional[trl.trainer.reward_config.RewardConfig] = None"}, {"name": "data_collator", "val": ": typing.Optional[typing.Callable[[list[typing.Any]], dict[str, typing.Any]]] = None"}, {"name": "train_dataset", "val": ": typing.Optional[datasets.arrow_dataset.Dataset] = None"}, {"name": "eval_dataset", "val": ": typing.Union[datasets.arrow_dataset.Dataset, dict[str, datasets.arrow_dataset.Dataset], NoneType] = None"}, {"name": "processing_class", "val": ": typing.Union[transformers.tokenization_utils_base.PreTrainedTokenizerBase, transformers.image_processing_utils.BaseImageProcessor, transformers.feature_extraction_utils.FeatureExtractionMixin, transformers.processing_utils.ProcessorMixin, NoneType] = None"}, {"name": "model_init", "val": ": typing.Optional[typing.Callable[[], transformers.modeling_utils.PreTrainedModel]] = None"}, {"name": "compute_metrics", "val": ": typing.Optional[typing.Callable[[transformers.trainer_utils.EvalPrediction], dict]] = None"}, {"name": "callbacks", "val": ": typing.Optional[list[transformers.trainer_callback.TrainerCallback]] = None"}, {"name": "optimizers", "val": ": tuple = (None, None)"}, {"name": "preprocess_logits_for_metrics", "val": ": typing.Optional[typing.Callable[[torch.Tensor, torch.Tensor], torch.Tensor]] = None"}, {"name": "peft_config", "val": ": typing.Optional[dict] = None"}]</parameters><paramsdesc>- **model** ([PreTrainedModel](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/model#transformers.PreTrainedModel) or `torch.nn.Module`, *optional*) --
  Model to be trained, preferably an [AutoModelForSequenceClassification](https://huggingface.co/docs/transformers/v4.57.0/en/model_doc/auto#transformers.AutoModelForSequenceClassification).
- **args** ([RewardConfig](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardConfig), *optional*) --
  Training arguments.
- **data_collator** (`DataCollator`, *optional*) --
  The data collator to use for training. If None is specified, the default data collator
  `RewardDataCollatorWithPadding` will be used which will pad the sequences to the maximum
  length of the sequences in the batch, given a dataset of paired sequences.
- **train_dataset** ([Dataset](https://huggingface.co/docs/datasets/v4.1.1/en/package_reference/main_classes#datasets.Dataset), *optional*) --
  The dataset to use for training.
- **eval_dataset** ([Dataset](https://huggingface.co/docs/datasets/v4.1.1/en/package_reference/main_classes#datasets.Dataset), *optional*) --
  The dataset to use for evaluation.
- **processing_class** ([PreTrainedTokenizerBase](https://huggingface.co/docs/transformers/v4.57.0/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase), [BaseImageProcessor](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/image_processor#transformers.BaseImageProcessor), [FeatureExtractionMixin](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/feature_extractor#transformers.FeatureExtractionMixin) or [ProcessorMixin](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/processors#transformers.ProcessorMixin), *optional*) --
  Processing class used to process the data. If provided, will be used to automatically process the inputs
  for the model, and it will be saved along the model to make it easier to rerun an interrupted training or
  reuse the fine-tuned model.
- **model_init** (`Callable[[], transformers.PreTrainedModel]`, *optional*) --
  The model initializer to use for training. If None is specified, the default model initializer will be
  used.
- **compute_metrics** (`Callable[[transformers.EvalPrediction], dict]`, *optional*, defaults to `compute_accuracy()`) --
  Function to compute metrics at evaluation. Must take in an [EvalPrediction](https://huggingface.co/docs/transformers/v4.57.0/en/internal/trainer_utils#transformers.EvalPrediction) and return a
  dictionary string to float.
- **callbacks** (`list` of [TrainerCallback](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/callback#transformers.TrainerCallback), *optional*) --
  Callbacks to use during training.
- **optimizers** (`tuple` of `torch.optim.Optimizer` and `torch.optim.lr_scheduler.LambdaLR`, *optional*, defaults to `(None, None)`) --
  Tuple containing the optimizer and the learning rate scheduler to use for training.
- **preprocess_logits_for_metrics** (`Callable[[torch.Tensor, torch.Tensor], torch.Tensor]`, *optional*) --
  Function to preprocess the logits before computing the metrics. Must take in the `logits` and `labels` and
  return the logits to be used for metrics computation.
- **peft_config** (`dict`, *optional*) --
  PEFT configuration to use PEFT for training. If `None`, PEFT is not used. If provided, the `model` will be
  wrapped with the specified PEFT adapter.</paramsdesc><paramgroups>0</paramgroups></docstring>

Trainer for custom reward.





<div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8">


<docstring><name>train</name><anchor>trl.RewardTrainer.train</anchor><source>https://github.com/huggingface/trl/blob/v0.23.1/transformers/trainer.py#L2213</source><parameters>[{"name": "resume_from_checkpoint", "val": ": typing.Union[str, bool, NoneType] = None"}, {"name": "trial", "val": ": typing.Union[ForwardRef('optuna.Trial'), dict[str, typing.Any], NoneType] = None"}, {"name": "ignore_keys_for_eval", "val": ": typing.Optional[list[str]] = None"}, {"name": "**kwargs", "val": ": typing.Any"}]</parameters><paramsdesc>- **resume_from_checkpoint** (`str` or `bool`, *optional*) --
  If a `str`, local path to a saved checkpoint as saved by a previous instance of `Trainer`. If a
  `bool` and equals `True`, load the last checkpoint in *args.output_dir* as saved by a previous instance
  of `Trainer`. If present, training will resume from the model/optimizer/scheduler states loaded here.
- **trial** (`optuna.Trial` or `dict[str, Any]`, *optional*) --
  The trial run or the hyperparameter dictionary for hyperparameter search.
- **ignore_keys_for_eval** (`list[str]`, *optional*) --
  A list of keys in the output of your model (if it is a dictionary) that should be ignored when
  gathering predictions for evaluation during the training.
- **kwargs** (`dict[str, Any]`, *optional*) --
  Additional keyword arguments used to hide deprecated arguments</paramsdesc><paramgroups>0</paramgroups></docstring>

Main training entry point.




</div>
<div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8">


<docstring><name>save_model</name><anchor>trl.RewardTrainer.save_model</anchor><source>https://github.com/huggingface/trl/blob/v0.23.1/transformers/trainer.py#L4177</source><parameters>[{"name": "output_dir", "val": ": typing.Optional[str] = None"}, {"name": "_internal_call", "val": ": bool = False"}]</parameters></docstring>

Will save the model, so you can reload it using `from_pretrained()`.

Will only save from the main process.


</div>
<div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8">


<docstring><name>push_to_hub</name><anchor>trl.RewardTrainer.push_to_hub</anchor><source>https://github.com/huggingface/trl/blob/v0.23.1/transformers/trainer.py#L5117</source><parameters>[{"name": "commit_message", "val": ": typing.Optional[str] = 'End of training'"}, {"name": "blocking", "val": ": bool = True"}, {"name": "token", "val": ": typing.Optional[str] = None"}, {"name": "revision", "val": ": typing.Optional[str] = None"}, {"name": "**kwargs", "val": ""}]</parameters><paramsdesc>- **commit_message** (`str`, *optional*, defaults to `"End of training"`) --
  Message to commit while pushing.
- **blocking** (`bool`, *optional*, defaults to `True`) --
  Whether the function should return only when the `git push` has finished.
- **token** (`str`, *optional*, defaults to `None`) --
  Token with write permission to overwrite Trainer's original args.
- **revision** (`str`, *optional*) --
  The git revision to commit from. Defaults to the head of the "main" branch.
- **kwargs** (`dict[str, Any]`, *optional*) --
  Additional keyword arguments passed along to `~Trainer.create_model_card`.</paramsdesc><paramgroups>0</paramgroups><retdesc>The URL of the repository where the model was pushed if `blocking=False`, or a `Future` object tracking the
progress of the commit if `blocking=True`.</retdesc></docstring>

Upload `self.model` and `self.processing_class` to the 🤗 model hub on the repo `self.args.hub_model_id`.






</div></div>

## RewardConfig[[trl.RewardConfig]]

<div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8">


<docstring><name>class trl.RewardConfig</name><anchor>trl.RewardConfig</anchor><source>https://github.com/huggingface/trl/blob/v0.23.1/trl/trainer/reward_config.py#L22</source><parameters>[{"name": "output_dir", "val": ": typing.Optional[str] = None"}, {"name": "overwrite_output_dir", "val": ": bool = False"}, {"name": "do_train", "val": ": bool = False"}, {"name": "do_eval", "val": ": bool = False"}, {"name": "do_predict", "val": ": bool = False"}, {"name": "eval_strategy", "val": ": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'no'"}, {"name": "prediction_loss_only", "val": ": bool = False"}, {"name": "per_device_train_batch_size", "val": ": int = 8"}, {"name": "per_device_eval_batch_size", "val": ": int = 8"}, {"name": "per_gpu_train_batch_size", "val": ": typing.Optional[int] = None"}, {"name": "per_gpu_eval_batch_size", "val": ": typing.Optional[int] = None"}, {"name": "gradient_accumulation_steps", "val": ": int = 1"}, {"name": "eval_accumulation_steps", "val": ": typing.Optional[int] = None"}, {"name": "eval_delay", "val": ": float = 0"}, {"name": "torch_empty_cache_steps", "val": ": typing.Optional[int] = None"}, {"name": "learning_rate", "val": ": float = 5e-05"}, {"name": "weight_decay", "val": ": float = 0.0"}, {"name": "adam_beta1", "val": ": float = 0.9"}, {"name": "adam_beta2", "val": ": float = 0.999"}, {"name": "adam_epsilon", "val": ": float = 1e-08"}, {"name": "max_grad_norm", "val": ": float = 1.0"}, {"name": "num_train_epochs", "val": ": float = 3.0"}, {"name": "max_steps", "val": ": int = -1"}, {"name": "lr_scheduler_type", "val": ": typing.Union[transformers.trainer_utils.SchedulerType, str] = 'linear'"}, {"name": "lr_scheduler_kwargs", "val": ": typing.Union[dict[str, typing.Any], str] = <factory>"}, {"name": "warmup_ratio", "val": ": float = 0.0"}, {"name": "warmup_steps", "val": ": int = 0"}, {"name": "log_level", "val": ": str = 'passive'"}, {"name": "log_level_replica", "val": ": str = 'warning'"}, {"name": "log_on_each_node", "val": ": bool = True"}, {"name": "logging_dir", "val": ": typing.Optional[str] = None"}, {"name": "logging_strategy", "val": ": typing.Union[transformers.trainer_utils.IntervalStrategy, str] = 'steps'"}, {"name": "logging_first_step", "val": ": bool = False"}, {"name": "logging_steps", "val": ": float = 10"}, {"name": "logging_nan_inf_filter", "val": ": bool = True"}, {"name": "save_strategy", "val": ": typing.Union[transformers.trainer_utils.SaveStrategy, str] = 'steps'"}, {"name": "save_steps", "val": ": float = 500"}, {"name": "save_total_limit", "val": ": typing.Optional[int] = None"}, {"name": "save_safetensors", "val": ": bool = True"}, {"name": "save_on_each_node", "val": ": bool = False"}, {"name": "save_only_model", "val": ": bool = False"}, {"name": "restore_callback_states_from_checkpoint", "val": ": bool = False"}, {"name": "no_cuda", "val": ": bool = False"}, {"name": "use_cpu", "val": ": bool = False"}, {"name": "use_mps_device", "val": ": bool = False"}, {"name": "seed", "val": ": int = 42"}, {"name": "data_seed", "val": ": typing.Optional[int] = None"}, {"name": "jit_mode_eval", "val": ": bool = False"}, {"name": "bf16", "val": ": typing.Optional[bool] = None"}, {"name": "fp16", "val": ": bool = False"}, {"name": "fp16_opt_level", "val": ": str = 'O1'"}, {"name": "half_precision_backend", "val": ": str = 'auto'"}, {"name": "bf16_full_eval", "val": ": bool = False"}, {"name": "fp16_full_eval", "val": ": bool = False"}, {"name": "tf32", "val": ": typing.Optional[bool] = None"}, {"name": "local_rank", "val": ": int = -1"}, {"name": "ddp_backend", "val": ": typing.Optional[str] = None"}, {"name": "tpu_num_cores", "val": ": typing.Optional[int] = None"}, {"name": "tpu_metrics_debug", "val": ": bool = False"}, {"name": "debug", "val": ": typing.Union[str, list[transformers.debug_utils.DebugOption]] = ''"}, {"name": "dataloader_drop_last", "val": ": bool = False"}, {"name": "eval_steps", "val": ": typing.Optional[float] = None"}, {"name": "dataloader_num_workers", "val": ": int = 0"}, {"name": "dataloader_prefetch_factor", "val": ": typing.Optional[int] = None"}, {"name": "past_index", "val": ": int = -1"}, {"name": "run_name", "val": ": typing.Optional[str] = None"}, {"name": "disable_tqdm", "val": ": typing.Optional[bool] = None"}, {"name": "remove_unused_columns", "val": ": bool = False"}, {"name": "label_names", "val": ": typing.Optional[list[str]] = None"}, {"name": "load_best_model_at_end", "val": ": bool = False"}, {"name": "metric_for_best_model", "val": ": typing.Optional[str] = None"}, {"name": "greater_is_better", "val": ": typing.Optional[bool] = None"}, {"name": "ignore_data_skip", "val": ": bool = False"}, {"name": "fsdp", "val": ": typing.Union[list[transformers.trainer_utils.FSDPOption], str, bool] = <factory>"}, {"name": "fsdp_min_num_params", "val": ": int = 0"}, {"name": "fsdp_config", "val": ": typing.Union[dict[str, typing.Any], str, NoneType] = None"}, {"name": "fsdp_transformer_layer_cls_to_wrap", "val": ": typing.Optional[str] = None"}, {"name": "accelerator_config", "val": ": typing.Union[dict, str, NoneType] = None"}, {"name": "parallelism_config", "val": ": typing.Optional[accelerate.parallelism_config.ParallelismConfig] = None"}, {"name": "deepspeed", "val": ": typing.Union[dict, str, NoneType] = None"}, {"name": "label_smoothing_factor", "val": ": float = 0.0"}, {"name": "optim", "val": ": typing.Union[transformers.training_args.OptimizerNames, str] = 'adamw_torch_fused'"}, {"name": "optim_args", "val": ": typing.Optional[str] = None"}, {"name": "adafactor", "val": ": bool = False"}, {"name": "group_by_length", "val": ": bool = False"}, {"name": "length_column_name", "val": ": str = 'length'"}, {"name": "report_to", "val": ": typing.Union[NoneType, str, list[str]] = None"}, {"name": "project", "val": ": str = 'huggingface'"}, {"name": "trackio_space_id", "val": ": typing.Optional[str] = 'trackio'"}, {"name": "ddp_find_unused_parameters", "val": ": typing.Optional[bool] = None"}, {"name": "ddp_bucket_cap_mb", "val": ": typing.Optional[int] = None"}, {"name": "ddp_broadcast_buffers", "val": ": typing.Optional[bool] = None"}, {"name": "dataloader_pin_memory", "val": ": bool = True"}, {"name": "dataloader_persistent_workers", "val": ": bool = False"}, {"name": "skip_memory_metrics", "val": ": bool = True"}, {"name": "use_legacy_prediction_loop", "val": ": bool = False"}, {"name": "push_to_hub", "val": ": bool = False"}, {"name": "resume_from_checkpoint", "val": ": typing.Optional[str] = None"}, {"name": "hub_model_id", "val": ": typing.Optional[str] = None"}, {"name": "hub_strategy", "val": ": typing.Union[transformers.trainer_utils.HubStrategy, str] = 'every_save'"}, {"name": "hub_token", "val": ": typing.Optional[str] = None"}, {"name": "hub_private_repo", "val": ": typing.Optional[bool] = None"}, {"name": "hub_always_push", "val": ": bool = False"}, {"name": "hub_revision", "val": ": typing.Optional[str] = None"}, {"name": "gradient_checkpointing", "val": ": bool = True"}, {"name": "gradient_checkpointing_kwargs", "val": ": typing.Union[dict[str, typing.Any], str, NoneType] = None"}, {"name": "include_inputs_for_metrics", "val": ": bool = False"}, {"name": "include_for_metrics", "val": ": list = <factory>"}, {"name": "eval_do_concat_batches", "val": ": bool = True"}, {"name": "fp16_backend", "val": ": str = 'auto'"}, {"name": "push_to_hub_model_id", "val": ": typing.Optional[str] = None"}, {"name": "push_to_hub_organization", "val": ": typing.Optional[str] = None"}, {"name": "push_to_hub_token", "val": ": typing.Optional[str] = None"}, {"name": "mp_parameters", "val": ": str = ''"}, {"name": "auto_find_batch_size", "val": ": bool = False"}, {"name": "full_determinism", "val": ": bool = False"}, {"name": "torchdynamo", "val": ": typing.Optional[str] = None"}, {"name": "ray_scope", "val": ": typing.Optional[str] = 'last'"}, {"name": "ddp_timeout", "val": ": int = 1800"}, {"name": "torch_compile", "val": ": bool = False"}, {"name": "torch_compile_backend", "val": ": typing.Optional[str] = None"}, {"name": "torch_compile_mode", "val": ": typing.Optional[str] = None"}, {"name": "include_tokens_per_second", "val": ": bool = False"}, {"name": "include_num_input_tokens_seen", "val": ": typing.Union[str, bool] = False"}, {"name": "neftune_noise_alpha", "val": ": typing.Optional[float] = None"}, {"name": "optim_target_modules", "val": ": typing.Union[NoneType, str, list[str]] = None"}, {"name": "batch_eval_metrics", "val": ": bool = False"}, {"name": "eval_on_start", "val": ": bool = False"}, {"name": "use_liger_kernel", "val": ": bool = False"}, {"name": "liger_kernel_config", "val": ": typing.Optional[dict[str, bool]] = None"}, {"name": "eval_use_gather_object", "val": ": bool = False"}, {"name": "average_tokens_across_devices", "val": ": bool = True"}, {"name": "max_length", "val": ": typing.Optional[int] = 1024"}, {"name": "disable_dropout", "val": ": bool = True"}, {"name": "dataset_num_proc", "val": ": typing.Optional[int] = None"}, {"name": "center_rewards_coefficient", "val": ": typing.Optional[float] = None"}]</parameters><paramsdesc>- **max_length** (`int` or `None`, *optional*, defaults to `1024`) --
  Maximum length of the sequences (prompt + completion) in the batch, filters out entries that exceed the
  limit. This argument is required if you want to use the default data collator.
- **disable_dropout** (`bool`, *optional*, defaults to `True`) --
  Whether to disable dropout in the model.
- **dataset_num_proc** (`int`, *optional*, defaults to `None`) --
  Number of processes to use for processing the dataset.
- **center_rewards_coefficient** (`float`, *optional*, defaults to `None`) --
  Coefficient to incentivize the reward model to output mean-zero rewards (proposed by
  https://huggingface.co/papers/2312.09244, Eq. 2). Recommended value: `0.01`.
- **remove_unused_columns** (`bool`, *optional*, defaults to `False`) --
  Whether to remove the columns that are not used by the model's forward pass. Can be `True` only if the
  dataset is pretokenized.</paramsdesc><paramgroups>0</paramgroups></docstring>

Configuration class for the [RewardTrainer](/docs/trl/v0.23.1/en/reward_trainer#trl.RewardTrainer).

This class includes only the parameters that are specific to Reward training. For a full list of training
arguments, please refer to the [TrainingArguments](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/trainer#transformers.TrainingArguments) documentation. Note that default values in this
class may differ from those in [TrainingArguments](https://huggingface.co/docs/transformers/v4.57.0/en/main_classes/trainer#transformers.TrainingArguments).

Using [HfArgumentParser](https://huggingface.co/docs/transformers/v4.57.0/en/internal/trainer_utils#transformers.HfArgumentParser) we can turn this class into
[argparse](https://docs.python.org/3/library/argparse#module-argparse) arguments that can be specified on the
command line.




</div>

<EditOnGithub source="https://github.com/huggingface/trl/blob/main/docs/source/reward_trainer.md" />