import{S as ru,i as iu,s as lu,e as o,k as p,w as T,t,M as cu,c as a,d as n,m as g,a as r,x as j,h as s,b as u,G as e,g as b,y as v,q as J,o as U,B as x,v as du,L as Xe}from"../../chunks/vendor-hf-doc-builder.js";import{T as nn}from"../../chunks/Tip-hf-doc-builder.js";import{D as $}from"../../chunks/Docstring-hf-doc-builder.js";import{C as Re}from"../../chunks/CodeBlock-hf-doc-builder.js";import{I as Sa}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ne}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function mu(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdlbmVyYXRpb25Db25maWclMEElMEElMjMlMjBEb3dubG9hZCUyMGNvbmZpZ3VyYXRpb24lMjBmcm9tJTIwaHVnZ2luZ2ZhY2UuY28lMjBhbmQlMjBjYWNoZS4lMEFnZW5lcmF0aW9uX2NvbmZpZyUyMCUzRCUyMEdlbmVyYXRpb25Db25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBJTIzJTIwRS5nLiUyMGNvbmZpZyUyMHdhcyUyMHNhdmVkJTIwdXNpbmclMjAqc2F2ZV9wcmV0cmFpbmVkKCcuJTJGdGVzdCUyRnNhdmVkX21vZGVsJTJGJykqJTBBZ2VuZXJhdGlvbl9jb25maWcuc2F2ZV9wcmV0cmFpbmVkKCUyMi4lMkZ0ZXN0JTJGc2F2ZWRfbW9kZWwlMkYlMjIpJTBBZ2VuZXJhdGlvbl9jb25maWclMjAlM0QlMjBHZW5lcmF0aW9uQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjIuJTJGdGVzdCUyRnNhdmVkX21vZGVsJTJGJTIyKSUwQSUwQSUyMyUyMFlvdSUyMGNhbiUyMGFsc28lMjBzcGVjaWZ5JTIwY29uZmlndXJhdGlvbiUyMG5hbWVzJTIwdG8lMjB5b3VyJTIwZ2VuZXJhdGlvbiU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ighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GenerationConfig

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Download configuration from huggingface.co and cache.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config = GenerationConfig.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># E.g. config was saved using *save_pretrained(&#x27;./test/saved_model/&#x27;)*</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config.save_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config = GenerationConfig.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># You can also specify configuration names to your generation configuration file</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config.save_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>, config_file_name=<span class="hljs-string">&quot;my_configuration.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config = GenerationConfig.from_pretrained(<span class="hljs-string">&quot;./test/saved_model/&quot;</span>, <span class="hljs-string">&quot;my_configuration.json&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you&#x27;d like to try a minor variation to an existing configuration, you can also pass generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># arguments to \`.from_pretrained()\`. Be mindful that typos and unused arguments will be ignored</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config, unused_kwargs = GenerationConfig.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;gpt2&quot;</span>, top_k=<span class="hljs-number">1</span>, foo=<span class="hljs-literal">False</span>, do_sample=<span class="hljs-literal">True</span>, return_unused_kwargs=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config.top_k
<span class="hljs-number">1</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>unused_kwargs
{<span class="hljs-string">&#x27;foo&#x27;</span>: <span class="hljs-literal">False</span>}`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function pu(k){let c,_,m,d,f,i,h,G,w,y,E,Z,N,ie,F,q,S;return{c(){c=o("p"),_=t("Most generation-controlling parameters are set in "),m=o("code"),d=t("generation_config"),f=t(` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),i=o("code"),h=t("generation_config"),G=t(` by passing the corresponding
parameters to generate(), e.g. `),w=o("code"),y=t(".generate(inputs, num_beams=4, do_sample=True)"),E=t("."),Z=p(),N=o("p"),ie=t("For an overview of generation strategies and code examples, check out the "),F=o("a"),q=t(`following
guide`),S=t("."),this.h()},l(B){c=a(B,"P",{});var I=r(c);_=s(I,"Most generation-controlling parameters are set in "),m=a(I,"CODE",{});var P=r(m);d=s(P,"generation_config"),P.forEach(n),f=s(I,` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),i=a(I,"CODE",{});var Ve=r(i);h=s(Ve,"generation_config"),Ve.forEach(n),G=s(I,` by passing the corresponding
parameters to generate(), e.g. `),w=a(I,"CODE",{});var $e=r(w);y=s($e,".generate(inputs, num_beams=4, do_sample=True)"),$e.forEach(n),E=s(I,"."),I.forEach(n),Z=g(B),N=a(B,"P",{});var A=r(N);ie=s(A,"For an overview of generation strategies and code examples, check out the "),F=a(A,"A",{href:!0});var Se=r(F);q=s(Se,`following
guide`),Se.forEach(n),S=s(A,"."),A.forEach(n),this.h()},h(){u(F,"href","../generation_strategies")},m(B,I){b(B,c,I),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G),e(c,w),e(w,y),e(c,E),b(B,Z,I),b(B,N,I),e(N,ie),e(N,F),e(F,q),e(N,S)},d(B){B&&n(c),B&&n(Z),B&&n(N)}}}function gu(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQWltcG9ydCUyMG51bXB5JTIwYXMlMjBucCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEdQVDJUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEF0b2tlbml6ZXIucGFkX3Rva2VuX2lkJTIwJTNEJTIwdG9rZW5pemVyLmVvc190b2tlbl9pZCUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglNUIlMjJUb2RheSUyMGlzJTIyJTVEJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEElMjMlMjBFeGFtcGxlJTIwMSUzQSUyMFByaW50JTIwdGhlJTIwc2NvcmVzJTIwZm9yJTIwZWFjaCUyMHRva2VuJTIwZ2VuZXJhdGVkJTIwd2l0aCUyMEdyZWVkeSUyMFNlYXJjaCUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNENSUyQyUyMHJldHVybl9kaWN0X2luX2dlbmVyYXRlJTNEVHJ1ZSUyQyUyMG91dHB1dF9zY29yZXMlM0RUcnVlKSUwQXRyYW5zaXRpb25fc2NvcmVzJ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3JlcyUyMGlzJTIwb25seSUyMGd1YXJhbnRlZWQlMjB0byUyMG1hdGNoJTIwd2l0aCUyMCU2MG5vcm1hbGl6ZV9sb2dpdHMlM0RGYWxzZSU2MC4lMjBEZXBlbmRpbmclMjBvbiUyMHRoZSUwQSUyMyUyMHVzZSUyMGNhc2UlMkMlMjB5b3UlMjBtaWdodCUyMHdhbnQlMjB0byUyMHJlY29tcHV0ZSUyMGl0JTIwd2l0aCUyMCU2MG5vcm1hbGl6ZV9sb2dpdHMlM0RUcnVlJTYwLiUwQW91dHB1dF9sZW5ndGglMjAlM0QlMjBpbnB1dF9sZW5ndGglMjAlMkIlMjBucC5zdW0odHJhbnNpdGlvbl9zY29yZXMubnVtcHkoKSUyMCUzQyUyMDAlMkMlMjBheGlzJTNEMSklMEFsZW5ndGhfcGVuYWx0eSUyMCUzRCUyMG1vZGVsLmdlbmVyYXRpb25fY29uZmlnLmxlbmd0aF9wZW5hbHR5JTBBcmVjb25zdHJ1Y3RlZF9zY29yZXMlMjAlM0QlMjB0cmFuc2l0aW9uX3Njb3Jlcy5zdW0oYXhpcyUzRDEpJTIwJTJGJTIwKG91dHB1dF9sZW5ndGgqKmxlbmd0aF9wZW5hbHR5KSUwQXByaW50KG5wLmFsbGNsb3NlKG91dHB1dHMuc2VxdWVuY2VzX3Njb3JlcyUyQyUyMHJlY29uc3RydWN0ZWRfc2NvcmVzKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, AutoModelForCausalLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.pad_token_id = tokenizer.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer([<span class="hljs-string">&quot;Today is&quot;</span>], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Example 1: Print the scores for each token generated with Greedy Search</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, max_new_tokens=<span class="hljs-number">5</span>, return_dict_in_generate=<span class="hljs-literal">True</span>, output_scores=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transition_scores = model.compute_transition_scores(
<span class="hljs-meta">... </span>    outputs.sequences, outputs.scores, normalize_logits=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># input_length is the length of the input prompt for decoder-only models, like the GPT family, and 1 for</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># encoder-decoder models, like BART or T5.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_length = <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> model.config.is_encoder_decoder <span class="hljs-keyword">else</span> inputs.input_ids.shape[<span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_tokens = outputs.sequences[:, input_length:]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> tok, score <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(generated_tokens[<span class="hljs-number">0</span>], transition_scores[<span class="hljs-number">0</span>]):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># | token | token string | logits | probability</span>
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;| <span class="hljs-subst">{tok:5d}</span> | <span class="hljs-subst">{tokenizer.decode(tok):8s}</span> | <span class="hljs-subst">{score.numpy():<span class="hljs-number">.3</span>f}</span> | <span class="hljs-subst">{np.exp(score.numpy()):<span class="hljs-number">.2</span>%}</span>&quot;</span>)
|   <span class="hljs-number">262</span> |  the     | -<span class="hljs-number">1.414</span> | <span class="hljs-number">24.33</span>%
|  <span class="hljs-number">1110</span> |  day     | -<span class="hljs-number">2.609</span> | <span class="hljs-number">7.36</span>%
|   <span class="hljs-number">618</span> |  when    | -<span class="hljs-number">2.010</span> | <span class="hljs-number">13.40</span>%
|   <span class="hljs-number">356</span> |  we      | -<span class="hljs-number">1.859</span> | <span class="hljs-number">15.58</span>%
|   <span class="hljs-number">460</span> |  can     | -<span class="hljs-number">2.508</span> | <span class="hljs-number">8.14</span>%

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Example 2: Reconstruct the sequence scores from Beam Search</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">5</span>,
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    num_return_sequences=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    output_scores=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transition_scores = model.compute_transition_scores(
<span class="hljs-meta">... </span>    outputs.sequences, outputs.scores, outputs.beam_indices, normalize_logits=<span class="hljs-literal">False</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you sum the generated tokens&#x27; scores and apply the length penalty, you&#x27;ll get the sequence scores.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Tip: recomputing the scores is only guaranteed to match with \`normalize_logits=False\`. Depending on the</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># use case, you might want to recompute it with \`normalize_logits=True\`.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>output_length = input_length + np.<span class="hljs-built_in">sum</span>(transition_scores.numpy() &lt; <span class="hljs-number">0</span>, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>length_penalty = model.generation_config.length_penalty
<span class="hljs-meta">&gt;&gt;&gt; </span>reconstructed_scores = transition_scores.<span class="hljs-built_in">sum</span>(axis=<span class="hljs-number">1</span>) / (output_length**length_penalty)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(np.allclose(outputs.sequences_scores, reconstructed_scores))
<span class="hljs-literal">True</span>`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function hu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("greedy_search()"),f=t(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"greedy_search()"),E.forEach(n),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w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Nlc3NvcnMlMEFsb2dpdHNfcHJvY2Vzc29yJTIwJTNEJTIwTG9naXRzUHJvY2Vzc29yTGlzdCglMEElMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBNaW5MZW5ndGhMb2dpdHNQcm9jZXNzb3IoMTAlMkMlMjBlb3NfdG9rZW5faWQlM0Rtb2RlbC5nZW5lcmF0aW9uX2NvbmZpZy5lb3NfdG9rZW5faWQpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKSUwQXN0b3BwaW5nX2NyaXRlcmlhJTIwJTNEJTIwU3RvcHBpbmdDcml0ZXJpYUxpc3QoJTVCTWF4TGVuZ3RoQ3JpdGVyaWEobWF4X2xlbmd0aCUzRDIwKSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ3JlZWR5X3NlYXJjaCglMEElMjAlMjAlMjAlMjBpbnB1dF9pZHMlMkMlMjBsb2dpdHNfcHJvY2Vzc29yJTNEbG9naXRzX3Byb2Nlc3NvciUyQyUyMHN0b3BwaW5nX2NyaXRlcmlhJTNEc3RvcHBpbmdfY3JpdGVyaWElMEEpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForCausalLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    StoppingCriteriaList,
<span class="hljs-meta">... </span>    MaxLengthCriteria,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># set pad_token_id to eos_token_id because GPT2 does not have a PAD token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config.pad_token_id = model.generation_config.eos_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span>input_prompt = <span class="hljs-string">&quot;It might be possible to&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(input_prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        MinLengthLogitsProcessor(<span class="hljs-number">10</span>, eos_token_id=model.generation_config.eos_token_id),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>stopping_criteria = StoppingCriteriaList([MaxLengthCriteria(max_length=<span class="hljs-number">20</span>)])

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.greedy_search(
<span class="hljs-meta">... </span>    input_ids, logits_processor=logits_processor, stopping_criteria=stopping_criteria
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&quot;It might be possible to get a better understanding of the nature of the problem, but it&#x27;s not&quot;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function fu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("sample()"),f=t(` directly. Use generate() instead.
For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"sample()"),E.forEach(n),f=s(y,` directly. Use generate() instead.
For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w&&n(c)}}}function _u(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMEElMjAlMjAlMjAlMjBMb2dpdHNQcm9jZXNzb3JMaXN0JTJDJTBBJTIwJTIwJTIwJTIwTWluTGVuZ3RoTG9naXRzUHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwVG9wS0xvZ2l0c1dhcnBlciUyQyUwQSUyMCUyMCUyMCUyMFRlbXBlcmF0dXJlTG9naXRzV2FycGVyJTJDJTBBJTIwJTIwJTIwJTIwU3RvcHBpbmdDcml0ZXJpYUxpc3QlMkMlMEElMjAlMjAlMjAlMjBNYXhMZW5ndGhDcml0ZXJpYSUyQyUwQSklMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9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QWxvZ2l0c193YXJwZXIlMjAlM0QlMjBMb2dpdHNQcm9jZXNzb3JMaXN0KCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFRvcEtMb2dpdHNXYXJwZXIoNTApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwVGVtcGVyYXR1cmVMb2dpdHNXYXJwZXIoMC43KSUyQyUwQSUyMCUyMCUyMCUyMCU1RCUwQSklMEElMEFzdG9wcGluZ19jcml0ZXJpYSUyMCUzRCUyMFN0b3BwaW5nQ3JpdGVyaWFMaXN0KCU1Qk1heExlbmd0aENyaXRlcmlhKG1heF9sZW5ndGglM0QyMCklNUQpJTBBJTBBdG9yY2gubWFudWFsX3NlZWQoMCklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuc2FtcGxlKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGxvZ2l0c19wcm9jZXNzb3IlM0Rsb2dpdHNfcHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwbG9naXRzX3dhcnBlciUzRGxvZ2l0c193YXJwZXIlMkMlMEElMjAlMjAlMjAlMjBzdG9wcGluZ19jcml0ZXJpYSUzRHN0b3BwaW5nX2NyaXRlcmlhJTJDJTBBKSUwQSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForCausalLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    TopKLogitsWarper,
<span class="hljs-meta">... </span>    TemperatureLogitsWarper,
<span class="hljs-meta">... </span>    StoppingCriteriaList,
<span class="hljs-meta">... </span>    MaxLengthCriteria,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># set pad_token_id to eos_token_id because GPT2 does not have a EOS token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = model.config.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config.pad_token_id = model.config.eos_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span>input_prompt = <span class="hljs-string">&quot;Today is a beautiful day, and&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(input_prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        MinLengthLogitsProcessor(<span class="hljs-number">15</span>, eos_token_id=model.generation_config.eos_token_id),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_warper = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        TopKLogitsWarper(<span class="hljs-number">50</span>),
<span class="hljs-meta">... </span>        TemperatureLogitsWarper(<span class="hljs-number">0.7</span>),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>stopping_criteria = StoppingCriteriaList([MaxLengthCriteria(max_length=<span class="hljs-number">20</span>)])

<span class="hljs-meta">&gt;&gt;&gt; </span>torch.manual_seed(<span class="hljs-number">0</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.sample(
<span class="hljs-meta">... </span>    input_ids,
<span class="hljs-meta">... </span>    logits_processor=logits_processor,
<span class="hljs-meta">... </span>    logits_warper=logits_warper,
<span class="hljs-meta">... </span>    stopping_criteria=stopping_criteria,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Today is a beautiful day, and we must do everything possible to make it a day of celebration.&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function yu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("beam_search()"),f=t(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"beam_search()"),E.forEach(n),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(i,"href","../generation_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5MZW5ndGhMb2dpdHNQcm9jZXNzb3IoNSUyQyUyMGVvc190b2tlbl9pZCUzRG1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5iZWFtX3NlYXJjaChpbnB1dF9pZHMlMkMlMjBiZWFtX3Njb3JlciUyQyUyMGxvZ2l0c19wcm9jZXNzb3IlM0Rsb2dpdHNfcHJvY2Vzc29yJTJDJTIwKiptb2RlbF9rd2FyZ3MpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForSeq2SeqLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    BeamSearchScorer,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_str = <span class="hljs-string">&quot;translate English to German: How old are you?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_ids = tokenizer(encoder_input_str, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># lets run beam search using 3 beams</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_beams = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># define decoder start token ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.ones((num_beams, <span class="hljs-number">1</span>), device=model.device, dtype=torch.long)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_ids * model.config.decoder_start_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add encoder_outputs to model keyword arguments</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_kwargs = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;encoder_outputs&quot;</span>: model.get_encoder()(
<span class="hljs-meta">... </span>        encoder_input_ids.repeat_interleave(num_beams, dim=<span class="hljs-number">0</span>), return_dict=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate beam scorer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>beam_scorer = BeamSearchScorer(
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    num_beams=num_beams,
<span class="hljs-meta">... </span>    device=model.device,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        MinLengthLogitsProcessor(<span class="hljs-number">5</span>, eos_token_id=model.config.eos_token_id),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.beam_search(input_ids, beam_scorer, logits_processor=logits_processor, **model_kwargs)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Wie alt bist du?&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function bu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("beam_sample()"),f=t(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"beam_sample()"),E.forEach(n),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w&&n(c)}}}function wu(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNJTJDJTBBJTIwJTIwJTIwJTIwTG9naXRzUHJvY2Vzc29yTGlzdCUyQyUwQSUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMFRvcEtMb2dpdHNXYXJwZXIlMkM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UyMCUyMCUyMCUyMFRvcEtMb2dpdHNXYXJwZXIoNTApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwVGVtcGVyYXR1cmVMb2dpdHNXYXJwZXIoMC43KSUyQyUwQSUyMCUyMCUyMCUyMCU1RCUwQSklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuYmVhbV9zYW1wbGUoJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTJDJTIwYmVhbV9zY29yZXIlMkMlMjBsb2dpdHNfcHJvY2Vzc29yJTNEbG9naXRzX3Byb2Nlc3NvciUyQyUyMGxvZ2l0c193YXJwZXIlM0Rsb2dpdHNfd2FycGVyJTJDJTIwKiptb2RlbF9rd2FyZ3MlMEEpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForSeq2SeqLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    TopKLogitsWarper,
<span class="hljs-meta">... </span>    TemperatureLogitsWarper,
<span class="hljs-meta">... </span>    BeamSearchScorer,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_str = <span class="hljs-string">&quot;translate English to German: How old are you?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_ids = tokenizer(encoder_input_str, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># lets run beam search using 3 beams</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_beams = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># define decoder start token ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.ones((num_beams, <span class="hljs-number">1</span>), device=model.device, dtype=torch.long)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_ids * model.config.decoder_start_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add encoder_outputs to model keyword arguments</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_kwargs = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;encoder_outputs&quot;</span>: model.get_encoder()(
<span class="hljs-meta">... </span>        encoder_input_ids.repeat_interleave(num_beams, dim=<span class="hljs-number">0</span>), return_dict=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate beam scorer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>beam_scorer = BeamSearchScorer(
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    max_length=model.config.max_length,
<span class="hljs-meta">... </span>    num_beams=num_beams,
<span class="hljs-meta">... </span>    device=model.device,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [MinLengthLogitsProcessor(<span class="hljs-number">5</span>, eos_token_id=model.config.eos_token_id)]
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_warper = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        TopKLogitsWarper(<span class="hljs-number">50</span>),
<span class="hljs-meta">... </span>        TemperatureLogitsWarper(<span class="hljs-number">0.7</span>),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.beam_sample(
<span class="hljs-meta">... </span>    input_ids, beam_scorer, logits_processor=logits_processor, logits_warper=logits_warper, **model_kwargs
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Wie alt bist du?&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function Tu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("contrastive_search()"),f=t(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"contrastive_search()"),E.forEach(n),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w&&n(c)}}}function ju(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMEElMjAlMjAlMjAlMjBTdG9wcGluZ0NyaXRlcmlhTGlzdCUyQyUwQSUyMCUyMCUyMCUyME1heExlbmd0aENyaXRlcmlhJTJDJTBBKSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmZhY2Vib29rJTJGb3B0LTEyNW0lMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZmFjZWJvb2slMkZvcHQtMTI1bSUyMiklMEElMjMlMjBzZXQlMjBwYWRfdG9rZW5faWQlMjB0byUyMGVvc190b2tlbl9pZCUyMGJlY2F1c2UlMjBPUFQlMjBkb2VzJTIwbm90JTIwaGF2ZSUyMGElMjBQQUQlMjB0b2tlbiUwQW1vZGVsLmNvbmZpZy5wYWRfdG9rZW5faWQlMjAlM0QlMjBtb2RlbC5jb25maWcuZW9zX3Rva2VuX2lkJTBBaW5wdXRfcHJvbXB0JTIwJTNEJTIwJTIyRGVlcE1pbmQlMjBDb21wYW55JTIwaXMlMjIlMEFpbnB1dF9pZHMlMjAlM0QlMjB0b2tlbml6ZXIoaW5wdXRfcHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEFzdG9wcGluZ19jcml0ZXJpYSUyMCUzRCUyMFN0b3BwaW5nQ3JpdGVyaWFMaXN0KCU1Qk1heExlbmd0aENyaXRlcmlhKG1heF9sZW5ndGglM0Q2NCklNUQpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmNvbnRyYXN0aXZlX3NlYXJjaCglMEElMjAlMjAlMjAlMjAqKmlucHV0X2lkcyUyQyUyMHBlbmFsdHlfYWxwaGElM0QwLjYlMkMlMjB0b3BfayUzRDQlMkMlMjBzdG9wcGluZ19jcml0ZXJpYSUzRHN0b3BwaW5nX2NyaXRlcmlhJTBBKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForCausalLM,
<span class="hljs-meta">... </span>    StoppingCriteriaList,
<span class="hljs-meta">... </span>    MaxLengthCriteria,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;facebook/opt-125m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;facebook/opt-125m&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># set pad_token_id to eos_token_id because OPT does not have a PAD token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model.config.pad_token_id = model.config.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>input_prompt = <span class="hljs-string">&quot;DeepMind Company is&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = tokenizer(input_prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>stopping_criteria = StoppingCriteriaList([MaxLengthCriteria(max_length=<span class="hljs-number">64</span>)])
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.contrastive_search(
<span class="hljs-meta">... </span>    **input_ids, penalty_alpha=<span class="hljs-number">0.6</span>, top_k=<span class="hljs-number">4</span>, stopping_criteria=stopping_criteria
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;DeepMind Company is a company that focuses on the development and commercialization of artificial intelligence (AI). DeepMind\u2019s mission is to help people understand and solve problems that are difficult to solve in the world today.\\n\\nIn this post, we talk about the benefits of deep learning in business and how it&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function vu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("group_beam_search()"),f=t(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"group_beam_search()"),E.forEach(n),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w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vcnMlMEFsb2dpdHNfcHJvY2Vzc29yJTIwJTNEJTIwTG9naXRzUHJvY2Vzc29yTGlzdCglMEElMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBIYW1taW5nRGl2ZXJzaXR5TG9naXRzUHJvY2Vzc29yKDUuNSUyQyUyMG51bV9iZWFtcyUzRDYlMkMlMjBudW1fYmVhbV9ncm91cHMlM0QzKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3Nvcig1JTJDJTIwZW9zX3Rva2VuX2lkJTNEbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCklMkMlMEElMjAlMjAlMjAlMjAlNUQlMEEpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdyb3VwX2JlYW1fc2VhcmNoKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUyMGJlYW1fc2NvcmVyJTJDJTIwbG9naXRzX3Byb2Nlc3NvciUzRGxvZ2l0c19wcm9jZXNzb3IlMkMlMjAqKm1vZGVsX2t3YXJncyUwQSklMEElMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForSeq2SeqLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    HammingDiversityLogitsProcessor,
<span class="hljs-meta">... </span>    BeamSearchScorer,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_str = <span class="hljs-string">&quot;translate English to German: How old are you?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_ids = tokenizer(encoder_input_str, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># lets run diverse beam search using 6 beams</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_beams = <span class="hljs-number">6</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># define decoder start token ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.ones((num_beams, <span class="hljs-number">1</span>), device=model.device, dtype=torch.long)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_ids * model.config.decoder_start_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add encoder_outputs to model keyword arguments</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_kwargs = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;encoder_outputs&quot;</span>: model.get_encoder()(
<span class="hljs-meta">... </span>        encoder_input_ids.repeat_interleave(num_beams, dim=<span class="hljs-number">0</span>), return_dict=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>}

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate beam scorer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>beam_scorer = BeamSearchScorer(
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    max_length=model.config.max_length,
<span class="hljs-meta">... </span>    num_beams=num_beams,
<span class="hljs-meta">... </span>    device=model.device,
<span class="hljs-meta">... </span>    num_beam_groups=<span class="hljs-number">3</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        HammingDiversityLogitsProcessor(<span class="hljs-number">5.5</span>, num_beams=<span class="hljs-number">6</span>, num_beam_groups=<span class="hljs-number">3</span>),
<span class="hljs-meta">... </span>        MinLengthLogitsProcessor(<span class="hljs-number">5</span>, eos_token_id=model.config.eos_token_id),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.group_beam_search(
<span class="hljs-meta">... </span>    input_ids, beam_scorer, logits_processor=logits_processor, **model_kwargs
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Wie alt bist du?&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function Uu(k){let c,_,m,d,f,i,h,G;return{c(){c=o("p"),_=t("In most cases, you do not need to call "),m=o("a"),d=t("constrained_beam_search()"),f=t(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=o("a"),h=t(`following
guide`),G=t("."),this.h()},l(w){c=a(w,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),m=a(y,"A",{href:!0});var E=r(m);d=s(E,"constrained_beam_search()"),E.forEach(n),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),i=a(y,"A",{href:!0});var Z=r(i);h=s(Z,`following
guide`),Z.forEach(n),G=s(y,"."),y.forEach(n),this.h()},h(){u(m,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.constrained_beam_search"),u(i,"href","../generation_strategies")},m(w,y){b(w,c,y),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G)},d(w){w&&n(c)}}}function xu(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNJTJDJTBBJTIwJTIwJTIwJTIwTG9naXRzUHJvY2Vzc29yTGlzdCUyQyUwQSUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMENvbnN0cmFpbmVkQmVhbVNlYXJjaFNjb3JlciUyQyUwQSUyMCUyMCUyMCUyMFBocmFzYWxDb25zdHJhaW50JTJDJTBBKSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydDUtYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIydDUtYmFzZSUyMiklMEElMEFlbmNvZGVyX2lucHV0X3N0ciUyMCUzRCUyMCUyMnRyYW5zbGF0ZSUyMEVuZ2xpc2glMjB0byUyMEdlcm1hbiUzQSUyMEhvdyUyMG9sZCUyMGFyZSUyMHlvdSUzRiUyMiUwQWVuY29kZXJfaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyKGVuY29kZXJfaW5wdXRfc3RyJTJDJTIwcmV0dXJu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&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> (
<span class="hljs-meta">... </span>    AutoTokenizer,
<span class="hljs-meta">... </span>    AutoModelForSeq2SeqLM,
<span class="hljs-meta">... </span>    LogitsProcessorList,
<span class="hljs-meta">... </span>    MinLengthLogitsProcessor,
<span class="hljs-meta">... </span>    ConstrainedBeamSearchScorer,
<span class="hljs-meta">... </span>    PhrasalConstraint,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;t5-base&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_str = <span class="hljs-string">&quot;translate English to German: How old are you?&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>encoder_input_ids = tokenizer(encoder_input_str, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>).input_ids


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># lets run beam search using 3 beams</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_beams = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># define decoder start token ids</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = torch.ones((num_beams, <span class="hljs-number">1</span>), device=model.device, dtype=torch.long)
<span class="hljs-meta">&gt;&gt;&gt; </span>input_ids = input_ids * model.config.decoder_start_token_id

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># add encoder_outputs to model keyword arguments</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_kwargs = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;encoder_outputs&quot;</span>: model.get_encoder()(
<span class="hljs-meta">... </span>        encoder_input_ids.repeat_interleave(num_beams, dim=<span class="hljs-number">0</span>), return_dict=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>    )
<span class="hljs-meta">... </span>}

<span class="hljs-meta">&gt;&gt;&gt; </span>constraint_str = <span class="hljs-string">&quot;Sie&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>constraint_token_ids = tokenizer.encode(constraint_str)[:-<span class="hljs-number">1</span>]  <span class="hljs-comment"># slice to remove eos token</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>constraints = [PhrasalConstraint(token_ids=constraint_token_ids)]


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate beam scorer</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>beam_scorer = ConstrainedBeamSearchScorer(
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">1</span>, num_beams=num_beams, device=model.device, constraints=constraints
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># instantiate logits processors</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logits_processor = LogitsProcessorList(
<span class="hljs-meta">... </span>    [
<span class="hljs-meta">... </span>        MinLengthLogitsProcessor(<span class="hljs-number">5</span>, eos_token_id=model.config.eos_token_id),
<span class="hljs-meta">... </span>    ]
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.constrained_beam_search(
<span class="hljs-meta">... </span>    input_ids, beam_scorer, constraints=constraints, logits_processor=logits_processor, **model_kwargs
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
[<span class="hljs-string">&#x27;Wie alt sind Sie?&#x27;</span>]`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function Gu(k){let c,_,m,d,f,i,h,G,w,y,E,Z,N,ie,F,q,S;return{c(){c=o("p"),_=t("Most generation-controlling parameters are set in "),m=o("code"),d=t("generation_config"),f=t(` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),i=o("code"),h=t("generation_config"),G=t(` by passing the corresponding
parameters to generate, e.g. `),w=o("code"),y=t(".generate(inputs, num_beams=4, do_sample=True)"),E=t("."),Z=p(),N=o("p"),ie=t("For an overview of generation strategies and code examples, check out the "),F=o("a"),q=t(`following
guide`),S=t("."),this.h()},l(B){c=a(B,"P",{});var I=r(c);_=s(I,"Most generation-controlling parameters are set in "),m=a(I,"CODE",{});var P=r(m);d=s(P,"generation_config"),P.forEach(n),f=s(I,` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),i=a(I,"CODE",{});var Ve=r(i);h=s(Ve,"generation_config"),Ve.forEach(n),G=s(I,` by passing the corresponding
parameters to generate, e.g. `),w=a(I,"CODE",{});var $e=r(w);y=s($e,".generate(inputs, num_beams=4, do_sample=True)"),$e.forEach(n),E=s(I,"."),I.forEach(n),Z=g(B),N=a(B,"P",{});var A=r(N);ie=s(A,"For an overview of generation strategies and code examples, check out the "),F=a(A,"A",{href:!0});var Se=r(F);q=s(Se,`following
guide`),Se.forEach(n),S=s(A,"."),A.forEach(n),this.h()},h(){u(F,"href","../generation_strategies")},m(B,I){b(B,c,I),e(c,_),e(c,m),e(m,d),e(c,f),e(c,i),e(i,h),e(c,G),e(c,w),e(w,y),e(c,E),b(B,Z,I),b(B,N,I),e(N,ie),e(N,F),e(F,q),e(N,S)},d(B){B&&n(c),B&&n(Z),B&&n(N)}}}function ku(k){let c,_,m,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydC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FvdXRwdXRfbGVuZ3RoJTIwJTNEJTIwaW5wdXRfbGVuZ3RoJTIwJTJCJTIwbnAuc3VtKHRyYW5zaXRpb25fc2NvcmVzLm51bXB5KCklMjAlM0MlMjAwJTJDJTIwYXhpcyUzRDEpJTBBbGVuZ3RoX3BlbmFsdHklMjAlM0QlMjBtb2RlbC5nZW5lcmF0aW9uX2NvbmZpZy5sZW5ndGhfcGVuYWx0eSUwQXJlY29uc3RydWN0ZWRfc2NvcmVzJTIwJTNEJTIwbnAuc3VtKHRyYW5zaXRpb25fc2NvcmVzJTJDJTIwYXhpcyUzRDEpJTIwJTJGJTIwKG91dHB1dF9sZW5ndGgqKmxlbmd0aF9wZW5hbHR5KSUwQXByaW50KG5wLmFsbGNsb3NlKG91dHB1dHMuc2VxdWVuY2VzX3Njb3JlcyUyQyUyMHJlY29uc3RydWN0ZWRfc2NvcmVzKSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> GPT2Tokenizer, TFAutoModelForCausalLM
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = GPT2Tokenizer.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;gpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.pad_token_id = tokenizer.eos_token_id
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer([<span class="hljs-string">&quot;Today is&quot;</span>], return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Example 1: Print the scores for each token generated with Greedy Search</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, max_new_tokens=<span class="hljs-number">5</span>, return_dict_in_generate=<span class="hljs-literal">True</span>, output_scores=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transition_scores = model.compute_transition_scores(
<span class="hljs-meta">... </span>    outputs.sequences, outputs.scores, normalize_logits=<span class="hljs-literal">True</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># input_length is the length of the input prompt for decoder-only models, like the GPT family, and 1 for</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># encoder-decoder models, like BART or T5.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>input_length = <span class="hljs-number">1</span> <span class="hljs-keyword">if</span> model.config.is_encoder_decoder <span class="hljs-keyword">else</span> inputs.input_ids.shape[<span class="hljs-number">1</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>generated_tokens = outputs.sequences[:, input_length:]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> tok, score <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(generated_tokens[<span class="hljs-number">0</span>], transition_scores[<span class="hljs-number">0</span>]):
<span class="hljs-meta">... </span>    <span class="hljs-comment"># | token | token string | logits | probability</span>
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;| <span class="hljs-subst">{tok:5d}</span> | <span class="hljs-subst">{tokenizer.decode(tok):8s}</span> | <span class="hljs-subst">{score.numpy():<span class="hljs-number">.3</span>f}</span> | <span class="hljs-subst">{np.exp(score.numpy()):<span class="hljs-number">.2</span>%}</span>&quot;</span>)
|   <span class="hljs-number">262</span> |  the     | -<span class="hljs-number">1.413</span> | <span class="hljs-number">24.33</span>%
|  <span class="hljs-number">1110</span> |  day     | -<span class="hljs-number">2.609</span> | <span class="hljs-number">7.36</span>%
|   <span class="hljs-number">618</span> |  when    | -<span class="hljs-number">2.009</span> | <span class="hljs-number">13.41</span>%
|   <span class="hljs-number">356</span> |  we      | -<span class="hljs-number">1.859</span> | <span class="hljs-number">15.58</span>%
|   <span class="hljs-number">460</span> |  can     | -<span class="hljs-number">2.508</span> | <span class="hljs-number">8.14</span>%

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Example 2: Reconstruct the sequence scores from Beam Search</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(
<span class="hljs-meta">... </span>    **inputs,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">5</span>,
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    num_return_sequences=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    return_dict_in_generate=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    output_scores=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>transition_scores = model.compute_transition_scores(
<span class="hljs-meta">... </span>    outputs.sequences, outputs.scores, outputs.beam_indices, normalize_logits=<span class="hljs-literal">False</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># If you sum the generated tokens&#x27; scores and apply the length penalty, you&#x27;ll get the sequence scores.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Tip: recomputing the scores is only guaranteed to match with \`normalize_logits=False\`. Depending on the</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># use case, you might want to recompute it with \`normalize_logits=True\`.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>output_length = input_length + np.<span class="hljs-built_in">sum</span>(transition_scores.numpy() &lt; <span class="hljs-number">0</span>, axis=<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>length_penalty = model.generation_config.length_penalty
<span class="hljs-meta">&gt;&gt;&gt; </span>reconstructed_scores = np.<span class="hljs-built_in">sum</span>(transition_scores, axis=<span class="hljs-number">1</span>) / (output_length**length_penalty)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(np.allclose(outputs.sequences_scores, reconstructed_scores))
<span class="hljs-literal">True</span>`}}),{c(){c=o("p"),_=t("Examples:"),m=p(),T(d.$$.fragment)},l(i){c=a(i,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(n),m=g(i),j(d.$$.fragment,i)},m(i,h){b(i,c,h),e(c,_),b(i,m,h),v(d,i,h),f=!0},p:Xe,i(i){f||(J(d.$$.fragment,i),f=!0)},o(i){U(d.$$.fragment,i),f=!1},d(i){i&&n(c),i&&n(m),x(d,i)}}}function Eu(k){let c,_,m,d,f,i,h,G,w,y,E,Z,N,ie,F,q,S,B,I,P,Ve,$e,A,Se,Jr,Ur,Fe,xr,Pt,Gr,kr,Kt,Er,Zr,Br,ze,Cr,es,Ir,Wr,ns,Nr,Xr,Fa,tn,Rr,ts,Vr,$r,za,sn,Sr,ss,Fr,zr,La,Le,on,Fs,rt,Lr,zs,Ar,Aa,X,it,Qr,lt,Yr,Ls,Dr,Hr,Or,R,le,As,qr,Pr,os,Kr,ei,Qs,ni,ti,Ys,si,oi,ce,Ds,ai,ri,as,ii,li,Hs,ci,di,Os,mi,pi,de,qs,gi,hi,rs,ui,fi,Ps,_i,yi,Ks,Mi,bi,me,eo,wi,Ti,is,ji,vi,no,Ji,Ui,to,xi,Gi,pe,so,ki,Ei,ls,Zi,Bi,oo,Ci,Ii,ao,Wi,Ni,ge,ro,Xi,Ri,cs,Vi,$i,io,Si,Fi,lo,zi,Li,he,co,Ai,Qi,ds,Yi,Di,mo,Hi,Oi,po,qi,Pi,ue,go,Ki,el,ho,nl,tl,uo,sl,ol,fo,al,rl,ct,il,ms,ll,cl,dl,Ee,dt,ml,mt,pl,ps,gl,hl,ul,an,fl,rn,pt,_l,O,yl,gs,Ml,bl,hs,wl,Tl,us,jl,vl,fs,Jl,Ul,xl,ln,gt,Gl,Ae,kl,_o,El,Zl,_s,Bl,Cl,Qa,Qe,cn,yo,ht,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ym,Ie,St,Dm,ha,Hm,Om,Gn,Oa,He,kn,ua,Ft,qm,fa,Pm,qa,L,zt,Km,Lt,ep,Zs,np,tp,sp,At,op,Bs,ap,rp,ip,Oe,xe,_a,lp,cp,ya,dp,mp,Ma,pp,gp,ba,hp,up,Ge,wa,fp,_p,Ta,yp,Mp,ja,bp,wp,va,Tp,jp,ke,Ja,vp,Jp,Ua,Up,xp,xa,Gp,kp,Ga,Ep,Zp,Qt,Bp,Cs,Cp,Ip,Wp,En,Yt,Np,ka,Xp,Pa;return i=new Sa({}),rt=new Sa({}),it=new $({props:{name:"class transformers.GenerationConfig",anchor:"transformers.GenerationConfig",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/configuration_utils.py#L39",parameterGroups:[{title:"Parameters that control the length of the output",parametersDescription:[{anchor:"transformers.GenerationConfig.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
The maximum length the generated tokens can have. Corresponds to the length of the input prompt +
<code>max_new_tokens</code>. Its effect is overridden by <code>max_new_tokens</code>, if also set.`,name:"max_length"},{anchor:"transformers.GenerationConfig.max_new_tokens",description:`<strong>max_new_tokens</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The maximum numbers of tokens to generate, ignoring the number of tokens in the prompt.`,name:"max_new_tokens"},{anchor:"transformers.GenerationConfig.min_length",description:`<strong>min_length</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
The minimum length of the sequence to be generated. Corresponds to the length of the input prompt +
<code>min_new_tokens</code>. Its effect is overridden by <code>min_new_tokens</code>, if also set.`,name:"min_length"},{anchor:"transformers.GenerationConfig.min_new_tokens",description:`<strong>min_new_tokens</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The minimum numbers of tokens to generate, ignoring the number of tokens in the prompt.`,name:"min_new_tokens"},{anchor:"transformers.GenerationConfig.early_stopping",description:`<strong>early_stopping</strong> (<code>bool</code> or <code>str</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Controls the stopping condition for beam-based methods, like beam-search. It accepts the following values:
<code>True</code>, where the generation stops as soon as there are <code>num_beams</code> complete candidates; <code>False</code>, where an
heuristic is applied and the generation stops when is it very unlikely to find better candidates;
<code>&quot;never&quot;</code>, where the beam search procedure only stops when there cannot be better candidates (canonical
beam search algorithm).`,name:"early_stopping"},{anchor:"transformers.GenerationConfig.max_time(float,",description:`<strong>max_time(<code>float</code>,</strong> <em>optional</em>) &#x2014;
The maximum amount of time you allow the computation to run for in seconds. generation will still finish
the current pass after allocated time has been passed.`,name:"max_time(float,"}]},{title:"Parameters that control the generation strategy used",parametersDescription:[{anchor:"transformers.GenerationConfig.do_sample",description:`<strong>do_sample</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to use sampling ; use greedy decoding otherwise.`,name:"do_sample"},{anchor:"transformers.GenerationConfig.num_beams",description:`<strong>num_beams</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of beams for beam search. 1 means no beam search.`,name:"num_beams"},{anchor:"transformers.GenerationConfig.num_beam_groups",description:`<strong>num_beam_groups</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of groups to divide <code>num_beams</code> into in order to ensure diversity among different groups of beams.
<a href="https://arxiv.org/pdf/1610.02424.pdf" rel="nofollow">this paper</a> for more details.`,name:"num_beam_groups"},{anchor:"transformers.GenerationConfig.penalty_alpha",description:`<strong>penalty_alpha</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The values balance the model confidence and the degeneration penalty in contrastive search decoding.`,name:"penalty_alpha"},{anchor:"transformers.GenerationConfig.use_cache",description:`<strong>use_cache</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not the model should use the past last key/values attentions (if applicable to the model) to
speed up decoding.`,name:"use_cache"}]},{title:"Parameters for manipulation of the model output logits",parametersDescription:[{anchor:"transformers.GenerationConfig.temperature",description:`<strong>temperature</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The value used to modulate the next token probabilities.`,name:"temperature"},{anchor:"transformers.GenerationConfig.top_k",description:`<strong>top_k</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#x2014;
The number of highest probability vocabulary tokens to keep for top-k-filtering.`,name:"top_k"},{anchor:"transformers.GenerationConfig.top_p",description:`<strong>top_p</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
If set to float &lt; 1, only the smallest set of most probable tokens with probabilities that add up to
<code>top_p</code> or higher are kept for generation.`,name:"top_p"},{anchor:"transformers.GenerationConfig.typical_p",description:`<strong>typical_p</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Local typicality measures how similar the conditional probability of predicting a target token next is to
the expected conditional probability of predicting a random token next, given the partial text already
generated. If set to float &lt; 1, the smallest set of the most locally typical tokens with probabilities that
add up to <code>typical_p</code> or higher are kept for generation. See <a href="https://arxiv.org/pdf/2202.00666.pdf" rel="nofollow">this
paper</a> for more details.`,name:"typical_p"},{anchor:"transformers.GenerationConfig.epsilon_cutoff",description:`<strong>epsilon_cutoff</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
If set to float strictly between 0 and 1, only tokens with a conditional probability greater than
<code>epsilon_cutoff</code> will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on the
size of the model. See <a href="https://arxiv.org/abs/2210.15191" rel="nofollow">Truncation Sampling as Language Model
Desmoothing</a> for more details.`,name:"epsilon_cutoff"},{anchor:"transformers.GenerationConfig.eta_cutoff",description:`<strong>eta_cutoff</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between
0 and 1, a token is only considered if it is greater than either <code>eta_cutoff</code> or <code>sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits)))</code>. The latter term is intuitively the expected next token
probability, scaled by <code>sqrt(eta_cutoff)</code>. In the paper, suggested values range from 3e-4 to 2e-3,
depending on the size of the model. See <a href="https://arxiv.org/abs/2210.15191" rel="nofollow">Truncation Sampling as Language Model
Desmoothing</a> for more details.`,name:"eta_cutoff"},{anchor:"transformers.GenerationConfig.diversity_penalty",description:`<strong>diversity_penalty</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
This value is subtracted from a beam&#x2019;s score if it generates a token same as any beam from other group at a
particular time. Note that <code>diversity_penalty</code> is only effective if <code>group beam search</code> is enabled.`,name:"diversity_penalty"},{anchor:"transformers.GenerationConfig.repetition_penalty",description:`<strong>repetition_penalty</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The parameter for repetition penalty. 1.0 means no penalty. See <a href="https://arxiv.org/pdf/1909.05858.pdf" rel="nofollow">this
paper</a> for more details.`,name:"repetition_penalty"},{anchor:"transformers.GenerationConfig.encoder_repetition_penalty",description:`<strong>encoder_repetition_penalty</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
The paramater for encoder_repetition_penalty. An exponential penalty on sequences that are not in the
original input. 1.0 means no penalty.`,name:"encoder_repetition_penalty"},{anchor:"transformers.GenerationConfig.length_penalty",description:`<strong>length_penalty</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
Exponential penalty to the length that is used with beam-based generation. It is applied as an exponent to
the sequence length, which in turn is used to divide the score of the sequence. Since the score is the log
likelihood of the sequence (i.e. negative), <code>length_penalty</code> &gt; 0.0 promotes longer sequences, while
<code>length_penalty</code> &lt; 0.0 encourages shorter sequences.`,name:"length_penalty"},{anchor:"transformers.GenerationConfig.no_repeat_ngram_size",description:`<strong>no_repeat_ngram_size</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to int &gt; 0, all ngrams of that size can only occur once.`,name:"no_repeat_ngram_size"},{anchor:"transformers.GenerationConfig.bad_words_ids(List[List[int]],",description:`<strong>bad_words_ids(<code>List[List[int]]</code>,</strong> <em>optional</em>) &#x2014;
List of list of token ids that are not allowed to be generated. Check
<a href="/docs/transformers/main/en/internal/generation_utils#transformers.NoBadWordsLogitsProcessor">NoBadWordsLogitsProcessor</a> for further documentation and examples.`,name:"bad_words_ids(List[List[int]],"},{anchor:"transformers.GenerationConfig.force_words_ids(List[List[int]]",description:`<strong>force_words_ids(<code>List[List[int]]</code></strong> or <code>List[List[List[int]]]</code>, <em>optional</em>) &#x2014;
List of token ids that must be generated. If given a <code>List[List[int]]</code>, this is treated as a simple list of
words that must be included, the opposite to <code>bad_words_ids</code>. If given <code>List[List[List[int]]]</code>, this
triggers a <a href="https://github.com/huggingface/transformers/issues/14081" rel="nofollow">disjunctive constraint</a>, where one
can allow different forms of each word.`,name:"force_words_ids(List[List[int]]"},{anchor:"transformers.GenerationConfig.renormalize_logits",description:`<strong>renormalize_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to renormalize the logits after applying all the logits processors or warpers (including the custom
ones). It&#x2019;s highly recommended to set this flag to <code>True</code> as the search algorithms suppose the score logits
are normalized but some logit processors or warpers break the normalization.`,name:"renormalize_logits"},{anchor:"transformers.GenerationConfig.constraints",description:`<strong>constraints</strong> (<code>List[Constraint]</code>, <em>optional</em>) &#x2014;
Custom constraints that can be added to the generation to ensure that the output will contain the use of
certain tokens as defined by <code>Constraint</code> objects, in the most sensible way possible.`,name:"constraints"},{anchor:"transformers.GenerationConfig.forced_bos_token_id",description:`<strong>forced_bos_token_id</strong> (<code>int</code>, <em>optional</em>, defaults to <code>model.config.forced_bos_token_id</code>) &#x2014;
The id of the token to force as the first generated token after the <code>decoder_start_token_id</code>. Useful for
multilingual models like <a href="../model_doc/mbart">mBART</a> where the first generated token needs to be the target
language token.`,name:"forced_bos_token_id"},{anchor:"transformers.GenerationConfig.forced_eos_token_id",description:`<strong>forced_eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>, defaults to <code>model.config.forced_eos_token_id</code>) &#x2014;
The id of the token to force as the last generated token when <code>max_length</code> is reached. Optionally, use a
list to set multiple <em>end-of-sequence</em> tokens.`,name:"forced_eos_token_id"},{anchor:"transformers.GenerationConfig.remove_invalid_values",description:`<strong>remove_invalid_values</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>model.config.remove_invalid_values</code>) &#x2014;
Whether to remove possible <em>nan</em> and <em>inf</em> outputs of the model to prevent the generation method to crash.
Note that using <code>remove_invalid_values</code> can slow down generation.`,name:"remove_invalid_values"},{anchor:"transformers.GenerationConfig.exponential_decay_length_penalty",description:`<strong>exponential_decay_length_penalty</strong> (<code>tuple(int, float)</code>, <em>optional</em>) &#x2014;
This Tuple adds an exponentially increasing length penalty, after a certain amount of tokens have been
generated. The tuple shall consist of: <code>(start_index, decay_factor)</code> where <code>start_index</code> indicates where
penalty starts and <code>decay_factor</code> represents the factor of exponential decay`,name:"exponential_decay_length_penalty"},{anchor:"transformers.GenerationConfig.suppress_tokens",description:`<strong>suppress_tokens</strong>  (<code>List[int]</code>, <em>optional</em>) &#x2014;
A list of tokens that will be suppressed at generation. The <code>SupressTokens</code> logit processor will set their
log probs to <code>-inf</code> so that they are not sampled.`,name:"suppress_tokens"},{anchor:"transformers.GenerationConfig.begin_suppress_tokens",description:`<strong>begin_suppress_tokens</strong>  (<code>List[int]</code>, <em>optional</em>) &#x2014;
A list of tokens that will be suppressed at the beginning of the generation. The <code>SupressBeginTokens</code> logit
processor will set their log probs to <code>-inf</code> so that they are not sampled.`,name:"begin_suppress_tokens"},{anchor:"transformers.GenerationConfig.forced_decoder_ids",description:`<strong>forced_decoder_ids</strong> (<code>List[List[int]]</code>, <em>optional</em>) &#x2014;
A list of pairs of integers which indicates a mapping from generation indices to token indices that will be
forced before sampling. For example, <code>[[1, 123]]</code> means the second generated token will always be a token
of index 123.`,name:"forced_decoder_ids"},{anchor:"transformers.GenerationConfig.sequence_bias",description:`<strong>sequence_bias</strong> (<code>Dict[Tuple[int], float]</code>, <em>optional</em>)) &#x2014;
Dictionary that maps a sequence of tokens to its bias term. Positive biases increase the odds of the
sequence being selected, while negative biases do the opposite. Check
<a href="/docs/transformers/main/en/internal/generation_utils#transformers.SequenceBiasLogitsProcessor">SequenceBiasLogitsProcessor</a> for further documentation and examples.`,name:"sequence_bias"},{anchor:"transformers.GenerationConfig.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
The guidance scale for classifier free guidance (CFG). CFG is enabled by setting <code>guidance_scale &gt; 1</code>.
Higher guidance scale encourages the model to generate samples that are more closely linked to the input
prompt, usually at the expense of poorer quality.`,name:"guidance_scale"},{anchor:"transformers.GenerationConfig.low_memory",description:`<strong>low_memory</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Switch to sequential topk for contrastive search to reduce peak memory. Used with contrastive search.`,name:"low_memory"}]},{title:"Parameters that define the output variables of `generate`",parametersDescription:[{anchor:"transformers.GenerationConfig.num_return_sequences(int,",description:`<strong>num_return_sequences(<code>int</code>,</strong> <em>optional</em>, defaults to 1) &#x2014;
The number of independently computed returned sequences for each element in the batch.`,name:"num_return_sequences(int,"},{anchor:"transformers.GenerationConfig.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under returned
tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationConfig.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors for
more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationConfig.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationConfig.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"}]},{title:"Special tokens that can be used at generation time",parametersDescription:[{anchor:"transformers.GenerationConfig.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationConfig.bos_token_id",description:`<strong>bos_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>beginning-of-sequence</em> token.`,name:"bos_token_id"},{anchor:"transformers.GenerationConfig.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"}]},{title:"Generation parameters exclusive to encoder-decoder models",parametersDescription:[{anchor:"transformers.GenerationConfig.encoder_no_repeat_ngram_size",description:`<strong>encoder_no_repeat_ngram_size</strong> (<code>int</code>, <em>optional</em>, defaults to 0) &#x2014;
If set to int &gt; 0, all ngrams of that size that occur in the <code>encoder_input_ids</code> cannot occur in the
<code>decoder_input_ids</code>.`,name:"encoder_no_repeat_ngram_size"},{anchor:"transformers.GenerationConfig.decoder_start_token_id",description:`<strong>decoder_start_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
If an encoder-decoder model starts decoding with a different token than <em>bos</em>, the id of that token.`,name:"decoder_start_token_id"}]},{title:"Wild card",parametersDescription:[]}]}}),dt=new $({props:{name:"from_pretrained",anchor:"transformers.GenerationConfig.from_pretrained",parameters:[{name:"pretrained_model_name",val:": typing.Union[str, os.PathLike]"},{name:"config_file_name",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"cache_dir",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"force_download",val:": bool = False"},{name:"local_files_only",val:": bool = False"},{name:"token",val:": typing.Union[str, bool, NoneType] = None"},{name:"revision",val:": str = 'main'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationConfig.from_pretrained.pretrained_model_name",description:`<strong>pretrained_model_name</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
This can be either:</p>
<ul>
<li>a string, the <em>model id</em> of a pretrained model configuration hosted inside a model repo on
huggingface.co. Valid model ids can be located at the root-level, like <code>bert-base-uncased</code>, or
namespaced under a user or organization name, like <code>dbmdz/bert-base-german-cased</code>.</li>
<li>a path to a <em>directory</em> containing a configuration file saved using the
<a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig.save_pretrained">save_pretrained()</a> method, e.g., <code>./my_model_directory/</code>.</li>
</ul>`,name:"pretrained_model_name"},{anchor:"transformers.GenerationConfig.from_pretrained.config_file_name",description:`<strong>config_file_name</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>, defaults to <code>&quot;generation_config.json&quot;</code>) &#x2014;
Name of the generation configuration JSON file to be loaded from <code>pretrained_model_name</code>.`,name:"config_file_name"},{anchor:"transformers.GenerationConfig.from_pretrained.cache_dir",description:`<strong>cache_dir</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>) &#x2014;
Path to a directory in which a downloaded pretrained model configuration should be cached if the
standard cache should not be used.`,name:"cache_dir"},{anchor:"transformers.GenerationConfig.from_pretrained.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force to (re-)download the configuration files and override the cached versions if
they exist.`,name:"force_download"},{anchor:"transformers.GenerationConfig.from_pretrained.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to delete incompletely received file. Attempts to resume the download if such a file
exists.`,name:"resume_download"},{anchor:"transformers.GenerationConfig.from_pretrained.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, e.g., <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}.</code> The proxies are used on each request.`,name:"proxies"},{anchor:"transformers.GenerationConfig.from_pretrained.token",description:`<strong>token</strong> (<code>str</code> or <code>bool</code>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, or not specified, will use
the token generated when running <code>huggingface-cli login</code> (stored in <code>~/.huggingface</code>).`,name:"token"},{anchor:"transformers.GenerationConfig.from_pretrained.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, or a commit id, since we use a
git-based system for storing models and other artifacts on huggingface.co, so <code>revision</code> can be any
identifier allowed by git.</p>
<div class="course-tip  bg-gradient-to-br dark:bg-gradient-to-r before:border-green-500 dark:before:border-green-800 from-green-50 dark:from-gray-900 to-white dark:to-gray-950 border border-green-50 text-green-700 dark:text-gray-400">
						
<p>To test a pull request you made on the Hub, you can pass \`revision=&#x201C;refs/pr/<pr_number>&#x201C;.</pr_number></p>

					</div>`,name:"revision"},{anchor:"transformers.GenerationConfig.from_pretrained.return_unused_kwargs",description:`<strong>return_unused_kwargs</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
If <code>False</code>, then this function returns just the final configuration object.</p>
<p>If <code>True</code>, then this functions returns a <code>Tuple(config, unused_kwargs)</code> where <em>unused_kwargs</em> is a
dictionary consisting of the key/value pairs whose keys are not configuration attributes: i.e., the
part of <code>kwargs</code> which has not been used to update <code>config</code> and is otherwise ignored.`,name:"return_unused_kwargs"},{anchor:"transformers.GenerationConfig.from_pretrained.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
In case the relevant files are located inside a subfolder of the model repo on huggingface.co, you can
specify the folder name here.`,name:"subfolder"},{anchor:"transformers.GenerationConfig.from_pretrained.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
The values in kwargs of any keys which are configuration attributes will be used to override the loaded
values. Behavior concerning key/value pairs whose keys are <em>not</em> configuration attributes is controlled
by the <code>return_unused_kwargs</code> keyword parameter.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/configuration_utils.py#L555",returnDescription:`
<p>The configuration object instantiated from this pretrained model.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"
>GenerationConfig</a></p>
`}}),an=new Ne({props:{anchor:"transformers.GenerationConfig.from_pretrained.example",$$slots:{default:[mu]},$$scope:{ctx:k}}}),pt=new $({props:{name:"from_model_config",anchor:"transformers.GenerationConfig.from_model_config",parameters:[{name:"model_config",val:": PretrainedConfig"}],parametersDescription:[{anchor:"transformers.GenerationConfig.from_model_config.model_config",description:`<strong>model_config</strong> (<code>PretrainedConfig</code>) &#x2014;
The model config that will be used to instantiate the generation config.`,name:"model_config"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/configuration_utils.py#L858",returnDescription:`
<p>The configuration object instantiated from those parameters.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"
>GenerationConfig</a></p>
`}}),gt=new $({props:{name:"save_pretrained",anchor:"transformers.GenerationConfig.save_pretrained",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"config_file_name",val:": typing.Union[str, os.PathLike, NoneType] = None"},{name:"push_to_hub",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationConfig.save_pretrained.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory where the configuration JSON file will be saved (will be created if it does not exist).`,name:"save_directory"},{anchor:"transformers.GenerationConfig.save_pretrained.config_file_name",description:`<strong>config_file_name</strong> (<code>str</code> or <code>os.PathLike</code>, <em>optional</em>, defaults to <code>&quot;generation_config.json&quot;</code>) &#x2014;
Name of the generation configuration JSON file to be saved in <code>save_directory</code>.`,name:"config_file_name"},{anchor:"transformers.GenerationConfig.save_pretrained.push_to_hub",description:`<strong>push_to_hub</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to push your model to the Hugging Face model hub after saving it. You can specify the
repository you want to push to with <code>repo_id</code> (will default to the name of <code>save_directory</code> in your
namespace).`,name:"push_to_hub"},{anchor:"transformers.GenerationConfig.save_pretrained.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/main/en/internal/tokenization_utils#transformers.PreTrainedTokenizerBase.push_to_hub">push_to_hub()</a> method.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/configuration_utils.py#L477"}}),ht=new Sa({}),ut=new $({props:{name:"class transformers.GenerationMixin",anchor:"transformers.GenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L488"}}),Mt=new $({props:{name:"generate",anchor:"transformers.GenerationMixin.generate",parameters:[{name:"inputs",val:": typing.Optional[torch.Tensor] = None"},{name:"generation_config",val:": typing.Optional[transformers.generation.configuration_utils.GenerationConfig] = None"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"prefix_allowed_tokens_fn",val:": typing.Union[typing.Callable[[int, torch.Tensor], typing.List[int]], NoneType] = None"},{name:"synced_gpus",val:": typing.Optional[bool] = None"},{name:"assistant_model",val:": typing.Optional[ForwardRef('PreTrainedModel')] = None"},{name:"streamer",val:": typing.Optional[ForwardRef('BaseStreamer')] = None"},{name:"negative_prompt_ids",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_attention_mask",val:": typing.Optional[torch.Tensor] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.generate.inputs",description:`<strong>inputs</strong> (<code>torch.Tensor</code> of varying shape depending on the modality, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation or as model inputs to the encoder. If <code>None</code> the
method initializes it with <code>bos_token_id</code> and a batch size of 1. For decoder-only models <code>inputs</code>
should of in the format of <code>input_ids</code>. For encoder-decoder models <em>inputs</em> can represent any of
<code>input_ids</code>, <code>input_values</code>, <code>input_features</code>, or <code>pixel_values</code>.`,name:"inputs"},{anchor:"transformers.GenerationMixin.generate.generation_config",description:`<strong>generation_config</strong> (<code>~generation.GenerationConfig</code>, <em>optional</em>) &#x2014;
The generation configuration to be used as base parametrization for the generation call. <code>**kwargs</code>
passed to generate matching the attributes of <code>generation_config</code> will override them. If
<code>generation_config</code> is not provided, the default will be used, which had the following loading
priority: 1) from the <code>generation_config.json</code> model file, if it exists; 2) from the model
configuration. Please note that unspecified parameters will inherit <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig">GenerationConfig</a>&#x2019;s
default values, whose documentation should be checked to parameterize generation.`,name:"generation_config"},{anchor:"transformers.GenerationMixin.generate.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
Custom logits processors that complement the default logits processors built from arguments and
generation config. If a logit processor is passed that is already created with the arguments or a
generation config an error is thrown. This feature is intended for advanced users.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.generate.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
Custom stopping criteria that complement the default stopping criteria built from arguments and a
generation config. If a stopping criteria is passed that is already created with the arguments or a
generation config an error is thrown. This feature is intended for advanced users.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.generate.prefix_allowed_tokens_fn",description:`<strong>prefix_allowed_tokens_fn</strong> (<code>Callable[[int, torch.Tensor], List[int]]</code>, <em>optional</em>) &#x2014;
If provided, this function constraints the beam search to allowed tokens only at each step. If not
provided no constraint is applied. This function takes 2 arguments: the batch ID <code>batch_id</code> and
<code>input_ids</code>. It has to return a list with the allowed tokens for the next generation step conditioned
on the batch ID <code>batch_id</code> and the previously generated tokens <code>inputs_ids</code>. This argument is useful
for constrained generation conditioned on the prefix, as described in <a href="https://arxiv.org/abs/2010.00904" rel="nofollow">Autoregressive Entity
Retrieval</a>.`,name:"prefix_allowed_tokens_fn"},{anchor:"transformers.GenerationMixin.generate.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to continue running the while loop until max_length. Unless overridden this flag will be set to
<code>True</code> under DeepSpeed ZeRO Stage 3 multiple GPUs environment to avoid hanging if one GPU finished
generating before other GPUs. Otherwise it&#x2019;ll be set to <code>False</code>.`,name:"synced_gpus"},{anchor:"transformers.GenerationMixin.generate.assistant_model",description:`<strong>assistant_model</strong> (<code>PreTrainedModel</code>, <em>optional</em>) &#x2014;
An assistant model that can be used to accelerate generation. The assistant model must have the exact
same tokenizer. The acceleration is achieved when forecasting candidate tokens with the assistent model
is much faster than running generation with the model you&#x2019;re calling generate from. As such, the
assistant model should be much smaller.`,name:"assistant_model"},{anchor:"transformers.GenerationMixin.generate.streamer",description:`<strong>streamer</strong> (<code>BaseStreamer</code>, <em>optional</em>) &#x2014;
Streamer object that will be used to stream the generated sequences. Generated tokens are passed
through <code>streamer.put(token_ids)</code> and the streamer is responsible for any further processing.`,name:"streamer"},{anchor:"transformers.GenerationMixin.generate.negative_prompt_ids",description:`<strong>negative_prompt_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
The negative prompt needed for some processors such as CFG. The batch size must match the input batch
size. This is an experimental feature, subject to breaking API changes in future versions.`,name:"negative_prompt_ids"},{anchor:"transformers.GenerationMixin.generate.negative_prompt_attention_mask",description:`<strong>negative_prompt_attention_mask</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>, <em>optional</em>) &#x2014;
Attention_mask for <code>negative_prompt_ids</code>.`,name:"negative_prompt_attention_mask"},{anchor:"transformers.GenerationMixin.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Ad hoc parametrization of <code>generate_config</code> and/or additional model-specific kwargs that will be
forwarded to the <code>forward</code> function of the model. If the model is an encoder-decoder model, encoder
specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with <em>decoder_</em>.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L1294",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> (if <code>return_dict_in_generate=True</code>
or when <code>config.return_dict_in_generate=True</code>) or a <code>torch.FloatTensor</code>.</p>
<p>If the model is <em>not</em> an encoder-decoder model (<code>model.config.is_encoder_decoder=False</code>), the possible
<a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchDecoderOnlyOutput"
>GreedySearchDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleDecoderOnlyOutput"
>SampleDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleDecoderOnlyOutput"
>BeamSampleDecoderOnlyOutput</a></li>
</ul>
<p>If the model is an encoder-decoder model (<code>model.config.is_encoder_decoder=True</code>), the possible
<a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchEncoderDecoderOutput"
>GreedySearchEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleEncoderDecoderOutput"
>SampleEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleEncoderDecoderOutput"
>BeamSampleEncoderDecoderOutput</a></li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> or <code>torch.LongTensor</code></p>
`}}),dn=new nn({props:{warning:!0,$$slots:{default:[pu]},$$scope:{ctx:k}}}),bt=new $({props:{name:"compute_transition_scores",anchor:"transformers.GenerationMixin.compute_transition_scores",parameters:[{name:"sequences",val:": Tensor"},{name:"scores",val:": typing.Tuple[torch.Tensor]"},{name:"beam_indices",val:": typing.Optional[torch.Tensor] = None"},{name:"normalize_logits",val:": bool = False"}],parametersDescription:[{anchor:"transformers.GenerationMixin.compute_transition_scores.sequences",description:`<strong>sequences</strong> (<code>torch.LongTensor</code>) &#x2014;
The generated sequences. The second dimension (sequence_length) is either equal to <code>max_length</code> or
shorter if all batches finished early due to the <code>eos_token_id</code>.`,name:"sequences"},{anchor:"transformers.GenerationMixin.compute_transition_scores.scores",description:`<strong>scores</strong> (<code>tuple(torch.FloatTensor)</code>) &#x2014;
Transition scores for each vocabulary token at each generation step. Beam transition scores consisting
of log probabilities of tokens conditioned on log softmax of previously generated tokens Tuple of
<code>torch.FloatTensor</code> with up to <code>max_new_tokens</code> elements (one element for each generated token), with
each tensor of shape <code>(batch_size*num_beams, config.vocab_size)</code>.`,name:"scores"},{anchor:"transformers.GenerationMixin.compute_transition_scores.beam_indices",description:`<strong>beam_indices</strong> (<code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Beam indices of generated token id at each generation step. <code>torch.LongTensor</code> of shape
<code>(batch_size*num_return_sequences, sequence_length)</code>. Only required if a <code>num_beams&gt;1</code> at
generate-time.`,name:"beam_indices"},{anchor:"transformers.GenerationMixin.compute_transition_scores.normalize_logits",description:`<strong>normalize_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to normalize the logits (which, for legacy reasons, may be unnormalized).`,name:"normalize_logits"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L1052",returnDescription:`
<p>A <code>torch.Tensor</code> of shape <code>(batch_size*num_return_sequences, sequence_length)</code> containing
the transition scores (logits)</p>
`,returnType:`
<p><code>torch.Tensor</code></p>
`}}),mn=new Ne({props:{anchor:"transformers.GenerationMixin.compute_transition_scores.example",$$slots:{default:[gu]},$$scope:{ctx:k}}}),wt=new $({props:{name:"greedy_search",anchor:"transformers.GenerationMixin.greedy_search",parameters:[{name:"input_ids",val:": LongTensor"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"streamer",val:": typing.Optional[ForwardRef('BaseStreamer')] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.greedy_search.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.greedy_search.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.greedy_search.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.greedy_search.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.greedy_search.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.greedy_search.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.greedy_search.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.greedy_search.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.greedy_search.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.greedy_search.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.greedy_search.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)`,name:"synced_gpus"},{anchor:"transformers.GenerationMixin.greedy_search.streamer",description:`<strong>streamer</strong> (<code>BaseStreamer</code>, <em>optional</em>) &#x2014;
Streamer object that will be used to stream the generated sequences. Generated tokens are passed
through <code>streamer.put(token_ids)</code> and the streamer is responsible for any further processing.
model_kwargs &#x2014;
Additional model specific keyword arguments will be forwarded to the <code>forward</code> function of the model.
If model is an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"streamer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L2276",returnDescription:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchDecoderOnlyOutput"
>GreedySearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchEncoderDecoderOutput"
>GreedySearchEncoderDecoderOutput</a> or
<code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchDecoderOnlyOutput"
>GreedySearchDecoderOnlyOutput</a> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.GreedySearchEncoderDecoderOutput"
>GreedySearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),pn=new nn({props:{warning:!0,$$slots:{default:[hu]},$$scope:{ctx:k}}}),gn=new Ne({props:{anchor:"transformers.GenerationMixin.greedy_search.example",$$slots:{default:[uu]},$$scope:{ctx:k}}}),jt=new $({props:{name:"sample",anchor:"transformers.GenerationMixin.sample",parameters:[{name:"input_ids",val:": LongTensor"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"logits_warper",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"streamer",val:": typing.Optional[ForwardRef('BaseStreamer')] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.sample.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.sample.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.sample.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.sample.logits_warper",description:`<strong>logits_warper</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsWarper">LogitsWarper</a> used
to warp the prediction score distribution of the language modeling head applied before multinomial
sampling at each generation step.`,name:"logits_warper"},{anchor:"transformers.GenerationMixin.sample.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.sample.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.sample.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.sample.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.sample.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.sample.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.sample.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.sample.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)`,name:"synced_gpus"},{anchor:"transformers.GenerationMixin.sample.streamer",description:`<strong>streamer</strong> (<code>BaseStreamer</code>, <em>optional</em>) &#x2014;
Streamer object that will be used to stream the generated sequences. Generated tokens are passed
through <code>streamer.put(token_ids)</code> and the streamer is responsible for any further processing.
model_kwargs &#x2014;
Additional model specific kwargs will be forwarded to the <code>forward</code> function of the model. If model is
an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"streamer"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L2535",returnDescription:`
<p>A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleDecoderOnlyOutput"
>SampleDecoderOnlyOutput</a> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleEncoderDecoderOutput"
>SampleEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleDecoderOnlyOutput"
>SampleDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.SampleEncoderDecoderOutput"
>SampleEncoderDecoderOutput</a> or <code>torch.LongTensor</code></p>
`}}),hn=new nn({props:{warning:!0,$$slots:{default:[fu]},$$scope:{ctx:k}}}),un=new Ne({props:{anchor:"transformers.GenerationMixin.sample.example",$$slots:{default:[_u]},$$scope:{ctx:k}}}),Jt=new $({props:{name:"beam_search",anchor:"transformers.GenerationMixin.beam_search",parameters:[{name:"input_ids",val:": LongTensor"},{name:"beam_scorer",val:": BeamScorer"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.beam_search.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.beam_search.beam_scorer",description:`<strong>beam_scorer</strong> (<code>BeamScorer</code>) &#x2014;
An derived instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> that defines how beam hypotheses are constructed, stored and
sorted during generation. For more information, the documentation of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> should be read.`,name:"beam_scorer"},{anchor:"transformers.GenerationMixin.beam_search.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.beam_search.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.beam_search.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.beam_search.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.beam_search.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.beam_search.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.beam_search.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.beam_search.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.beam_search.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.beam_search.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)
model_kwargs &#x2014;
Additional model specific kwargs will be forwarded to the <code>forward</code> function of the model. If model is
an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"synced_gpus"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L2817",returnDescription:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>generation.BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> or
<code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),fn=new nn({props:{warning:!0,$$slots:{default:[yu]},$$scope:{ctx:k}}}),_n=new Ne({props:{anchor:"transformers.GenerationMixin.beam_search.example",$$slots:{default:[Mu]},$$scope:{ctx:k}}}),xt=new $({props:{name:"beam_sample",anchor:"transformers.GenerationMixin.beam_sample",parameters:[{name:"input_ids",val:": LongTensor"},{name:"beam_scorer",val:": BeamScorer"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"logits_warper",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.beam_sample.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.beam_sample.beam_scorer",description:`<strong>beam_scorer</strong> (<code>BeamScorer</code>) &#x2014;
A derived instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> that defines how beam hypotheses are constructed, stored and
sorted during generation. For more information, the documentation of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> should be read.`,name:"beam_scorer"},{anchor:"transformers.GenerationMixin.beam_sample.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.beam_sample.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.beam_sample.logits_warper",description:`<strong>logits_warper</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsWarper">LogitsWarper</a> used
to warp the prediction score distribution of the language modeling head applied before multinomial
sampling at each generation step.`,name:"logits_warper"},{anchor:"transformers.GenerationMixin.beam_sample.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.beam_sample.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.beam_sample.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.beam_sample.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.beam_sample.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.beam_sample.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.beam_sample.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.beam_sample.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)
model_kwargs &#x2014;
Additional model specific kwargs will be forwarded to the <code>forward</code> function of the model. If model is
an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"synced_gpus"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L3138",returnDescription:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleDecoderOnlyOutput"
>BeamSampleDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleEncoderDecoderOutput"
>BeamSampleEncoderDecoderOutput</a> or
<code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleDecoderOnlyOutput"
>BeamSampleDecoderOnlyOutput</a> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSampleEncoderDecoderOutput"
>BeamSampleEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),yn=new nn({props:{warning:!0,$$slots:{default:[bu]},$$scope:{ctx:k}}}),Mn=new Ne({props:{anchor:"transformers.GenerationMixin.beam_sample.example",$$slots:{default:[wu]},$$scope:{ctx:k}}}),kt=new $({props:{name:"contrastive_search",anchor:"transformers.GenerationMixin.contrastive_search",parameters:[{name:"input_ids",val:": LongTensor"},{name:"top_k",val:": typing.Optional[int] = 1"},{name:"penalty_alpha",val:": typing.Optional[float] = 0"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"logits_warper",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"streamer",val:": typing.Optional[ForwardRef('BaseStreamer')] = None"},{name:"sequential",val:": typing.Optional[bool] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.contrastive_search.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.contrastive_search.top_k",description:`<strong>top_k</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The size of the candidate set that is used to re-rank for contrastive search`,name:"top_k"},{anchor:"transformers.GenerationMixin.contrastive_search.penalty_alpha",description:`<strong>penalty_alpha</strong> (<code>float</code>, <em>optional</em>, defaults to 0) &#x2014;
The degeneration penalty for contrastive search; activate when it is larger than 0`,name:"penalty_alpha"},{anchor:"transformers.GenerationMixin.contrastive_search.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.contrastive_search.logits_warper",description:`<strong>logits_warper</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsWarper">LogitsWarper</a> used
to warp the prediction score distribution of the language modeling head applied before multinomial
sampling at each generation step.`,name:"logits_warper"},{anchor:"transformers.GenerationMixin.contrastive_search.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.contrastive_search.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.contrastive_search.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.contrastive_search.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.contrastive_search.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.contrastive_search.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.contrastive_search.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.contrastive_search.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)`,name:"synced_gpus"},{anchor:"transformers.GenerationMixin.contrastive_search.streamer",description:`<strong>streamer</strong> (<code>BaseStreamer</code>, <em>optional</em>) &#x2014;
Streamer object that will be used to stream the generated sequences. Generated tokens are passed
through <code>streamer.put(token_ids)</code> and the streamer is responsible for any further processing.`,name:"streamer"},{anchor:"transformers.GenerationMixin.contrastive_search.sequential",description:`<strong>sequential</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Switches topk hidden state computation from parallel to sequential to reduce memory if True.
model_kwargs &#x2014;
Additional model specific keyword arguments will be forwarded to the <code>forward</code> function of the model.
If model is an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"sequential"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L1832",returnDescription:`
<p><code>ContrastiveSearchDecoderOnlyOutput</code>, <code>ContrastiveSearchEncoderDecoderOutput</code>
or <code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<code>ContrastiveSearchDecoderOnlyOutput</code> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <code>ContrastiveSearchEncoderDecoderOutput</code> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),bn=new nn({props:{warning:!0,$$slots:{default:[Tu]},$$scope:{ctx:k}}}),wn=new Ne({props:{anchor:"transformers.GenerationMixin.contrastive_search.example",$$slots:{default:[ju]},$$scope:{ctx:k}}}),Zt=new $({props:{name:"group_beam_search",anchor:"transformers.GenerationMixin.group_beam_search",parameters:[{name:"input_ids",val:": LongTensor"},{name:"beam_scorer",val:": BeamScorer"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": bool = False"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.group_beam_search.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.group_beam_search.beam_scorer",description:`<strong>beam_scorer</strong> (<code>BeamScorer</code>) &#x2014;
An derived instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> that defines how beam hypotheses are constructed, stored and
sorted during generation. For more information, the documentation of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> should be read.`,name:"beam_scorer"},{anchor:"transformers.GenerationMixin.group_beam_search.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.group_beam_search.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.group_beam_search.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.group_beam_search.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.group_beam_search.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.group_beam_search.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.group_beam_search.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.group_beam_search.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.group_beam_search.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.group_beam_search.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)</p>
<p>model_kwargs &#x2014;
Additional model specific kwargs that will be forwarded to the <code>forward</code> function of the model. If
model is an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"synced_gpus"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L3468",returnDescription:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> or
<code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a> if <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a> if
<code>model.config.is_encoder_decoder=False</code> and <code>return_dict_in_generate=True</code> or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if <code>model.config.is_encoder_decoder=True</code>.</p>
`}}),Tn=new nn({props:{warning:!0,$$slots:{default:[vu]},$$scope:{ctx:k}}}),jn=new Ne({props:{anchor:"transformers.GenerationMixin.group_beam_search.example",$$slots:{default:[Ju]},$$scope:{ctx:k}}}),Ct=new $({props:{name:"constrained_beam_search",anchor:"transformers.GenerationMixin.constrained_beam_search",parameters:[{name:"input_ids",val:": LongTensor"},{name:"constrained_beam_scorer",val:": ConstrainedBeamSearchScorer"},{name:"logits_processor",val:": typing.Optional[transformers.generation.logits_process.LogitsProcessorList] = None"},{name:"stopping_criteria",val:": typing.Optional[transformers.generation.stopping_criteria.StoppingCriteriaList] = None"},{name:"max_length",val:": typing.Optional[int] = None"},{name:"pad_token_id",val:": typing.Optional[int] = None"},{name:"eos_token_id",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"output_attentions",val:": typing.Optional[bool] = None"},{name:"output_hidden_states",val:": typing.Optional[bool] = None"},{name:"output_scores",val:": typing.Optional[bool] = None"},{name:"return_dict_in_generate",val:": typing.Optional[bool] = None"},{name:"synced_gpus",val:": typing.Optional[bool] = None"},{name:"**model_kwargs",val:""}],parametersDescription:[{anchor:"transformers.GenerationMixin.constrained_beam_search.input_ids",description:`<strong>input_ids</strong> (<code>torch.LongTensor</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.GenerationMixin.constrained_beam_search.constrained_beam_scorer",description:`<strong>constrained_beam_scorer</strong> (<code>ConstrainedBeamSearchScorer</code>) &#x2014;
A derived instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.BeamScorer">BeamScorer</a> that defines how beam hypotheses are constructed, stored and
sorted during generation, while satisfying a list of positive constraints. For more information, the
documentation of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.ConstrainedBeamSearchScorer">ConstrainedBeamSearchScorer</a> should be read.`,name:"constrained_beam_scorer"},{anchor:"transformers.GenerationMixin.constrained_beam_search.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessor">LogitsProcessor</a>
used to modify the prediction scores of the language modeling head applied at each generation step.`,name:"logits_processor"},{anchor:"transformers.GenerationMixin.constrained_beam_search.stopping_criteria",description:`<strong>stopping_criteria</strong> (<code>StoppingCriteriaList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.StoppingCriteria">StoppingCriteria</a>
used to tell if the generation loop should stop.`,name:"stopping_criteria"},{anchor:"transformers.GenerationMixin.constrained_beam_search.logits_warper",description:`<strong>logits_warper</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
An instance of <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/main/en/internal/generation_utils#transformers.LogitsWarper">LogitsWarper</a> used
to warp the prediction score distribution of the language modeling head applied before multinomial
sampling at each generation step.`,name:"logits_warper"},{anchor:"transformers.GenerationMixin.constrained_beam_search.max_length",description:`<strong>max_length</strong> (<code>int</code>, <em>optional</em>, defaults to 20) &#x2014;
<strong>DEPRECATED</strong>. Use <code>logits_processor</code> or <code>stopping_criteria</code> directly to cap the number of generated
tokens. The maximum length of the sequence to be generated.`,name:"max_length"},{anchor:"transformers.GenerationMixin.constrained_beam_search.pad_token_id",description:`<strong>pad_token_id</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The id of the <em>padding</em> token.`,name:"pad_token_id"},{anchor:"transformers.GenerationMixin.constrained_beam_search.eos_token_id",description:`<strong>eos_token_id</strong> (<code>Union[int, List[int]]</code>, <em>optional</em>) &#x2014;
The id of the <em>end-of-sequence</em> token. Optionally, use a list to set multiple <em>end-of-sequence</em> tokens.`,name:"eos_token_id"},{anchor:"transformers.GenerationMixin.constrained_beam_search.output_attentions",description:`<strong>output_attentions</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the attentions tensors of all attention layers. See <code>attentions</code> under
returned tensors for more details.`,name:"output_attentions"},{anchor:"transformers.GenerationMixin.constrained_beam_search.output_hidden_states",description:`<strong>output_hidden_states</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the hidden states of all layers. See <code>hidden_states</code> under returned tensors
for more details.`,name:"output_hidden_states"},{anchor:"transformers.GenerationMixin.constrained_beam_search.output_scores",description:`<strong>output_scores</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return the prediction scores. See <code>scores</code> under returned tensors for more details.`,name:"output_scores"},{anchor:"transformers.GenerationMixin.constrained_beam_search.return_dict_in_generate",description:`<strong>return_dict_in_generate</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to return a <a href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput">ModelOutput</a> instead of a plain tuple.`,name:"return_dict_in_generate"},{anchor:"transformers.GenerationMixin.constrained_beam_search.synced_gpus",description:`<strong>synced_gpus</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to continue running the while loop until max_length (needed for ZeRO stage 3)
model_kwargs &#x2014;
Additional model specific kwargs will be forwarded to the <code>forward</code> function of the model. If model is
an encoder-decoder model the kwargs should include <code>encoder_outputs</code>.`,name:"synced_gpus"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/utils.py#L3847",returnDescription:`
<p><a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>generation.BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> or
<code>torch.LongTensor</code>: A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a> if <code>model.config.is_encoder_decoder=False</code> and
<code>return_dict_in_generate=True</code> or a <a
  href="/docs/transformers/main/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),vn=new nn({props:{warning:!0,$$slots:{default:[Uu]},$$scope:{ctx:k}}}),Jn=new Ne({props:{anchor:"transformers.GenerationMixin.constrained_beam_search.example",$$slots:{default:[xu]},$$scope:{ctx:k}}}),Wt=new Sa({}),Nt=new $({props:{name:"class transformers.TFGenerationMixin",anchor:"transformers.TFGenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/tf_utils.py#L444"}}),$t=new $({props:{name:"generate",anchor:"transformers.TFGenerationMixin.generate",parameters:[{name:"inputs",val:": typing.Optional[tensorflow.python.framework.ops.Tensor] = None"},{name:"generation_config",val:": typing.Optional[transformers.generation.configuration_utils.GenerationConfig] = None"},{name:"logits_processor",val:": typing.Optional[transformers.generation.tf_logits_process.TFLogitsProcessorList] = None"},{name:"seed",val:" = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.TFGenerationMixin.generate.inputs",description:`<strong>inputs</strong> (<code>tf.Tensor</code> of varying shape depending on the modality, <em>optional</em>) &#x2014;
The sequence used as a prompt for the generation or as model inputs to the encoder. If <code>None</code> the
method initializes it with <code>bos_token_id</code> and a batch size of 1. For decoder-only models <code>inputs</code>
should of in the format of <code>input_ids</code>. For encoder-decoder models <em>inputs</em> can represent any of
<code>input_ids</code>, <code>input_values</code>, <code>input_features</code>, or <code>pixel_values</code>.`,name:"inputs"},{anchor:"transformers.TFGenerationMixin.generate.generation_config",description:`<strong>generation_config</strong> (<code>~generation.GenerationConfig</code>, <em>optional</em>) &#x2014;
The generation configuration to be used as base parametrization for the generation call. <code>**kwargs</code>
passed to generate matching the attributes of <code>generation_config</code> will override them. If
<code>generation_config</code> is not provided, the default will be used, which had the following loading
priority: 1) from the <code>generation_config.json</code> model file, if it exists; 2) from the model
configuration. Please note that unspecified parameters will inherit <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig">GenerationConfig</a>&#x2019;s
default values, whose documentation should be checked to parameterize generation.`,name:"generation_config"},{anchor:"transformers.TFGenerationMixin.generate.logits_processor",description:`<strong>logits_processor</strong> (<code>LogitsProcessorList</code>, <em>optional</em>) &#x2014;
Custom logits processors that complement the default logits processors built from arguments and
generation config. If a logit processor is passed that is already created with the arguments or a
generation config an error is thrown. This feature is intended for advanced users.`,name:"logits_processor"},{anchor:"transformers.TFGenerationMixin.generate.seed",description:`<strong>seed</strong> (<code>List[int]</code>, <em>optional</em>) &#x2014;
Random seed to control sampling, containing two integers, used when <code>do_sample</code> is <code>True</code>. See the
<code>seed</code> argument from stateless functions in <code>tf.random</code>.`,name:"seed"},{anchor:"transformers.TFGenerationMixin.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Ad hoc parametrization of <code>generate_config</code> and/or additional model-specific kwargs that will be
forwarded to the <code>forward</code> function of the model. If the model is an encoder-decoder model, encoder
specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with <em>decoder_</em>.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/tf_utils.py#L645",returnDescription:`
<p>A <a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> (if <code>return_dict_in_generate=True</code> or when
<code>config.return_dict_in_generate=True</code>) or a <code>tf.Tensor</code>.</p>
<p>If the model is <em>not</em> an encoder-decoder model (<code>model.config.is_encoder_decoder=False</code>), the possible
<a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><code>TFGreedySearchDecoderOnlyOutput</code>,</li>
<li><code>TFSampleDecoderOnlyOutput</code>,</li>
<li><code>TFBeamSearchDecoderOnlyOutput</code>,</li>
<li><code>TFBeamSampleDecoderOnlyOutput</code></li>
</ul>
<p>If the model is an encoder-decoder model (<code>model.config.is_encoder_decoder=True</code>), the possible
<a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><code>TFGreedySearchEncoderDecoderOutput</code>,</li>
<li><code>TFSampleEncoderDecoderOutput</code>,</li>
<li><code>TFBeamSearchEncoderDecoderOutput</code>,</li>
<li><code>TFBeamSampleEncoderDecoderOutput</code></li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> or <code>tf.Tensor</code></p>
`}}),xn=new nn({props:{warning:!0,$$slots:{default:[Gu]},$$scope:{ctx:k}}}),St=new $({props:{name:"compute_transition_scores",anchor:"transformers.TFGenerationMixin.compute_transition_scores",parameters:[{name:"sequences",val:": Tensor"},{name:"scores",val:": typing.Tuple[tensorflow.python.framework.ops.Tensor]"},{name:"beam_indices",val:": typing.Optional[tensorflow.python.framework.ops.Tensor] = None"},{name:"normalize_logits",val:": bool = False"}],parametersDescription:[{anchor:"transformers.TFGenerationMixin.compute_transition_scores.sequences",description:`<strong>sequences</strong> (<code>tf.Tensor</code>) &#x2014;
The generated sequences. The second dimension (sequence_length) is either equal to <code>max_length</code> or
shorter if all batches finished early due to the <code>eos_token_id</code>.`,name:"sequences"},{anchor:"transformers.TFGenerationMixin.compute_transition_scores.scores",description:`<strong>scores</strong> (<code>tuple(tf.Tensor)</code>) &#x2014;
Transition scores for each vocabulary token at each generation step. Beam transition scores consisting
of log probabilities of tokens conditioned on log softmax of previously generated tokens Tuple of
<code>tf.Tensor</code> with up to <code>max_new_tokens</code> elements (one element for each generated token), with each
tensor of shape <code>(batch_size*num_beams, config.vocab_size)</code>.`,name:"scores"},{anchor:"transformers.TFGenerationMixin.compute_transition_scores.beam_indices",description:`<strong>beam_indices</strong> (<code>tf.Tensor</code>, <em>optional</em>) &#x2014;
Beam indices of generated token id at each generation step. <code>tf.Tensor</code> of shape
<code>(batch_size*num_return_sequences, sequence_length)</code>. Only required if a <code>num_beams&gt;1</code> at
generate-time.`,name:"beam_indices"},{anchor:"transformers.TFGenerationMixin.compute_transition_scores.normalize_logits",description:`<strong>normalize_logits</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to normalize the logits (which, for legacy reasons, may be unnormalized).`,name:"normalize_logits"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/tf_utils.py#L477",returnDescription:`
<p>A <code>tf.Tensor</code> of shape <code>(batch_size*num_return_sequences, sequence_length)</code> containing
the transition scores (logits)</p>
`,returnType:`
<p><code>tf.Tensor</code></p>
`}}),Gn=new Ne({props:{anchor:"transformers.TFGenerationMixin.compute_transition_scores.example",$$slots:{default:[ku]},$$scope:{ctx:k}}}),Ft=new Sa({}),zt=new $({props:{name:"class transformers.FlaxGenerationMixin",anchor:"transformers.FlaxGenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/flax_utils.py#L129"}}),Yt=new $({props:{name:"generate",anchor:"transformers.FlaxGenerationMixin.generate",parameters:[{name:"input_ids",val:": Array"},{name:"generation_config",val:": typing.Optional[transformers.generation.configuration_utils.GenerationConfig] = None"},{name:"prng_key",val:": typing.Optional[jax.Array] = None"},{name:"trace",val:": bool = True"},{name:"params",val:": typing.Union[typing.Dict[str, jax.Array], NoneType] = None"},{name:"logits_processor",val:": typing.Optional[transformers.generation.flax_logits_process.FlaxLogitsProcessorList] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"transformers.FlaxGenerationMixin.generate.input_ids",description:`<strong>input_ids</strong> (<code>jnp.ndarray</code> of shape <code>(batch_size, sequence_length)</code>) &#x2014;
The sequence used as a prompt for the generation.`,name:"input_ids"},{anchor:"transformers.FlaxGenerationMixin.generate.generation_config",description:`<strong>generation_config</strong> (<code>~generation.GenerationConfig</code>, <em>optional</em>) &#x2014;
The generation configuration to be used as base parametrization for the generation call. <code>**kwargs</code>
passed to generate matching the attributes of <code>generation_config</code> will override them. If
<code>generation_config</code> is not provided, the default will be used, which had the following loading
priority: 1) from the <code>generation_config.json</code> model file, if it exists; 2) from the model
configuration. Please note that unspecified parameters will inherit <a href="/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig">GenerationConfig</a>&#x2019;s
default values, whose documentation should be checked to parameterize generation.`,name:"generation_config"},{anchor:"transformers.FlaxGenerationMixin.generate.trace",description:`<strong>trace</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to trace generation. Setting <code>trace=False</code> should only be used for debugging and will lead to a
considerably slower runtime.`,name:"trace"},{anchor:"transformers.FlaxGenerationMixin.generate.params",description:`<strong>params</strong> (<code>Dict[str, jnp.ndarray]</code>, <em>optional</em>) &#x2014;
Optionally the model parameters can be passed. Can be useful for parallelized generation.`,name:"params"},{anchor:"transformers.FlaxGenerationMixin.generate.logits_processor",description:`<strong>logits_processor</strong> (<code>FlaxLogitsProcessorList </code>, <em>optional</em>) &#x2014;
Custom logits processors that complement the default logits processors built from arguments and
generation config. If a logit processor is passed that is already created with the arguments or a
generation config an error is thrown. This feature is intended for advanced users.`,name:"logits_processor"},{anchor:"transformers.FlaxGenerationMixin.generate.kwargs",description:`<strong>kwargs</strong> (<code>Dict[str, Any]</code>, <em>optional</em>) &#x2014;
Ad hoc parametrization of <code>generate_config</code> and/or additional model-specific kwargs that will be
forwarded to the <code>forward</code> function of the model. If the model is an encoder-decoder model, encoder
specific kwargs should not be prefixed and decoder specific kwargs should be prefixed with <em>decoder_</em>.`,name:"kwargs"}],source:"https://github.com/huggingface/transformers/blob/main/src/transformers/generation/flax_utils.py#L267",returnDescription:`
<p><a
  href="/docs/transformers/main/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a>.</p>
`}}),{c(){c=o("meta"),_=p(),m=o("h1"),d=o("a"),f=o("span"),T(i.$$.fragment),h=p(),G=o("span"),w=t("Generation"),y=p(),E=o("p"),Z=t("Each framework has a generate method for text generation implemented in their respective "),N=o("code"),ie=t("GenerationMixin"),F=t(" class:"),q=p(),S=o("ul"),B=o("li"),I=t("PyTorch "),P=o("a"),Ve=t("generate()"),$e=t(" is implemented in "),A=o("a"),Se=t("GenerationMixin"),Jr=t("."),Ur=p(),Fe=o("li"),xr=t("TensorFlow "),Pt=o("a"),Gr=t("generate()"),kr=t(" is implemented in "),Kt=o("a"),Er=t("TFGenerationMixin"),Zr=t("."),Br=p(),ze=o("li"),Cr=t("Flax/JAX "),es=o("a"),Ir=t("generate()"),Wr=t(" is implemented in "),ns=o("a"),Nr=t("FlaxGenerationMixin"),Xr=t("."),Fa=p(),tn=o("p"),Rr=t("Regardless of your framework of choice, you can parameterize the generate method with a "),ts=o("a"),Vr=t("GenerationConfig"),$r=t(`
class instance. Please refer to this class for the complete list of generation parameters, which control the behavior
of the generation method.`),za=p(),sn=o("p"),Sr=t(`To learn how to inspect a model\u2019s generation configuration, what are the defaults, how to change the parameters ad hoc,
and how to create and save a customized generation configuration, refer to the
`),ss=o("a"),Fr=t("text generation strategies guide"),zr=t(`. The guide also explains how to use related features,
like token streaming.`),La=p(),Le=o("h2"),on=o("a"),Fs=o("span"),T(rt.$$.fragment),Lr=p(),zs=o("span"),Ar=t("GenerationConfig"),Aa=p(),X=o("div"),T(it.$$.fragment),Qr=p(),lt=o("p"),Yr=t("Class that holds a configuration for a generation task. A "),Ls=o("code"),Dr=t("generate"),Hr=t(` call supports the following generation methods
for text-decoder, text-to-text, speech-to-text, and vision-to-text models:`),Or=p(),R=o("ul"),le=o("li"),As=o("em"),qr=t("greedy decoding"),Pr=t(" by calling "),os=o("a"),Kr=t("greedy_search()"),ei=t(" if "),Qs=o("code"),ni=t("num_beams=1"),ti=t(` and
`),Ys=o("code"),si=t("do_sample=False"),oi=p(),ce=o("li"),Ds=o("em"),ai=t("contrastive search"),ri=t(" by calling "),as=o("a"),ii=t("contrastive_search()"),li=t(" if "),Hs=o("code"),ci=t("penalty_alpha>0."),di=t(`
and `),Os=o("code"),mi=t("top_k>1"),pi=p(),de=o("li"),qs=o("em"),gi=t("multinomial sampling"),hi=t(" by calling "),rs=o("a"),ui=t("sample()"),fi=t(" if "),Ps=o("code"),_i=t("num_beams=1"),yi=t(` and
`),Ks=o("code"),Mi=t("do_sample=True"),bi=p(),me=o("li"),eo=o("em"),wi=t("beam-search decoding"),Ti=t(" by calling "),is=o("a"),ji=t("beam_search()"),vi=t(" if "),no=o("code"),Ji=t("num_beams>1"),Ui=t(` and
`),to=o("code"),xi=t("do_sample=False"),Gi=p(),pe=o("li"),so=o("em"),ki=t("beam-search multinomial sampling"),Ei=t(" by calling "),ls=o("a"),Zi=t("beam_sample()"),Bi=t(` if
`),oo=o("code"),Ci=t("num_beams>1"),Ii=t(" and "),ao=o("code"),Wi=t("do_sample=True"),Ni=p(),ge=o("li"),ro=o("em"),Xi=t("diverse beam-search decoding"),Ri=t(" by calling "),cs=o("a"),Vi=t("group_beam_search()"),$i=t(`, if
`),io=o("code"),Si=t("num_beams>1"),Fi=t(" and "),lo=o("code"),zi=t("num_beam_groups>1"),Li=p(),he=o("li"),co=o("em"),Ai=t("constrained beam-search decoding"),Qi=t(" by calling "),ds=o("a"),Yi=t("constrained_beam_search()"),Di=t(`, if
`),mo=o("code"),Hi=t("constraints!=None"),Oi=t(" or "),po=o("code"),qi=t("force_words_ids!=None"),Pi=p(),ue=o("li"),go=o("em"),Ki=t("assisted decoding"),el=t(" by calling "),ho=o("code"),nl=t("assisted_decoding()"),tl=t(`, if
`),uo=o("code"),sl=t("assistant_model"),ol=t(" is passed to "),fo=o("code"),al=t(".generate()"),rl=p(),ct=o("p"),il=t(`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018.generate()\u2018. To learn
more about decoding strategies refer to the `),ms=o("a"),ll=t("text generation strategies guide"),cl=t("."),dl=p(),Ee=o("div"),T(dt.$$.fragment),ml=p(),mt=o("p"),pl=t("Instantiate a "),ps=o("a"),gl=t("GenerationConfig"),hl=t(" from a generation configuration file."),ul=p(),T(an.$$.fragment),fl=p(),rn=o("div"),T(pt.$$.fragment),_l=p(),O=o("p"),yl=t("Instantiates a "),gs=o("a"),Ml=t("GenerationConfig"),bl=t(" from a "),hs=o("a"),wl=t("PretrainedConfig"),Tl=t(`. This function is useful to convert legacy
`),us=o("a"),jl=t("PretrainedConfig"),vl=t(" objects, which may contain generation parameters, into a stand-alone "),fs=o("a"),Jl=t("GenerationConfig"),Ul=t("."),xl=p(),ln=o("div"),T(gt.$$.fragment),Gl=p(),Ae=o("p"),kl=t("Save a generation configuration object to the directory "),_o=o("code"),El=t("save_directory"),Zl=t(`, so that it can be re-loaded using the
`),_s=o("a"),Bl=t("from_pretrained()"),Cl=t(" class method."),Qa=p(),Qe=o("h2"),cn=o("a"),yo=o("span"),T(ht.$$.fragment),Il=p(),Mo=o("span"),Wl=t("GenerationMixin"),Ya=p(),C=o("div"),T(ut.$$.fragment),Nl=p(),ft=o("p"),Xl=t("A class containing all functions for auto-regressive text generation, to be used as a mixin in "),ys=o("a"),Rl=t("PreTrainedModel"),Vl=t("."),$l=p(),_t=o("p"),Sl=t("The class exposes "),Ms=o("a"),Fl=t("generate()"),zl=t(", which can be used for:"),Ll=p(),z=o("ul"),fe=o("li"),bo=o("em"),Al=t("greedy decoding"),Ql=t(" by calling "),bs=o("a"),Yl=t("greedy_search()"),Dl=t(" if "),wo=o("code"),Hl=t("num_beams=1"),Ol=t(` and
`),To=o("code"),ql=t("do_sample=False"),Pl=p(),_e=o("li"),jo=o("em"),Kl=t("contrastive search"),ec=t(" by calling "),ws=o("a"),nc=t("contrastive_search()"),tc=t(" if "),vo=o("code"),sc=t("penalty_alpha>0"),oc=t(` and
`),Jo=o("code"),ac=t("top_k>1"),rc=p(),ye=o("li"),Uo=o("em"),ic=t("multinomial sampling"),lc=t(" by calling "),Ts=o("a"),cc=t("sample()"),dc=t(" if "),xo=o("code"),mc=t("num_beams=1"),pc=t(` and
`),Go=o("code"),gc=t("do_sample=True"),hc=p(),Me=o("li"),ko=o("em"),uc=t("beam-search decoding"),fc=t(" by calling "),js=o("a"),_c=t("beam_search()"),yc=t(" if "),Eo=o("code"),Mc=t("num_beams>1"),bc=t(` and
`),Zo=o("code"),wc=t("do_sample=False"),Tc=p(),be=o("li"),Bo=o("em"),jc=t("beam-search multinomial sampling"),vc=t(" by calling "),vs=o("a"),Jc=t("beam_sample()"),Uc=t(" if "),Co=o("code"),xc=t("num_beams>1"),Gc=t(`
and `),Io=o("code"),kc=t("do_sample=True"),Ec=p(),we=o("li"),Wo=o("em"),Zc=t("diverse beam-search decoding"),Bc=t(" by calling "),Js=o("a"),Cc=t("group_beam_search()"),Ic=t(", if "),No=o("code"),Wc=t("num_beams>1"),Nc=t(`
and `),Xo=o("code"),Xc=t("num_beam_groups>1"),Rc=p(),Te=o("li"),Ro=o("em"),Vc=t("constrained beam-search decoding"),$c=t(" by calling "),Us=o("a"),Sc=t("constrained_beam_search()"),Fc=t(`, if
`),Vo=o("code"),zc=t("constraints!=None"),Lc=t(" or "),$o=o("code"),Ac=t("force_words_ids!=None"),Qc=p(),yt=o("p"),Yc=t(`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),xs=o("a"),Dc=t("text generation strategies guide"),Hc=t("."),Oc=p(),Ze=o("div"),T(Mt.$$.fragment),qc=p(),So=o("p"),Pc=t("Generates sequences of token ids for models with a language modeling head."),Kc=p(),T(dn.$$.fragment),ed=p(),Be=o("div"),T(bt.$$.fragment),nd=p(),Fo=o("p"),td=t(`Computes the transition scores of sequences given the generation scores (and beam indices, if beam search was
used). This is a convenient method to quicky obtain the scores of the selected tokens at generation time.`),sd=p(),T(mn.$$.fragment),od=p(),K=o("div"),T(wt.$$.fragment),ad=p(),Tt=o("p"),rd=t("Generates sequences of token ids for models with a language modeling head using "),zo=o("strong"),id=t("greedy decoding"),ld=t(` and can be
used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),cd=p(),T(pn.$$.fragment),dd=p(),T(gn.$$.fragment),md=p(),ee=o("div"),T(jt.$$.fragment),pd=p(),vt=o("p"),gd=t("Generates sequences of token ids for models with a language modeling head using "),Lo=o("strong"),hd=t("multinomial sampling"),ud=t(` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),fd=p(),T(hn.$$.fragment),_d=p(),T(un.$$.fragment),yd=p(),ne=o("div"),T(Jt.$$.fragment),Md=p(),Ut=o("p"),bd=t("Generates sequences of token ids for models with a language modeling head using "),Ao=o("strong"),wd=t("beam search decoding"),Td=t(` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),jd=p(),T(fn.$$.fragment),vd=p(),T(_n.$$.fragment),Jd=p(),te=o("div"),T(xt.$$.fragment),Ud=p(),Gt=o("p"),xd=t("Generates sequences of token ids for models with a language modeling head using "),Qo=o("strong"),Gd=t(`beam search multinomial
sampling`),kd=t(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),Ed=p(),T(yn.$$.fragment),Zd=p(),T(Mn.$$.fragment),Bd=p(),se=o("div"),T(kt.$$.fragment),Cd=p(),Et=o("p"),Id=t("Generates sequences of token ids for models with a language modeling head using "),Yo=o("strong"),Wd=t("contrastive search"),Nd=t(` and can
be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),Xd=p(),T(bn.$$.fragment),Rd=p(),T(wn.$$.fragment),Vd=p(),oe=o("div"),T(Zt.$$.fragment),$d=p(),Bt=o("p"),Sd=t("Generates sequences of token ids for models with a language modeling head using "),Do=o("strong"),Fd=t(`diverse beam search
decoding`),zd=t(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),Ld=p(),T(Tn.$$.fragment),Ad=p(),T(jn.$$.fragment),Qd=p(),ae=o("div"),T(Ct.$$.fragment),Yd=p(),It=o("p"),Dd=t("Generates sequences of token ids for models with a language modeling head using "),Ho=o("strong"),Hd=t(`constrained beam search
decoding`),Od=t(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),qd=p(),T(vn.$$.fragment),Pd=p(),T(Jn.$$.fragment),Da=p(),Ye=o("h2"),Un=o("a"),Oo=o("span"),T(Wt.$$.fragment),Kd=p(),qo=o("span"),em=t("TFGenerationMixin"),Ha=p(),V=o("div"),T(Nt.$$.fragment),nm=p(),Xt=o("p"),tm=t("A class containing all of the functions supporting generation, to be used as a mixin in "),Gs=o("a"),sm=t("TFPreTrainedModel"),om=t("."),am=p(),Rt=o("p"),rm=t("The class exposes "),ks=o("a"),im=t("generate()"),lm=t(", which can be used for:"),cm=p(),je=o("ul"),ve=o("li"),Po=o("em"),dm=t("greedy decoding"),mm=t(" by calling "),Ko=o("code"),pm=t("greedy_search()"),gm=t(" if "),ea=o("code"),hm=t("num_beams=1"),um=t(` and
`),na=o("code"),fm=t("do_sample=False"),_m=p(),Je=o("li"),ta=o("em"),ym=t("contrastive search"),Mm=t(" by calling "),sa=o("code"),bm=t("contrastive_search()"),wm=t(" if "),oa=o("code"),Tm=t("penalty_alpha>0"),jm=t(` and
`),aa=o("code"),vm=t("top_k>1"),Jm=p(),Ue=o("li"),ra=o("em"),Um=t("multinomial sampling"),xm=t(" by calling "),ia=o("code"),Gm=t("sample()"),km=t(" if "),la=o("code"),Em=t("num_beams=1"),Zm=t(` and
`),ca=o("code"),Bm=t("do_sample=True"),Cm=p(),De=o("li"),da=o("em"),Im=t("beam-search decoding"),Wm=t(" by calling "),ma=o("code"),Nm=t("beam_search()"),Xm=t(" if "),pa=o("code"),Rm=t("num_beams>1"),Vm=p(),Vt=o("p"),$m=t(`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),Es=o("a"),Sm=t("text generation strategies guide"),Fm=t("."),zm=p(),Ce=o("div"),T($t.$$.fragment),Lm=p(),ga=o("p"),Am=t("Generates sequences of token ids for models with a language modeling head."),Qm=p(),T(xn.$$.fragment),Ym=p(),Ie=o("div"),T(St.$$.fragment),Dm=p(),ha=o("p"),Hm=t(`Computes the transition scores of sequences given the generation scores (and beam indices, if beam search was
used). This is a convenient method to quicky obtain the scores of the selected tokens at generation time.`),Om=p(),T(Gn.$$.fragment),Oa=p(),He=o("h2"),kn=o("a"),ua=o("span"),T(Ft.$$.fragment),qm=p(),fa=o("span"),Pm=t("FlaxGenerationMixin"),qa=p(),L=o("div"),T(zt.$$.fragment),Km=p(),Lt=o("p"),ep=t(`A class containing all functions for auto-regressive text generation, to be used as a mixin in
`),Zs=o("a"),np=t("FlaxPreTrainedModel"),tp=t("."),sp=p(),At=o("p"),op=t("The class exposes "),Bs=o("a"),ap=t("generate()"),rp=t(", which can be used for:"),ip=p(),Oe=o("ul"),xe=o("li"),_a=o("em"),lp=t("greedy decoding"),cp=t(" by calling "),ya=o("code"),dp=t("_greedy_search()"),mp=t(" if "),Ma=o("code"),pp=t("num_beams=1"),gp=t(` and
`),ba=o("code"),hp=t("do_sample=False"),up=p(),Ge=o("li"),wa=o("em"),fp=t("multinomial sampling"),_p=t(" by calling "),Ta=o("code"),yp=t("_sample()"),Mp=t(" if "),ja=o("code"),bp=t("num_beams=1"),wp=t(` and
`),va=o("code"),Tp=t("do_sample=True"),jp=p(),ke=o("li"),Ja=o("em"),vp=t("beam-search decoding"),Jp=t(" by calling "),Ua=o("code"),Up=t("_beam_search()"),xp=t(" if "),xa=o("code"),Gp=t("num_beams>1"),kp=t(` and
`),Ga=o("code"),Ep=t("do_sample=False"),Zp=p(),Qt=o("p"),Bp=t(`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),Cs=o("a"),Cp=t("text generation strategies guide"),Ip=t("."),Wp=p(),En=o("div"),T(Yt.$$.fragment),Np=p(),ka=o("p"),Xp=t("Generates sequences of token ids for models with a language modeling head."),this.h()},l(l){const M=cu('[data-svelte="svelte-1phssyn"]',document.head);c=a(M,"META",{name:!0,content:!0}),M.forEach(n),_=g(l),m=a(l,"H1",{class:!0});var Dt=r(m);d=a(Dt,"A",{id:!0,class:!0,href:!0});var Ea=r(d);f=a(Ea,"SPAN",{});var Za=r(f);j(i.$$.fragment,Za),Za.forEach(n),Ea.forEach(n),h=g(Dt),G=a(Dt,"SPAN",{});var Ba=r(G);w=s(Ba,"Generation"),Ba.forEach(n),Dt.forEach(n),y=g(l),E=a(l,"P",{});var Ht=r(E);Z=s(Ht,"Each framework has a generate method for text generation implemented in their respective "),N=a(Ht,"CODE",{});var Ca=r(N);ie=s(Ca,"GenerationMixin"),Ca.forEach(n),F=s(Ht," class:"),Ht.forEach(n),q=g(l),S=a(l,"UL",{});var qe=r(S);B=a(qe,"LI",{});var Pe=r(B);I=s(Pe,"PyTorch "),P=a(Pe,"A",{href:!0});var Ia=r(P);Ve=s(Ia,"generate()"),Ia.forEach(n),$e=s(Pe," is implemented in "),A=a(Pe,"A",{href:!0});var Wa=r(A);Se=s(Wa,"GenerationMixin"),Wa.forEach(n),Jr=s(Pe,"."),Pe.forEach(n),Ur=g(qe),Fe=a(qe,"LI",{});var Ke=r(Fe);xr=s(Ke,"TensorFlow "),Pt=a(Ke,"A",{href:!0});var Na=r(Pt);Gr=s(Na,"generate()"),Na.forEach(n),kr=s(Ke," is implemented in "),Kt=a(Ke,"A",{href:!0});var Xa=r(Kt);Er=s(Xa,"TFGenerationMixin"),Xa.forEach(n),Zr=s(Ke,"."),Ke.forEach(n),Br=g(qe),ze=a(qe,"LI",{});var en=r(ze);Cr=s(en,"Flax/JAX "),es=a(en,"A",{href:!0});var Ra=r(es);Ir=s(Ra,"generate()"),Ra.forEach(n),Wr=s(en," is implemented in "),ns=a(en,"A",{href:!0});var Va=r(ns);Nr=s(Va,"FlaxGenerationMixin"),Va.forEach(n),Xr=s(en,"."),en.forEach(n),qe.forEach(n),Fa=g(l),tn=a(l,"P",{});var Ot=r(tn);Rr=s(Ot,"Regardless of your framework of choice, you can parameterize the generate method with a "),ts=a(Ot,"A",{href:!0});var $a=r(ts);Vr=s($a,"GenerationConfig"),$a.forEach(n),$r=s(Ot,`
class instance. Please refer to this class for the complete list of generation parameters, which control the behavior
of the generation method.`),Ot.forEach(n),za=g(l),sn=a(l,"P",{});var qt=r(sn);Sr=s(qt,`To learn how to inspect a model\u2019s generation configuration, what are the defaults, how to change the parameters ad hoc,
and how to create and save a customized generation configuration, refer to the
`),ss=a(qt,"A",{href:!0});var Rp=r(ss);Fr=s(Rp,"text generation strategies guide"),Rp.forEach(n),zr=s(qt,`. The guide also explains how to use related features,
like token streaming.`),qt.forEach(n),La=g(l),Le=a(l,"H2",{class:!0});var Ka=r(Le);on=a(Ka,"A",{id:!0,class:!0,href:!0});var Vp=r(on);Fs=a(Vp,"SPAN",{});var $p=r(Fs);j(rt.$$.fragment,$p),$p.forEach(n),Vp.forEach(n),Lr=g(Ka),zs=a(Ka,"SPAN",{});var Sp=r(zs);Ar=s(Sp,"GenerationConfig"),Sp.forEach(n),Ka.forEach(n),Aa=g(l),X=a(l,"DIV",{class:!0});var Y=r(X);j(it.$$.fragment,Y),Qr=g(Y),lt=a(Y,"P",{});var er=r(lt);Yr=s(er,"Class that holds a configuration for a generation task. A "),Ls=a(er,"CODE",{});var Fp=r(Ls);Dr=s(Fp,"generate"),Fp.forEach(n),Hr=s(er,` call supports the following generation methods
for text-decoder, text-to-text, speech-to-text, and vision-to-text models:`),er.forEach(n),Or=g(Y),R=a(Y,"UL",{});var Q=r(R);le=a(Q,"LI",{});var Zn=r(le);As=a(Zn,"EM",{});var zp=r(As);qr=s(zp,"greedy decoding"),zp.forEach(n),Pr=s(Zn," by calling "),os=a(Zn,"A",{href:!0});var Lp=r(os);Kr=s(Lp,"greedy_search()"),Lp.forEach(n),ei=s(Zn," if "),Qs=a(Zn,"CODE",{});var Ap=r(Qs);ni=s(Ap,"num_beams=1"),Ap.forEach(n),ti=s(Zn,` and
`),Ys=a(Zn,"CODE",{});var Qp=r(Ys);si=s(Qp,"do_sample=False"),Qp.forEach(n),Zn.forEach(n),oi=g(Q),ce=a(Q,"LI",{});var Bn=r(ce);Ds=a(Bn,"EM",{});var Yp=r(Ds);ai=s(Yp,"contrastive search"),Yp.forEach(n),ri=s(Bn," by calling "),as=a(Bn,"A",{href:!0});var Dp=r(as);ii=s(Dp,"contrastive_search()"),Dp.forEach(n),li=s(Bn," if "),Hs=a(Bn,"CODE",{});var Hp=r(Hs);ci=s(Hp,"penalty_alpha>0."),Hp.forEach(n),di=s(Bn,`
and `),Os=a(Bn,"CODE",{});var Op=r(Os);mi=s(Op,"top_k>1"),Op.forEach(n),Bn.forEach(n),pi=g(Q),de=a(Q,"LI",{});var Cn=r(de);qs=a(Cn,"EM",{});var qp=r(qs);gi=s(qp,"multinomial sampling"),qp.forEach(n),hi=s(Cn," by calling "),rs=a(Cn,"A",{href:!0});var Pp=r(rs);ui=s(Pp,"sample()"),Pp.forEach(n),fi=s(Cn," if "),Ps=a(Cn,"CODE",{});var Kp=r(Ps);_i=s(Kp,"num_beams=1"),Kp.forEach(n),yi=s(Cn,` and
`),Ks=a(Cn,"CODE",{});var eg=r(Ks);Mi=s(eg,"do_sample=True"),eg.forEach(n),Cn.forEach(n),bi=g(Q),me=a(Q,"LI",{});var In=r(me);eo=a(In,"EM",{});var ng=r(eo);wi=s(ng,"beam-search decoding"),ng.forEach(n),Ti=s(In," by calling "),is=a(In,"A",{href:!0});var tg=r(is);ji=s(tg,"beam_search()"),tg.forEach(n),vi=s(In," if "),no=a(In,"CODE",{});var sg=r(no);Ji=s(sg,"num_beams>1"),sg.forEach(n),Ui=s(In,` and
`),to=a(In,"CODE",{});var og=r(to);xi=s(og,"do_sample=False"),og.forEach(n),In.forEach(n),Gi=g(Q),pe=a(Q,"LI",{});var Wn=r(pe);so=a(Wn,"EM",{});var ag=r(so);ki=s(ag,"beam-search multinomial sampling"),ag.forEach(n),Ei=s(Wn," by calling "),ls=a(Wn,"A",{href:!0});var rg=r(ls);Zi=s(rg,"beam_sample()"),rg.forEach(n),Bi=s(Wn,` if
`),oo=a(Wn,"CODE",{});var ig=r(oo);Ci=s(ig,"num_beams>1"),ig.forEach(n),Ii=s(Wn," and "),ao=a(Wn,"CODE",{});var lg=r(ao);Wi=s(lg,"do_sample=True"),lg.forEach(n),Wn.forEach(n),Ni=g(Q),ge=a(Q,"LI",{});var Nn=r(ge);ro=a(Nn,"EM",{});var cg=r(ro);Xi=s(cg,"diverse beam-search decoding"),cg.forEach(n),Ri=s(Nn," by calling "),cs=a(Nn,"A",{href:!0});var dg=r(cs);Vi=s(dg,"group_beam_search()"),dg.forEach(n),$i=s(Nn,`, if
`),io=a(Nn,"CODE",{});var mg=r(io);Si=s(mg,"num_beams>1"),mg.forEach(n),Fi=s(Nn," and "),lo=a(Nn,"CODE",{});var pg=r(lo);zi=s(pg,"num_beam_groups>1"),pg.forEach(n),Nn.forEach(n),Li=g(Q),he=a(Q,"LI",{});var Xn=r(he);co=a(Xn,"EM",{});var gg=r(co);Ai=s(gg,"constrained beam-search decoding"),gg.forEach(n),Qi=s(Xn," by calling "),ds=a(Xn,"A",{href:!0});var hg=r(ds);Yi=s(hg,"constrained_beam_search()"),hg.forEach(n),Di=s(Xn,`, if
`),mo=a(Xn,"CODE",{});var ug=r(mo);Hi=s(ug,"constraints!=None"),ug.forEach(n),Oi=s(Xn," or "),po=a(Xn,"CODE",{});var fg=r(po);qi=s(fg,"force_words_ids!=None"),fg.forEach(n),Xn.forEach(n),Pi=g(Q),ue=a(Q,"LI",{});var Rn=r(ue);go=a(Rn,"EM",{});var _g=r(go);Ki=s(_g,"assisted decoding"),_g.forEach(n),el=s(Rn," by calling "),ho=a(Rn,"CODE",{});var yg=r(ho);nl=s(yg,"assisted_decoding()"),yg.forEach(n),tl=s(Rn,`, if
`),uo=a(Rn,"CODE",{});var Mg=r(uo);sl=s(Mg,"assistant_model"),Mg.forEach(n),ol=s(Rn," is passed to "),fo=a(Rn,"CODE",{});var bg=r(fo);al=s(bg,".generate()"),bg.forEach(n),Rn.forEach(n),Q.forEach(n),rl=g(Y),ct=a(Y,"P",{});var nr=r(ct);il=s(nr,`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018.generate()\u2018. To learn
more about decoding strategies refer to the `),ms=a(nr,"A",{href:!0});var wg=r(ms);ll=s(wg,"text generation strategies guide"),wg.forEach(n),cl=s(nr,"."),nr.forEach(n),dl=g(Y),Ee=a(Y,"DIV",{class:!0});var Is=r(Ee);j(dt.$$.fragment,Is),ml=g(Is),mt=a(Is,"P",{});var tr=r(mt);pl=s(tr,"Instantiate a "),ps=a(tr,"A",{href:!0});var Tg=r(ps);gl=s(Tg,"GenerationConfig"),Tg.forEach(n),hl=s(tr," from a generation configuration file."),tr.forEach(n),ul=g(Is),j(an.$$.fragment,Is),Is.forEach(n),fl=g(Y),rn=a(Y,"DIV",{class:!0});var sr=r(rn);j(pt.$$.fragment,sr),_l=g(sr),O=a(sr,"P",{});var We=r(O);yl=s(We,"Instantiates a "),gs=a(We,"A",{href:!0});var jg=r(gs);Ml=s(jg,"GenerationConfig"),jg.forEach(n),bl=s(We," from a "),hs=a(We,"A",{href:!0});var vg=r(hs);wl=s(vg,"PretrainedConfig"),vg.forEach(n),Tl=s(We,`. This function is useful to convert legacy
`),us=a(We,"A",{href:!0});var Jg=r(us);jl=s(Jg,"PretrainedConfig"),Jg.forEach(n),vl=s(We," objects, which may contain generation parameters, into a stand-alone "),fs=a(We,"A",{href:!0});var Ug=r(fs);Jl=s(Ug,"GenerationConfig"),Ug.forEach(n),Ul=s(We,"."),We.forEach(n),sr.forEach(n),xl=g(Y),ln=a(Y,"DIV",{class:!0});var or=r(ln);j(gt.$$.fragment,or),Gl=g(or),Ae=a(or,"P",{});var Ws=r(Ae);kl=s(Ws,"Save a generation configuration object to the directory "),_o=a(Ws,"CODE",{});var xg=r(_o);El=s(xg,"save_directory"),xg.forEach(n),Zl=s(Ws,`, so that it can be re-loaded using the
`),_s=a(Ws,"A",{href:!0});var Gg=r(_s);Bl=s(Gg,"from_pretrained()"),Gg.forEach(n),Cl=s(Ws," class method."),Ws.forEach(n),or.forEach(n),Y.forEach(n),Qa=g(l),Qe=a(l,"H2",{class:!0});var ar=r(Qe);cn=a(ar,"A",{id:!0,class:!0,href:!0});var kg=r(cn);yo=a(kg,"SPAN",{});var Eg=r(yo);j(ht.$$.fragment,Eg),Eg.forEach(n),kg.forEach(n),Il=g(ar),Mo=a(ar,"SPAN",{});var Zg=r(Mo);Wl=s(Zg,"GenerationMixin"),Zg.forEach(n),ar.forEach(n),Ya=g(l),C=a(l,"DIV",{class:!0});var W=r(C);j(ut.$$.fragment,W),Nl=g(W),ft=a(W,"P",{});var rr=r(ft);Xl=s(rr,"A class containing all functions for auto-regressive text generation, to be used as a mixin in "),ys=a(rr,"A",{href:!0});var Bg=r(ys);Rl=s(Bg,"PreTrainedModel"),Bg.forEach(n),Vl=s(rr,"."),rr.forEach(n),$l=g(W),_t=a(W,"P",{});var ir=r(_t);Sl=s(ir,"The class exposes "),Ms=a(ir,"A",{href:!0});var Cg=r(Ms);Fl=s(Cg,"generate()"),Cg.forEach(n),zl=s(ir,", which can be used for:"),ir.forEach(n),Ll=g(W),z=a(W,"UL",{});var D=r(z);fe=a(D,"LI",{});var Vn=r(fe);bo=a(Vn,"EM",{});var Ig=r(bo);Al=s(Ig,"greedy decoding"),Ig.forEach(n),Ql=s(Vn," by calling "),bs=a(Vn,"A",{href:!0});var Wg=r(bs);Yl=s(Wg,"greedy_search()"),Wg.forEach(n),Dl=s(Vn," if "),wo=a(Vn,"CODE",{});var Ng=r(wo);Hl=s(Ng,"num_beams=1"),Ng.forEach(n),Ol=s(Vn,` and
`),To=a(Vn,"CODE",{});var Xg=r(To);ql=s(Xg,"do_sample=False"),Xg.forEach(n),Vn.forEach(n),Pl=g(D),_e=a(D,"LI",{});var $n=r(_e);jo=a($n,"EM",{});var Rg=r(jo);Kl=s(Rg,"contrastive search"),Rg.forEach(n),ec=s($n," by calling "),ws=a($n,"A",{href:!0});var Vg=r(ws);nc=s(Vg,"contrastive_search()"),Vg.forEach(n),tc=s($n," if "),vo=a($n,"CODE",{});var $g=r(vo);sc=s($g,"penalty_alpha>0"),$g.forEach(n),oc=s($n,` and
`),Jo=a($n,"CODE",{});var Sg=r(Jo);ac=s(Sg,"top_k>1"),Sg.forEach(n),$n.forEach(n),rc=g(D),ye=a(D,"LI",{});var Sn=r(ye);Uo=a(Sn,"EM",{});var Fg=r(Uo);ic=s(Fg,"multinomial sampling"),Fg.forEach(n),lc=s(Sn," by calling "),Ts=a(Sn,"A",{href:!0});var zg=r(Ts);cc=s(zg,"sample()"),zg.forEach(n),dc=s(Sn," if "),xo=a(Sn,"CODE",{});var Lg=r(xo);mc=s(Lg,"num_beams=1"),Lg.forEach(n),pc=s(Sn,` and
`),Go=a(Sn,"CODE",{});var Ag=r(Go);gc=s(Ag,"do_sample=True"),Ag.forEach(n),Sn.forEach(n),hc=g(D),Me=a(D,"LI",{});var Fn=r(Me);ko=a(Fn,"EM",{});var Qg=r(ko);uc=s(Qg,"beam-search decoding"),Qg.forEach(n),fc=s(Fn," by calling "),js=a(Fn,"A",{href:!0});var Yg=r(js);_c=s(Yg,"beam_search()"),Yg.forEach(n),yc=s(Fn," if "),Eo=a(Fn,"CODE",{});var Dg=r(Eo);Mc=s(Dg,"num_beams>1"),Dg.forEach(n),bc=s(Fn,` and
`),Zo=a(Fn,"CODE",{});var Hg=r(Zo);wc=s(Hg,"do_sample=False"),Hg.forEach(n),Fn.forEach(n),Tc=g(D),be=a(D,"LI",{});var zn=r(be);Bo=a(zn,"EM",{});var Og=r(Bo);jc=s(Og,"beam-search multinomial sampling"),Og.forEach(n),vc=s(zn," by calling "),vs=a(zn,"A",{href:!0});var qg=r(vs);Jc=s(qg,"beam_sample()"),qg.forEach(n),Uc=s(zn," if "),Co=a(zn,"CODE",{});var Pg=r(Co);xc=s(Pg,"num_beams>1"),Pg.forEach(n),Gc=s(zn,`
and `),Io=a(zn,"CODE",{});var Kg=r(Io);kc=s(Kg,"do_sample=True"),Kg.forEach(n),zn.forEach(n),Ec=g(D),we=a(D,"LI",{});var Ln=r(we);Wo=a(Ln,"EM",{});var eh=r(Wo);Zc=s(eh,"diverse beam-search decoding"),eh.forEach(n),Bc=s(Ln," by calling "),Js=a(Ln,"A",{href:!0});var nh=r(Js);Cc=s(nh,"group_beam_search()"),nh.forEach(n),Ic=s(Ln,", if "),No=a(Ln,"CODE",{});var th=r(No);Wc=s(th,"num_beams>1"),th.forEach(n),Nc=s(Ln,`
and `),Xo=a(Ln,"CODE",{});var sh=r(Xo);Xc=s(sh,"num_beam_groups>1"),sh.forEach(n),Ln.forEach(n),Rc=g(D),Te=a(D,"LI",{});var An=r(Te);Ro=a(An,"EM",{});var oh=r(Ro);Vc=s(oh,"constrained beam-search decoding"),oh.forEach(n),$c=s(An," by calling "),Us=a(An,"A",{href:!0});var ah=r(Us);Sc=s(ah,"constrained_beam_search()"),ah.forEach(n),Fc=s(An,`, if
`),Vo=a(An,"CODE",{});var rh=r(Vo);zc=s(rh,"constraints!=None"),rh.forEach(n),Lc=s(An," or "),$o=a(An,"CODE",{});var ih=r($o);Ac=s(ih,"force_words_ids!=None"),ih.forEach(n),An.forEach(n),D.forEach(n),Qc=g(W),yt=a(W,"P",{});var lr=r(yt);Yc=s(lr,`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),xs=a(lr,"A",{href:!0});var lh=r(xs);Dc=s(lh,"text generation strategies guide"),lh.forEach(n),Hc=s(lr,"."),lr.forEach(n),Oc=g(W),Ze=a(W,"DIV",{class:!0});var Ns=r(Ze);j(Mt.$$.fragment,Ns),qc=g(Ns),So=a(Ns,"P",{});var ch=r(So);Pc=s(ch,"Generates sequences of token ids for models with a language modeling head."),ch.forEach(n),Kc=g(Ns),j(dn.$$.fragment,Ns),Ns.forEach(n),ed=g(W),Be=a(W,"DIV",{class:!0});var Xs=r(Be);j(bt.$$.fragment,Xs),nd=g(Xs),Fo=a(Xs,"P",{});var dh=r(Fo);td=s(dh,`Computes the transition scores of sequences given the generation scores (and beam indices, if beam search was
used). This is a convenient method to quicky obtain the scores of the selected tokens at generation time.`),dh.forEach(n),sd=g(Xs),j(mn.$$.fragment,Xs),Xs.forEach(n),od=g(W),K=a(W,"DIV",{class:!0});var Qn=r(K);j(wt.$$.fragment,Qn),ad=g(Qn),Tt=a(Qn,"P",{});var cr=r(Tt);rd=s(cr,"Generates sequences of token ids for models with a language modeling head using "),zo=a(cr,"STRONG",{});var mh=r(zo);id=s(mh,"greedy decoding"),mh.forEach(n),ld=s(cr,` and can be
used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),cr.forEach(n),cd=g(Qn),j(pn.$$.fragment,Qn),dd=g(Qn),j(gn.$$.fragment,Qn),Qn.forEach(n),md=g(W),ee=a(W,"DIV",{class:!0});var Yn=r(ee);j(jt.$$.fragment,Yn),pd=g(Yn),vt=a(Yn,"P",{});var dr=r(vt);gd=s(dr,"Generates sequences of token ids for models with a language modeling head using "),Lo=a(dr,"STRONG",{});var ph=r(Lo);hd=s(ph,"multinomial sampling"),ph.forEach(n),ud=s(dr,` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),dr.forEach(n),fd=g(Yn),j(hn.$$.fragment,Yn),_d=g(Yn),j(un.$$.fragment,Yn),Yn.forEach(n),yd=g(W),ne=a(W,"DIV",{class:!0});var Dn=r(ne);j(Jt.$$.fragment,Dn),Md=g(Dn),Ut=a(Dn,"P",{});var mr=r(Ut);bd=s(mr,"Generates sequences of token ids for models with a language modeling head using "),Ao=a(mr,"STRONG",{});var gh=r(Ao);wd=s(gh,"beam search decoding"),gh.forEach(n),Td=s(mr,` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),mr.forEach(n),jd=g(Dn),j(fn.$$.fragment,Dn),vd=g(Dn),j(_n.$$.fragment,Dn),Dn.forEach(n),Jd=g(W),te=a(W,"DIV",{class:!0});var Hn=r(te);j(xt.$$.fragment,Hn),Ud=g(Hn),Gt=a(Hn,"P",{});var pr=r(Gt);xd=s(pr,"Generates sequences of token ids for models with a language modeling head using "),Qo=a(pr,"STRONG",{});var hh=r(Qo);Gd=s(hh,`beam search multinomial
sampling`),hh.forEach(n),kd=s(pr," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),pr.forEach(n),Ed=g(Hn),j(yn.$$.fragment,Hn),Zd=g(Hn),j(Mn.$$.fragment,Hn),Hn.forEach(n),Bd=g(W),se=a(W,"DIV",{class:!0});var On=r(se);j(kt.$$.fragment,On),Cd=g(On),Et=a(On,"P",{});var gr=r(Et);Id=s(gr,"Generates sequences of token ids for models with a language modeling head using "),Yo=a(gr,"STRONG",{});var uh=r(Yo);Wd=s(uh,"contrastive search"),uh.forEach(n),Nd=s(gr,` and can
be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),gr.forEach(n),Xd=g(On),j(bn.$$.fragment,On),Rd=g(On),j(wn.$$.fragment,On),On.forEach(n),Vd=g(W),oe=a(W,"DIV",{class:!0});var qn=r(oe);j(Zt.$$.fragment,qn),$d=g(qn),Bt=a(qn,"P",{});var hr=r(Bt);Sd=s(hr,"Generates sequences of token ids for models with a language modeling head using "),Do=a(hr,"STRONG",{});var fh=r(Do);Fd=s(fh,`diverse beam search
decoding`),fh.forEach(n),zd=s(hr," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),hr.forEach(n),Ld=g(qn),j(Tn.$$.fragment,qn),Ad=g(qn),j(jn.$$.fragment,qn),qn.forEach(n),Qd=g(W),ae=a(W,"DIV",{class:!0});var Pn=r(ae);j(Ct.$$.fragment,Pn),Yd=g(Pn),It=a(Pn,"P",{});var ur=r(It);Dd=s(ur,"Generates sequences of token ids for models with a language modeling head using "),Ho=a(ur,"STRONG",{});var _h=r(Ho);Hd=s(_h,`constrained beam search
decoding`),_h.forEach(n),Od=s(ur," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),ur.forEach(n),qd=g(Pn),j(vn.$$.fragment,Pn),Pd=g(Pn),j(Jn.$$.fragment,Pn),Pn.forEach(n),W.forEach(n),Da=g(l),Ye=a(l,"H2",{class:!0});var fr=r(Ye);Un=a(fr,"A",{id:!0,class:!0,href:!0});var yh=r(Un);Oo=a(yh,"SPAN",{});var Mh=r(Oo);j(Wt.$$.fragment,Mh),Mh.forEach(n),yh.forEach(n),Kd=g(fr),qo=a(fr,"SPAN",{});var bh=r(qo);em=s(bh,"TFGenerationMixin"),bh.forEach(n),fr.forEach(n),Ha=g(l),V=a(l,"DIV",{class:!0});var H=r(V);j(Nt.$$.fragment,H),nm=g(H),Xt=a(H,"P",{});var _r=r(Xt);tm=s(_r,"A class containing all of the functions supporting generation, to be used as a mixin in "),Gs=a(_r,"A",{href:!0});var wh=r(Gs);sm=s(wh,"TFPreTrainedModel"),wh.forEach(n),om=s(_r,"."),_r.forEach(n),am=g(H),Rt=a(H,"P",{});var yr=r(Rt);rm=s(yr,"The class exposes "),ks=a(yr,"A",{href:!0});var Th=r(ks);im=s(Th,"generate()"),Th.forEach(n),lm=s(yr,", which can be used for:"),yr.forEach(n),cm=g(H),je=a(H,"UL",{});var Kn=r(je);ve=a(Kn,"LI",{});var et=r(ve);Po=a(et,"EM",{});var jh=r(Po);dm=s(jh,"greedy decoding"),jh.forEach(n),mm=s(et," by calling "),Ko=a(et,"CODE",{});var vh=r(Ko);pm=s(vh,"greedy_search()"),vh.forEach(n),gm=s(et," if "),ea=a(et,"CODE",{});var Jh=r(ea);hm=s(Jh,"num_beams=1"),Jh.forEach(n),um=s(et,` and
`),na=a(et,"CODE",{});var Uh=r(na);fm=s(Uh,"do_sample=False"),Uh.forEach(n),et.forEach(n),_m=g(Kn),Je=a(Kn,"LI",{});var nt=r(Je);ta=a(nt,"EM",{});var xh=r(ta);ym=s(xh,"contrastive search"),xh.forEach(n),Mm=s(nt," by calling "),sa=a(nt,"CODE",{});var Gh=r(sa);bm=s(Gh,"contrastive_search()"),Gh.forEach(n),wm=s(nt," if "),oa=a(nt,"CODE",{});var kh=r(oa);Tm=s(kh,"penalty_alpha>0"),kh.forEach(n),jm=s(nt,` and
`),aa=a(nt,"CODE",{});var Eh=r(aa);vm=s(Eh,"top_k>1"),Eh.forEach(n),nt.forEach(n),Jm=g(Kn),Ue=a(Kn,"LI",{});var tt=r(Ue);ra=a(tt,"EM",{});var Zh=r(ra);Um=s(Zh,"multinomial sampling"),Zh.forEach(n),xm=s(tt," by calling "),ia=a(tt,"CODE",{});var Bh=r(ia);Gm=s(Bh,"sample()"),Bh.forEach(n),km=s(tt," if "),la=a(tt,"CODE",{});var Ch=r(la);Em=s(Ch,"num_beams=1"),Ch.forEach(n),Zm=s(tt,` and
`),ca=a(tt,"CODE",{});var Ih=r(ca);Bm=s(Ih,"do_sample=True"),Ih.forEach(n),tt.forEach(n),Cm=g(Kn),De=a(Kn,"LI",{});var Rs=r(De);da=a(Rs,"EM",{});var Wh=r(da);Im=s(Wh,"beam-search decoding"),Wh.forEach(n),Wm=s(Rs," by calling "),ma=a(Rs,"CODE",{});var Nh=r(ma);Nm=s(Nh,"beam_search()"),Nh.forEach(n),Xm=s(Rs," if "),pa=a(Rs,"CODE",{});var Xh=r(pa);Rm=s(Xh,"num_beams>1"),Xh.forEach(n),Rs.forEach(n),Kn.forEach(n),Vm=g(H),Vt=a(H,"P",{});var Mr=r(Vt);$m=s(Mr,`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),Es=a(Mr,"A",{href:!0});var Rh=r(Es);Sm=s(Rh,"text generation strategies guide"),Rh.forEach(n),Fm=s(Mr,"."),Mr.forEach(n),zm=g(H),Ce=a(H,"DIV",{class:!0});var Vs=r(Ce);j($t.$$.fragment,Vs),Lm=g(Vs),ga=a(Vs,"P",{});var Vh=r(ga);Am=s(Vh,"Generates sequences of token ids for models with a language modeling head."),Vh.forEach(n),Qm=g(Vs),j(xn.$$.fragment,Vs),Vs.forEach(n),Ym=g(H),Ie=a(H,"DIV",{class:!0});var $s=r(Ie);j(St.$$.fragment,$s),Dm=g($s),ha=a($s,"P",{});var $h=r(ha);Hm=s($h,`Computes the transition scores of sequences given the generation scores (and beam indices, if beam search was
used). This is a convenient method to quicky obtain the scores of the selected tokens at generation time.`),$h.forEach(n),Om=g($s),j(Gn.$$.fragment,$s),$s.forEach(n),H.forEach(n),Oa=g(l),He=a(l,"H2",{class:!0});var br=r(He);kn=a(br,"A",{id:!0,class:!0,href:!0});var Sh=r(kn);ua=a(Sh,"SPAN",{});var Fh=r(ua);j(Ft.$$.fragment,Fh),Fh.forEach(n),Sh.forEach(n),qm=g(br),fa=a(br,"SPAN",{});var zh=r(fa);Pm=s(zh,"FlaxGenerationMixin"),zh.forEach(n),br.forEach(n),qa=g(l),L=a(l,"DIV",{class:!0});var re=r(L);j(zt.$$.fragment,re),Km=g(re),Lt=a(re,"P",{});var wr=r(Lt);ep=s(wr,`A class containing all functions for auto-regressive text generation, to be used as a mixin in
`),Zs=a(wr,"A",{href:!0});var Lh=r(Zs);np=s(Lh,"FlaxPreTrainedModel"),Lh.forEach(n),tp=s(wr,"."),wr.forEach(n),sp=g(re),At=a(re,"P",{});var Tr=r(At);op=s(Tr,"The class exposes "),Bs=a(Tr,"A",{href:!0});var Ah=r(Bs);ap=s(Ah,"generate()"),Ah.forEach(n),rp=s(Tr,", which can be used for:"),Tr.forEach(n),ip=g(re),Oe=a(re,"UL",{});var Ss=r(Oe);xe=a(Ss,"LI",{});var st=r(xe);_a=a(st,"EM",{});var Qh=r(_a);lp=s(Qh,"greedy decoding"),Qh.forEach(n),cp=s(st," by calling "),ya=a(st,"CODE",{});var Yh=r(ya);dp=s(Yh,"_greedy_search()"),Yh.forEach(n),mp=s(st," if "),Ma=a(st,"CODE",{});var Dh=r(Ma);pp=s(Dh,"num_beams=1"),Dh.forEach(n),gp=s(st,` and
`),ba=a(st,"CODE",{});var Hh=r(ba);hp=s(Hh,"do_sample=False"),Hh.forEach(n),st.forEach(n),up=g(Ss),Ge=a(Ss,"LI",{});var ot=r(Ge);wa=a(ot,"EM",{});var Oh=r(wa);fp=s(Oh,"multinomial sampling"),Oh.forEach(n),_p=s(ot," by calling "),Ta=a(ot,"CODE",{});var qh=r(Ta);yp=s(qh,"_sample()"),qh.forEach(n),Mp=s(ot," if "),ja=a(ot,"CODE",{});var Ph=r(ja);bp=s(Ph,"num_beams=1"),Ph.forEach(n),wp=s(ot,` and
`),va=a(ot,"CODE",{});var Kh=r(va);Tp=s(Kh,"do_sample=True"),Kh.forEach(n),ot.forEach(n),jp=g(Ss),ke=a(Ss,"LI",{});var at=r(ke);Ja=a(at,"EM",{});var eu=r(Ja);vp=s(eu,"beam-search decoding"),eu.forEach(n),Jp=s(at," by calling "),Ua=a(at,"CODE",{});var nu=r(Ua);Up=s(nu,"_beam_search()"),nu.forEach(n),xp=s(at," if "),xa=a(at,"CODE",{});var tu=r(xa);Gp=s(tu,"num_beams>1"),tu.forEach(n),kp=s(at,` and
`),Ga=a(at,"CODE",{});var su=r(Ga);Ep=s(su,"do_sample=False"),su.forEach(n),at.forEach(n),Ss.forEach(n),Zp=g(re),Qt=a(re,"P",{});var jr=r(Qt);Bp=s(jr,`You do not need to call any of the above methods directly. Pass custom parameter values to \u2018generate\u2019 instead. To
learn more about decoding strategies refer to the `),Cs=a(jr,"A",{href:!0});var ou=r(Cs);Cp=s(ou,"text generation strategies guide"),ou.forEach(n),Ip=s(jr,"."),jr.forEach(n),Wp=g(re),En=a(re,"DIV",{class:!0});var vr=r(En);j(Yt.$$.fragment,vr),Np=g(vr),ka=a(vr,"P",{});var au=r(ka);Xp=s(au,"Generates sequences of token ids for models with a language modeling head."),au.forEach(n),vr.forEach(n),re.forEach(n),this.h()},h(){u(c,"name","hf:doc:metadata"),u(c,"content",JSON.stringify(Zu)),u(d,"id","generation"),u(d,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(d,"href","#generation"),u(m,"class","relative group"),u(P,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate"),u(A,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin"),u(Pt,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.TFGenerationMixin.generate"),u(Kt,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.TFGenerationMixin"),u(es,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.FlaxGenerationMixin.generate"),u(ns,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.FlaxGenerationMixin"),u(ts,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"),u(ss,"href","../generation_strategies"),u(on,"id","transformers.GenerationConfig"),u(on,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(on,"href","#transformers.GenerationConfig"),u(Le,"class","relative group"),u(os,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(as,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),u(rs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(is,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(ls,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(cs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(ds,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.constrained_beam_search"),u(ms,"href","../generation_strategies"),u(ps,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"),u(Ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(gs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"),u(hs,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(us,"href","/docs/transformers/main/en/main_classes/configuration#transformers.PretrainedConfig"),u(fs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig"),u(rn,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(_s,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationConfig.from_pretrained"),u(ln,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(cn,"id","transformers.GenerationMixin"),u(cn,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(cn,"href","#transformers.GenerationMixin"),u(Qe,"class","relative group"),u(ys,"href","/docs/transformers/main/en/main_classes/model#transformers.PreTrainedModel"),u(Ms,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.generate"),u(bs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(ws,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),u(Ts,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(js,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(vs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(Js,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(Us,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.GenerationMixin.constrained_beam_search"),u(xs,"href","../generation_strategies"),u(Ze,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Be,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ne,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(te,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(se,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(oe,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(ae,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Un,"id","transformers.TFGenerationMixin"),u(Un,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(Un,"href","#transformers.TFGenerationMixin"),u(Ye,"class","relative group"),u(Gs,"href","/docs/transformers/main/en/main_classes/model#transformers.TFPreTrainedModel"),u(ks,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.TFGenerationMixin.generate"),u(Es,"href","../generation_strategies"),u(Ce,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(Ie,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(kn,"id","transformers.FlaxGenerationMixin"),u(kn,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(kn,"href","#transformers.FlaxGenerationMixin"),u(He,"class","relative group"),u(Zs,"href","/docs/transformers/main/en/main_classes/model#transformers.FlaxPreTrainedModel"),u(Bs,"href","/docs/transformers/main/en/main_classes/text_generation#transformers.FlaxGenerationMixin.generate"),u(Cs,"href","../generation_strategies"),u(En,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(l,M){e(document.head,c),b(l,_,M),b(l,m,M),e(m,d),e(d,f),v(i,f,null),e(m,h),e(m,G),e(G,w),b(l,y,M),b(l,E,M),e(E,Z),e(E,N),e(N,ie),e(E,F),b(l,q,M),b(l,S,M),e(S,B),e(B,I),e(B,P),e(P,Ve),e(B,$e),e(B,A),e(A,Se),e(B,Jr),e(S,Ur),e(S,Fe),e(Fe,xr),e(Fe,Pt),e(Pt,Gr),e(Fe,kr),e(Fe,Kt),e(Kt,Er),e(Fe,Zr),e(S,Br),e(S,ze),e(ze,Cr),e(ze,es),e(es,Ir),e(ze,Wr),e(ze,ns),e(ns,Nr),e(ze,Xr),b(l,Fa,M),b(l,tn,M),e(tn,Rr),e(tn,ts),e(ts,Vr),e(tn,$r),b(l,za,M),b(l,sn,M),e(sn,Sr),e(sn,ss),e(ss,Fr),e(sn,zr),b(l,La,M),b(l,Le,M),e(Le,on),e(on,Fs),v(rt,Fs,null),e(Le,Lr),e(Le,zs),e(zs,Ar),b(l,Aa,M),b(l,X,M),v(it,X,null),e(X,Qr),e(X,lt),e(lt,Yr),e(lt,Ls),e(Ls,Dr),e(lt,Hr),e(X,Or),e(X,R),e(R,le),e(le,As),e(As,qr),e(le,Pr),e(le,os),e(os,Kr),e(le,ei),e(le,Qs),e(Qs,ni),e(le,ti),e(le,Ys),e(Ys,si),e(R,oi),e(R,ce),e(ce,Ds),e(Ds,ai),e(ce,ri),e(ce,as),e(as,ii),e(ce,li),e(ce,Hs),e(Hs,ci),e(ce,di),e(ce,Os),e(Os,mi),e(R,pi),e(R,de),e(de,qs),e(qs,gi),e(de,hi),e(de,rs),e(rs,ui),e(de,fi),e(de,Ps),e(Ps,_i),e(de,yi),e(de,Ks),e(Ks,Mi),e(R,bi),e(R,me),e(me,eo),e(eo,wi),e(me,Ti),e(me,is),e(is,ji),e(me,vi),e(me,no),e(no,Ji),e(me,Ui),e(me,to),e(to,xi),e(R,Gi),e(R,pe),e(pe,so),e(so,ki),e(pe,Ei),e(pe,ls),e(ls,Zi),e(pe,Bi),e(pe,oo),e(oo,Ci),e(pe,Ii),e(pe,ao),e(ao,Wi),e(R,Ni),e(R,ge),e(ge,ro),e(ro,Xi),e(ge,Ri),e(ge,cs),e(cs,Vi),e(ge,$i),e(ge,io),e(io,Si),e(ge,Fi),e(ge,lo),e(lo,zi),e(R,Li),e(R,he),e(he,co),e(co,Ai),e(he,Qi),e(he,ds),e(ds,Yi),e(he,Di),e(he,mo),e(mo,Hi),e(he,Oi),e(he,po),e(po,qi),e(R,Pi),e(R,ue),e(ue,go),e(go,Ki),e(ue,el),e(ue,ho),e(ho,nl),e(ue,tl),e(ue,uo),e(uo,sl),e(ue,ol),e(ue,fo),e(fo,al),e(X,rl),e(X,ct),e(ct,il),e(ct,ms),e(ms,ll),e(ct,cl),e(X,dl),e(X,Ee),v(dt,Ee,null),e(Ee,ml),e(Ee,mt),e(mt,pl),e(mt,ps),e(ps,gl),e(mt,hl),e(Ee,ul),v(an,Ee,null),e(X,fl),e(X,rn),v(pt,rn,null),e(rn,_l),e(rn,O),e(O,yl),e(O,gs),e(gs,Ml),e(O,bl),e(O,hs),e(hs,wl),e(O,Tl),e(O,us),e(us,jl),e(O,vl),e(O,fs),e(fs,Jl),e(O,Ul),e(X,xl),e(X,ln),v(gt,ln,null),e(ln,Gl),e(ln,Ae),e(Ae,kl),e(Ae,_o),e(_o,El),e(Ae,Zl),e(Ae,_s),e(_s,Bl),e(Ae,Cl),b(l,Qa,M),b(l,Qe,M),e(Qe,cn),e(cn,yo),v(ht,yo,null),e(Qe,Il),e(Qe,Mo),e(Mo,Wl),b(l,Ya,M),b(l,C,M),v(ut,C,null),e(C,Nl),e(C,ft),e(ft,Xl),e(ft,ys),e(ys,Rl),e(ft,Vl),e(C,$l),e(C,_t),e(_t,Sl),e(_t,Ms),e(Ms,Fl),e(_t,zl),e(C,Ll),e(C,z),e(z,fe),e(fe,bo),e(bo,Al),e(fe,Ql),e(fe,bs),e(bs,Yl),e(fe,Dl),e(fe,wo),e(wo,Hl),e(fe,Ol),e(fe,To),e(To,ql),e(z,Pl),e(z,_e),e(_e,jo),e(jo,Kl),e(_e,ec),e(_e,ws),e(ws,nc),e(_e,tc),e(_e,vo),e(vo,sc),e(_e,oc),e(_e,Jo),e(Jo,ac),e(z,rc),e(z,ye),e(ye,Uo),e(Uo,ic),e(ye,lc),e(ye,Ts),e(Ts,cc),e(ye,dc),e(ye,xo),e(xo,mc),e(ye,pc),e(ye,Go),e(Go,gc),e(z,hc),e(z,Me),e(Me,ko),e(ko,uc),e(Me,fc),e(Me,js),e(js,_c),e(Me,yc),e(Me,Eo),e(Eo,Mc),e(Me,bc),e(Me,Zo),e(Zo,wc),e(z,Tc),e(z,be),e(be,Bo),e(Bo,jc),e(be,vc),e(be,vs),e(vs,Jc),e(be,Uc),e(be,Co),e(Co,xc),e(be,Gc),e(be,Io),e(Io,kc),e(z,Ec),e(z,we),e(we,Wo),e(Wo,Zc),e(we,Bc),e(we,Js),e(Js,Cc),e(we,Ic),e(we,No),e(No,Wc),e(we,Nc),e(we,Xo),e(Xo,Xc),e(z,Rc),e(z,Te),e(Te,Ro),e(Ro,Vc),e(Te,$c),e(Te,Us),e(Us,Sc),e(Te,Fc),e(Te,Vo),e(Vo,zc),e(Te,Lc),e(Te,$o),e($o,Ac),e(C,Qc),e(C,yt),e(yt,Yc),e(yt,xs),e(xs,Dc),e(yt,Hc),e(C,Oc),e(C,Ze),v(Mt,Ze,null),e(Ze,qc),e(Ze,So),e(So,Pc),e(Ze,Kc),v(dn,Ze,null),e(C,ed),e(C,Be),v(bt,Be,null),e(Be,nd),e(Be,Fo),e(Fo,td),e(Be,sd),v(mn,Be,null),e(C,od),e(C,K),v(wt,K,null),e(K,ad),e(K,Tt),e(Tt,rd),e(Tt,zo),e(zo,id),e(Tt,ld),e(K,cd),v(pn,K,null),e(K,dd),v(gn,K,null),e(C,md),e(C,ee),v(jt,ee,null),e(ee,pd),e(ee,vt),e(vt,gd),e(vt,Lo),e(Lo,hd),e(vt,ud),e(ee,fd),v(hn,ee,null),e(ee,_d),v(un,ee,null),e(C,yd),e(C,ne),v(Jt,ne,null),e(ne,Md),e(ne,Ut),e(Ut,bd),e(Ut,Ao),e(Ao,wd),e(Ut,Td),e(ne,jd),v(fn,ne,null),e(ne,vd),v(_n,ne,null),e(C,Jd),e(C,te),v(xt,te,null),e(te,Ud),e(te,Gt),e(Gt,xd),e(Gt,Qo),e(Qo,Gd),e(Gt,kd),e(te,Ed),v(yn,te,null),e(te,Zd),v(Mn,te,null),e(C,Bd),e(C,se),v(kt,se,null),e(se,Cd),e(se,Et),e(Et,Id),e(Et,Yo),e(Yo,Wd),e(Et,Nd),e(se,Xd),v(bn,se,null),e(se,Rd),v(wn,se,null),e(C,Vd),e(C,oe),v(Zt,oe,null),e(oe,$d),e(oe,Bt),e(Bt,Sd),e(Bt,Do),e(Do,Fd),e(Bt,zd),e(oe,Ld),v(Tn,oe,null),e(oe,Ad),v(jn,oe,null),e(C,Qd),e(C,ae),v(Ct,ae,null),e(ae,Yd),e(ae,It),e(It,Dd),e(It,Ho),e(Ho,Hd),e(It,Od),e(ae,qd),v(vn,ae,null),e(ae,Pd),v(Jn,ae,null),b(l,Da,M),b(l,Ye,M),e(Ye,Un),e(Un,Oo),v(Wt,Oo,null),e(Ye,Kd),e(Ye,qo),e(qo,em),b(l,Ha,M),b(l,V,M),v(Nt,V,null),e(V,nm),e(V,Xt),e(Xt,tm),e(Xt,Gs),e(Gs,sm),e(Xt,om),e(V,am),e(V,Rt),e(Rt,rm),e(Rt,ks),e(ks,im),e(Rt,lm),e(V,cm),e(V,je),e(je,ve),e(ve,Po),e(Po,dm),e(ve,mm),e(ve,Ko),e(Ko,pm),e(ve,gm),e(ve,ea),e(ea,hm),e(ve,um),e(ve,na),e(na,fm),e(je,_m),e(je,Je),e(Je,ta),e(ta,ym),e(Je,Mm),e(Je,sa),e(sa,bm),e(Je,wm),e(Je,oa),e(oa,Tm),e(Je,jm),e(Je,aa),e(aa,vm),e(je,Jm),e(je,Ue),e(Ue,ra),e(ra,Um),e(Ue,xm),e(Ue,ia),e(ia,Gm),e(Ue,km),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ea.$$scope={dirty:M,ctx:l}),dn.$set(Ea);const Za={};M&2&&(Za.$$scope={dirty:M,ctx:l}),mn.$set(Za);const Ba={};M&2&&(Ba.$$scope={dirty:M,ctx:l}),pn.$set(Ba);const Ht={};M&2&&(Ht.$$scope={dirty:M,ctx:l}),gn.$set(Ht);const Ca={};M&2&&(Ca.$$scope={dirty:M,ctx:l}),hn.$set(Ca);const qe={};M&2&&(qe.$$scope={dirty:M,ctx:l}),un.$set(qe);const Pe={};M&2&&(Pe.$$scope={dirty:M,ctx:l}),fn.$set(Pe);const Ia={};M&2&&(Ia.$$scope={dirty:M,ctx:l}),_n.$set(Ia);const Wa={};M&2&&(Wa.$$scope={dirty:M,ctx:l}),yn.$set(Wa);const Ke={};M&2&&(Ke.$$scope={dirty:M,ctx:l}),Mn.$set(Ke);const Na={};M&2&&(Na.$$scope={dirty:M,ctx:l}),bn.$set(Na);const Xa={};M&2&&(Xa.$$scope={dirty:M,ctx:l}),wn.$set(Xa);const en={};M&2&&(en.$$scope={dirty:M,ctx:l}),Tn.$set(en);const Ra={};M&2&&(Ra.$$scope={dirty:M,ctx:l}),jn.$set(Ra);const Va={};M&2&&(Va.$$scope={dirty:M,ctx:l}),vn.$set(Va);const Ot={};M&2&&(Ot.$$scope={dirty:M,ctx:l}),Jn.$set(Ot);const $a={};M&2&&($a.$$scope={dirty:M,ctx:l}),xn.$set($a);const qt={};M&2&&(qt.$$scope={dirty:M,ctx:l}),Gn.$set(qt)},i(l){Pa||(J(i.$$.fragment,l),J(rt.$$.fragment,l),J(it.$$.fragment,l),J(dt.$$.fragment,l),J(an.$$.fragment,l),J(pt.$$.fragment,l),J(gt.$$.fragment,l),J(ht.$$.fragment,l),J(ut.$$.fragment,l),J(Mt.$$.fragment,l),J(dn.$$.fragment,l),J(bt.$$.fragment,l),J(mn.$$.fragment,l),J(wt.$$.fragment,l),J(pn.$$.fragment,l),J(gn.$$.fragment,l),J(jt.$$.fragment,l),J(hn.$$.fragment,l),J(un.$$.fragment,l),J(Jt.$$.fragment,l),J(fn.$$.fragment,l),J(_n.$$.fragment,l),J(xt.$$.fragment,l),J(yn.$$.fragment,l),J(Mn.$$.fragment,l),J(kt.$$.fragment,l),J(bn.$$.fragment,l),J(wn.$$.fragment,l),J(Zt.$$.fragment,l),J(Tn.$$.fragment,l),J(jn.$$.fragment,l),J(Ct.$$.fragment,l),J(vn.$$.fragment,l),J(Jn.$$.fragment,l),J(Wt.$$.fragment,l),J(Nt.$$.fragment,l),J($t.$$.fragment,l),J(xn.$$.fragment,l),J(St.$$.fragment,l),J(Gn.$$.fragment,l),J(Ft.$$.fragment,l),J(zt.$$.fragment,l),J(Yt.$$.fragment,l),Pa=!0)},o(l){U(i.$$.fragment,l),U(rt.$$.fragment,l),U(it.$$.fragment,l),U(dt.$$.fragment,l),U(an.$$.fragment,l),U(pt.$$.fragment,l),U(gt.$$.fragment,l),U(ht.$$.fragment,l),U(ut.$$.fragment,l),U(Mt.$$.fragment,l),U(dn.$$.fragment,l),U(bt.$$.fragment,l),U(mn.$$.fragment,l),U(wt.$$.fragment,l),U(pn.$$.fragment,l),U(gn.$$.fragment,l),U(jt.$$.fragment,l),U(hn.$$.fragment,l),U(un.$$.fragment,l),U(Jt.$$.fragment,l),U(fn.$$.fragment,l),U(_n.$$.fragment,l),U(xt.$$.fragment,l),U(yn.$$.fragment,l),U(Mn.$$.fragment,l),U(kt.$$.fragment,l),U(bn.$$.fragment,l),U(wn.$$.fragment,l),U(Zt.$$.fragment,l),U(Tn.$$.fragment,l),U(jn.$$.fragment,l),U(Ct.$$.fragment,l),U(vn.$$.fragment,l),U(Jn.$$.fragment,l),U(Wt.$$.fragment,l),U(Nt.$$.fragment,l),U($t.$$.fragment,l),U(xn.$$.fragment,l),U(St.$$.fragment,l),U(Gn.$$.fragment,l),U(Ft.$$.fragment,l),U(zt.$$.fragment,l),U(Yt.$$.fragment,l),Pa=!1},d(l){n(c),l&&n(_),l&&n(m),x(i),l&&n(y),l&&n(E),l&&n(q),l&&n(S),l&&n(Fa),l&&n(tn),l&&n(za),l&&n(sn),l&&n(La),l&&n(Le),x(rt),l&&n(Aa),l&&n(X),x(it),x(dt),x(an),x(pt),x(gt),l&&n(Qa),l&&n(Qe),x(ht),l&&n(Ya),l&&n(C),x(ut),x(Mt),x(dn),x(bt),x(mn),x(wt),x(pn),x(gn),x(jt),x(hn),x(un),x(Jt),x(fn),x(_n),x(xt),x(yn),x(Mn),x(kt),x(bn),x(wn),x(Zt),x(Tn),x(jn),x(Ct),x(vn),x(Jn),l&&n(Da),l&&n(Ye),x(Wt),l&&n(Ha),l&&n(V),x(Nt),x($t),x(xn),x(St),x(Gn),l&&n(Oa),l&&n(He),x(Ft),l&&n(qa),l&&n(L),x(zt),x(Yt)}}}const Zu={local:"generation",sections:[{local:"transformers.GenerationConfig",title:"GenerationConfig"},{local:"transformers.GenerationMixin",title:"GenerationMixin"},{local:"transformers.TFGenerationMixin",title:"TFGenerationMixin"},{local:"transformers.FlaxGenerationMixin",title:"FlaxGenerationMixin"}],title:"Generation"};function Bu(k){return du(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vu extends ru{constructor(c){super();iu(this,c,Bu,Eu,lu,{})}}export{Vu as default,Zu as metadata};
