import{s as bn,f as yn,n as On,o as Tn}from"../chunks/scheduler.d627b047.js";import{S as wn,i as xn,g as i,s as n,r as p,A as $n,h as s,f as t,c as o,j as b,u as m,x as d,k as v,y as l,a as r,v as g,d as h,t as u,w as f}from"../chunks/index.73c51727.js";import{D as y}from"../chunks/Docstring.0ad99a5d.js";import{C as Ca}from"../chunks/CodeBlock.5f78c87f.js";import{H as P,E as Pn}from"../chunks/index.8df1db42.js";function Mn(ka){let M,at,et,nt,U,ot,B,Ra='<a href="https://huggingface.co/models?other=orpo,trl" rel="nofollow"><img src="https://img.shields.io/badge/All_models-ORPO-blue"/></a> <a href="https://github.com/huggingface/smol-course/tree/main/2_preference_alignment" rel="nofollow"><img src="https://img.shields.io/badge/smol_course-Chapter_2-yellow"/></a>',rt,z,lt,J,Na='Odds Ratio Preference Optimization (ORPO) was introduced in <a href="https://huggingface.co/papers/2403.07691" rel="nofollow">ORPO: Monolithic Preference Optimization without Reference Model</a> by <a href="https://huggingface.co/JW17" rel="nofollow">Jiwoo Hong</a>, <a href="https://huggingface.co/nlee-208" rel="nofollow">Noah Lee</a>, and <a href="https://huggingface.co/j6mes" rel="nofollow">James Thorne</a>.',it,E,Fa="The abstract from the paper is the following:",st,H,La="<p>While recent preference alignment algorithms for language models have demonstrated promising results, supervised fine-tuning (SFT) remains imperative for achieving successful convergence. In this paper, we study the crucial role of SFT within the context of preference alignment, emphasizing that a minor penalty for the disfavored generation style is sufficient for preference-aligned SFT. Building on this foundation, we introduce a straightforward and innovative reference model-free monolithic odds ratio preference optimization algorithm, ORPO, eliminating the necessity for an additional preference alignment phase. We demonstrate, both empirically and theoretically, that the odds ratio is a sensible choice for contrasting favored and disfavored styles during SFT across the diverse sizes from 125M to 7B. Specifically, fine-tuning Phi-2 (2.7B), Llama-2 (7B), and Mistral (7B) with ORPO on the UltraFeedback alone surpasses the performance of state-of-the-art language models with more than 7B and 13B parameters: achieving up to 12.20% on AlpacaEval_{2.0} (Figure 1), 66.19% on IFEval (instruction-level loose, Table 6), and 7.32 in MT-Bench (Figure 12). We release code and model checkpoints for Mistral-ORPO-alpha (7B) and Mistral-ORPO-beta (7B).</p>",dt,q,ja="It studies the crucial role of SFT within the context of preference alignment. Using preference data the method posits that a minor penalty for the disfavored generation together with a strong adaption signal to the chosen response via a simple log odds ratio term appended to the NLL loss is sufficient for preference-aligned SFT.",ct,A,Ia="Thus ORPO is a reference model-free preference optimization algorithm eliminating the necessity for an additional preference alignment phase thus saving compute and memory.",pt,D,Wa='The official code can be found in <a href="https://github.com/xfactlab/orpo" rel="nofollow">xfactlab/orpo</a>.',mt,V,Ua='This post-training method was contributed by <a href="https://huggingface.co/kashif" rel="nofollow">Kashif Rasul</a>, <a href="https://huggingface.co/lewtun" rel="nofollow">Lewis Tunstall</a> and <a href="https://huggingface.co/alvarobartt" rel="nofollow">Alvaro Bartolome</a>.',gt,S,ht,Q,Ba='This example demonstrates how to train a model using the ORPO method. We use the <a href="https://huggingface.co/Qwen/Qwen2-0.5B-Instruct" rel="nofollow">Qwen 0.5B model</a> as the base model. We use the preference data from the <a href="https://huggingface.co/datasets/openbmb/UltraFeedback" rel="nofollow">UltraFeedback dataset</a>. You can view the data in the dataset here:',ut,w,za,ft,Z,Ja="Below is the script to train the model:",_t,X,vt,G,Ea="Execute the script using the following command:",bt,Y,yt,K,Ha="Distributed across 8 GPUs, the training takes approximately 30 minutes. You can verify the training progress by checking the reward graph. An increasing trend in the reward margin indicates that the model is improving and generating better responses over time.",Ot,ee,qa='<img src="https://huggingface.co/datasets/trl-lib/documentation-images/resolve/main/orpo-qwen2-reward-margin.png"/>',Tt,te,Aa='To see how the <a href="https://huggingface.co/trl-lib/Qwen2-0.5B-ORPO" rel="nofollow">trained model</a> performs, you can use the <a href="https://huggingface.co/docs/transformers/quicktour#chat-with-text-generation-models" rel="nofollow">Transformers Chat CLI</a>.',wt,ae,Da=`<code>$ transformers-cli chat --model_name_or_path trl-lib/Qwen2-0.5B-ORPO
<strong><span style="color: red;">&lt;quentin_gallouedec&gt;:</span></strong>
What is the best programming language?

<strong><span style="color: blue;">&lt;trl-lib/Qwen2-0.5B-ORPO&gt;:</span></strong>
It&#39;s challenging to determine the best programming language as no one language is perfect, as the complexity of a task and the type of project are significant factors. Some popular languages include Java, Python, JavaScript, and
C++. If you have specific needs or requirements for a specific project, it&#39;s important to choose the language that best suits those needs.                                                                                          

Here are some other factors to consider when choosing a programming language for a project:

 <strong><span style="color: green;">• Language proficiency:</span></strong> A good programming language is more likely to be easy to understand and use, and will allow developers to collaborate on projects more efficiently.                                     
 <strong><span style="color: green;">• Ease of use:</span></strong> There are tools and libraries available to make programming more accessible, so developers should choose a language that can help them get started easier.
 <strong><span style="color: green;">• Code readability:</span></strong> A clear and concise codebase should be easy to read and understand, especially when working with large projects.
 <strong><span style="color: green;">• Tool and framework support:</span></strong> There are numerous libraries available for Python, Java, and JavaScript, along with tools like IDEs and static code analysis tools.
 <strong><span style="color: green;">• Accessibility:</span></strong> Some languages and tools have features that make them more accessible to developers with disabilities, such as support for screen readers.
 <strong><span style="color: green;">• Version control:</span></strong> As your projects grow and complexity increases, version control tools can be beneficial for tracking changes.

</code>`,xt,ne,$t,oe,Va='ORPO requires a <a href="dataset_formats#preference">preference dataset</a>. The <a href="/docs/trl/main/en/orpo_trainer#trl.ORPOTrainer">ORPOTrainer</a> supports both <a href="dataset_formats#conversational">conversational</a> and <a href="dataset_formats#standard">standard</a> dataset format. When provided with a conversational dataset, the trainer will automatically apply the chat template to the dataset.',Pt,re,Sa='Although the <a href="/docs/trl/main/en/orpo_trainer#trl.ORPOTrainer">ORPOTrainer</a> supports both explicit and implicit prompts, we recommend using explicit prompts. If provided with an implicit prompt dataset, the trainer will automatically extract the prompt from the <code>&quot;chosen&quot;</code> and <code>&quot;rejected&quot;</code> columns. For more information, refer to the <a href="dataset_formats#preference">preference style</a> section.',Mt,le,Ct,ie,Qa='We provide an example script to train a model using the ORPO method. The script is available in <a href="https://github.com/huggingface/trl/blob/main/examples/scripts/orpo.py" rel="nofollow"><code>examples/scripts/orpo.py</code></a>',kt,se,Za='To test the ORPO script with the <a href="https://huggingface.co/Qwen/Qwen2-0.5B-Instruct" rel="nofollow">Qwen2 0.5B model</a> on the <a href="https://huggingface.co/datasets/trl-lib/ultrafeedback_binarized" rel="nofollow">UltraFeedback dataset</a>, run the following command:',Rt,de,Nt,ce,Ft,pe,Lt,me,Xa=`MOEs are the most efficient if the load is about equally distributed between experts.<br/>
To ensure that we train MOEs similarly during preference-tuning, it is beneficial to add the auxiliary loss from the load balancer to the final loss.`,jt,ge,Ga=`This option is enabled by setting <code>output_router_logits=True</code> in the model config (e.g. <a href="https://huggingface.co/docs/transformers/main/en/model_doc/mixtral#transformers.MixtralConfig" rel="nofollow">MixtralConfig</a>).<br/>
To scale how much the auxiliary loss contributes to the total loss, use the hyperparameter <code>router_aux_loss_coef=...</code> (default: <code>0.001</code>) in the model config.`,It,he,Wt,ue,Ya="While training and evaluating we record the following reward metrics:",Ut,fe,Ka="<li><code>rewards/chosen</code>: the mean log probabilities of the policy model for the chosen responses scaled by beta</li> <li><code>rewards/rejected</code>: the mean log probabilities of the policy model for the rejected responses scaled by beta</li> <li><code>rewards/accuracies</code>: mean of how often the chosen rewards are &gt; than the corresponding rejected rewards</li> <li><code>rewards/margins</code>: the mean difference between the chosen and corresponding rejected rewards</li> <li><code>log_odds_chosen</code>: the mean log odds ratio of the chosen responses over the rejected responses</li> <li><code>log_odds_ratio</code>: the mean of the <code>log(sigmoid(log_odds_chosen))</code></li> <li><code>nll_loss</code>: the mean negative log likelihood loss from the SFT part of the loss over chosen responses</li>",Bt,_e,zt,c,ve,Kt,Le,en="Initialize ORPOTrainer.",ea,C,be,ta,je,tn=`Llama tokenizer does satisfy <code>enc(a + b) = enc(a) + enc(b)</code>.
It does ensure <code>enc(a + b) = enc(a) + enc(a + b)[len(enc(a)):]</code>.
Reference:
<a href="https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257" rel="nofollow">https://github.com/EleutherAI/lm-evaluation-harness/pull/531#issuecomment-1595586257</a>`,aa,x,ye,na,Ie,an="Run the given model on the given batch of inputs, concatenating the chosen and rejected inputs together.",oa,We,nn="We do this to avoid doing two forward passes, because it’s faster for FSDP.",ra,k,Oe,la,Ue,on="Concatenate the chosen and rejected inputs into a single tensor.",ia,R,Te,sa,Be,rn="Creates a draft of a model card using the information available to the <code>Trainer</code>.",da,$,we,ca,ze,ln=`Overriding built-in evaluation loop to store metrics for each batch.
Prediction/evaluation loop, shared by <code>Trainer.evaluate()</code> and <code>Trainer.predict()</code>.`,pa,Je,sn="Works both with or without labels.",ma,N,xe,ga,Ee,dn="Generate samples from the model and reference model for the given batch of inputs.",ha,F,$e,ua,He,cn="Compute the log probabilities of the given labels under the given logits.",fa,L,Pe,_a,qe,pn="Compute the ORPO loss and other metrics for the given batch of inputs for train or test.",va,j,Me,ba,Ae,mn="Log <code>logs</code> on the various objects watching training, including stored metrics.",ya,I,Ce,Oa,De,gn="Compute ORPO’s odds ratio (OR) loss for a batch of policy and reference model log probabilities.",Ta,O,ke,wa,Ve,hn="Tokenize a single row from a ORPO specific dataset.",xa,Se,un=`At this stage, we don’t convert to PyTorch tensors yet; we just handle the truncation
in case the prompt + chosen or prompt + rejected responses is/are too long. First
we truncate the prompt; if we’re still too long, we truncate the chosen/rejected.`,$a,Qe,fn=`We also create the labels for the chosen/rejected responses, which are of length equal to
the sum of the length of the prompt and the chosen/rejected response, with
label_pad_token_id  for the prompt tokens.`,Jt,Re,Et,T,Ne,Pa,Ze,_n='Configuration class for the <a href="/docs/trl/main/en/orpo_trainer#trl.ORPOTrainer">ORPOTrainer</a>.',Ma,Xe,vn=`Using <a href="https://huggingface.co/docs/transformers/main/en/internal/trainer_utils#transformers.HfArgumentParser" rel="nofollow">HfArgumentParser</a> we can turn this class into
<a href="https://docs.python.org/3/library/argparse#module-argparse" rel="nofollow">argparse</a> arguments that can be specified on the
command line.`,Ht,Fe,qt,tt,At;return U=new P({props:{title:"ORPO Trainer",local:"orpo-trainer",headingTag:"h1"}}),z=new P({props:{title:"Overview",local:"overview",headingTag:"h2"}}),S=new P({props:{title:"Quick start",local:"quick-start",headingTag:"h2"}}),X=new Ca({props:{code:"JTIzJTIwdHJhaW5fb3Jwby5weSUwQWZyb20lMjBkYXRhc2V0cyUyMGltcG9ydCUyMGxvYWRfZGF0YXNldCUwQWZyb20lMjB0cmwlMjBpbXBvcnQlMjBPUlBPQ29uZmlnJTJDJTIwT1JQT1RyYWluZXIlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMjBBdXRvVG9rZW5pemVyJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyUXdlbiUyRlF3ZW4yLTAuNUItSW5zdHJ1Y3QlMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyUXdlbiUyRlF3ZW4yLTAuNUItSW5zdHJ1Y3QlMjIpJTBBdHJhaW5fZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ0cmwtbGliJTJGdWx0cmFmZWVkYmFja19iaW5hcml6ZWQlMjIlMkMlMjBzcGxpdCUzRCUyMnRyYWluJTIyKSUwQSUwQXRyYWluaW5nX2FyZ3MlMjAlM0QlMjBPUlBPQ29uZmlnKG91dHB1dF9kaXIlM0QlMjJRd2VuMi0wLjVCLU9SUE8lMjIlMkMlMjBsb2dnaW5nX3N0ZXBzJTNEMTApJTBBdHJhaW5lciUyMCUzRCUyME9SUE9UcmFpbmVyKG1vZGVsJTNEbW9kZWwlMkMlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUyMHByb2Nlc3NpbmdfY2xhc3MlM0R0b2tlbml6ZXIlMkMlMjB0cmFpbl9kYXRhc2V0JTNEdHJhaW5fZGF0YXNldCklMEF0cmFpbmVyLnRyYWluKCk=",highlighted:`<span class="hljs-comment"># train_orpo.py</span>
<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset
<span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> ORPOConfig, ORPOTrainer
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen2-0.5B-Instruct&quot;</span>)
tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;Qwen/Qwen2-0.5B-Instruct&quot;</span>)
train_dataset = load_dataset(<span class="hljs-string">&quot;trl-lib/ultrafeedback_binarized&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)

training_args = ORPOConfig(output_dir=<span class="hljs-string">&quot;Qwen2-0.5B-ORPO&quot;</span>, logging_steps=<span class="hljs-number">10</span>)
trainer = ORPOTrainer(model=model, args=training_args, processing_class=tokenizer, train_dataset=train_dataset)
trainer.train()`,wrap:!1}}),Y=new Ca({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX29ycG8ucHk=",highlighted:"accelerate launch train_orpo.py",wrap:!1}}),ne=new P({props:{title:"Expected dataset type",local:"expected-dataset-type",headingTag:"h2"}}),le=new P({props:{title:"Example script",local:"example-script",headingTag:"h2"}}),de=new Ca({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMGV4YW1wbGVzJTJGc2NyaXB0cyUyRm9ycG8ucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1vZGVsX25hbWVfb3JfcGF0aCUyMFF3ZW4lMkZRd2VuMi0wLjVCLUluc3RydWN0JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1kYXRhc2V0X25hbWUlMjB0cmwtbGliJTJGdWx0cmFmZWVkYmFja19iaW5hcml6ZWQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW51bV90cmFpbl9lcG9jaHMlMjAxJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1sb2dnaW5nX3N0ZXBzJTIwMjUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW91dHB1dF9kaXIlMjBRd2VuMi0wLjVCLU9SUE8=",highlighted:`accelerate launch examples/scripts/orpo.py \\
    --model_name_or_path Qwen/Qwen2-0.5B-Instruct \\
    --dataset_name trl-lib/ultrafeedback_binarized \\
    --num_train_epochs 1 \\
    --logging_steps 25 \\
    --output_dir Qwen2-0.5B-ORPO`,wrap:!1}}),ce=new P({props:{title:"Usage tips",local:"usage-tips",headingTag:"h2"}}),pe=new P({props:{title:"For Mixture of Experts Models: Enabling the auxiliary loss",local:"for-mixture-of-experts-models-enabling-the-auxiliary-loss",headingTag:"h3"}}),he=new P({props:{title:"Logged metrics",local:"logged-metrics",headingTag:"h2"}}),_e=new P({props:{title:"ORPOTrainer",local:"trl.ORPOTrainer",headingTag:"h2"}}),ve=new y({props:{name:"class trl.ORPOTrainer",anchor:"trl.ORPOTrainer",parameters:[{name:"model",val:": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module, str, NoneType] = None"},{name:"args",val:": typing.Optional[trl.trainer.orpo_config.ORPOConfig] = None"},{name:"data_collator",val:": typing.Optional[transformers.data.data_collator.DataCollator] = 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:"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"},{name:"compute_metrics",val:": typing.Optional[typing.Callable[[transformers.trainer_utils.EvalLoopOutput], dict]] = None"}],parametersDescription:[{anchor:"trl.ORPOTrainer.model",description:`<strong>model</strong> (<code>transformers.PreTrainedModel</code>) &#x2014;
The model to train, preferably an <code>AutoModelForSequenceClassification</code>.`,name:"model"},{anchor:"trl.ORPOTrainer.args",description:`<strong>args</strong> (<code>ORPOConfig</code>) &#x2014;
The ORPO config arguments to use for training.`,name:"args"},{anchor:"trl.ORPOTrainer.data_collator",description:`<strong>data_collator</strong> (<code>transformers.DataCollator</code>) &#x2014;
The data collator to use for training. If None is specified, the default data collator (<code>DPODataCollatorWithPadding</code>) will be used
which will pad the sequences to the maximum length of the sequences in the batch, given a dataset of paired sequences.`,name:"data_collator"},{anchor:"trl.ORPOTrainer.train_dataset",description:`<strong>train_dataset</strong> (<code>datasets.Dataset</code>) &#x2014;
The dataset to use for training.`,name:"train_dataset"},{anchor:"trl.ORPOTrainer.eval_dataset",description:`<strong>eval_dataset</strong> (<code>datasets.Dataset</code>) &#x2014;
The dataset to use for evaluation.`,name:"eval_dataset"},{anchor:"trl.ORPOTrainer.processing_class",description:`<strong>processing_class</strong> (<code>PreTrainedTokenizerBase</code> or <code>BaseImageProcessor</code> or <code>FeatureExtractionMixin</code> or <code>ProcessorMixin</code>, <em>optional</em>) &#x2014;
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.`,name:"processing_class"},{anchor:"trl.ORPOTrainer.model_init",description:`<strong>model_init</strong> (<code>Callable[[], transformers.PreTrainedModel]</code>) &#x2014;
The model initializer to use for training. If None is specified, the default model initializer will be used.`,name:"model_init"},{anchor:"trl.ORPOTrainer.callbacks",description:`<strong>callbacks</strong> (<code>list[transformers.TrainerCallback]</code>) &#x2014;
The callbacks to use for training.`,name:"callbacks"},{anchor:"trl.ORPOTrainer.optimizers",description:`<strong>optimizers</strong> (<code>tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR]</code>) &#x2014;
The optimizer and scheduler to use for training.`,name:"optimizers"},{anchor:"trl.ORPOTrainer.preprocess_logits_for_metrics",description:`<strong>preprocess_logits_for_metrics</strong> (<code>Callable[[torch.Tensor, torch.Tensor], torch.Tensor]</code>) &#x2014;
The function to use to preprocess the logits before computing the metrics.`,name:"preprocess_logits_for_metrics"},{anchor:"trl.ORPOTrainer.peft_config",description:`<strong>peft_config</strong> (<code>dict</code>, defaults to <code>None</code>) &#x2014;
The PEFT configuration to use for training. If you pass a PEFT configuration, the model will be wrapped in a PEFT model.`,name:"peft_config"},{anchor:"trl.ORPOTrainer.compute_metrics",description:`<strong>compute_metrics</strong> (<code>Callable[[EvalPrediction], dict]</code>, <em>optional</em>) &#x2014;
The function to use to compute the metrics. Must take a <code>EvalPrediction</code> and return
a dictionary string to metric values.`,name:"compute_metrics"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L79"}}),be=new y({props:{name:"build_tokenized_answer",anchor:"trl.ORPOTrainer.build_tokenized_answer",parameters:[{name:"prompt",val:""},{name:"answer",val:""}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L355"}}),ye=new y({props:{name:"concatenated_forward",anchor:"trl.ORPOTrainer.concatenated_forward",parameters:[{name:"model",val:": Module"},{name:"batch",val:": dict"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L692"}}),Oe=new y({props:{name:"concatenated_inputs",anchor:"trl.ORPOTrainer.concatenated_inputs",parameters:[{name:"batch",val:": dict"},{name:"is_encoder_decoder",val:": bool = False"},{name:"label_pad_token_id",val:": int = -100"},{name:"padding_value",val:": int = 0"},{name:"device",val:": typing.Optional[torch.device] = None"}],parametersDescription:[{anchor:"trl.ORPOTrainer.concatenated_inputs.batch",description:"<strong>batch</strong> &#x2014; A batch of data. Must contain the keys &#x2018;chosen_input_ids&#x2019; and &#x2018;rejected_input_ids&#x2019;, which are tensors of shape (batch_size, sequence_length).",name:"batch"},{anchor:"trl.ORPOTrainer.concatenated_inputs.is_encoder_decoder",description:"<strong>is_encoder_decoder</strong> &#x2014; Whether the model is an encoder-decoder model.",name:"is_encoder_decoder"},{anchor:"trl.ORPOTrainer.concatenated_inputs.label_pad_token_id",description:"<strong>label_pad_token_id</strong> &#x2014; The label pad token id.",name:"label_pad_token_id"},{anchor:"trl.ORPOTrainer.concatenated_inputs.padding_value",description:"<strong>padding_value</strong> &#x2014; The padding value to use for the concatenated inputs_ids.",name:"padding_value"},{anchor:"trl.ORPOTrainer.concatenated_inputs.device",description:"<strong>device</strong> &#x2014; The device for the concatenated inputs.",name:"device"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L561",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A dictionary containing the concatenated inputs under the key ‘concatenated_input_ids’.</p>
`}}),Te=new y({props:{name:"create_model_card",anchor:"trl.ORPOTrainer.create_model_card",parameters:[{name:"model_name",val:": typing.Optional[str] = None"},{name:"dataset_name",val:": typing.Optional[str] = None"},{name:"tags",val:": typing.Union[str, list[str], NoneType] = None"}],parametersDescription:[{anchor:"trl.ORPOTrainer.create_model_card.model_name",description:`<strong>model_name</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Name of the model.`,name:"model_name"},{anchor:"trl.ORPOTrainer.create_model_card.dataset_name",description:`<strong>dataset_name</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Name of the dataset used for training.`,name:"dataset_name"},{anchor:"trl.ORPOTrainer.create_model_card.tags",description:`<strong>tags</strong> (<code>str</code>, <code>list[str]</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Tags to be associated with the model card.`,name:"tags"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L1010"}}),we=new y({props:{name:"evaluation_loop",anchor:"trl.ORPOTrainer.evaluation_loop",parameters:[{name:"dataloader",val:": DataLoader"},{name:"description",val:": str"},{name:"prediction_loss_only",val:": typing.Optional[bool] = None"},{name:"ignore_keys",val:": typing.Optional[list[str]] = None"},{name:"metric_key_prefix",val:": str = 'eval'"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L915"}}),xe=new y({props:{name:"generate_from_model",anchor:"trl.ORPOTrainer.generate_from_model",parameters:[{name:"model",val:""},{name:"batch",val:": dict"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L850"}}),$e=new y({props:{name:"get_batch_logps",anchor:"trl.ORPOTrainer.get_batch_logps",parameters:[{name:"logits",val:": FloatTensor"},{name:"labels",val:": LongTensor"},{name:"average_log_prob",val:": bool = False"},{name:"label_pad_token_id",val:": int = -100"},{name:"is_encoder_decoder",val:": bool = False"}],parametersDescription:[{anchor:"trl.ORPOTrainer.get_batch_logps.logits",description:"<strong>logits</strong> &#x2014; Logits of the model (unnormalized). Shape: (batch_size, sequence_length, vocab_size)",name:"logits"},{anchor:"trl.ORPOTrainer.get_batch_logps.labels",description:"<strong>labels</strong> &#x2014; Labels for which to compute the log probabilities. Label tokens with a value of label_pad_token_id are ignored. Shape: (batch_size, sequence_length)",name:"labels"},{anchor:"trl.ORPOTrainer.get_batch_logps.average_log_prob",description:"<strong>average_log_prob</strong> &#x2014; If True, return the average log probability per (non-masked) token. Otherwise, return the sum of the log probabilities of the (non-masked) tokens.",name:"average_log_prob"},{anchor:"trl.ORPOTrainer.get_batch_logps.label_pad_token_id",description:"<strong>label_pad_token_id</strong> &#x2014; The label pad token id.",name:"label_pad_token_id"},{anchor:"trl.ORPOTrainer.get_batch_logps.is_encoder_decoder",description:"<strong>is_encoder_decoder</strong> &#x2014; Whether the model is an encoder-decoder model.",name:"is_encoder_decoder"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L654",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A tensor of shape (batch_size,) containing the average/sum log probabilities of the given labels under the given logits.</p>
`}}),Pe=new y({props:{name:"get_batch_loss_metrics",anchor:"trl.ORPOTrainer.get_batch_loss_metrics",parameters:[{name:"model",val:""},{name:"batch",val:": dict"},{name:"train_eval",val:": typing.Literal['train', 'eval'] = 'train'"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L773"}}),Me=new y({props:{name:"log",anchor:"trl.ORPOTrainer.log",parameters:[{name:"logs",val:": dict"},{name:"start_time",val:": typing.Optional[float] = None"}],parametersDescription:[{anchor:"trl.ORPOTrainer.log.logs",description:`<strong>logs</strong> (<code>dict[str, float]</code>) &#x2014;
The values to log.`,name:"logs"},{anchor:"trl.ORPOTrainer.log.start_time",description:`<strong>start_time</strong> (<code>float</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Start time of the training.`,name:"start_time"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L965"}}),Ce=new y({props:{name:"odds_ratio_loss",anchor:"trl.ORPOTrainer.odds_ratio_loss",parameters:[{name:"policy_chosen_logps",val:": FloatTensor"},{name:"policy_rejected_logps",val:": FloatTensor"}],parametersDescription:[{anchor:"trl.ORPOTrainer.odds_ratio_loss.policy_chosen_logps",description:"<strong>policy_chosen_logps</strong> &#x2014; Log probabilities of the policy model for the chosen responses. Shape: (batch_size,)",name:"policy_chosen_logps"},{anchor:"trl.ORPOTrainer.odds_ratio_loss.policy_rejected_logps",description:"<strong>policy_rejected_logps</strong> &#x2014; Log probabilities of the policy model for the rejected responses. Shape: (batch_size,)",name:"policy_rejected_logps"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L623",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>(losses, chosen_rewards, rejected_rewards).
The losses tensor contains the ORPO loss for each example in the batch.
The chosen_rewards and rejected_rewards tensors contain the rewards for the chosen and rejected responses, respectively.
The log odds ratio of the chosen responses over the rejected responses ratio for logging purposes.
The <code>log(sigmoid(log_odds_chosen))</code> for logging purposes.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A tuple of three tensors</p>
`}}),ke=new y({props:{name:"tokenize_row",anchor:"trl.ORPOTrainer.tokenize_row",parameters:[{name:"feature",val:""},{name:"model",val:": typing.Union[transformers.modeling_utils.PreTrainedModel, torch.nn.modules.module.Module, NoneType] = None"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_trainer.py#L405"}}),Re=new P({props:{title:"ORPOConfig",local:"trl.ORPOConfig",headingTag:"h2"}}),Ne=new y({props:{name:"class trl.ORPOConfig",anchor:"trl.ORPOConfig",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:": typing.Optional[float] = 0"},{name:"torch_empty_cache_steps",val:": typing.Optional[int] = None"},{name:"learning_rate",val:": float = 1e-06"},{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, NoneType] = <factory>"},{name:"warmup_ratio",val:": float = 0.0"},{name:"warmup_steps",val:": int = 0"},{name:"log_level",val:": typing.Optional[str] = 'passive'"},{name:"log_level_replica",val:": typing.Optional[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 = 500"},{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:": typing.Optional[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:"use_ipex",val:": bool = False"},{name:"bf16",val:": bool = False"},{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:": typing.Optional[bool] = True"},{name:"label_names",val:": typing.Optional[list[str]] = None"},{name:"load_best_model_at_end",val:": typing.Optional[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, NoneType] = ''"},{name:"fsdp_min_num_params",val:": int = 0"},{name:"fsdp_config",val:": typing.Union[dict, 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:"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'"},{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:": typing.Optional[str] = 'length'"},{name:"report_to",val:": typing.Union[NoneType, str, list[str]] = None"},{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:"gradient_checkpointing",val:": bool = False"},{name:"gradient_checkpointing_kwargs",val:": typing.Union[dict, 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:": typing.Optional[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:": typing.Optional[bool] = False"},{name:"include_num_input_tokens_seen",val:": typing.Optional[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:": typing.Optional[bool] = False"},{name:"eval_use_gather_object",val:": typing.Optional[bool] = False"},{name:"average_tokens_across_devices",val:": typing.Optional[bool] = False"},{name:"max_length",val:": typing.Optional[int] = 1024"},{name:"max_prompt_length",val:": typing.Optional[int] = 512"},{name:"max_completion_length",val:": typing.Optional[int] = None"},{name:"beta",val:": float = 0.1"},{name:"disable_dropout",val:": bool = True"},{name:"label_pad_token_id",val:": int = -100"},{name:"padding_value",val:": typing.Optional[int] = None"},{name:"truncation_mode",val:": str = 'keep_end'"},{name:"generate_during_eval",val:": bool = False"},{name:"is_encoder_decoder",val:": typing.Optional[bool] = None"},{name:"model_init_kwargs",val:": typing.Optional[dict[str, typing.Any]] = None"},{name:"dataset_num_proc",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"trl.ORPOConfig.learning_rate",description:`<strong>learning_rate</strong> (<code>float</code>, <em>optional</em>, defaults to <code>1e-6</code>) &#x2014;
Initial learning rate for <code>AdamW</code> optimizer. The default value replaces that of
<a href="https://huggingface.co/docs/transformers/main/en/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">TrainingArguments</a>.`,name:"learning_rate"},{anchor:"trl.ORPOConfig.max_length",description:`<strong>max_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>1024</code>) &#x2014;
Maximum length of the sequences (prompt + completion) in the batch. This argument is required if you want
to use the default data collator.`,name:"max_length"},{anchor:"trl.ORPOConfig.max_prompt_length",description:`<strong>max_prompt_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>512</code>) &#x2014;
Maximum length of the prompt. This argument is required if you want to use the default data collator.`,name:"max_prompt_length"},{anchor:"trl.ORPOConfig.max_completion_length",description:`<strong>max_completion_length</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Maximum length of the completion. This argument is required if you want to use the default data collator
and your model is an encoder-decoder.`,name:"max_completion_length"},{anchor:"trl.ORPOConfig.beta",description:`<strong>beta</strong> (<code>float</code>, <em>optional</em>, defaults to <code>0.1</code>) &#x2014;
Parameter controlling the relative ratio loss weight in the ORPO loss. In the <a href="https://huggingface.co/papers/2403.07691" rel="nofollow">paper</a>,
it is denoted by &#x3BB;. In the <a href="https://github.com/xfactlab/orpo" rel="nofollow">code</a>, it is denoted by <code>alpha</code>.`,name:"beta"},{anchor:"trl.ORPOConfig.disable_dropout",description:`<strong>disable_dropout</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to disable dropout in the model.`,name:"disable_dropout"},{anchor:"trl.ORPOConfig.label_pad_token_id",description:`<strong>label_pad_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>-100</code>) &#x2014;
Label pad token id. This argument is required if you want to use the default data collator.`,name:"label_pad_token_id"},{anchor:"trl.ORPOConfig.padding_value",description:`<strong>padding_value</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Padding value to use. If <code>None</code>, the padding value of the tokenizer is used.`,name:"padding_value"},{anchor:"trl.ORPOConfig.truncation_mode",description:`<strong>truncation_mode</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;keep_end&quot;</code>) &#x2014;
Truncation mode to use when the prompt is too long. Possible values are <code>&quot;keep_end&quot;</code> or <code>&quot;keep_start&quot;</code>.
This argument is required if you want to use the default data collator.`,name:"truncation_mode"},{anchor:"trl.ORPOConfig.generate_during_eval",description:`<strong>generate_during_eval</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, generates and logs completions from the model to W&amp;B or Comet during evaluation.`,name:"generate_during_eval"},{anchor:"trl.ORPOConfig.is_encoder_decoder",description:`<strong>is_encoder_decoder</strong> (<code>bool</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
When using the <code>model_init</code> argument (callable) to instantiate the model instead of the <code>model</code> argument,
you need to specify if the model returned by the callable is an encoder-decoder model.`,name:"is_encoder_decoder"},{anchor:"trl.ORPOConfig.model_init_kwargs",description:`<strong>model_init_kwargs</strong> (<code>dict[str, Any]</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Keyword arguments to pass to <code>AutoModelForCausalLM.from_pretrained</code> when instantiating the model from a
string.`,name:"model_init_kwargs"},{anchor:"trl.ORPOConfig.dataset_num_proc",description:`<strong>dataset_num_proc</strong> (<code>int</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Number of processes to use for processing the dataset.`,name:"dataset_num_proc"}],source:"https://github.com/huggingface/trl/blob/main/trl/trainer/orpo_config.py#L21"}}),Fe=new Pn({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/orpo_trainer.md"}}),{c(){M=i("meta"),at=n(),et=i("p"),nt=n(),p(U.$$.fragment),ot=n(),B=i("p"),B.innerHTML=Ra,rt=n(),p(z.$$.fragment),lt=n(),J=i("p"),J.innerHTML=Na,it=n(),E=i("p"),E.textContent=Fa,st=n(),H=i("blockquote"),H.innerHTML=La,dt=n(),q=i("p"),q.textContent=ja,ct=n(),A=i("p"),A.textContent=Ia,pt=n(),D=i("p"),D.innerHTML=Wa,mt=n(),V=i("p"),V.innerHTML=Ua,gt=n(),p(S.$$.fragment),ht=n(),Q=i("p"),Q.innerHTML=Ba,ut=n(),w=i("iframe"),ft=n(),Z=i("p"),Z.textContent=Ja,_t=n(),p(X.$$.fragment),vt=n(),G=i("p"),G.textContent=Ea,bt=n(),p(Y.$$.fragment),yt=n(),K=i("p"),K.textContent=Ha,Ot=n(),ee=i("p"),ee.innerHTML=qa,Tt=n(),te=i("p"),te.innerHTML=Aa,wt=n(),ae=i("pre"),ae.innerHTML=Da,xt=n(),p(ne.$$.fragment),$t=n(),oe=i("p"),oe.innerHTML=Va,Pt=n(),re=i("p"),re.innerHTML=Sa,Mt=n(),p(le.$$.fragment),Ct=n(),ie=i("p"),ie.innerHTML=Qa,kt=n(),se=i("p"),se.innerHTML=Za,Rt=n(),p(de.$$.fragment),Nt=n(),p(ce.$$.fragment),Ft=n(),p(pe.$$.fragment),Lt=n(),me=i("p"),me.innerHTML=Xa,jt=n(),ge=i("p"),ge.innerHTML=Ga,It=n(),p(he.$$.fragment),Wt=n(),ue=i("p"),ue.textContent=Ya,Ut=n(),fe=i("ul"),fe.innerHTML=Ka,Bt=n(),p(_e.$$.fragment),zt=n(),c=i("div"),p(ve.$$.fragment),Kt=n(),Le=i("p"),Le.textContent=en,ea=n(),C=i("div"),p(be.$$.fragment),ta=n(),je=i("p"),je.innerHTML=tn,aa=n(),x=i("div"),p(ye.$$.fragment),na=n(),Ie=i("p"),Ie.textContent=an,oa=n(),We=i("p"),We.textContent=nn,ra=n(),k=i("div"),p(Oe.$$.fragment),la=n(),Ue=i("p"),Ue.textContent=on,ia=n(),R=i("div"),p(Te.$$.fragment),sa=n(),Be=i("p"),Be.innerHTML=rn,da=n(),$=i("div"),p(we.$$.fragment),ca=n(),ze=i("p"),ze.innerHTML=ln,pa=n(),Je=i("p"),Je.textContent=sn,ma=n(),N=i("div"),p(xe.$$.fragment),ga=n(),Ee=i("p"),Ee.textContent=dn,ha=n(),F=i("div"),p($e.$$.fragment),ua=n(),He=i("p"),He.textContent=cn,fa=n(),L=i("div"),p(Pe.$$.fragment),_a=n(),qe=i("p"),qe.textContent=pn,va=n(),j=i("div"),p(Me.$$.fragment),ba=n(),Ae=i("p"),Ae.innerHTML=mn,ya=n(),I=i("div"),p(Ce.$$.fragment),Oa=n(),De=i("p"),De.textContent=gn,Ta=n(),O=i("div"),p(ke.$$.fragment),wa=n(),Ve=i("p"),Ve.textContent=hn,xa=n(),Se=i("p"),Se.textContent=un,$a=n(),Qe=i("p"),Qe.textContent=fn,Jt=n(),p(Re.$$.fragment),Et=n(),T=i("div"),p(Ne.$$.fragment),Pa=n(),Ze=i("p"),Ze.innerHTML=_n,Ma=n(),Xe=i("p"),Xe.innerHTML=vn,Ht=n(),p(Fe.$$.fragment),qt=n(),tt=i("p"),this.h()},l(e){const a=$n("svelte-u9bgzb",document.head);M=s(a,"META",{name:!0,content:!0}),a.forEach(t),at=o(e),et=s(e,"P",{}),b(et).forEach(t),nt=o(e),m(U.$$.fragment,e),ot=o(e),B=s(e,"P",{"data-svelte-h":!0}),d(B)!=="svelte-1avz9l5"&&(B.innerHTML=Ra),rt=o(e),m(z.$$.fragment,e),lt=o(e),J=s(e,"P",{"data-svelte-h":!0}),d(J)!=="svelte-lx4on6"&&(J.innerHTML=Na),it=o(e),E=s(e,"P",{"data-svelte-h":!0}),d(E)!=="svelte-vfdo9a"&&(E.textContent=Fa),st=o(e),H=s(e,"BLOCKQUOTE",{"data-svelte-h":!0}),d(H)!=="svelte-byw68w"&&(H.innerHTML=La),dt=o(e),q=s(e,"P",{"data-svelte-h":!0}),d(q)!=="svelte-gby4fv"&&(q.textContent=ja),ct=o(e),A=s(e,"P",{"data-svelte-h":!0}),d(A)!=="svelte-14fu8cb"&&(A.textContent=Ia),pt=o(e),D=s(e,"P",{"data-svelte-h":!0}),d(D)!=="svelte-1sqwqyq"&&(D.innerHTML=Wa),mt=o(e),V=s(e,"P",{"data-svelte-h":!0}),d(V)!=="svelte-koevdu"&&(V.innerHTML=Ua),gt=o(e),m(S.$$.fragment,e),ht=o(e),Q=s(e,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-1d01um3"&&(Q.innerHTML=Ba),ut=o(e),w=s(e,"IFRAME",{src:!0,frameborder:!0,width:!0,height:!0}),b(w).forEach(t),ft=o(e),Z=s(e,"P",{"data-svelte-h":!0}),d(Z)!=="svelte-uqytq6"&&(Z.textContent=Ja),_t=o(e),m(X.$$.fragment,e),vt=o(e),G=s(e,"P",{"data-svelte-h":!0}),d(G)!=="svelte-15hino8"&&(G.textContent=Ea),bt=o(e),m(Y.$$.fragment,e),yt=o(e),K=s(e,"P",{"data-svelte-h":!0}),d(K)!=="svelte-1k4c3p2"&&(K.textContent=Ha),Ot=o(e),ee=s(e,"P",{"data-svelte-h":!0}),d(ee)!=="svelte-s4edz4"&&(ee.innerHTML=qa),Tt=o(e),te=s(e,"P",{"data-svelte-h":!0}),d(te)!=="svelte-lsuodd"&&(te.innerHTML=Aa),wt=o(e),ae=s(e,"PRE",{"data-svelte-h":!0}),d(ae)!=="svelte-1ee0vfz"&&(ae.innerHTML=Da),xt=o(e),m(ne.$$.fragment,e),$t=o(e),oe=s(e,"P",{"data-svelte-h":!0}),d(oe)!=="svelte-1d4m998"&&(oe.innerHTML=Va),Pt=o(e),re=s(e,"P",{"data-svelte-h":!0}),d(re)!=="svelte-1c21q1z"&&(re.innerHTML=Sa),Mt=o(e),m(le.$$.fragment,e),Ct=o(e),ie=s(e,"P",{"data-svelte-h":!0}),d(ie)!=="svelte-197aywy"&&(ie.innerHTML=Qa),kt=o(e),se=s(e,"P",{"data-svelte-h":!0}),d(se)!=="svelte-1clopwb"&&(se.innerHTML=Za),Rt=o(e),m(de.$$.fragment,e),Nt=o(e),m(ce.$$.fragment,e),Ft=o(e),m(pe.$$.fragment,e),Lt=o(e),me=s(e,"P",{"data-svelte-h":!0}),d(me)!=="svelte-14px1ga"&&(me.innerHTML=Xa),jt=o(e),ge=s(e,"P",{"data-svelte-h":!0}),d(ge)!=="svelte-11it1aj"&&(ge.innerHTML=Ga),It=o(e),m(he.$$.fragment,e),Wt=o(e),ue=s(e,"P",{"data-svelte-h":!0}),d(ue)!=="svelte-132s7j9"&&(ue.textContent=Ya),Ut=o(e),fe=s(e,"UL",{"data-svelte-h":!0}),d(fe)!=="svelte-1uuduya"&&(fe.innerHTML=Ka),Bt=o(e),m(_e.$$.fragment,e),zt=o(e),c=s(e,"DIV",{class:!0});var _=b(c);m(ve.$$.fragment,_),Kt=o(_),Le=s(_,"P",{"data-svelte-h":!0}),d(Le)!=="svelte-1ggwo37"&&(Le.textContent=en),ea=o(_),C=s(_,"DIV",{class:!0});var Dt=b(C);m(be.$$.fragment,Dt),ta=o(Dt),je=s(Dt,"P",{"data-svelte-h":!0}),d(je)!=="svelte-mcz8nm"&&(je.innerHTML=tn),Dt.forEach(t),aa=o(_),x=s(_,"DIV",{class:!0});var Ge=b(x);m(ye.$$.fragment,Ge),na=o(Ge),Ie=s(Ge,"P",{"data-svelte-h":!0}),d(Ie)!=="svelte-16i1nac"&&(Ie.textContent=an),oa=o(Ge),We=s(Ge,"P",{"data-svelte-h":!0}),d(We)!=="svelte-tgti68"&&(We.textContent=nn),Ge.forEach(t),ra=o(_),k=s(_,"DIV",{class:!0});var Vt=b(k);m(Oe.$$.fragment,Vt),la=o(Vt),Ue=s(Vt,"P",{"data-svelte-h":!0}),d(Ue)!=="svelte-1cvsgkk"&&(Ue.textContent=on),Vt.forEach(t),ia=o(_),R=s(_,"DIV",{class:!0});var St=b(R);m(Te.$$.fragment,St),sa=o(St),Be=s(St,"P",{"data-svelte-h":!0}),d(Be)!=="svelte-1mh859w"&&(Be.innerHTML=rn),St.forEach(t),da=o(_),$=s(_,"DIV",{class:!0});var Ye=b($);m(we.$$.fragment,Ye),ca=o(Ye),ze=s(Ye,"P",{"data-svelte-h":!0}),d(ze)!=="svelte-8qlty5"&&(ze.innerHTML=ln),pa=o(Ye),Je=s(Ye,"P",{"data-svelte-h":!0}),d(Je)!=="svelte-1tyo99t"&&(Je.textContent=sn),Ye.forEach(t),ma=o(_),N=s(_,"DIV",{class:!0});var Qt=b(N);m(xe.$$.fragment,Qt),ga=o(Qt),Ee=s(Qt,"P",{"data-svelte-h":!0}),d(Ee)!=="svelte-18uwvbi"&&(Ee.textContent=dn),Qt.forEach(t),ha=o(_),F=s(_,"DIV",{class:!0});var Zt=b(F);m($e.$$.fragment,Zt),ua=o(Zt),He=s(Zt,"P",{"data-svelte-h":!0}),d(He)!=="svelte-4nmimv"&&(He.textContent=cn),Zt.forEach(t),fa=o(_),L=s(_,"DIV",{class:!0});var Xt=b(L);m(Pe.$$.fragment,Xt),_a=o(Xt),qe=s(Xt,"P",{"data-svelte-h":!0}),d(qe)!=="svelte-ndgk7s"&&(qe.textContent=pn),Xt.forEach(t),va=o(_),j=s(_,"DIV",{class:!0});var Gt=b(j);m(Me.$$.fragment,Gt),ba=o(Gt),Ae=s(Gt,"P",{"data-svelte-h":!0}),d(Ae)!=="svelte-nqksfz"&&(Ae.innerHTML=mn),Gt.forEach(t),ya=o(_),I=s(_,"DIV",{class:!0});var Yt=b(I);m(Ce.$$.fragment,Yt),Oa=o(Yt),De=s(Yt,"P",{"data-svelte-h":!0}),d(De)!=="svelte-y2dr0o"&&(De.textContent=gn),Yt.forEach(t),Ta=o(_),O=s(_,"DIV",{class:!0});var W=b(O);m(ke.$$.fragment,W),wa=o(W),Ve=s(W,"P",{"data-svelte-h":!0}),d(Ve)!=="svelte-xlsvih"&&(Ve.textContent=hn),xa=o(W),Se=s(W,"P",{"data-svelte-h":!0}),d(Se)!=="svelte-1mn1gnw"&&(Se.textContent=un),$a=o(W),Qe=s(W,"P",{"data-svelte-h":!0}),d(Qe)!=="svelte-1xvpyih"&&(Qe.textContent=fn),W.forEach(t),_.forEach(t),Jt=o(e),m(Re.$$.fragment,e),Et=o(e),T=s(e,"DIV",{class:!0});var Ke=b(T);m(Ne.$$.fragment,Ke),Pa=o(Ke),Ze=s(Ke,"P",{"data-svelte-h":!0}),d(Ze)!=="svelte-rsk48m"&&(Ze.innerHTML=_n),Ma=o(Ke),Xe=s(Ke,"P",{"data-svelte-h":!0}),d(Xe)!=="svelte-ekuf1t"&&(Xe.innerHTML=vn),Ke.forEach(t),Ht=o(e),m(Fe.$$.fragment,e),qt=o(e),tt=s(e,"P",{}),b(tt).forEach(t),this.h()},h(){v(M,"name","hf:doc:metadata"),v(M,"content",Cn),yn(w.src,za="https://huggingface.co/datasets/trl-lib/ultrafeedback_binarized/embed/viewer/default/train?row=0")||v(w,"src",za),v(w,"frameborder","0"),v(w,"width","100%"),v(w,"height","560px"),v(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,a){l(document.head,M),r(e,at,a),r(e,et,a),r(e,nt,a),g(U,e,a),r(e,ot,a),r(e,B,a),r(e,rt,a),g(z,e,a),r(e,lt,a),r(e,J,a),r(e,it,a),r(e,E,a),r(e,st,a),r(e,H,a),r(e,dt,a),r(e,q,a),r(e,ct,a),r(e,A,a),r(e,pt,a),r(e,D,a),r(e,mt,a),r(e,V,a),r(e,gt,a),g(S,e,a),r(e,ht,a),r(e,Q,a),r(e,ut,a),r(e,w,a),r(e,ft,a),r(e,Z,a),r(e,_t,a),g(X,e,a),r(e,vt,a),r(e,G,a),r(e,bt,a),g(Y,e,a),r(e,yt,a),r(e,K,a),r(e,Ot,a),r(e,ee,a),r(e,Tt,a),r(e,te,a),r(e,wt,a),r(e,ae,a),r(e,xt,a),g(ne,e,a),r(e,$t,a),r(e,oe,a),r(e,Pt,a),r(e,re,a),r(e,Mt,a),g(le,e,a),r(e,Ct,a),r(e,ie,a),r(e,kt,a),r(e,se,a),r(e,Rt,a),g(de,e,a),r(e,Nt,a),g(ce,e,a),r(e,Ft,a),g(pe,e,a),r(e,Lt,a),r(e,me,a),r(e,jt,a),r(e,ge,a),r(e,It,a),g(he,e,a),r(e,Wt,a),r(e,ue,a),r(e,Ut,a),r(e,fe,a),r(e,Bt,a),g(_e,e,a),r(e,zt,a),r(e,c,a),g(ve,c,null),l(c,Kt),l(c,Le),l(c,ea),l(c,C),g(be,C,null),l(C,ta),l(C,je),l(c,aa),l(c,x),g(ye,x,null),l(x,na),l(x,Ie),l(x,oa),l(x,We),l(c,ra),l(c,k),g(Oe,k,null),l(k,la),l(k,Ue),l(c,ia),l(c,R),g(Te,R,null),l(R,sa),l(R,Be),l(c,da),l(c,$),g(we,$,null),l($,ca),l($,ze),l($,pa),l($,Je),l(c,ma),l(c,N),g(xe,N,null),l(N,ga),l(N,Ee),l(c,ha),l(c,F),g($e,F,null),l(F,ua),l(F,He),l(c,fa),l(c,L),g(Pe,L,null),l(L,_a),l(L,qe),l(c,va),l(c,j),g(Me,j,null),l(j,ba),l(j,Ae),l(c,ya),l(c,I),g(Ce,I,null),l(I,Oa),l(I,De),l(c,Ta),l(c,O),g(ke,O,null),l(O,wa),l(O,Ve),l(O,xa),l(O,Se),l(O,$a),l(O,Qe),r(e,Jt,a),g(Re,e,a),r(e,Et,a),r(e,T,a),g(Ne,T,null),l(T,Pa),l(T,Ze),l(T,Ma),l(T,Xe),r(e,Ht,a),g(Fe,e,a),r(e,qt,a),r(e,tt,a),At=!0},p:On,i(e){At||(h(U.$$.fragment,e),h(z.$$.fragment,e),h(S.$$.fragment,e),h(X.$$.fragment,e),h(Y.$$.fragment,e),h(ne.$$.fragment,e),h(le.$$.fragment,e),h(de.$$.fragment,e),h(ce.$$.fragment,e),h(pe.$$.fragment,e),h(he.$$.fragment,e),h(_e.$$.fragment,e),h(ve.$$.fragment,e),h(be.$$.fragment,e),h(ye.$$.fragment,e),h(Oe.$$.fragment,e),h(Te.$$.fragment,e),h(we.$$.fragment,e),h(xe.$$.fragment,e),h($e.$$.fragment,e),h(Pe.$$.fragment,e),h(Me.$$.fragment,e),h(Ce.$$.fragment,e),h(ke.$$.fragment,e),h(Re.$$.fragment,e),h(Ne.$$.fragment,e),h(Fe.$$.fragment,e),At=!0)},o(e){u(U.$$.fragment,e),u(z.$$.fragment,e),u(S.$$.fragment,e),u(X.$$.fragment,e),u(Y.$$.fragment,e),u(ne.$$.fragment,e),u(le.$$.fragment,e),u(de.$$.fragment,e),u(ce.$$.fragment,e),u(pe.$$.fragment,e),u(he.$$.fragment,e),u(_e.$$.fragment,e),u(ve.$$.fragment,e),u(be.$$.fragment,e),u(ye.$$.fragment,e),u(Oe.$$.fragment,e),u(Te.$$.fragment,e),u(we.$$.fragment,e),u(xe.$$.fragment,e),u($e.$$.fragment,e),u(Pe.$$.fragment,e),u(Me.$$.fragment,e),u(Ce.$$.fragment,e),u(ke.$$.fragment,e),u(Re.$$.fragment,e),u(Ne.$$.fragment,e),u(Fe.$$.fragment,e),At=!1},d(e){e&&(t(at),t(et),t(nt),t(ot),t(B),t(rt),t(lt),t(J),t(it),t(E),t(st),t(H),t(dt),t(q),t(ct),t(A),t(pt),t(D),t(mt),t(V),t(gt),t(ht),t(Q),t(ut),t(w),t(ft),t(Z),t(_t),t(vt),t(G),t(bt),t(yt),t(K),t(Ot),t(ee),t(Tt),t(te),t(wt),t(ae),t(xt),t($t),t(oe),t(Pt),t(re),t(Mt),t(Ct),t(ie),t(kt),t(se),t(Rt),t(Nt),t(Ft),t(Lt),t(me),t(jt),t(ge),t(It),t(Wt),t(ue),t(Ut),t(fe),t(Bt),t(zt),t(c),t(Jt),t(Et),t(T),t(Ht),t(qt),t(tt)),t(M),f(U,e),f(z,e),f(S,e),f(X,e),f(Y,e),f(ne,e),f(le,e),f(de,e),f(ce,e),f(pe,e),f(he,e),f(_e,e),f(ve),f(be),f(ye),f(Oe),f(Te),f(we),f(xe),f($e),f(Pe),f(Me),f(Ce),f(ke),f(Re,e),f(Ne),f(Fe,e)}}}const Cn='{"title":"ORPO Trainer","local":"orpo-trainer","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Quick start","local":"quick-start","sections":[],"depth":2},{"title":"Expected dataset type","local":"expected-dataset-type","sections":[],"depth":2},{"title":"Example script","local":"example-script","sections":[],"depth":2},{"title":"Usage tips","local":"usage-tips","sections":[{"title":"For Mixture of Experts Models: Enabling the auxiliary loss","local":"for-mixture-of-experts-models-enabling-the-auxiliary-loss","sections":[],"depth":3}],"depth":2},{"title":"Logged metrics","local":"logged-metrics","sections":[],"depth":2},{"title":"ORPOTrainer","local":"trl.ORPOTrainer","sections":[],"depth":2},{"title":"ORPOConfig","local":"trl.ORPOConfig","sections":[],"depth":2}],"depth":1}';function kn(ka){return Tn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class In extends wn{constructor(M){super(),xn(this,M,kn,Mn,bn,{})}}export{In as component};
