import{s as de,o as ue,n as R}from"../chunks/scheduler.d627b047.js";import{S as he,i as ge,g as J,s as p,r as u,A as je,h as T,f as l,c as r,j as q,u as h,x as U,k as v,y as d,a as o,v as g,d as j,t as M,w as y}from"../chunks/index.73c51727.js";import{D}from"../chunks/Docstring.0ad99a5d.js";import{C as V}from"../chunks/CodeBlock.5f78c87f.js";import{E as X}from"../chunks/ExampleCodeBlock.e6081cec.js";import{H as k,E as Me}from"../chunks/index.8df1db42.js";function ye(x){let e,f="Examples:",i,a,c;return a=new V({props:{code:"ZXhhbXBsZSUyMCUzRCUyMCU3QiUyMnByb21wdCUyMiUzQSUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTVEJTdEJTBBaXNfY29udmVyc2F0aW9uYWwoZXhhbXBsZSklMEFleGFtcGxlJTIwJTNEJTIwJTdCJTIycHJvbXB0JTIyJTNBJTIwJTIyVGhlJTIwc2t5JTIwaXMlMjIlN0QpJTBBaXNfY29udmVyc2F0aW9uYWwoZXhhbXBsZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>example = {<span class="hljs-string">&quot;prompt&quot;</span>: [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>}]}
<span class="hljs-meta">&gt;&gt;&gt; </span>is_conversational(example)
<span class="hljs-literal">True</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>example = {<span class="hljs-string">&quot;prompt&quot;</span>: <span class="hljs-string">&quot;The sky is&quot;</span>})
<span class="hljs-meta">&gt;&gt;&gt; </span>is_conversational(example)
<span class="hljs-literal">False</span>`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-kvfsh7"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function Je(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJtaWNyb3NvZnQlMkZQaGktMy1taW5pLTEyOGstaW5zdHJ1Y3QlMjIpJTBBZXhhbXBsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnByb21wdCUyMiUzQSUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIyY29tcGxldGlvbiUyMiUzQSUyMCU1QiU3QiUyMnJvbGUlMjIlM0ElMjAlMjJhc3Npc3RhbnQlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySXQlMjBpcyUyMGJsdWUuJTIyJTdEJTVEJTBBJTdEJTBBYXBwbHlfY2hhdF90ZW1wbGF0ZShleGFtcGxlJTJDJTIwdG9rZW5pemVyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;microsoft/Phi-3-mini-128k-instruct&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>example = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;prompt&quot;</span>: [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>}],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;completion&quot;</span>: [{<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;It is blue.&quot;</span>}]
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>apply_chat_template(example, tokenizer)
{<span class="hljs-string">&#x27;prompt&#x27;</span>: <span class="hljs-string">&#x27;&lt;|user|&gt;\\nWhat color is the sky?&lt;|end|&gt;\\n&lt;|assistant|&gt;\\n&#x27;</span>, <span class="hljs-string">&#x27;completion&#x27;</span>: <span class="hljs-string">&#x27;It is blue.&lt;|end|&gt;\\n&lt;|endoftext|&gt;&#x27;</span>}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function Te(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMG1heWJlX2NvbnZlcnRfdG9fY2hhdG1sJTBBZXhhbXBsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmNvbnZlcnNhdGlvbnMlMjIlM0ElMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJmcm9tJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMnZhbHVlJTIyJTNBJTIwJTIyV2hhdCUyMGNvbG9yJTIwaXMlMjB0aGUlMjBza3klM0YlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJmcm9tJTIyJTNBJTIwJTIyYXNzaXN0YW50JTIyJTJDJTIwJTIydmFsdWUlMjIlM0ElMjAlMjJJdCUyMGlzJTIwYmx1ZS4lMjIlN0QlMEElMjAlMjAlMjAlMjAlNUQlMEElN0QlMEFtYXliZV9jb252ZXJ0X3RvX2NoYXRtbChleGFtcGxlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> maybe_convert_to_chatml
<span class="hljs-meta">&gt;&gt;&gt; </span>example = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;conversations&quot;</span>: [
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;from&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;value&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>},
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;from&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;value&quot;</span>: <span class="hljs-string">&quot;It is blue.&quot;</span>}
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>maybe_convert_to_chatml(example)
{<span class="hljs-string">&#x27;messages&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;user&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;What color is the sky?&#x27;</span>},
              {<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;assistant&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;It is blue.&#x27;</span>}]}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function fe(x){let e,f="Examples:",i,a,c;return a=new V({props:{code:"ZXhhbXBsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmNob3NlbiUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJJdCUyMGlzJTIwYmx1ZS4lMjIlN0QlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjJyZWplY3RlZCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJJdCUyMGlzJTIwZ3JlZW4uJTIyJTdEJTBBJTIwJTIwJTIwJTIwJTVEJTBBJTdEJTBBZXh0cmFjdF9wcm9tcHQoZXhhbXBsZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>example = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;chosen&quot;</span>: [
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>},
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;It is blue.&quot;</span>}
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;rejected&quot;</span>: [
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>},
<span class="hljs-meta">... </span>        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;It is green.&quot;</span>}
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>extract_prompt(example)
{<span class="hljs-string">&#x27;prompt&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;user&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;What color is the sky?&#x27;</span>}],
 <span class="hljs-string">&#x27;chosen&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;assistant&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;It is blue.&#x27;</span>}],
 <span class="hljs-string">&#x27;rejected&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;assistant&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;It is green.&#x27;</span>}]}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-kvfsh7"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function Ue(x){let e,f="Or, with the <code>map</code> method of <code>datasets.Dataset</code>:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMGV4dHJhY3RfcHJvbXB0JTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQWRhdGFzZXRfZGljdCUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmNob3NlbiUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJJdCUyMGlzJTIwYmx1ZS4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJXaGVyZSUyMGlzJTIwdGhlJTIwc3VuJTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJJbiUyMHRoZSUyMHNreS4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjJyZWplY3RlZCUyMiUzQSUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldoYXQlMjBjb2xvciUyMGlzJTIwdGhlJTIwc2t5JTNGJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMmFzc2lzdGFudCUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJJdCUyMGlzJTIwZ3JlZW4uJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyV2hlcmUlMjBpcyUyMHRoZSUyMHN1biUzRiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJhc3Npc3RhbnQlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIySW4lMjB0aGUlMjBzZWEuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTdEJTBBZGF0YXNldCUyMCUzRCUyMERhdGFzZXQuZnJvbV9kaWN0KGRhdGFzZXRfZGljdCklMEFkYXRhc2V0JTIwJTNEJTIwZGF0YXNldC5tYXAoZXh0cmFjdF9wcm9tcHQpJTBBZGF0YXNldCU1QjAlNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> extract_prompt
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_dict = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;chosen&quot;</span>: [
<span class="hljs-meta">... </span>        [
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>},
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;It is blue.&quot;</span>},
<span class="hljs-meta">... </span>        ],
<span class="hljs-meta">... </span>        [
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Where is the sun?&quot;</span>},
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;In the sky.&quot;</span>},
<span class="hljs-meta">... </span>        ],
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;rejected&quot;</span>: [
<span class="hljs-meta">... </span>        [
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;What color is the sky?&quot;</span>},
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;It is green.&quot;</span>},
<span class="hljs-meta">... </span>        ],
<span class="hljs-meta">... </span>        [
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Where is the sun?&quot;</span>},
<span class="hljs-meta">... </span>            {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;In the sea.&quot;</span>},
<span class="hljs-meta">... </span>        ],
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = Dataset.from_dict(dataset_dict)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.<span class="hljs-built_in">map</span>(extract_prompt)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;prompt&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;user&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;What color is the sky?&#x27;</span>}],
 <span class="hljs-string">&#x27;chosen&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;assistant&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;It is blue.&#x27;</span>}],
 <span class="hljs-string">&#x27;rejected&#x27;</span>: [{<span class="hljs-string">&#x27;role&#x27;</span>: <span class="hljs-string">&#x27;assistant&#x27;</span>, <span class="hljs-string">&#x27;content&#x27;</span>: <span class="hljs-string">&#x27;It is green.&#x27;</span>}]}`,wrap:!1}}),{c(){e=J("p"),e.innerHTML=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-ati26f"&&(e.innerHTML=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function xe(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQWRhdGFzZXRfZGljdCUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnByb21wdCUyMiUzQSUyMCU1QiUyMlRoZSUyMHNreSUyMGlzJTIyJTJDJTIwJTIyVGhlJTIwc3VuJTIwaXMlMjIlNUQlMEElMjAlMjAlMjAlMjAlMjJjaG9zZW4lMjIlM0ElMjAlNUIlMjIlMjBibHVlLiUyMiUyQyUyMCUyMmluJTIwdGhlJTIwc2t5LiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMnJlamVjdGVkJTIyJTNBJTIwJTVCJTIyJTIwZ3JlZW4uJTIyJTJDJTIwJTIyJTIwaW4lMjB0aGUlMjBzZWEuJTIyJTVEJTBBJTdEJTBBZGF0YXNldCUyMCUzRCUyMERhdGFzZXQuZnJvbV9kaWN0KGRhdGFzZXRfZGljdCklMEFkYXRhc2V0JTIwJTNEJTIwdW5wYWlyX3ByZWZlcmVuY2VfZGF0YXNldChkYXRhc2V0KSUwQWRhdGFzZXQlMEFkYXRhc2V0JTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_dict = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;prompt&quot;</span>: [<span class="hljs-string">&quot;The sky is&quot;</span>, <span class="hljs-string">&quot;The sun is&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;chosen&quot;</span>: [<span class="hljs-string">&quot; blue.&quot;</span>, <span class="hljs-string">&quot;in the sky.&quot;</span>],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;rejected&quot;</span>: [<span class="hljs-string">&quot; green.&quot;</span>, <span class="hljs-string">&quot; in the sea.&quot;</span>]
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = Dataset.from_dict(dataset_dict)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = unpair_preference_dataset(dataset)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset
Dataset({
    features: [<span class="hljs-string">&#x27;prompt&#x27;</span>, <span class="hljs-string">&#x27;completion&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>],
    num_rows: <span class="hljs-number">4</span>
})
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;prompt&#x27;</span>: <span class="hljs-string">&#x27;The sky is&#x27;</span>, <span class="hljs-string">&#x27;completion&#x27;</span>: <span class="hljs-string">&#x27; blue.&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-literal">True</span>}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function $e(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQWRhdGFzZXRfZGljdCUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnByb21wdCUyMiUzQSUyMCU1QiUyMlRoZSUyMHNreSUyMGlzJTIyJTJDJTIwJTIyVGhlJTIwc3VuJTIwaXMlMjIlNUQlMEElMjAlMjAlMjAlMjAlMjJjaG9zZW4lMjIlM0ElMjAlNUIlMjIlMjBibHVlLiUyMiUyQyUyMCUyMmluJTIwdGhlJTIwc2t5LiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMnJlamVjdGVkJTIyJTNBJTIwJTVCJTIyJTIwZ3JlZW4uJTIyJTJDJTIwJTIyJTIwaW4lMjB0aGUlMjBzZWEuJTIyJTVEJTBBJTdEJTBBZGF0YXNldCUyMCUzRCUyMERhdGFzZXQuZnJvbV9kaWN0KGRhdGFzZXRfZGljdCklMEFkYXRhc2V0JTIwJTNEJTIwdW5wYWlyX3ByZWZlcmVuY2VfZGF0YXNldChkYXRhc2V0KSUwQWRhdGFzZXQlMEFkYXRhc2V0JTVCMCU1RA==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset_dict = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;prompt&quot;</span>: [<span class="hljs-string">&quot;The sky is&quot;</span>, <span class="hljs-string">&quot;The sun is&quot;</span>]
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;chosen&quot;</span>: [<span class="hljs-string">&quot; blue.&quot;</span>, <span class="hljs-string">&quot;in the sky.&quot;</span>],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;rejected&quot;</span>: [<span class="hljs-string">&quot; green.&quot;</span>, <span class="hljs-string">&quot; in the sea.&quot;</span>]
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = Dataset.from_dict(dataset_dict)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = unpair_preference_dataset(dataset)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset
Dataset({
    features: [<span class="hljs-string">&#x27;prompt&#x27;</span>, <span class="hljs-string">&#x27;completion&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>],
    num_rows: <span class="hljs-number">4</span>
})
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">0</span>]
{<span class="hljs-string">&#x27;prompt&#x27;</span>: <span class="hljs-string">&#x27;The sky is&#x27;</span>, <span class="hljs-string">&#x27;completion&#x27;</span>: <span class="hljs-string">&#x27; blue.&#x27;</span>, <span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-literal">True</span>}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function be(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMHRybCUyMGltcG9ydCUyMHBhY2tfZXhhbXBsZXMlMEFleGFtcGxlcyUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmlucHV0X2lkcyUyMiUzQSUyMCU1QiU1QjElMkMlMjAyJTJDJTIwMyU1RCUyQyUyMCU1QjQlMkMlMjA1JTJDJTIwNiUyQyUyMDclNUQlMkMlMjAlNUI4JTVEJTVEJTJDJTBBJTIwJTIwJTIwJTIwJTIyYXR0ZW50aW9uX21hc2slMjIlM0ElMjAlNUIlNUIwJTJDJTIwMSUyQyUyMDElNUQlMkMlMjAlNUIwJTJDJTIwMCUyQyUyMDElMkMlMjAxJTVEJTJDJTIwJTVCMSU1RCU1RCUyQyUwQSU3RCUwQXBhY2tfZXhhbXBsZXMoZXhhbXBsZXMlMkMlMjBzZXFfbGVuZ3RoJTNENSklMEFwYWNrX2V4YW1wbGVzKGV4YW1wbGVzJTJDJTIwc2VxX2xlbmd0aCUzRDIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> trl <span class="hljs-keyword">import</span> pack_examples
<span class="hljs-meta">&gt;&gt;&gt; </span>examples = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;input_ids&quot;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>], [<span class="hljs-number">8</span>]],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;attention_mask&quot;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>]],
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>pack_examples(examples, seq_length=<span class="hljs-number">5</span>)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>], [<span class="hljs-number">6</span>, <span class="hljs-number">7</span>, <span class="hljs-number">8</span>]], <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]}
<span class="hljs-meta">&gt;&gt;&gt; </span>pack_examples(examples, seq_length=<span class="hljs-number">2</span>)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>, <span class="hljs-number">8</span>]], <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function we(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQWV4YW1wbGVzJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIyaW5wdXRfaWRzJTIyJTNBJTIwJTVCJTVCMSUyQyUyMDIlNUQlMkMlMjAlNUIzJTJDJTIwNCU1RCUyQyUyMCU1QjUlMkMlMjA2JTVEJTJDJTIwJTVCNyU1RCU1RCUyQyUwQSUyMCUyMCUyMCUyMCUyMmF0dGVudGlvbl9tYXNrJTIyJTNBJTIwJTVCJTVCMSUyQyUyMDElNUQlMkMlMjAlNUIwJTJDJTIwMSU1RCUyQyUyMCU1QjElMkMlMjAxJTVEJTJDJTIwJTVCMSU1RCU1RCUyQyUwQSU3RCUwQWRhdGFzZXQlMjAlM0QlMjBEYXRhc2V0LmZyb21fZGljdChleGFtcGxlcyklMEFwYWNrZWRfZGF0YXNldCUyMCUzRCUyMHBhY2tfZGF0YXNldChkYXRhc2V0JTJDJTIwc2VxX2xlbmd0aCUzRDQpJTBBcGFja2VkX2RhdGFzZXQlNUIlM0ElNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>examples = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;input_ids&quot;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>], [<span class="hljs-number">7</span>]],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;attention_mask&quot;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>]],
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = Dataset.from_dict(examples)
<span class="hljs-meta">&gt;&gt;&gt; </span>packed_dataset = pack_dataset(dataset, seq_length=<span class="hljs-number">4</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>packed_dataset[:]
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>], [<span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>]],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]]}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function _e(x){let e,f="Example:",i,a,c;return a=new V({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQWV4YW1wbGVzJTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIyaW5wdXRfaWRzJTIyJTNBJTIwJTVCJTVCMSUyQyUyMDIlMkMlMjAzJTVEJTJDJTIwJTVCNCUyQyUyMDUlMkMlMjA2JTJDJTIwNyU1RCUyQyUyMCU1QjglNUQlNUQlMkMlMEElMjAlMjAlMjAlMjAlMjJhdHRlbnRpb25fbWFzayUyMiUzQSUyMCU1QiU1QjAlMkMlMjAxJTJDJTIwMSU1RCUyQyUyMCU1QjAlMkMlMjAwJTJDJTIwMSUyQyUyMDElNUQlMkMlMjAlNUIxJTVEJTVEJTJDJTBBJTdEJTBBZGF0YXNldCUyMCUzRCUyMERhdGFzZXQuZnJvbV9kaWN0KGV4YW1wbGVzKSUwQXRydW5jYXRlZF9kYXRhc2V0JTIwJTNEJTIwdHJ1bmNhdGVfZGF0YXNldChkYXRhc2V0JTJDJTIwbWF4X2xlbmd0aCUzRDIpJTBBdHJ1bmNhdGVkX2RhdGFzZXQlNUIlM0ElNUQ=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset
<span class="hljs-meta">&gt;&gt;&gt; </span>examples = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;input_ids&quot;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">6</span>, <span class="hljs-number">7</span>], [<span class="hljs-number">8</span>]],
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;attention_mask&quot;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">1</span>]],
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = Dataset.from_dict(examples)
<span class="hljs-meta">&gt;&gt;&gt; </span>truncated_dataset = truncate_dataset(dataset, max_length=<span class="hljs-number">2</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>truncated_dataset[:]
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>], [<span class="hljs-number">4</span>, <span class="hljs-number">5</span>], [<span class="hljs-number">8</span>]],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>], [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>], [<span class="hljs-number">1</span>]]}`,wrap:!1}}),{c(){e=J("p"),e.textContent=f,i=p(),u(a.$$.fragment)},l(t){e=T(t,"P",{"data-svelte-h":!0}),U(e)!=="svelte-11lpom8"&&(e.textContent=f),i=r(t),h(a.$$.fragment,t)},m(t,m){o(t,e,m),o(t,i,m),g(a,t,m),c=!0},p:R,i(t){c||(j(a.$$.fragment,t),c=!0)},o(t){M(a.$$.fragment,t),c=!1},d(t){t&&(l(e),l(i)),y(a,t)}}}function Ie(x){let e,f,i,a,c,t,m,Ls,Q,os,Tt,qs,Yt="Check if the example is in a conversational format.",ft,O,Ps,cs,Os,G,is,Ut,vs,Ht="Apply a chat template to a conversational example along with the schema for a list of functions in <code>tools</code>.",xt,ks,Lt='For more details, see <a href="/docs/trl/main/en/data_utils#trl.maybe_apply_chat_template">maybe_apply_chat_template()</a>.',Ks,ms,st,$,ds,$t,Qs,Pt="If the example is in a conversational format, apply a chat template to it.",bt,Gs,Ot="Notes:",wt,Es,Kt=`<li><p>This function does not alter the keys, except for Language modeling dataset, where <code>&quot;messages&quot;</code> is replaced
by <code>&quot;text&quot;</code>.</p></li> <li><p>In case of prompt-only data, if the last role is <code>&quot;user&quot;</code>, the generation prompt is added to the prompt.
Else, if the last role is <code>&quot;assistant&quot;</code>, the final message is continued.</p></li>`,_t,K,tt,us,et,b,hs,It,Ns,se="Convert a conversational dataset with fields <code>from</code> and <code>value</code> to ChatML format.",Ct,As,te="This function modifies conversational data to align with OpenAI’s ChatML format:",qt,Zs,ee="<li>Replaces the key <code>&quot;from&quot;</code> with <code>&quot;role&quot;</code> in message dictionaries.</li> <li>Replaces the key <code>&quot;value&quot;</code> with <code>&quot;content&quot;</code> in message dictionaries.</li> <li>Renames <code>&quot;conversations&quot;</code> to <code>&quot;messages&quot;</code> for consistency with ChatML.</li>",vt,ss,at,gs,nt,E,js,kt,Bs,ae=`Extracts the shared prompt from a preference data example, where the prompt is implicit within both
the chosen and rejected completions.`,Qt,zs,ne='For more details, see <a href="/docs/trl/main/en/data_utils#trl.maybe_extract_prompt">maybe_extract_prompt()</a>.',lt,Ms,pt,w,ys,Gt,Ds,le=`Extracts the shared prompt from a preference data example, where the prompt is implicit within both
the chosen and rejected completions.`,Et,Xs,pe=`If the example already contains a <code>&quot;prompt&quot;</code> key, the function returns the example as is. Else, the function
identifies the longest common sequence (prefix) of conversation turns between the “chosen” and “rejected”
completions and extracts this as the prompt. It then removes this prompt from the respective “chosen” and
“rejected” completions.`,Nt,ts,At,es,rt,Js,ot,N,Ts,Zt,Rs,re="Unpair a preference dataset.",Bt,as,ct,fs,it,A,Us,zt,Vs,oe="Unpair a preference dataset if it is paired.",Dt,ns,mt,xs,dt,Z,$s,Xt,Ss,ce="Pack examples into chunks of size <code>seq_length</code>.",Rt,ls,ut,bs,ht,B,ws,Vt,Ws,ie="Pack sequences in a dataset into chunks of size <code>seq_length</code>.",St,ps,gt,_s,jt,z,Is,Wt,Fs,me="Truncate sequences in a dataset to a specifed <code>max_length</code>.",Ft,rs,Mt,Cs,yt,Hs,Jt;return c=new k({props:{title:"Data Utilities",local:"data-utilities",headingTag:"h1"}}),m=new k({props:{title:"is_conversational",local:"trl.is_conversational",headingTag:"h2"}}),os=new D({props:{name:"trl.is_conversational",anchor:"trl.is_conversational",parameters:[{name:"example",val:": dict"}],parametersDescription:[{anchor:"trl.is_conversational.example",description:`<strong>example</strong> (<code>dict[str, Any]</code>) &#x2014;
A single data entry of a dataset. The example can have different keys depending on the
dataset type.`,name:"example"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L30",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>True</code> if the data is in a conversational format, <code>False</code> otherwise.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>bool</code></p>
`}}),O=new X({props:{anchor:"trl.is_conversational.example",$$slots:{default:[ye]},$$scope:{ctx:x}}}),cs=new k({props:{title:"apply_chat_template",local:"trl.apply_chat_template",headingTag:"h2"}}),is=new D({props:{name:"trl.apply_chat_template",anchor:"trl.apply_chat_template",parameters:[{name:"example",val:": dict"},{name:"tokenizer",val:": PreTrainedTokenizerBase"},{name:"tools",val:": typing.Optional[list[typing.Union[dict, typing.Callable]]] = None"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L71"}}),ms=new k({props:{title:"maybe_apply_chat_template",local:"trl.maybe_apply_chat_template",headingTag:"h2"}}),ds=new D({props:{name:"trl.maybe_apply_chat_template",anchor:"trl.maybe_apply_chat_template",parameters:[{name:"example",val:": dict"},{name:"tokenizer",val:": PreTrainedTokenizerBase"},{name:"tools",val:": typing.Optional[list[typing.Union[dict, typing.Callable]]] = None"}],parametersDescription:[{anchor:"trl.maybe_apply_chat_template.example",description:`<strong>example</strong> (<code>dict[str, list[dict[str, str]]</code>) &#x2014;
Dictionary representing a single data entry of a conversational dataset. Each data entry can have different
keys depending on the dataset type. The supported dataset types are:</p>
<ul>
<li>Language modeling dataset: <code>&quot;messages&quot;</code>.</li>
<li>Prompt-only dataset: <code>&quot;prompt&quot;</code>.</li>
<li>Prompt-completion dataset: <code>&quot;prompt&quot;</code> and <code>&quot;completion&quot;</code>.</li>
<li>Preference dataset: <code>&quot;prompt&quot;</code>, <code>&quot;chosen&quot;</code>, and <code>&quot;rejected&quot;</code>.</li>
<li>Preference dataset with implicit prompt: <code>&quot;chosen&quot;</code> and <code>&quot;rejected&quot;</code>.</li>
<li>Unpaired preference dataset: <code>&quot;prompt&quot;</code>, <code>&quot;completion&quot;</code>, and <code>&quot;label&quot;</code>.</li>
</ul>
<p>For keys <code>&quot;messages&quot;</code>, <code>&quot;prompt&quot;</code>, <code>&quot;chosen&quot;</code>, <code>&quot;rejected&quot;</code>, and <code>&quot;completion&quot;</code>, the values are lists of
messages, where each message is a dictionary with keys <code>&quot;role&quot;</code> and <code>&quot;content&quot;</code>.`,name:"example"},{anchor:"trl.maybe_apply_chat_template.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizerBase</code>) &#x2014;
Tokenizer to apply the chat template with.`,name:"tokenizer"},{anchor:"trl.maybe_apply_chat_template.tools",description:`<strong>tools</strong> (<code>list[Union[dict, Callable]]</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
A list of tools (callable functions) that will be accessible to the model.
If the template does not support function calling, this argument will have no effect`,name:"tools"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L172",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Formatted example with the chat template applied.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>dict[str, str]</code></p>
`}}),K=new X({props:{anchor:"trl.maybe_apply_chat_template.example",$$slots:{default:[Je]},$$scope:{ctx:x}}}),us=new k({props:{title:"maybe_convert_to_chatml",local:"trl.maybe_convert_to_chatml",headingTag:"h2"}}),hs=new D({props:{name:"trl.maybe_convert_to_chatml",anchor:"trl.maybe_convert_to_chatml",parameters:[{name:"example",val:": dict"}],parametersDescription:[{anchor:"trl.maybe_convert_to_chatml.example",description:`<strong>example</strong> (<code>dict[str, list]</code>) &#x2014;
A single data entry containing a list of messages.`,name:"example"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L601",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Example reformatted to ChatML style.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>dict[str, list]</code></p>
`}}),ss=new X({props:{anchor:"trl.maybe_convert_to_chatml.example",$$slots:{default:[Te]},$$scope:{ctx:x}}}),gs=new k({props:{title:"extract_prompt",local:"trl.extract_prompt",headingTag:"h2"}}),js=new D({props:{name:"trl.extract_prompt",anchor:"trl.extract_prompt",parameters:[{name:"example",val:": dict"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L330"}}),Ms=new k({props:{title:"maybe_extract_prompt",local:"trl.maybe_extract_prompt",headingTag:"h2"}}),ys=new D({props:{name:"trl.maybe_extract_prompt",anchor:"trl.maybe_extract_prompt",parameters:[{name:"example",val:": dict"}],parametersDescription:[{anchor:"trl.maybe_extract_prompt.example",description:`<strong>example</strong> (<code>dict[str, list]</code>) &#x2014;
A dictionary representing a single data entry in the preference dataset. It must contain the keys
<code>&quot;chosen&quot;</code> and <code>&quot;rejected&quot;</code>, where each value is either conversational or standard (<code>str</code>).`,name:"example"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L349",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A dictionary containing:</p>
<ul>
<li><code>"prompt"</code>: The longest common prefix between the “chosen” and “rejected” completions.</li>
<li><code>"chosen"</code>: The remainder of the “chosen” completion, with the prompt removed.</li>
<li><code>"rejected"</code>: The remainder of the “rejected” completion, with the prompt removed.</li>
</ul>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>dict[str, list]</code></p>
`}}),ts=new X({props:{anchor:"trl.maybe_extract_prompt.example",$$slots:{default:[fe]},$$scope:{ctx:x}}}),es=new X({props:{anchor:"trl.maybe_extract_prompt.example-2",$$slots:{default:[Ue]},$$scope:{ctx:x}}}),Js=new k({props:{title:"unpair_preference_dataset",local:"trl.unpair_preference_dataset",headingTag:"h2"}}),Ts=new D({props:{name:"trl.unpair_preference_dataset",anchor:"trl.unpair_preference_dataset",parameters:[{name:"dataset",val:": ~DatasetType"},{name:"num_proc",val:": typing.Optional[int] = None"},{name:"desc",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"trl.unpair_preference_dataset.dataset",description:`<strong>dataset</strong> (<code>Dataset</code> or <code>DatasetDict</code>) &#x2014;
Preference dataset to unpair. The dataset must have columns <code>&quot;chosen&quot;</code>, <code>&quot;rejected&quot;</code> and optionally
<code>&quot;prompt&quot;</code>.`,name:"dataset"},{anchor:"trl.unpair_preference_dataset.num_proc",description:`<strong>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:"num_proc"},{anchor:"trl.unpair_preference_dataset.desc",description:`<strong>desc</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Meaningful description to be displayed alongside with the progress bar while mapping examples.`,name:"desc"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L241",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The unpaired preference dataset.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Dataset</code></p>
`}}),as=new X({props:{anchor:"trl.unpair_preference_dataset.example",$$slots:{default:[xe]},$$scope:{ctx:x}}}),fs=new k({props:{title:"maybe_unpair_preference_dataset",local:"trl.maybe_unpair_preference_dataset",headingTag:"h2"}}),Us=new D({props:{name:"trl.maybe_unpair_preference_dataset",anchor:"trl.maybe_unpair_preference_dataset",parameters:[{name:"dataset",val:": ~DatasetType"},{name:"num_proc",val:": typing.Optional[int] = None"},{name:"desc",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"trl.maybe_unpair_preference_dataset.dataset",description:`<strong>dataset</strong> (<code>Dataset</code> or <code>DatasetDict</code>) &#x2014;
Preference dataset to unpair. The dataset must have columns <code>&quot;chosen&quot;</code>, <code>&quot;rejected&quot;</code> and optionally
<code>&quot;prompt&quot;</code>.`,name:"dataset"},{anchor:"trl.maybe_unpair_preference_dataset.num_proc",description:`<strong>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:"num_proc"},{anchor:"trl.maybe_unpair_preference_dataset.desc",description:`<strong>desc</strong> (<code>str</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Meaningful description to be displayed alongside with the progress bar while mapping examples.`,name:"desc"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L282",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The unpaired preference dataset if it was paired, otherwise the original dataset.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Dataset</code> or <code>DatasetDict</code></p>
`}}),ns=new X({props:{anchor:"trl.maybe_unpair_preference_dataset.example",$$slots:{default:[$e]},$$scope:{ctx:x}}}),xs=new k({props:{title:"pack_examples",local:"trl.pack_examples",headingTag:"h2"}}),$s=new D({props:{name:"trl.pack_examples",anchor:"trl.pack_examples",parameters:[{name:"examples",val:": dict"},{name:"seq_length",val:": int"}],parametersDescription:[{anchor:"trl.pack_examples.examples",description:`<strong>examples</strong> (<code>dict[str, list[list]]</code>) &#x2014;
Dictionary of examples with keys as strings and values as lists of lists.`,name:"examples"},{anchor:"trl.pack_examples.seq_length",description:`<strong>seq_length</strong> (<code>int</code>) &#x2014;
Maximum sequence length.`,name:"seq_length"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L441",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>Dictionary of examples with keys as strings and values as lists of lists.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>dict[str, list[list]]</code></p>
`}}),ls=new X({props:{anchor:"trl.pack_examples.example",$$slots:{default:[be]},$$scope:{ctx:x}}}),bs=new k({props:{title:"pack_dataset",local:"trl.pack_dataset",headingTag:"h2"}}),ws=new D({props:{name:"trl.pack_dataset",anchor:"trl.pack_dataset",parameters:[{name:"dataset",val:": ~DatasetType"},{name:"seq_length",val:": int"},{name:"map_kwargs",val:": typing.Optional[dict[str, typing.Any]] = None"}],parametersDescription:[{anchor:"trl.pack_dataset.dataset",description:`<strong>dataset</strong> (<code>Dataset</code> or <code>DatasetDict</code>) &#x2014;
Dataset to pack`,name:"dataset"},{anchor:"trl.pack_dataset.seq_length",description:`<strong>seq_length</strong> (<code>int</code>) &#x2014;
Target sequence length to pack to.`,name:"seq_length"},{anchor:"trl.pack_dataset.map_kwargs",description:`<strong>map_kwargs</strong> (<code>dict</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Additional keyword arguments to pass to the dataset&#x2019;s map method when packing examples.`,name:"map_kwargs"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L475",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The dataset with packed sequences. The number of examples may
decrease as sequences are combined.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Dataset</code> or <code>DatasetDict</code></p>
`}}),ps=new X({props:{anchor:"trl.pack_dataset.example",$$slots:{default:[we]},$$scope:{ctx:x}}}),_s=new k({props:{title:"truncate_dataset",local:"trl.truncate_dataset",headingTag:"h2"}}),Is=new D({props:{name:"trl.truncate_dataset",anchor:"trl.truncate_dataset",parameters:[{name:"dataset",val:": ~DatasetType"},{name:"max_length",val:": int"},{name:"map_kwargs",val:": typing.Optional[dict[str, typing.Any]] = None"}],parametersDescription:[{anchor:"trl.truncate_dataset.dataset",description:`<strong>dataset</strong> (<code>Dataset</code> or <code>DatasetDict</code>) &#x2014;
Dataset to truncate.`,name:"dataset"},{anchor:"trl.truncate_dataset.seq_length",description:`<strong>seq_length</strong> (<code>int</code>) &#x2014;
Maximum sequence length to truncate to.`,name:"seq_length"},{anchor:"trl.truncate_dataset.map_kwargs",description:`<strong>map_kwargs</strong> (<code>dict</code> or <code>None</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Additional keyword arguments to pass to the dataset&#x2019;s map method when truncating examples.`,name:"map_kwargs"}],source:"https://github.com/huggingface/trl/blob/main/trl/data_utils.py#L537",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The dataset with truncated sequences.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>Dataset</code> or <code>DatasetDict</code></p>
`}}),rs=new X({props:{anchor:"trl.truncate_dataset.example",$$slots:{default:[_e]},$$scope:{ctx:x}}}),Cs=new Me({props:{source:"https://github.com/huggingface/trl/blob/main/docs/source/data_utils.md"}}),{c(){e=J("meta"),f=p(),i=J("p"),a=p(),u(c.$$.fragment),t=p(),u(m.$$.fragment),Ls=p(),Q=J("div"),u(os.$$.fragment),Tt=p(),qs=J("p"),qs.textContent=Yt,ft=p(),u(O.$$.fragment),Ps=p(),u(cs.$$.fragment),Os=p(),G=J("div"),u(is.$$.fragment),Ut=p(),vs=J("p"),vs.innerHTML=Ht,xt=p(),ks=J("p"),ks.innerHTML=Lt,Ks=p(),u(ms.$$.fragment),st=p(),$=J("div"),u(ds.$$.fragment),$t=p(),Qs=J("p"),Qs.textContent=Pt,bt=p(),Gs=J("p"),Gs.textContent=Ot,wt=p(),Es=J("ul"),Es.innerHTML=Kt,_t=p(),u(K.$$.fragment),tt=p(),u(us.$$.fragment),et=p(),b=J("div"),u(hs.$$.fragment),It=p(),Ns=J("p"),Ns.innerHTML=se,Ct=p(),As=J("p"),As.textContent=te,qt=p(),Zs=J("ul"),Zs.innerHTML=ee,vt=p(),u(ss.$$.fragment),at=p(),u(gs.$$.fragment),nt=p(),E=J("div"),u(js.$$.fragment),kt=p(),Bs=J("p"),Bs.textContent=ae,Qt=p(),zs=J("p"),zs.innerHTML=ne,lt=p(),u(Ms.$$.fragment),pt=p(),w=J("div"),u(ys.$$.fragment),Gt=p(),Ds=J("p"),Ds.textContent=le,Et=p(),Xs=J("p"),Xs.innerHTML=pe,Nt=p(),u(ts.$$.fragment),At=p(),u(es.$$.fragment),rt=p(),u(Js.$$.fragment),ot=p(),N=J("div"),u(Ts.$$.fragment),Zt=p(),Rs=J("p"),Rs.textContent=re,Bt=p(),u(as.$$.fragment),ct=p(),u(fs.$$.fragment),it=p(),A=J("div"),u(Us.$$.fragment),zt=p(),Vs=J("p"),Vs.textContent=oe,Dt=p(),u(ns.$$.fragment),mt=p(),u(xs.$$.fragment),dt=p(),Z=J("div"),u($s.$$.fragment),Xt=p(),Ss=J("p"),Ss.innerHTML=ce,Rt=p(),u(ls.$$.fragment),ut=p(),u(bs.$$.fragment),ht=p(),B=J("div"),u(ws.$$.fragment),Vt=p(),Ws=J("p"),Ws.innerHTML=ie,St=p(),u(ps.$$.fragment),gt=p(),u(_s.$$.fragment),jt=p(),z=J("div"),u(Is.$$.fragment),Wt=p(),Fs=J("p"),Fs.innerHTML=me,Ft=p(),u(rs.$$.fragment),Mt=p(),u(Cs.$$.fragment),yt=p(),Hs=J("p"),this.h()},l(s){const n=je("svelte-u9bgzb",document.head);e=T(n,"META",{name:!0,content:!0}),n.forEach(l),f=r(s),i=T(s,"P",{}),q(i).forEach(l),a=r(s),h(c.$$.fragment,s),t=r(s),h(m.$$.fragment,s),Ls=r(s),Q=T(s,"DIV",{class:!0});var S=q(Q);h(os.$$.fragment,S),Tt=r(S),qs=T(S,"P",{"data-svelte-h":!0}),U(qs)!=="svelte-q00sz7"&&(qs.textContent=Yt),ft=r(S),h(O.$$.fragment,S),S.forEach(l),Ps=r(s),h(cs.$$.fragment,s),Os=r(s),G=T(s,"DIV",{class:!0});var W=q(G);h(is.$$.fragment,W),Ut=r(W),vs=T(W,"P",{"data-svelte-h":!0}),U(vs)!=="svelte-pjar9v"&&(vs.innerHTML=Ht),xt=r(W),ks=T(W,"P",{"data-svelte-h":!0}),U(ks)!=="svelte-1b3iriy"&&(ks.innerHTML=Lt),W.forEach(l),Ks=r(s),h(ms.$$.fragment,s),st=r(s),$=T(s,"DIV",{class:!0});var _=q($);h(ds.$$.fragment,_),$t=r(_),Qs=T(_,"P",{"data-svelte-h":!0}),U(Qs)!=="svelte-1v8a0vq"&&(Qs.textContent=Pt),bt=r(_),Gs=T(_,"P",{"data-svelte-h":!0}),U(Gs)!=="svelte-1biq3pv"&&(Gs.textContent=Ot),wt=r(_),Es=T(_,"UL",{"data-svelte-h":!0}),U(Es)!=="svelte-1vl2nw4"&&(Es.innerHTML=Kt),_t=r(_),h(K.$$.fragment,_),_.forEach(l),tt=r(s),h(us.$$.fragment,s),et=r(s),b=T(s,"DIV",{class:!0});var I=q(b);h(hs.$$.fragment,I),It=r(I),Ns=T(I,"P",{"data-svelte-h":!0}),U(Ns)!=="svelte-1fnifvu"&&(Ns.innerHTML=se),Ct=r(I),As=T(I,"P",{"data-svelte-h":!0}),U(As)!=="svelte-1ibbdsi"&&(As.textContent=te),qt=r(I),Zs=T(I,"UL",{"data-svelte-h":!0}),U(Zs)!=="svelte-mbqtod"&&(Zs.innerHTML=ee),vt=r(I),h(ss.$$.fragment,I),I.forEach(l),at=r(s),h(gs.$$.fragment,s),nt=r(s),E=T(s,"DIV",{class:!0});var F=q(E);h(js.$$.fragment,F),kt=r(F),Bs=T(F,"P",{"data-svelte-h":!0}),U(Bs)!=="svelte-16hl5p6"&&(Bs.textContent=ae),Qt=r(F),zs=T(F,"P",{"data-svelte-h":!0}),U(zs)!=="svelte-1iykao4"&&(zs.innerHTML=ne),F.forEach(l),lt=r(s),h(Ms.$$.fragment,s),pt=r(s),w=T(s,"DIV",{class:!0});var C=q(w);h(ys.$$.fragment,C),Gt=r(C),Ds=T(C,"P",{"data-svelte-h":!0}),U(Ds)!=="svelte-16hl5p6"&&(Ds.textContent=le),Et=r(C),Xs=T(C,"P",{"data-svelte-h":!0}),U(Xs)!=="svelte-maka2s"&&(Xs.innerHTML=pe),Nt=r(C),h(ts.$$.fragment,C),At=r(C),h(es.$$.fragment,C),C.forEach(l),rt=r(s),h(Js.$$.fragment,s),ot=r(s),N=T(s,"DIV",{class:!0});var Y=q(N);h(Ts.$$.fragment,Y),Zt=r(Y),Rs=T(Y,"P",{"data-svelte-h":!0}),U(Rs)!=="svelte-xsd4cz"&&(Rs.textContent=re),Bt=r(Y),h(as.$$.fragment,Y),Y.forEach(l),ct=r(s),h(fs.$$.fragment,s),it=r(s),A=T(s,"DIV",{class:!0});var H=q(A);h(Us.$$.fragment,H),zt=r(H),Vs=T(H,"P",{"data-svelte-h":!0}),U(Vs)!=="svelte-zi61t2"&&(Vs.textContent=oe),Dt=r(H),h(ns.$$.fragment,H),H.forEach(l),mt=r(s),h(xs.$$.fragment,s),dt=r(s),Z=T(s,"DIV",{class:!0});var L=q(Z);h($s.$$.fragment,L),Xt=r(L),Ss=T(L,"P",{"data-svelte-h":!0}),U(Ss)!=="svelte-p9rs3t"&&(Ss.innerHTML=ce),Rt=r(L),h(ls.$$.fragment,L),L.forEach(l),ut=r(s),h(bs.$$.fragment,s),ht=r(s),B=T(s,"DIV",{class:!0});var P=q(B);h(ws.$$.fragment,P),Vt=r(P),Ws=T(P,"P",{"data-svelte-h":!0}),U(Ws)!=="svelte-bn3260"&&(Ws.innerHTML=ie),St=r(P),h(ps.$$.fragment,P),P.forEach(l),gt=r(s),h(_s.$$.fragment,s),jt=r(s),z=T(s,"DIV",{class:!0});var Ys=q(z);h(Is.$$.fragment,Ys),Wt=r(Ys),Fs=T(Ys,"P",{"data-svelte-h":!0}),U(Fs)!=="svelte-1twgtnd"&&(Fs.innerHTML=me),Ft=r(Ys),h(rs.$$.fragment,Ys),Ys.forEach(l),Mt=r(s),h(Cs.$$.fragment,s),yt=r(s),Hs=T(s,"P",{}),q(Hs).forEach(l),this.h()},h(){v(e,"name","hf:doc:metadata"),v(e,"content",Ce),v(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(G,"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(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(w,"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(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),v(z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(s,n){d(document.head,e),o(s,f,n),o(s,i,n),o(s,a,n),g(c,s,n),o(s,t,n),g(m,s,n),o(s,Ls,n),o(s,Q,n),g(os,Q,null),d(Q,Tt),d(Q,qs),d(Q,ft),g(O,Q,null),o(s,Ps,n),g(cs,s,n),o(s,Os,n),o(s,G,n),g(is,G,null),d(G,Ut),d(G,vs),d(G,xt),d(G,ks),o(s,Ks,n),g(ms,s,n),o(s,st,n),o(s,$,n),g(ds,$,null),d($,$t),d($,Qs),d($,bt),d($,Gs),d($,wt),d($,Es),d($,_t),g(K,$,null),o(s,tt,n),g(us,s,n),o(s,et,n),o(s,b,n),g(hs,b,null),d(b,It),d(b,Ns),d(b,Ct),d(b,As),d(b,qt),d(b,Zs),d(b,vt),g(ss,b,null),o(s,at,n),g(gs,s,n),o(s,nt,n),o(s,E,n),g(js,E,null),d(E,kt),d(E,Bs),d(E,Qt),d(E,zs),o(s,lt,n),g(Ms,s,n),o(s,pt,n),o(s,w,n),g(ys,w,null),d(w,Gt),d(w,Ds),d(w,Et),d(w,Xs),d(w,Nt),g(ts,w,null),d(w,At),g(es,w,null),o(s,rt,n),g(Js,s,n),o(s,ot,n),o(s,N,n),g(Ts,N,null),d(N,Zt),d(N,Rs),d(N,Bt),g(as,N,null),o(s,ct,n),g(fs,s,n),o(s,it,n),o(s,A,n),g(Us,A,null),d(A,zt),d(A,Vs),d(A,Dt),g(ns,A,null),o(s,mt,n),g(xs,s,n),o(s,dt,n),o(s,Z,n),g($s,Z,null),d(Z,Xt),d(Z,Ss),d(Z,Rt),g(ls,Z,null),o(s,ut,n),g(bs,s,n),o(s,ht,n),o(s,B,n),g(ws,B,null),d(B,Vt),d(B,Ws),d(B,St),g(ps,B,null),o(s,gt,n),g(_s,s,n),o(s,jt,n),o(s,z,n),g(Is,z,null),d(z,Wt),d(z,Fs),d(z,Ft),g(rs,z,null),o(s,Mt,n),g(Cs,s,n),o(s,yt,n),o(s,Hs,n),Jt=!0},p(s,[n]){const S={};n&2&&(S.$$scope={dirty:n,ctx:s}),O.$set(S);const W={};n&2&&(W.$$scope={dirty:n,ctx:s}),K.$set(W);const _={};n&2&&(_.$$scope={dirty:n,ctx:s}),ss.$set(_);const I={};n&2&&(I.$$scope={dirty:n,ctx:s}),ts.$set(I);const F={};n&2&&(F.$$scope={dirty:n,ctx:s}),es.$set(F);const C={};n&2&&(C.$$scope={dirty:n,ctx:s}),as.$set(C);const Y={};n&2&&(Y.$$scope={dirty:n,ctx:s}),ns.$set(Y);const H={};n&2&&(H.$$scope={dirty:n,ctx:s}),ls.$set(H);const L={};n&2&&(L.$$scope={dirty:n,ctx:s}),ps.$set(L);const P={};n&2&&(P.$$scope={dirty:n,ctx:s}),rs.$set(P)},i(s){Jt||(j(c.$$.fragment,s),j(m.$$.fragment,s),j(os.$$.fragment,s),j(O.$$.fragment,s),j(cs.$$.fragment,s),j(is.$$.fragment,s),j(ms.$$.fragment,s),j(ds.$$.fragment,s),j(K.$$.fragment,s),j(us.$$.fragment,s),j(hs.$$.fragment,s),j(ss.$$.fragment,s),j(gs.$$.fragment,s),j(js.$$.fragment,s),j(Ms.$$.fragment,s),j(ys.$$.fragment,s),j(ts.$$.fragment,s),j(es.$$.fragment,s),j(Js.$$.fragment,s),j(Ts.$$.fragment,s),j(as.$$.fragment,s),j(fs.$$.fragment,s),j(Us.$$.fragment,s),j(ns.$$.fragment,s),j(xs.$$.fragment,s),j($s.$$.fragment,s),j(ls.$$.fragment,s),j(bs.$$.fragment,s),j(ws.$$.fragment,s),j(ps.$$.fragment,s),j(_s.$$.fragment,s),j(Is.$$.fragment,s),j(rs.$$.fragment,s),j(Cs.$$.fragment,s),Jt=!0)},o(s){M(c.$$.fragment,s),M(m.$$.fragment,s),M(os.$$.fragment,s),M(O.$$.fragment,s),M(cs.$$.fragment,s),M(is.$$.fragment,s),M(ms.$$.fragment,s),M(ds.$$.fragment,s),M(K.$$.fragment,s),M(us.$$.fragment,s),M(hs.$$.fragment,s),M(ss.$$.fragment,s),M(gs.$$.fragment,s),M(js.$$.fragment,s),M(Ms.$$.fragment,s),M(ys.$$.fragment,s),M(ts.$$.fragment,s),M(es.$$.fragment,s),M(Js.$$.fragment,s),M(Ts.$$.fragment,s),M(as.$$.fragment,s),M(fs.$$.fragment,s),M(Us.$$.fragment,s),M(ns.$$.fragment,s),M(xs.$$.fragment,s),M($s.$$.fragment,s),M(ls.$$.fragment,s),M(bs.$$.fragment,s),M(ws.$$.fragment,s),M(ps.$$.fragment,s),M(_s.$$.fragment,s),M(Is.$$.fragment,s),M(rs.$$.fragment,s),M(Cs.$$.fragment,s),Jt=!1},d(s){s&&(l(f),l(i),l(a),l(t),l(Ls),l(Q),l(Ps),l(Os),l(G),l(Ks),l(st),l($),l(tt),l(et),l(b),l(at),l(nt),l(E),l(lt),l(pt),l(w),l(rt),l(ot),l(N),l(ct),l(it),l(A),l(mt),l(dt),l(Z),l(ut),l(ht),l(B),l(gt),l(jt),l(z),l(Mt),l(yt),l(Hs)),l(e),y(c,s),y(m,s),y(os),y(O),y(cs,s),y(is),y(ms,s),y(ds),y(K),y(us,s),y(hs),y(ss),y(gs,s),y(js),y(Ms,s),y(ys),y(ts),y(es),y(Js,s),y(Ts),y(as),y(fs,s),y(Us),y(ns),y(xs,s),y($s),y(ls),y(bs,s),y(ws),y(ps),y(_s,s),y(Is),y(rs),y(Cs,s)}}}const Ce='{"title":"Data Utilities","local":"data-utilities","sections":[{"title":"is_conversational","local":"trl.is_conversational","sections":[],"depth":2},{"title":"apply_chat_template","local":"trl.apply_chat_template","sections":[],"depth":2},{"title":"maybe_apply_chat_template","local":"trl.maybe_apply_chat_template","sections":[],"depth":2},{"title":"maybe_convert_to_chatml","local":"trl.maybe_convert_to_chatml","sections":[],"depth":2},{"title":"extract_prompt","local":"trl.extract_prompt","sections":[],"depth":2},{"title":"maybe_extract_prompt","local":"trl.maybe_extract_prompt","sections":[],"depth":2},{"title":"unpair_preference_dataset","local":"trl.unpair_preference_dataset","sections":[],"depth":2},{"title":"maybe_unpair_preference_dataset","local":"trl.maybe_unpair_preference_dataset","sections":[],"depth":2},{"title":"pack_examples","local":"trl.pack_examples","sections":[],"depth":2},{"title":"pack_dataset","local":"trl.pack_dataset","sections":[],"depth":2},{"title":"truncate_dataset","local":"trl.truncate_dataset","sections":[],"depth":2}],"depth":1}';function qe(x){return ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ae extends he{constructor(e){super(),ge(this,e,qe,Ie,de,{})}}export{Ae as component};
