import{S as ru,i as lu,s as iu,e as o,k as m,w,t as n,M as cu,c as a,d as t,m as g,a as r,x as T,h as s,b as u,G as e,g as b,y as j,q as J,o as U,B as x,v as du,L as Ne}from"../../chunks/vendor-hf-doc-builder.js";import{T as tt}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 Xe}from"../../chunks/ExampleCodeBlock-hf-doc-builder.js";function pu(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdlbmVyYXRpb25Db25maWclMEElMEElMjMlMjBEb3dubG9hZCUyMGNvbmZpZ3VyYXRpb24lMjBmcm9tJTIwaHVnZ2luZ2ZhY2UuY28lMjBhbmQlMjBjYWNoZS4lMEFnZW5lcmF0aW9uX2NvbmZpZyUyMCUzRCUyMEdlbmVyYXRpb25Db25maWcuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBJTBBJTIzJTIwRS5nLiUyMGNvbmZpZyUyMHdhcyUyMHNhdmVkJTIwdXNpbmclMjAqc2F2ZV9wcmV0cmFpbmVkKCcuJTJGdGVzdCUyRnNhdmVkX21vZGVsJTJGJykqJTBBZ2VuZXJhdGlvbl9jb25maWcuc2F2ZV9wcmV0cmFpbmVkKCUyMi4lMkZ0ZXN0JTJGc2F2ZWRfbW9kZWwlMkYlMjIpJTBBZ2VuZXJhdGlvbl9jb25maWclMjAlM0QlMjBHZW5lcmF0aW9uQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjIuJTJGdGVzdCUyRnNhdmVkX21vZGVsJTJGJTIyKSUwQSUwQSUyMyUyMFlvdSUyMGNhbiUyMGFsc28lMjBzcGVjaWZ5JTIwY29uZmlndXJhdGlvbiUyMG5hbWVzJTIwdG8lMjB5b3VyJTIwZ2VuZXJhdGlvbiU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ljs-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>, 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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function mu(k){let c,_,p,d,f,l,h,G,v,y,E,Z,X,le,F,q,S;return{c(){c=o("p"),_=n("Most generation-controlling parameters are set in "),p=o("code"),d=n("generation_config"),f=n(` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),l=o("code"),h=n("generation_config"),G=n(` by passing the corresponding
parameters to generate(), e.g. `),v=o("code"),y=n(".generate(inputs, num_beams=4, do_sample=True)"),E=n("."),Z=m(),X=o("p"),le=n("For an overview of generation strategies and code examples, check out the "),F=o("a"),q=n(`following
guide`),S=n("."),this.h()},l(B){c=a(B,"P",{});var I=r(c);_=s(I,"Most generation-controlling parameters are set in "),p=a(I,"CODE",{});var P=r(p);d=s(P,"generation_config"),P.forEach(t),f=s(I,` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),l=a(I,"CODE",{});var Ve=r(l);h=s(Ve,"generation_config"),Ve.forEach(t),G=s(I,` by passing the corresponding
parameters to generate(), e.g. `),v=a(I,"CODE",{});var $e=r(v);y=s($e,".generate(inputs, num_beams=4, do_sample=True)"),$e.forEach(t),E=s(I,"."),I.forEach(t),Z=g(B),X=a(B,"P",{});var A=r(X);le=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(t),S=s(A,"."),A.forEach(t),this.h()},h(){u(F,"href","../generation_strategies")},m(B,I){b(B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0aCUyMCU2MG5vcm1hbGl6ZV9sb2dpdHMlM0RGYWxzZSU2MC4lMjBEZXBlbmRpbmclMjBvbiUyMHRoZSUwQSUyMyUyMHVzZSUyMGNhc2UlMkMlMjB5b3UlMjBtaWdodCUyMHdhbnQlMjB0byUyMHJlY29tcHV0ZSUyMGl0JTIwd2l0aCUyMCU2MG5vcm1hbGl6ZV9sb2dpdHMlM0RUcnVlJTYwLiUwQW91dHB1dF9sZW5ndGglMjAlM0QlMjBpbnB1dF9sZW5ndGglMjAlMkIlMjBucC5zdW0odHJhbnNpdGlvbl9zY29yZXMubnVtcHkoKSUyMCUzQyUyMDAlMkMlMjBheGlzJTNEMSklMEFsZW5ndGhfcGVuYWx0eSUyMCUzRCUyMG1vZGVsLmdlbmVyYXRpb25fY29uZmlnLmxlbmd0aF9wZW5hbHR5JTBBcmVjb25zdHJ1Y3RlZF9zY29yZXMlMjAlM0QlMjB0cmFuc2l0aW9uX3Njb3Jlcy5zdW0oYXhpcyUzRDEpJTIwJTJGJTIwKG91dHB1dF9sZW5ndGgqKmxlbmd0aF9wZW5hbHR5KSUwQXByaW50KG5wLmFsbGNsb3NlKG91dHB1dHMuc2VxdWVuY2VzX3Njb3JlcyUyQyUyMHJlY29uc3RydWN0ZWRfc2NvcmVzKSk=",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function hu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("greedy_search()"),f=n(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"greedy_search()"),E.forEach(t),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G)},d(v){v&&t(c)}}}function uu(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW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UHJvY2Vzc29yTGlzdCglMEElMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBNaW5MZW5ndGhMb2dpdHNQcm9jZXNzb3IoMTAlMkMlMjBlb3NfdG9rZW5faWQlM0Rtb2RlbC5nZW5lcmF0aW9uX2NvbmZpZy5lb3NfdG9rZW5faWQpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKSUwQXN0b3BwaW5nX2NyaXRlcmlhJTIwJTNEJTIwU3RvcHBpbmdDcml0ZXJpYUxpc3QoJTVCTWF4TGVuZ3RoQ3JpdGVyaWEobWF4X2xlbmd0aCUzRDIwKSU1RCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ3JlZWR5X3NlYXJjaCglMEElMjAlMjAlMjAlMjBpbnB1dF9pZHMlMkMlMjBsb2dpdHNfcHJvY2Vzc29yJTNEbG9naXRzX3Byb2Nlc3NvciUyQyUyMHN0b3BwaW5nX2NyaXRlcmlhJTNEc3RvcHBpbmdfY3JpdGVyaWElMEEpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function fu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("sample()"),f=n(` directly. Use generate() instead.
For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"sample()"),E.forEach(t),f=s(y,` directly. Use generate() instead.
For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G)},d(v){v&&t(c)}}}function _u(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0lMkMlMEElMjAlMjAlMjAlMjBMb2dpdHNQcm9jZXNzb3JMaXN0JTJDJTBBJTIwJTIwJTIwJTIwTWluTGVuZ3RoTG9naXRzUHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwVG9wS0xvZ2l0c1dhcnBlciUyQyUwQSUyMCUyMCUyMCUyMFRlbXBlcmF0dXJlTG9naXRzV2FycGVyJTJDJTBBJTIwJTIwJTIwJTIwU3RvcHBpbmdDcml0ZXJpYUxpc3QlMkMlMEElMjAlMjAlMjAlMjBNYXhMZW5ndGhDcml0ZXJpYSUyQyUwQSklMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIp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JMaXN0KCUwQSUyMCUyMCUyMCUyMCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFRvcEtMb2dpdHNXYXJwZXIoNTApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwVGVtcGVyYXR1cmVMb2dpdHNXYXJwZXIoMC43KSUyQyUwQSUyMCUyMCUyMCUyMCU1RCUwQSklMEElMEFzdG9wcGluZ19jcml0ZXJpYSUyMCUzRCUyMFN0b3BwaW5nQ3JpdGVyaWFMaXN0KCU1Qk1heExlbmd0aENyaXRlcmlhKG1heF9sZW5ndGglM0QyMCklNUQpJTBBJTBBdG9yY2gubWFudWFsX3NlZWQoMCklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuc2FtcGxlKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUwQSUyMCUyMCUyMCUyMGxvZ2l0c19wcm9jZXNzb3IlM0Rsb2dpdHNfcHJvY2Vzc29yJTJDJTBBJTIwJTIwJTIwJTIwbG9naXRzX3dhcnBlciUzRGxvZ2l0c193YXJwZXIlMkMlMEElMjAlMjAlMjAlMjBzdG9wcGluZ19jcml0ZXJpYSUzRHN0b3BwaW5nX2NyaXRlcmlhJTJDJTBBKSUwQSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function yu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("beam_search()"),f=n(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"beam_search()"),E.forEach(t),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e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b2tlbl9pZCUzRG1vZGVsLmNvbmZpZy5lb3NfdG9rZW5faWQpJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTBBKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5iZWFtX3NlYXJjaChpbnB1dF9pZHMlMkMlMjBiZWFtX3Njb3JlciUyQyUyMGxvZ2l0c19wcm9jZXNzb3IlM0Rsb2dpdHNfcHJvY2Vzc29yJTJDJTIwKiptb2RlbF9rd2FyZ3MpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function bu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("beam_sample()"),f=n(` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"beam_sample()"),E.forEach(t),f=s(y,` directly. Use generate()
instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G)},d(v){v&&t(c)}}}function vu(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNJTJDJTBBJTIwJTIwJTIwJTIwTG9naXRzUHJvY2Vzc29yTGlzdCUyQyUwQSUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMFRvcEtMb2dpdHNXYXJwZXIlMkMlMEElMjAlMjAlMjAlMjBUZW1wZXJhdHVyZUxvZ2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TApJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwVGVtcGVyYXR1cmVMb2dpdHNXYXJwZXIoMC43KSUyQyUwQSUyMCUyMCUyMCUyMCU1RCUwQSklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuYmVhbV9zYW1wbGUoJTBBJTIwJTIwJTIwJTIwaW5wdXRfaWRzJTJDJTIwYmVhbV9zY29yZXIlMkMlMjBsb2dpdHNfcHJvY2Vzc29yJTNEbG9naXRzX3Byb2Nlc3NvciUyQyUyMGxvZ2l0c193YXJwZXIlM0Rsb2dpdHNfd2FycGVyJTJDJTIwKiptb2RlbF9rd2FyZ3MlMEEpJTBBJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function wu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("contrastive_search()"),f=n(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"contrastive_search()"),E.forEach(t),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),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heF9sZW5ndGglM0Q2NCklNUQpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmNvbnRyYXN0aXZlX3NlYXJjaCglMEElMjAlMjAlMjAlMjAqKmlucHV0X2lkcyUyQyUyMHBlbmFsdHlfYWxwaGElM0QwLjYlMkMlMjB0b3BfayUzRDQlMkMlMjBzdG9wcGluZ19jcml0ZXJpYSUzRHN0b3BwaW5nX2NyaXRlcmlhJTBBKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function ju(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("group_beam_search()"),f=n(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"group_beam_search()"),E.forEach(t),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G)},d(v){v&&t(c)}}}function Ju(k){let c,_,p,d,f;return d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JTIwJTNEJTIwTG9naXRzUHJvY2Vzc29yTGlzdCglMEElMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBIYW1taW5nRGl2ZXJzaXR5TG9naXRzUHJvY2Vzc29yKDUuNSUyQyUyMG51bV9iZWFtcyUzRDYlMkMlMjBudW1fYmVhbV9ncm91cHMlM0QzKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3Nvcig1JTJDJTIwZW9zX3Rva2VuX2lkJTNEbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCklMkMlMEElMjAlMjAlMjAlMjAlNUQlMEEpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdyb3VwX2JlYW1fc2VhcmNoKCUwQSUyMCUyMCUyMCUyMGlucHV0X2lkcyUyQyUyMGJlYW1fc2NvcmVyJTJDJTIwbG9naXRzX3Byb2Nlc3NvciUzRGxvZ2l0c19wcm9jZXNzb3IlMkMlMjAqKm1vZGVsX2t3YXJncyUwQSklMEElMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function Uu(k){let c,_,p,d,f,l,h,G;return{c(){c=o("p"),_=n("In most cases, you do not need to call "),p=o("a"),d=n("constrained_beam_search()"),f=n(` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=o("a"),h=n(`following
guide`),G=n("."),this.h()},l(v){c=a(v,"P",{});var y=r(c);_=s(y,"In most cases, you do not need to call "),p=a(y,"A",{href:!0});var E=r(p);d=s(E,"constrained_beam_search()"),E.forEach(t),f=s(y,` directly. Use
generate() instead. For an overview of generation strategies and code examples, check the `),l=a(y,"A",{href:!0});var Z=r(l);h=s(Z,`following
guide`),Z.forEach(t),G=s(y,"."),y.forEach(t),this.h()},h(){u(p,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.constrained_beam_search"),u(l,"href","../generation_strategies")},m(v,y){b(v,c,y),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G)},d(v){v&&t(c)}}}function xu(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMCglMEElMjAlMjAlMjAlMjBBdXRvVG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwQXV0b01vZGVsRm9yU2VxMlNlcUxNJTJDJTBBJTIwJTIwJTIwJTIwTG9naXRzUHJvY2Vzc29yTGlzdCUyQyUwQSUyMCUyMCUyMCUyME1pbkxlbmd0aExvZ2l0c1Byb2Nlc3NvciUyQyUwQSUyMCUyMCUyMCUyMENvbnN0cmFpbmVkQmVhbVNlYXJjaFNjb3JlciUyQyUwQSUyMCUyMCUyMCUyMFBocmFzYWxDb25zdHJhaW50JTJDJTBBKSUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydDUtYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIydDUtYmFzZSUyMiklMEElMEFlbmNvZGVyX2lucHV0X3N0ciUyMCUzRCUyMCUyMnRyYW5zbGF0ZSUyMEVuZ2xpc2glMjB0byUyMEdlcm1hbiUzQSUyMEhvdyUyMG9sZCUyMGFyZSUyMHlvdSUzRiUyMiUwQWVuY29kZXJfaW5wdXRfaWRzJTIwJTNEJTIwdG9rZW5pemVyKGVuY29kZXJfaW5wdXRfc3RyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUy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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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function Gu(k){let c,_,p,d,f,l,h,G,v,y,E,Z,X,le,F,q,S;return{c(){c=o("p"),_=n("Most generation-controlling parameters are set in "),p=o("code"),d=n("generation_config"),f=n(` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),l=o("code"),h=n("generation_config"),G=n(` by passing the corresponding
parameters to generate, e.g. `),v=o("code"),y=n(".generate(inputs, num_beams=4, do_sample=True)"),E=n("."),Z=m(),X=o("p"),le=n("For an overview of generation strategies and code examples, check out the "),F=o("a"),q=n(`following
guide`),S=n("."),this.h()},l(B){c=a(B,"P",{});var I=r(c);_=s(I,"Most generation-controlling parameters are set in "),p=a(I,"CODE",{});var P=r(p);d=s(P,"generation_config"),P.forEach(t),f=s(I,` which, if not passed, will be set to the
model\u2019s default generation configuration. You can override any `),l=a(I,"CODE",{});var Ve=r(l);h=s(Ve,"generation_config"),Ve.forEach(t),G=s(I,` by passing the corresponding
parameters to generate, e.g. `),v=a(I,"CODE",{});var $e=r(v);y=s($e,".generate(inputs, num_beams=4, do_sample=True)"),$e.forEach(t),E=s(I,"."),I.forEach(t),Z=g(B),X=a(B,"P",{});var A=r(X);le=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(t),S=s(A,"."),A.forEach(t),this.h()},h(){u(F,"href","../generation_strategies")},m(B,I){b(B,c,I),e(c,_),e(c,p),e(p,d),e(c,f),e(c,l),e(l,h),e(c,G),e(c,v),e(v,y),e(c,E),b(B,Z,I),b(B,X,I),e(X,le),e(X,F),e(F,q),e(X,S)},d(B){B&&t(c),B&&t(Z),B&&t(X)}}}function ku(k){let c,_,p,d,f;return d=new Re({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEdQVDJUb2tlbml6ZXIlMkMlMj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TIwaW5wdXRfbGVuZ3RoJTIwJTJCJTIwbnAuc3VtKHRyYW5zaXRpb25fc2NvcmVzLm51bXB5KCklMjAlM0MlMjAwJTJDJTIwYXhpcyUzRDEpJTBBbGVuZ3RoX3BlbmFsdHklMjAlM0QlMjBtb2RlbC5nZW5lcmF0aW9uX2NvbmZpZy5sZW5ndGhfcGVuYWx0eSUwQXJlY29uc3RydWN0ZWRfc2NvcmVzJTIwJTNEJTIwbnAuc3VtKHRyYW5zaXRpb25fc2NvcmVzJTJDJTIwYXhpcyUzRDEpJTIwJTJGJTIwKG91dHB1dF9sZW5ndGgqKmxlbmd0aF9wZW5hbHR5KSUwQXByaW50KG5wLmFsbGNsb3NlKG91dHB1dHMuc2VxdWVuY2VzX3Njb3JlcyUyQyUyMHJlY29uc3RydWN0ZWRfc2NvcmVzKSk=",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"),_=n("Examples:"),p=m(),w(d.$$.fragment)},l(l){c=a(l,"P",{});var h=r(c);_=s(h,"Examples:"),h.forEach(t),p=g(l),T(d.$$.fragment,l)},m(l,h){b(l,c,h),e(c,_),b(l,p,h),j(d,l,h),f=!0},p:Ne,i(l){f||(J(d.$$.fragment,l),f=!0)},o(l){U(d.$$.fragment,l),f=!1},d(l){l&&t(c),l&&t(p),x(d,l)}}}function Eu(k){let c,_,p,d,f,l,h,G,v,y,E,Z,X,le,F,q,S,B,I,P,Ve,$e,A,Se,Jr,Ur,Fe,xr,Pn,Gr,kr,Kn,Er,Zr,Br,ze,Cr,es,Ir,Wr,ts,Xr,Nr,Fa,nt,Rr,ns,Vr,$r,za,st,Sr,ss,Fr,zr,La,Le,ot,Fs,an,Lr,zs,Ar,Aa,N,rn,Qr,ln,Yr,Ls,Dr,Hr,Or,R,ie,As,qr,Pr,os,Kr,el,Qs,tl,nl,Ys,sl,ol,ce,Ds,al,rl,as,ll,il,Hs,cl,dl,Os,pl,ml,de,qs,gl,hl,rs,ul,fl,Ps,_l,yl,Ks,Ml,bl,pe,eo,vl,wl,ls,Tl,jl,to,Jl,Ul,no,xl,Gl,me,so,kl,El,is,Zl,Bl,oo,Cl,Il,ao,Wl,Xl,ge,ro,Nl,Rl,cs,Vl,$l,lo,Sl,Fl,io,zl,Ll,he,co,Al,Ql,ds,Yl,Dl,po,Hl,Ol,mo,ql,Pl,ue,go,Kl,ei,ho,ti,ni,uo,si,oi,fo,ai,ri,cn,li,ps,ii,ci,di,Ee,dn,pi,pn,mi,ms,gi,hi,ui,at,fi,rt,mn,_i,O,yi,gs,Mi,bi,hs,vi,wi,us,Ti,ji,fs,Ji,Ui,xi,lt,gn,Gi,Ae,ki,_o,Ei,Zi,_s,Bi,Ci,Qa,Qe,it,yo,hn,Ii,Mo,Wi,Ya,C,un,Xi,fn,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xt,Oa,He,Gt,ua,Fn,qp,fa,Pp,qa,L,zn,Kp,Ln,em,Zs,tm,nm,sm,An,om,Bs,am,rm,lm,Oe,xe,_a,im,cm,ya,dm,pm,Ma,mm,gm,ba,hm,um,Ge,va,fm,_m,wa,ym,Mm,Ta,bm,vm,ja,wm,Tm,ke,Ja,jm,Jm,Ua,Um,xm,xa,Gm,km,Ga,Em,Zm,Qn,Bm,Cs,Cm,Im,Wm,kt,Yn,Xm,ka,Nm,Pa;return l=new Sa({}),an=new Sa({}),rn=new $({props:{name:"class transformers.GenerationConfig",anchor:"transformers.GenerationConfig",parameters:[{name:"**kwargs",val:""}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/configuration_utils.py#L38",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 token ids that are not allowed to be generated. In order to get the token ids of the words that
should not appear in the generated text, use <code>tokenizer(bad_words, add_prefix_space=True, add_special_tokens=False).input_ids</code>.`,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"}]},{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/v4.30.0/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:[]}]}}),dn=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:"**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/v4.30.0/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.use_auth_token",description:`<strong>use_auth_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:"use_auth_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/v4.30.0/src/transformers/generation/configuration_utils.py#L375",returnDescription:`
<p>The configuration object instantiated from this pretrained model.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig"
>GenerationConfig</a></p>
`}}),at=new Xe({props:{anchor:"transformers.GenerationConfig.from_pretrained.example",$$slots:{default:[pu]},$$scope:{ctx:k}}}),mn=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/v4.30.0/src/transformers/generation/configuration_utils.py#L667",returnDescription:`
<p>The configuration object instantiated from those parameters.</p>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig"
>GenerationConfig</a></p>
`}}),gn=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).
kwargs &#x2014;
Additional key word arguments passed along to the <a href="/docs/transformers/v4.30.0/en/internal/image_processing_utils#transformers.ImageProcessingMixin.push_to_hub">push_to_hub()</a> method.`,name:"push_to_hub"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/configuration_utils.py#L325"}}),hn=new Sa({}),un=new $({props:{name:"class transformers.GenerationMixin",anchor:"transformers.GenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/utils.py#L469"}}),Mn=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:"**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/v4.30.0/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.
kwargs &#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:"streamer"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/utils.py#L1149",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.GreedySearchDecoderOnlyOutput"
>GreedySearchDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.SampleDecoderOnlyOutput"
>SampleDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> types are:</p>
<ul>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.GreedySearchEncoderDecoderOutput"
>GreedySearchEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.SampleEncoderDecoderOutput"
>SampleEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a>,</li>
<li><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSampleEncoderDecoderOutput"
>BeamSampleEncoderDecoderOutput</a></li>
</ul>
`,returnType:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> or <code>torch.LongTensor</code></p>
`}}),ct=new tt({props:{warning:!0,$$slots:{default:[mu]},$$scope:{ctx:k}}}),bn=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/v4.30.0/src/transformers/generation/utils.py#L979",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>
`}}),dt=new Xe({props:{anchor:"transformers.GenerationMixin.compute_transition_scores.example",$$slots:{default:[gu]},$$scope:{ctx:k}}}),vn=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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L2171",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.GreedySearchDecoderOnlyOutput"
>GreedySearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.GreedySearchEncoderDecoderOutput"
>GreedySearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),pt=new tt({props:{warning:!0,$$slots:{default:[hu]},$$scope:{ctx:k}}}),mt=new Xe({props:{anchor:"transformers.GenerationMixin.greedy_search.example",$$slots:{default:[uu]},$$scope:{ctx:k}}}),Tn=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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L2430",returnDescription:`
<p>A <code>torch.LongTensor</code> containing the generated tokens (default behaviour) or a
<a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.SampleDecoderOnlyOutput"
>SampleDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.SampleEncoderDecoderOutput"
>SampleEncoderDecoderOutput</a> or <code>torch.LongTensor</code></p>
`}}),gt=new tt({props:{warning:!0,$$slots:{default:[fu]},$$scope:{ctx:k}}}),ht=new Xe({props:{anchor:"transformers.GenerationMixin.sample.example",$$slots:{default:[_u]},$$scope:{ctx:k}}}),Jn=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/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L2712",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>generation.BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),ut=new tt({props:{warning:!0,$$slots:{default:[yu]},$$scope:{ctx:k}}}),ft=new Xe({props:{anchor:"transformers.GenerationMixin.beam_search.example",$$slots:{default:[Mu]},$$scope:{ctx:k}}}),xn=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/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L3035",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSampleDecoderOnlyOutput"
>BeamSampleDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSampleEncoderDecoderOutput"
>BeamSampleEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),_t=new tt({props:{warning:!0,$$slots:{default:[bu]},$$scope:{ctx:k}}}),yt=new Xe({props:{anchor:"transformers.GenerationMixin.beam_sample.example",$$slots:{default:[vu]},$$scope:{ctx:k}}}),kn=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:"**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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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.
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/v4.30.0/src/transformers/generation/utils.py#L1797",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>
`}}),Mt=new tt({props:{warning:!0,$$slots:{default:[wu]},$$scope:{ctx:k}}}),bt=new Xe({props:{anchor:"transformers.GenerationMixin.contrastive_search.example",$$slots:{default:[Tu]},$$scope:{ctx:k}}}),Zn=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/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L3368",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>BeamSearchDecoderOnlyOutput</a> if <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if <code>model.config.is_encoder_decoder=True</code>.</p>
`}}),vt=new tt({props:{warning:!0,$$slots:{default:[ju]},$$scope:{ctx:k}}}),wt=new Xe({props:{anchor:"transformers.GenerationMixin.group_beam_search.example",$$slots:{default:[Ju]},$$scope:{ctx:k}}}),Cn=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/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.StoppingCriteriaList">StoppingCriteriaList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.LogitsProcessorList">LogitsProcessorList</a>. List of instances of class derived from <a href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/src/transformers/generation/utils.py#L3748",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchDecoderOnlyOutput"
>generation.BeamSearchDecoderOnlyOutput</a>, <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/en/internal/generation_utils#transformers.generation.BeamSearchEncoderDecoderOutput"
>BeamSearchEncoderDecoderOutput</a> if
<code>model.config.is_encoder_decoder=True</code>.</p>
`}}),Tt=new tt({props:{warning:!0,$$slots:{default:[Uu]},$$scope:{ctx:k}}}),jt=new Xe({props:{anchor:"transformers.GenerationMixin.constrained_beam_search.example",$$slots:{default:[xu]},$$scope:{ctx:k}}}),Wn=new Sa({}),Xn=new $({props:{name:"class transformers.TFGenerationMixin",anchor:"transformers.TFGenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/tf_utils.py#L444"}}),$n=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/v4.30.0/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>.
kwargs &#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:"seed"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/tf_utils.py#L666",returnDescription:`
<p>A <a
  href="/docs/transformers/v4.30.0/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/v4.30.0/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/v4.30.0/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/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a> or <code>tf.Tensor</code></p>
`}}),Ut=new tt({props:{warning:!0,$$slots:{default:[Gu]},$$scope:{ctx:k}}}),Sn=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/v4.30.0/src/transformers/generation/tf_utils.py#L498",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>
`}}),xt=new Xe({props:{anchor:"transformers.TFGenerationMixin.compute_transition_scores.example",$$slots:{default:[ku]},$$scope:{ctx:k}}}),Fn=new Sa({}),zn=new $({props:{name:"class transformers.FlaxGenerationMixin",anchor:"transformers.FlaxGenerationMixin",parameters:[],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/flax_utils.py#L129"}}),Yn=new $({props:{name:"generate",anchor:"transformers.FlaxGenerationMixin.generate",parameters:[{name:"input_ids",val:": ndarray"},{name:"generation_config",val:": typing.Optional[transformers.generation.configuration_utils.GenerationConfig] = None"},{name:"prng_key",val:": typing.Optional[jax._src.numpy.ndarray.ndarray] = None"},{name:"trace",val:": bool = True"},{name:"params",val:": typing.Union[typing.Dict[str, jax._src.numpy.ndarray.ndarray], 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/v4.30.0/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.
kwargs &#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:"logits_processor"}],source:"https://github.com/huggingface/transformers/blob/v4.30.0/src/transformers/generation/flax_utils.py#L267",returnDescription:`
<p><a
  href="/docs/transformers/v4.30.0/en/main_classes/output#transformers.utils.ModelOutput"
>ModelOutput</a>.</p>
`}}),{c(){c=o("meta"),_=m(),p=o("h1"),d=o("a"),f=o("span"),w(l.$$.fragment),h=m(),G=o("span"),v=n("Generation"),y=m(),E=o("p"),Z=n("Each framework has a generate method for text generation implemented in their respective "),X=o("code"),le=n("GenerationMixin"),F=n(" class:"),q=m(),S=o("ul"),B=o("li"),I=n("PyTorch "),P=o("a"),Ve=n("generate()"),$e=n(" is implemented in "),A=o("a"),Se=n("GenerationMixin"),Jr=n("."),Ur=m(),Fe=o("li"),xr=n("TensorFlow "),Pn=o("a"),Gr=n("generate()"),kr=n(" is implemented in "),Kn=o("a"),Er=n("TFGenerationMixin"),Zr=n("."),Br=m(),ze=o("li"),Cr=n("Flax/JAX "),es=o("a"),Ir=n("generate()"),Wr=n(" is implemented in "),ts=o("a"),Xr=n("FlaxGenerationMixin"),Nr=n("."),Fa=m(),nt=o("p"),Rr=n("Regardless of your framework of choice, you can parameterize the generate method with a "),ns=o("a"),Vr=n("GenerationConfig"),$r=n(`
class instance. Please refer to this class for the complete list of generation parameters, which control the behavior
of the generation method.`),za=m(),st=o("p"),Sr=n(`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=n("text generation strategies guide"),zr=n(`. The guide also explains how to use related features,
like token streaming.`),La=m(),Le=o("h2"),ot=o("a"),Fs=o("span"),w(an.$$.fragment),Lr=m(),zs=o("span"),Ar=n("GenerationConfig"),Aa=m(),N=o("div"),w(rn.$$.fragment),Qr=m(),ln=o("p"),Yr=n("Class that holds a configuration for a generation task. A "),Ls=o("code"),Dr=n("generate"),Hr=n(` call supports the following generation methods
for text-decoder, text-to-text, speech-to-text, and vision-to-text models:`),Or=m(),R=o("ul"),ie=o("li"),As=o("em"),qr=n("greedy decoding"),Pr=n(" by calling "),os=o("a"),Kr=n("greedy_search()"),el=n(" if "),Qs=o("code"),tl=n("num_beams=1"),nl=n(` and
`),Ys=o("code"),sl=n("do_sample=False"),ol=m(),ce=o("li"),Ds=o("em"),al=n("contrastive search"),rl=n(" by calling "),as=o("a"),ll=n("contrastive_search()"),il=n(" if "),Hs=o("code"),cl=n("penalty_alpha>0."),dl=n(`
and `),Os=o("code"),pl=n("top_k>1"),ml=m(),de=o("li"),qs=o("em"),gl=n("multinomial sampling"),hl=n(" by calling "),rs=o("a"),ul=n("sample()"),fl=n(" if "),Ps=o("code"),_l=n("num_beams=1"),yl=n(` and
`),Ks=o("code"),Ml=n("do_sample=True"),bl=m(),pe=o("li"),eo=o("em"),vl=n("beam-search decoding"),wl=n(" by calling "),ls=o("a"),Tl=n("beam_search()"),jl=n(" if "),to=o("code"),Jl=n("num_beams>1"),Ul=n(` and
`),no=o("code"),xl=n("do_sample=False"),Gl=m(),me=o("li"),so=o("em"),kl=n("beam-search multinomial sampling"),El=n(" by calling "),is=o("a"),Zl=n("beam_sample()"),Bl=n(` if
`),oo=o("code"),Cl=n("num_beams>1"),Il=n(" and "),ao=o("code"),Wl=n("do_sample=True"),Xl=m(),ge=o("li"),ro=o("em"),Nl=n("diverse beam-search decoding"),Rl=n(" by calling "),cs=o("a"),Vl=n("group_beam_search()"),$l=n(`, if
`),lo=o("code"),Sl=n("num_beams>1"),Fl=n(" and "),io=o("code"),zl=n("num_beam_groups>1"),Ll=m(),he=o("li"),co=o("em"),Al=n("constrained beam-search decoding"),Ql=n(" by calling "),ds=o("a"),Yl=n("constrained_beam_search()"),Dl=n(`, if
`),po=o("code"),Hl=n("constraints!=None"),Ol=n(" or "),mo=o("code"),ql=n("force_words_ids!=None"),Pl=m(),ue=o("li"),go=o("em"),Kl=n("assisted decoding"),ei=n(" by calling "),ho=o("code"),ti=n("assisted_decoding()"),ni=n(`, if
`),uo=o("code"),si=n("assistant_model"),oi=n(" is passed to "),fo=o("code"),ai=n(".generate()"),ri=m(),cn=o("p"),li=n(`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 `),ps=o("a"),ii=n("text generation strategies guide"),ci=n("."),di=m(),Ee=o("div"),w(dn.$$.fragment),pi=m(),pn=o("p"),mi=n("Instantiate a "),ms=o("a"),gi=n("GenerationConfig"),hi=n(" from a generation configuration file."),ui=m(),w(at.$$.fragment),fi=m(),rt=o("div"),w(mn.$$.fragment),_i=m(),O=o("p"),yi=n("Instantiates a "),gs=o("a"),Mi=n("GenerationConfig"),bi=n(" from a "),hs=o("a"),vi=n("PretrainedConfig"),wi=n(`. This function is useful to convert legacy
`),us=o("a"),Ti=n("PretrainedConfig"),ji=n(" objects, which may contain generation parameters, into a stand-alone "),fs=o("a"),Ji=n("GenerationConfig"),Ui=n("."),xi=m(),lt=o("div"),w(gn.$$.fragment),Gi=m(),Ae=o("p"),ki=n("Save a generation configuration object to the directory "),_o=o("code"),Ei=n("save_directory"),Zi=n(`, so that it can be re-loaded using the
`),_s=o("a"),Bi=n("from_pretrained()"),Ci=n(" class method."),Qa=m(),Qe=o("h2"),it=o("a"),yo=o("span"),w(hn.$$.fragment),Ii=m(),Mo=o("span"),Wi=n("GenerationMixin"),Ya=m(),C=o("div"),w(un.$$.fragment),Xi=m(),fn=o("p"),Ni=n("A class containing all functions for auto-regressive text generation, to be used as a mixin in "),ys=o("a"),Ri=n("PreTrainedModel"),Vi=n("."),$i=m(),_n=o("p"),Si=n("The class exposes "),Ms=o("a"),Fi=n("generate()"),zi=n(", which can be used for:"),Li=m(),z=o("ul"),fe=o("li"),bo=o("em"),Ai=n("greedy decoding"),Qi=n(" by calling "),bs=o("a"),Yi=n("greedy_search()"),Di=n(" if "),vo=o("code"),Hi=n("num_beams=1"),Oi=n(` and
`),wo=o("code"),qi=n("do_sample=False"),Pi=m(),_e=o("li"),To=o("em"),Ki=n("contrastive search"),ec=n(" by calling "),vs=o("a"),tc=n("contrastive_search()"),nc=n(" if "),jo=o("code"),sc=n("penalty_alpha>0"),oc=n(` and
`),Jo=o("code"),ac=n("top_k>1"),rc=m(),ye=o("li"),Uo=o("em"),lc=n("multinomial sampling"),ic=n(" by calling "),ws=o("a"),cc=n("sample()"),dc=n(" if "),xo=o("code"),pc=n("num_beams=1"),mc=n(` and
`),Go=o("code"),gc=n("do_sample=True"),hc=m(),Me=o("li"),ko=o("em"),uc=n("beam-search decoding"),fc=n(" by calling "),Ts=o("a"),_c=n("beam_search()"),yc=n(" if "),Eo=o("code"),Mc=n("num_beams>1"),bc=n(` and
`),Zo=o("code"),vc=n("do_sample=False"),wc=m(),be=o("li"),Bo=o("em"),Tc=n("beam-search multinomial sampling"),jc=n(" by calling "),js=o("a"),Jc=n("beam_sample()"),Uc=n(" if "),Co=o("code"),xc=n("num_beams>1"),Gc=n(`
and `),Io=o("code"),kc=n("do_sample=True"),Ec=m(),ve=o("li"),Wo=o("em"),Zc=n("diverse beam-search decoding"),Bc=n(" by calling "),Js=o("a"),Cc=n("group_beam_search()"),Ic=n(", if "),Xo=o("code"),Wc=n("num_beams>1"),Xc=n(`
and `),No=o("code"),Nc=n("num_beam_groups>1"),Rc=m(),we=o("li"),Ro=o("em"),Vc=n("constrained beam-search decoding"),$c=n(" by calling "),Us=o("a"),Sc=n("constrained_beam_search()"),Fc=n(`, if
`),Vo=o("code"),zc=n("constraints!=None"),Lc=n(" or "),$o=o("code"),Ac=n("force_words_ids!=None"),Qc=m(),yn=o("p"),Yc=n(`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=n("text generation strategies guide"),Hc=n("."),Oc=m(),Ze=o("div"),w(Mn.$$.fragment),qc=m(),So=o("p"),Pc=n("Generates sequences of token ids for models with a language modeling head."),Kc=m(),w(ct.$$.fragment),ed=m(),Be=o("div"),w(bn.$$.fragment),td=m(),Fo=o("p"),nd=n(`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=m(),w(dt.$$.fragment),od=m(),K=o("div"),w(vn.$$.fragment),ad=m(),wn=o("p"),rd=n("Generates sequences of token ids for models with a language modeling head using "),zo=o("strong"),ld=n("greedy decoding"),id=n(` and can be
used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),cd=m(),w(pt.$$.fragment),dd=m(),w(mt.$$.fragment),pd=m(),ee=o("div"),w(Tn.$$.fragment),md=m(),jn=o("p"),gd=n("Generates sequences of token ids for models with a language modeling head using "),Lo=o("strong"),hd=n("multinomial sampling"),ud=n(` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),fd=m(),w(gt.$$.fragment),_d=m(),w(ht.$$.fragment),yd=m(),te=o("div"),w(Jn.$$.fragment),Md=m(),Un=o("p"),bd=n("Generates sequences of token ids for models with a language modeling head using "),Ao=o("strong"),vd=n("beam search decoding"),wd=n(` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),Td=m(),w(ut.$$.fragment),jd=m(),w(ft.$$.fragment),Jd=m(),ne=o("div"),w(xn.$$.fragment),Ud=m(),Gn=o("p"),xd=n("Generates sequences of token ids for models with a language modeling head using "),Qo=o("strong"),Gd=n(`beam search multinomial
sampling`),kd=n(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),Ed=m(),w(_t.$$.fragment),Zd=m(),w(yt.$$.fragment),Bd=m(),se=o("div"),w(kn.$$.fragment),Cd=m(),En=o("p"),Id=n("Generates sequences of token ids for models with a language modeling head using "),Yo=o("strong"),Wd=n("contrastive search"),Xd=n(` and can
be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),Nd=m(),w(Mt.$$.fragment),Rd=m(),w(bt.$$.fragment),Vd=m(),oe=o("div"),w(Zn.$$.fragment),$d=m(),Bn=o("p"),Sd=n("Generates sequences of token ids for models with a language modeling head using "),Do=o("strong"),Fd=n(`diverse beam search
decoding`),zd=n(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),Ld=m(),w(vt.$$.fragment),Ad=m(),w(wt.$$.fragment),Qd=m(),ae=o("div"),w(Cn.$$.fragment),Yd=m(),In=o("p"),Dd=n("Generates sequences of token ids for models with a language modeling head using "),Ho=o("strong"),Hd=n(`constrained beam search
decoding`),Od=n(" and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),qd=m(),w(Tt.$$.fragment),Pd=m(),w(jt.$$.fragment),Da=m(),Ye=o("h2"),Jt=o("a"),Oo=o("span"),w(Wn.$$.fragment),Kd=m(),qo=o("span"),ep=n("TFGenerationMixin"),Ha=m(),V=o("div"),w(Xn.$$.fragment),tp=m(),Nn=o("p"),np=n("A class containing all of the functions supporting generation, to be used as a mixin in "),Gs=o("a"),sp=n("TFPreTrainedModel"),op=n("."),ap=m(),Rn=o("p"),rp=n("The class exposes "),ks=o("a"),lp=n("generate()"),ip=n(", which can be used for:"),cp=m(),Te=o("ul"),je=o("li"),Po=o("em"),dp=n("greedy decoding"),pp=n(" by calling "),Ko=o("code"),mp=n("greedy_search()"),gp=n(" if "),ea=o("code"),hp=n("num_beams=1"),up=n(` and
`),ta=o("code"),fp=n("do_sample=False"),_p=m(),Je=o("li"),na=o("em"),yp=n("contrastive search"),Mp=n(" by calling "),sa=o("code"),bp=n("contrastive_search()"),vp=n(" if "),oa=o("code"),wp=n("penalty_alpha>0"),Tp=n(` and
`),aa=o("code"),jp=n("top_k>1"),Jp=m(),Ue=o("li"),ra=o("em"),Up=n("multinomial sampling"),xp=n(" by calling "),la=o("code"),Gp=n("sample()"),kp=n(" if "),ia=o("code"),Ep=n("num_beams=1"),Zp=n(` and
`),ca=o("code"),Bp=n("do_sample=True"),Cp=m(),De=o("li"),da=o("em"),Ip=n("beam-search decoding"),Wp=n(" by calling "),pa=o("code"),Xp=n("beam_search()"),Np=n(" if "),ma=o("code"),Rp=n("num_beams>1"),Vp=m(),Vn=o("p"),$p=n(`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"),Sp=n("text generation strategies guide"),Fp=n("."),zp=m(),Ce=o("div"),w($n.$$.fragment),Lp=m(),ga=o("p"),Ap=n("Generates sequences of token ids for models with a language modeling head."),Qp=m(),w(Ut.$$.fragment),Yp=m(),Ie=o("div"),w(Sn.$$.fragment),Dp=m(),ha=o("p"),Hp=n(`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.`),Op=m(),w(xt.$$.fragment),Oa=m(),He=o("h2"),Gt=o("a"),ua=o("span"),w(Fn.$$.fragment),qp=m(),fa=o("span"),Pp=n("FlaxGenerationMixin"),qa=m(),L=o("div"),w(zn.$$.fragment),Kp=m(),Ln=o("p"),em=n(`A class containing all functions for auto-regressive text generation, to be used as a mixin in
`),Zs=o("a"),tm=n("FlaxPreTrainedModel"),nm=n("."),sm=m(),An=o("p"),om=n("The class exposes "),Bs=o("a"),am=n("generate()"),rm=n(", which can be used for:"),lm=m(),Oe=o("ul"),xe=o("li"),_a=o("em"),im=n("greedy decoding"),cm=n(" by calling "),ya=o("code"),dm=n("_greedy_search()"),pm=n(" if "),Ma=o("code"),mm=n("num_beams=1"),gm=n(` and
`),ba=o("code"),hm=n("do_sample=False"),um=m(),Ge=o("li"),va=o("em"),fm=n("multinomial sampling"),_m=n(" by calling "),wa=o("code"),ym=n("_sample()"),Mm=n(" if "),Ta=o("code"),bm=n("num_beams=1"),vm=n(` and
`),ja=o("code"),wm=n("do_sample=True"),Tm=m(),ke=o("li"),Ja=o("em"),jm=n("beam-search decoding"),Jm=n(" by calling "),Ua=o("code"),Um=n("_beam_search()"),xm=n(" if "),xa=o("code"),Gm=n("num_beams>1"),km=n(` and
`),Ga=o("code"),Em=n("do_sample=False"),Zm=m(),Qn=o("p"),Bm=n(`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"),Cm=n("text generation strategies guide"),Im=n("."),Wm=m(),kt=o("div"),w(Yn.$$.fragment),Xm=m(),ka=o("p"),Nm=n("Generates sequences of token ids for models with a language modeling head."),this.h()},l(i){const M=cu('[data-svelte="svelte-1phssyn"]',document.head);c=a(M,"META",{name:!0,content:!0}),M.forEach(t),_=g(i),p=a(i,"H1",{class:!0});var Dn=r(p);d=a(Dn,"A",{id:!0,class:!0,href:!0});var Ea=r(d);f=a(Ea,"SPAN",{});var Za=r(f);T(l.$$.fragment,Za),Za.forEach(t),Ea.forEach(t),h=g(Dn),G=a(Dn,"SPAN",{});var Ba=r(G);v=s(Ba,"Generation"),Ba.forEach(t),Dn.forEach(t),y=g(i),E=a(i,"P",{});var Hn=r(E);Z=s(Hn,"Each framework has a generate method for text generation implemented in their respective "),X=a(Hn,"CODE",{});var Ca=r(X);le=s(Ca,"GenerationMixin"),Ca.forEach(t),F=s(Hn," class:"),Hn.forEach(t),q=g(i),S=a(i,"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(t),$e=s(Pe," is implemented in "),A=a(Pe,"A",{href:!0});var Wa=r(A);Se=s(Wa,"GenerationMixin"),Wa.forEach(t),Jr=s(Pe,"."),Pe.forEach(t),Ur=g(qe),Fe=a(qe,"LI",{});var Ke=r(Fe);xr=s(Ke,"TensorFlow "),Pn=a(Ke,"A",{href:!0});var Xa=r(Pn);Gr=s(Xa,"generate()"),Xa.forEach(t),kr=s(Ke," is implemented in "),Kn=a(Ke,"A",{href:!0});var Na=r(Kn);Er=s(Na,"TFGenerationMixin"),Na.forEach(t),Zr=s(Ke,"."),Ke.forEach(t),Br=g(qe),ze=a(qe,"LI",{});var et=r(ze);Cr=s(et,"Flax/JAX "),es=a(et,"A",{href:!0});var Ra=r(es);Ir=s(Ra,"generate()"),Ra.forEach(t),Wr=s(et," is implemented in "),ts=a(et,"A",{href:!0});var Va=r(ts);Xr=s(Va,"FlaxGenerationMixin"),Va.forEach(t),Nr=s(et,"."),et.forEach(t),qe.forEach(t),Fa=g(i),nt=a(i,"P",{});var On=r(nt);Rr=s(On,"Regardless of your framework of choice, you can parameterize the generate method with a "),ns=a(On,"A",{href:!0});var $a=r(ns);Vr=s($a,"GenerationConfig"),$a.forEach(t),$r=s(On,`
class instance. Please refer to this class for the complete list of generation parameters, which control the behavior
of the generation method.`),On.forEach(t),za=g(i),st=a(i,"P",{});var qn=r(st);Sr=s(qn,`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(qn,"A",{href:!0});var Rm=r(ss);Fr=s(Rm,"text generation strategies guide"),Rm.forEach(t),zr=s(qn,`. The guide also explains how to use related features,
like token streaming.`),qn.forEach(t),La=g(i),Le=a(i,"H2",{class:!0});var Ka=r(Le);ot=a(Ka,"A",{id:!0,class:!0,href:!0});var Vm=r(ot);Fs=a(Vm,"SPAN",{});var $m=r(Fs);T(an.$$.fragment,$m),$m.forEach(t),Vm.forEach(t),Lr=g(Ka),zs=a(Ka,"SPAN",{});var Sm=r(zs);Ar=s(Sm,"GenerationConfig"),Sm.forEach(t),Ka.forEach(t),Aa=g(i),N=a(i,"DIV",{class:!0});var Y=r(N);T(rn.$$.fragment,Y),Qr=g(Y),ln=a(Y,"P",{});var er=r(ln);Yr=s(er,"Class that holds a configuration for a generation task. A "),Ls=a(er,"CODE",{});var Fm=r(Ls);Dr=s(Fm,"generate"),Fm.forEach(t),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(t),Or=g(Y),R=a(Y,"UL",{});var Q=r(R);ie=a(Q,"LI",{});var Et=r(ie);As=a(Et,"EM",{});var zm=r(As);qr=s(zm,"greedy decoding"),zm.forEach(t),Pr=s(Et," by calling "),os=a(Et,"A",{href:!0});var Lm=r(os);Kr=s(Lm,"greedy_search()"),Lm.forEach(t),el=s(Et," if "),Qs=a(Et,"CODE",{});var Am=r(Qs);tl=s(Am,"num_beams=1"),Am.forEach(t),nl=s(Et,` and
`),Ys=a(Et,"CODE",{});var Qm=r(Ys);sl=s(Qm,"do_sample=False"),Qm.forEach(t),Et.forEach(t),ol=g(Q),ce=a(Q,"LI",{});var Zt=r(ce);Ds=a(Zt,"EM",{});var Ym=r(Ds);al=s(Ym,"contrastive search"),Ym.forEach(t),rl=s(Zt," by calling "),as=a(Zt,"A",{href:!0});var Dm=r(as);ll=s(Dm,"contrastive_search()"),Dm.forEach(t),il=s(Zt," if "),Hs=a(Zt,"CODE",{});var Hm=r(Hs);cl=s(Hm,"penalty_alpha>0."),Hm.forEach(t),dl=s(Zt,`
and `),Os=a(Zt,"CODE",{});var Om=r(Os);pl=s(Om,"top_k>1"),Om.forEach(t),Zt.forEach(t),ml=g(Q),de=a(Q,"LI",{});var Bt=r(de);qs=a(Bt,"EM",{});var qm=r(qs);gl=s(qm,"multinomial sampling"),qm.forEach(t),hl=s(Bt," by calling "),rs=a(Bt,"A",{href:!0});var Pm=r(rs);ul=s(Pm,"sample()"),Pm.forEach(t),fl=s(Bt," if "),Ps=a(Bt,"CODE",{});var Km=r(Ps);_l=s(Km,"num_beams=1"),Km.forEach(t),yl=s(Bt,` and
`),Ks=a(Bt,"CODE",{});var eg=r(Ks);Ml=s(eg,"do_sample=True"),eg.forEach(t),Bt.forEach(t),bl=g(Q),pe=a(Q,"LI",{});var Ct=r(pe);eo=a(Ct,"EM",{});var tg=r(eo);vl=s(tg,"beam-search decoding"),tg.forEach(t),wl=s(Ct," by calling "),ls=a(Ct,"A",{href:!0});var ng=r(ls);Tl=s(ng,"beam_search()"),ng.forEach(t),jl=s(Ct," if "),to=a(Ct,"CODE",{});var sg=r(to);Jl=s(sg,"num_beams>1"),sg.forEach(t),Ul=s(Ct,` and
`),no=a(Ct,"CODE",{});var og=r(no);xl=s(og,"do_sample=False"),og.forEach(t),Ct.forEach(t),Gl=g(Q),me=a(Q,"LI",{});var It=r(me);so=a(It,"EM",{});var ag=r(so);kl=s(ag,"beam-search multinomial sampling"),ag.forEach(t),El=s(It," by calling "),is=a(It,"A",{href:!0});var rg=r(is);Zl=s(rg,"beam_sample()"),rg.forEach(t),Bl=s(It,` if
`),oo=a(It,"CODE",{});var lg=r(oo);Cl=s(lg,"num_beams>1"),lg.forEach(t),Il=s(It," and "),ao=a(It,"CODE",{});var ig=r(ao);Wl=s(ig,"do_sample=True"),ig.forEach(t),It.forEach(t),Xl=g(Q),ge=a(Q,"LI",{});var Wt=r(ge);ro=a(Wt,"EM",{});var cg=r(ro);Nl=s(cg,"diverse beam-search decoding"),cg.forEach(t),Rl=s(Wt," by calling "),cs=a(Wt,"A",{href:!0});var dg=r(cs);Vl=s(dg,"group_beam_search()"),dg.forEach(t),$l=s(Wt,`, if
`),lo=a(Wt,"CODE",{});var pg=r(lo);Sl=s(pg,"num_beams>1"),pg.forEach(t),Fl=s(Wt," and "),io=a(Wt,"CODE",{});var mg=r(io);zl=s(mg,"num_beam_groups>1"),mg.forEach(t),Wt.forEach(t),Ll=g(Q),he=a(Q,"LI",{});var Xt=r(he);co=a(Xt,"EM",{});var gg=r(co);Al=s(gg,"constrained beam-search decoding"),gg.forEach(t),Ql=s(Xt," by calling "),ds=a(Xt,"A",{href:!0});var hg=r(ds);Yl=s(hg,"constrained_beam_search()"),hg.forEach(t),Dl=s(Xt,`, if
`),po=a(Xt,"CODE",{});var ug=r(po);Hl=s(ug,"constraints!=None"),ug.forEach(t),Ol=s(Xt," or "),mo=a(Xt,"CODE",{});var fg=r(mo);ql=s(fg,"force_words_ids!=None"),fg.forEach(t),Xt.forEach(t),Pl=g(Q),ue=a(Q,"LI",{});var Nt=r(ue);go=a(Nt,"EM",{});var _g=r(go);Kl=s(_g,"assisted decoding"),_g.forEach(t),ei=s(Nt," by calling "),ho=a(Nt,"CODE",{});var yg=r(ho);ti=s(yg,"assisted_decoding()"),yg.forEach(t),ni=s(Nt,`, if
`),uo=a(Nt,"CODE",{});var Mg=r(uo);si=s(Mg,"assistant_model"),Mg.forEach(t),oi=s(Nt," is passed to "),fo=a(Nt,"CODE",{});var bg=r(fo);ai=s(bg,".generate()"),bg.forEach(t),Nt.forEach(t),Q.forEach(t),ri=g(Y),cn=a(Y,"P",{});var tr=r(cn);li=s(tr,`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 `),ps=a(tr,"A",{href:!0});var vg=r(ps);ii=s(vg,"text generation strategies guide"),vg.forEach(t),ci=s(tr,"."),tr.forEach(t),di=g(Y),Ee=a(Y,"DIV",{class:!0});var Is=r(Ee);T(dn.$$.fragment,Is),pi=g(Is),pn=a(Is,"P",{});var nr=r(pn);mi=s(nr,"Instantiate a "),ms=a(nr,"A",{href:!0});var wg=r(ms);gi=s(wg,"GenerationConfig"),wg.forEach(t),hi=s(nr," from a generation configuration file."),nr.forEach(t),ui=g(Is),T(at.$$.fragment,Is),Is.forEach(t),fi=g(Y),rt=a(Y,"DIV",{class:!0});var sr=r(rt);T(mn.$$.fragment,sr),_i=g(sr),O=a(sr,"P",{});var We=r(O);yi=s(We,"Instantiates a "),gs=a(We,"A",{href:!0});var Tg=r(gs);Mi=s(Tg,"GenerationConfig"),Tg.forEach(t),bi=s(We," from a "),hs=a(We,"A",{href:!0});var jg=r(hs);vi=s(jg,"PretrainedConfig"),jg.forEach(t),wi=s(We,`. This function is useful to convert legacy
`),us=a(We,"A",{href:!0});var Jg=r(us);Ti=s(Jg,"PretrainedConfig"),Jg.forEach(t),ji=s(We," objects, which may contain generation parameters, into a stand-alone "),fs=a(We,"A",{href:!0});var Ug=r(fs);Ji=s(Ug,"GenerationConfig"),Ug.forEach(t),Ui=s(We,"."),We.forEach(t),sr.forEach(t),xi=g(Y),lt=a(Y,"DIV",{class:!0});var or=r(lt);T(gn.$$.fragment,or),Gi=g(or),Ae=a(or,"P",{});var Ws=r(Ae);ki=s(Ws,"Save a generation configuration object to the directory "),_o=a(Ws,"CODE",{});var xg=r(_o);Ei=s(xg,"save_directory"),xg.forEach(t),Zi=s(Ws,`, so that it can be re-loaded using the
`),_s=a(Ws,"A",{href:!0});var Gg=r(_s);Bi=s(Gg,"from_pretrained()"),Gg.forEach(t),Ci=s(Ws," class method."),Ws.forEach(t),or.forEach(t),Y.forEach(t),Qa=g(i),Qe=a(i,"H2",{class:!0});var ar=r(Qe);it=a(ar,"A",{id:!0,class:!0,href:!0});var kg=r(it);yo=a(kg,"SPAN",{});var Eg=r(yo);T(hn.$$.fragment,Eg),Eg.forEach(t),kg.forEach(t),Ii=g(ar),Mo=a(ar,"SPAN",{});var Zg=r(Mo);Wi=s(Zg,"GenerationMixin"),Zg.forEach(t),ar.forEach(t),Ya=g(i),C=a(i,"DIV",{class:!0});var W=r(C);T(un.$$.fragment,W),Xi=g(W),fn=a(W,"P",{});var rr=r(fn);Ni=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);Ri=s(Bg,"PreTrainedModel"),Bg.forEach(t),Vi=s(rr,"."),rr.forEach(t),$i=g(W),_n=a(W,"P",{});var lr=r(_n);Si=s(lr,"The class exposes "),Ms=a(lr,"A",{href:!0});var Cg=r(Ms);Fi=s(Cg,"generate()"),Cg.forEach(t),zi=s(lr,", which can be used for:"),lr.forEach(t),Li=g(W),z=a(W,"UL",{});var D=r(z);fe=a(D,"LI",{});var Rt=r(fe);bo=a(Rt,"EM",{});var Ig=r(bo);Ai=s(Ig,"greedy decoding"),Ig.forEach(t),Qi=s(Rt," by calling "),bs=a(Rt,"A",{href:!0});var Wg=r(bs);Yi=s(Wg,"greedy_search()"),Wg.forEach(t),Di=s(Rt," if "),vo=a(Rt,"CODE",{});var Xg=r(vo);Hi=s(Xg,"num_beams=1"),Xg.forEach(t),Oi=s(Rt,` and
`),wo=a(Rt,"CODE",{});var Ng=r(wo);qi=s(Ng,"do_sample=False"),Ng.forEach(t),Rt.forEach(t),Pi=g(D),_e=a(D,"LI",{});var Vt=r(_e);To=a(Vt,"EM",{});var Rg=r(To);Ki=s(Rg,"contrastive search"),Rg.forEach(t),ec=s(Vt," by calling "),vs=a(Vt,"A",{href:!0});var Vg=r(vs);tc=s(Vg,"contrastive_search()"),Vg.forEach(t),nc=s(Vt," if "),jo=a(Vt,"CODE",{});var $g=r(jo);sc=s($g,"penalty_alpha>0"),$g.forEach(t),oc=s(Vt,` and
`),Jo=a(Vt,"CODE",{});var Sg=r(Jo);ac=s(Sg,"top_k>1"),Sg.forEach(t),Vt.forEach(t),rc=g(D),ye=a(D,"LI",{});var $t=r(ye);Uo=a($t,"EM",{});var Fg=r(Uo);lc=s(Fg,"multinomial sampling"),Fg.forEach(t),ic=s($t," by calling "),ws=a($t,"A",{href:!0});var zg=r(ws);cc=s(zg,"sample()"),zg.forEach(t),dc=s($t," if "),xo=a($t,"CODE",{});var Lg=r(xo);pc=s(Lg,"num_beams=1"),Lg.forEach(t),mc=s($t,` and
`),Go=a($t,"CODE",{});var Ag=r(Go);gc=s(Ag,"do_sample=True"),Ag.forEach(t),$t.forEach(t),hc=g(D),Me=a(D,"LI",{});var St=r(Me);ko=a(St,"EM",{});var Qg=r(ko);uc=s(Qg,"beam-search decoding"),Qg.forEach(t),fc=s(St," by calling "),Ts=a(St,"A",{href:!0});var Yg=r(Ts);_c=s(Yg,"beam_search()"),Yg.forEach(t),yc=s(St," if "),Eo=a(St,"CODE",{});var Dg=r(Eo);Mc=s(Dg,"num_beams>1"),Dg.forEach(t),bc=s(St,` and
`),Zo=a(St,"CODE",{});var Hg=r(Zo);vc=s(Hg,"do_sample=False"),Hg.forEach(t),St.forEach(t),wc=g(D),be=a(D,"LI",{});var Ft=r(be);Bo=a(Ft,"EM",{});var Og=r(Bo);Tc=s(Og,"beam-search multinomial sampling"),Og.forEach(t),jc=s(Ft," by calling "),js=a(Ft,"A",{href:!0});var qg=r(js);Jc=s(qg,"beam_sample()"),qg.forEach(t),Uc=s(Ft," if "),Co=a(Ft,"CODE",{});var Pg=r(Co);xc=s(Pg,"num_beams>1"),Pg.forEach(t),Gc=s(Ft,`
and `),Io=a(Ft,"CODE",{});var Kg=r(Io);kc=s(Kg,"do_sample=True"),Kg.forEach(t),Ft.forEach(t),Ec=g(D),ve=a(D,"LI",{});var zt=r(ve);Wo=a(zt,"EM",{});var eh=r(Wo);Zc=s(eh,"diverse beam-search decoding"),eh.forEach(t),Bc=s(zt," by calling "),Js=a(zt,"A",{href:!0});var th=r(Js);Cc=s(th,"group_beam_search()"),th.forEach(t),Ic=s(zt,", if "),Xo=a(zt,"CODE",{});var nh=r(Xo);Wc=s(nh,"num_beams>1"),nh.forEach(t),Xc=s(zt,`
and `),No=a(zt,"CODE",{});var sh=r(No);Nc=s(sh,"num_beam_groups>1"),sh.forEach(t),zt.forEach(t),Rc=g(D),we=a(D,"LI",{});var Lt=r(we);Ro=a(Lt,"EM",{});var oh=r(Ro);Vc=s(oh,"constrained beam-search decoding"),oh.forEach(t),$c=s(Lt," by calling "),Us=a(Lt,"A",{href:!0});var ah=r(Us);Sc=s(ah,"constrained_beam_search()"),ah.forEach(t),Fc=s(Lt,`, if
`),Vo=a(Lt,"CODE",{});var rh=r(Vo);zc=s(rh,"constraints!=None"),rh.forEach(t),Lc=s(Lt," or "),$o=a(Lt,"CODE",{});var lh=r($o);Ac=s(lh,"force_words_ids!=None"),lh.forEach(t),Lt.forEach(t),D.forEach(t),Qc=g(W),yn=a(W,"P",{});var ir=r(yn);Yc=s(ir,`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(ir,"A",{href:!0});var ih=r(xs);Dc=s(ih,"text generation strategies guide"),ih.forEach(t),Hc=s(ir,"."),ir.forEach(t),Oc=g(W),Ze=a(W,"DIV",{class:!0});var Xs=r(Ze);T(Mn.$$.fragment,Xs),qc=g(Xs),So=a(Xs,"P",{});var ch=r(So);Pc=s(ch,"Generates sequences of token ids for models with a language modeling head."),ch.forEach(t),Kc=g(Xs),T(ct.$$.fragment,Xs),Xs.forEach(t),ed=g(W),Be=a(W,"DIV",{class:!0});var Ns=r(Be);T(bn.$$.fragment,Ns),td=g(Ns),Fo=a(Ns,"P",{});var dh=r(Fo);nd=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(t),sd=g(Ns),T(dt.$$.fragment,Ns),Ns.forEach(t),od=g(W),K=a(W,"DIV",{class:!0});var At=r(K);T(vn.$$.fragment,At),ad=g(At),wn=a(At,"P",{});var cr=r(wn);rd=s(cr,"Generates sequences of token ids for models with a language modeling head using "),zo=a(cr,"STRONG",{});var ph=r(zo);ld=s(ph,"greedy decoding"),ph.forEach(t),id=s(cr,` and can be
used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),cr.forEach(t),cd=g(At),T(pt.$$.fragment,At),dd=g(At),T(mt.$$.fragment,At),At.forEach(t),pd=g(W),ee=a(W,"DIV",{class:!0});var Qt=r(ee);T(Tn.$$.fragment,Qt),md=g(Qt),jn=a(Qt,"P",{});var dr=r(jn);gd=s(dr,"Generates sequences of token ids for models with a language modeling head using "),Lo=a(dr,"STRONG",{});var mh=r(Lo);hd=s(mh,"multinomial sampling"),mh.forEach(t),ud=s(dr,` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),dr.forEach(t),fd=g(Qt),T(gt.$$.fragment,Qt),_d=g(Qt),T(ht.$$.fragment,Qt),Qt.forEach(t),yd=g(W),te=a(W,"DIV",{class:!0});var Yt=r(te);T(Jn.$$.fragment,Yt),Md=g(Yt),Un=a(Yt,"P",{});var pr=r(Un);bd=s(pr,"Generates sequences of token ids for models with a language modeling head using "),Ao=a(pr,"STRONG",{});var gh=r(Ao);vd=s(gh,"beam search decoding"),gh.forEach(t),wd=s(pr,` and
can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),pr.forEach(t),Td=g(Yt),T(ut.$$.fragment,Yt),jd=g(Yt),T(ft.$$.fragment,Yt),Yt.forEach(t),Jd=g(W),ne=a(W,"DIV",{class:!0});var Dt=r(ne);T(xn.$$.fragment,Dt),Ud=g(Dt),Gn=a(Dt,"P",{});var mr=r(Gn);xd=s(mr,"Generates sequences of token ids for models with a language modeling head using "),Qo=a(mr,"STRONG",{});var hh=r(Qo);Gd=s(hh,`beam search multinomial
sampling`),hh.forEach(t),kd=s(mr," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),mr.forEach(t),Ed=g(Dt),T(_t.$$.fragment,Dt),Zd=g(Dt),T(yt.$$.fragment,Dt),Dt.forEach(t),Bd=g(W),se=a(W,"DIV",{class:!0});var Ht=r(se);T(kn.$$.fragment,Ht),Cd=g(Ht),En=a(Ht,"P",{});var gr=r(En);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(t),Xd=s(gr,` and can
be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models.`),gr.forEach(t),Nd=g(Ht),T(Mt.$$.fragment,Ht),Rd=g(Ht),T(bt.$$.fragment,Ht),Ht.forEach(t),Vd=g(W),oe=a(W,"DIV",{class:!0});var Ot=r(oe);T(Zn.$$.fragment,Ot),$d=g(Ot),Bn=a(Ot,"P",{});var hr=r(Bn);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(t),zd=s(hr," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),hr.forEach(t),Ld=g(Ot),T(vt.$$.fragment,Ot),Ad=g(Ot),T(wt.$$.fragment,Ot),Ot.forEach(t),Qd=g(W),ae=a(W,"DIV",{class:!0});var qt=r(ae);T(Cn.$$.fragment,qt),Yd=g(qt),In=a(qt,"P",{});var ur=r(In);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(t),Od=s(ur," and can be used for text-decoder, text-to-text, speech-to-text, and vision-to-text models."),ur.forEach(t),qd=g(qt),T(Tt.$$.fragment,qt),Pd=g(qt),T(jt.$$.fragment,qt),qt.forEach(t),W.forEach(t),Da=g(i),Ye=a(i,"H2",{class:!0});var fr=r(Ye);Jt=a(fr,"A",{id:!0,class:!0,href:!0});var yh=r(Jt);Oo=a(yh,"SPAN",{});var Mh=r(Oo);T(Wn.$$.fragment,Mh),Mh.forEach(t),yh.forEach(t),Kd=g(fr),qo=a(fr,"SPAN",{});var bh=r(qo);ep=s(bh,"TFGenerationMixin"),bh.forEach(t),fr.forEach(t),Ha=g(i),V=a(i,"DIV",{class:!0});var H=r(V);T(Xn.$$.fragment,H),tp=g(H),Nn=a(H,"P",{});var _r=r(Nn);np=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 vh=r(Gs);sp=s(vh,"TFPreTrainedModel"),vh.forEach(t),op=s(_r,"."),_r.forEach(t),ap=g(H),Rn=a(H,"P",{});var yr=r(Rn);rp=s(yr,"The class exposes "),ks=a(yr,"A",{href:!0});var wh=r(ks);lp=s(wh,"generate()"),wh.forEach(t),ip=s(yr,", which can be used for:"),yr.forEach(t),cp=g(H),Te=a(H,"UL",{});var Pt=r(Te);je=a(Pt,"LI",{});var Kt=r(je);Po=a(Kt,"EM",{});var Th=r(Po);dp=s(Th,"greedy decoding"),Th.forEach(t),pp=s(Kt," by calling "),Ko=a(Kt,"CODE",{});var jh=r(Ko);mp=s(jh,"greedy_search()"),jh.forEach(t),gp=s(Kt," if "),ea=a(Kt,"CODE",{});var Jh=r(ea);hp=s(Jh,"num_beams=1"),Jh.forEach(t),up=s(Kt,` and
`),ta=a(Kt,"CODE",{});var Uh=r(ta);fp=s(Uh,"do_sample=False"),Uh.forEach(t),Kt.forEach(t),_p=g(Pt),Je=a(Pt,"LI",{});var en=r(Je);na=a(en,"EM",{});var xh=r(na);yp=s(xh,"contrastive search"),xh.forEach(t),Mp=s(en," by calling "),sa=a(en,"CODE",{});var Gh=r(sa);bp=s(Gh,"contrastive_search()"),Gh.forEach(t),vp=s(en," if "),oa=a(en,"CODE",{});var kh=r(oa);wp=s(kh,"penalty_alpha>0"),kh.forEach(t),Tp=s(en,` and
`),aa=a(en,"CODE",{});var Eh=r(aa);jp=s(Eh,"top_k>1"),Eh.forEach(t),en.forEach(t),Jp=g(Pt),Ue=a(Pt,"LI",{});var tn=r(Ue);ra=a(tn,"EM",{});var Zh=r(ra);Up=s(Zh,"multinomial sampling"),Zh.forEach(t),xp=s(tn," by calling "),la=a(tn,"CODE",{});var Bh=r(la);Gp=s(Bh,"sample()"),Bh.forEach(t),kp=s(tn," if "),ia=a(tn,"CODE",{});var Ch=r(ia);Ep=s(Ch,"num_beams=1"),Ch.forEach(t),Zp=s(tn,` and
`),ca=a(tn,"CODE",{});var Ih=r(ca);Bp=s(Ih,"do_sample=True"),Ih.forEach(t),tn.forEach(t),Cp=g(Pt),De=a(Pt,"LI",{});var Rs=r(De);da=a(Rs,"EM",{});var Wh=r(da);Ip=s(Wh,"beam-search decoding"),Wh.forEach(t),Wp=s(Rs," by calling "),pa=a(Rs,"CODE",{});var Xh=r(pa);Xp=s(Xh,"beam_search()"),Xh.forEach(t),Np=s(Rs," if "),ma=a(Rs,"CODE",{});var Nh=r(ma);Rp=s(Nh,"num_beams>1"),Nh.forEach(t),Rs.forEach(t),Pt.forEach(t),Vp=g(H),Vn=a(H,"P",{});var Mr=r(Vn);$p=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);Sp=s(Rh,"text generation strategies guide"),Rh.forEach(t),Fp=s(Mr,"."),Mr.forEach(t),zp=g(H),Ce=a(H,"DIV",{class:!0});var Vs=r(Ce);T($n.$$.fragment,Vs),Lp=g(Vs),ga=a(Vs,"P",{});var Vh=r(ga);Ap=s(Vh,"Generates sequences of token ids for models with a language modeling head."),Vh.forEach(t),Qp=g(Vs),T(Ut.$$.fragment,Vs),Vs.forEach(t),Yp=g(H),Ie=a(H,"DIV",{class:!0});var $s=r(Ie);T(Sn.$$.fragment,$s),Dp=g($s),ha=a($s,"P",{});var $h=r(ha);Hp=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(t),Op=g($s),T(xt.$$.fragment,$s),$s.forEach(t),H.forEach(t),Oa=g(i),He=a(i,"H2",{class:!0});var br=r(He);Gt=a(br,"A",{id:!0,class:!0,href:!0});var Sh=r(Gt);ua=a(Sh,"SPAN",{});var Fh=r(ua);T(Fn.$$.fragment,Fh),Fh.forEach(t),Sh.forEach(t),qp=g(br),fa=a(br,"SPAN",{});var zh=r(fa);Pp=s(zh,"FlaxGenerationMixin"),zh.forEach(t),br.forEach(t),qa=g(i),L=a(i,"DIV",{class:!0});var re=r(L);T(zn.$$.fragment,re),Kp=g(re),Ln=a(re,"P",{});var vr=r(Ln);em=s(vr,`A class containing all functions for auto-regressive text generation, to be used as a mixin in
`),Zs=a(vr,"A",{href:!0});var Lh=r(Zs);tm=s(Lh,"FlaxPreTrainedModel"),Lh.forEach(t),nm=s(vr,"."),vr.forEach(t),sm=g(re),An=a(re,"P",{});var wr=r(An);om=s(wr,"The class exposes "),Bs=a(wr,"A",{href:!0});var Ah=r(Bs);am=s(Ah,"generate()"),Ah.forEach(t),rm=s(wr,", which can be used for:"),wr.forEach(t),lm=g(re),Oe=a(re,"UL",{});var Ss=r(Oe);xe=a(Ss,"LI",{});var nn=r(xe);_a=a(nn,"EM",{});var Qh=r(_a);im=s(Qh,"greedy decoding"),Qh.forEach(t),cm=s(nn," by calling "),ya=a(nn,"CODE",{});var Yh=r(ya);dm=s(Yh,"_greedy_search()"),Yh.forEach(t),pm=s(nn," if "),Ma=a(nn,"CODE",{});var Dh=r(Ma);mm=s(Dh,"num_beams=1"),Dh.forEach(t),gm=s(nn,` and
`),ba=a(nn,"CODE",{});var Hh=r(ba);hm=s(Hh,"do_sample=False"),Hh.forEach(t),nn.forEach(t),um=g(Ss),Ge=a(Ss,"LI",{});var sn=r(Ge);va=a(sn,"EM",{});var Oh=r(va);fm=s(Oh,"multinomial sampling"),Oh.forEach(t),_m=s(sn," by calling "),wa=a(sn,"CODE",{});var qh=r(wa);ym=s(qh,"_sample()"),qh.forEach(t),Mm=s(sn," if "),Ta=a(sn,"CODE",{});var Ph=r(Ta);bm=s(Ph,"num_beams=1"),Ph.forEach(t),vm=s(sn,` and
`),ja=a(sn,"CODE",{});var Kh=r(ja);wm=s(Kh,"do_sample=True"),Kh.forEach(t),sn.forEach(t),Tm=g(Ss),ke=a(Ss,"LI",{});var on=r(ke);Ja=a(on,"EM",{});var eu=r(Ja);jm=s(eu,"beam-search decoding"),eu.forEach(t),Jm=s(on," by calling "),Ua=a(on,"CODE",{});var tu=r(Ua);Um=s(tu,"_beam_search()"),tu.forEach(t),xm=s(on," if "),xa=a(on,"CODE",{});var nu=r(xa);Gm=s(nu,"num_beams>1"),nu.forEach(t),km=s(on,` and
`),Ga=a(on,"CODE",{});var su=r(Ga);Em=s(su,"do_sample=False"),su.forEach(t),on.forEach(t),Ss.forEach(t),Zm=g(re),Qn=a(re,"P",{});var Tr=r(Qn);Bm=s(Tr,`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(Tr,"A",{href:!0});var ou=r(Cs);Cm=s(ou,"text generation strategies guide"),ou.forEach(t),Im=s(Tr,"."),Tr.forEach(t),Wm=g(re),kt=a(re,"DIV",{class:!0});var jr=r(kt);T(Yn.$$.fragment,jr),Xm=g(jr),ka=a(jr,"P",{});var au=r(ka);Nm=s(au,"Generates sequences of token ids for models with a language modeling head."),au.forEach(t),jr.forEach(t),re.forEach(t),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(p,"class","relative group"),u(P,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),u(A,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin"),u(Pn,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.TFGenerationMixin.generate"),u(Kn,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.TFGenerationMixin"),u(es,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.FlaxGenerationMixin.generate"),u(ts,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.FlaxGenerationMixin"),u(ns,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig"),u(ss,"href","../generation_strategies"),u(ot,"id","transformers.GenerationConfig"),u(ot,"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(ot,"href","#transformers.GenerationConfig"),u(Le,"class","relative group"),u(os,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(as,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),u(rs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(ls,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(is,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(cs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(ds,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.constrained_beam_search"),u(ps,"href","../generation_strategies"),u(ms,"href","/docs/transformers/v4.30.0/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/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig"),u(hs,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),u(us,"href","/docs/transformers/v4.30.0/en/main_classes/configuration#transformers.PretrainedConfig"),u(fs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig"),u(rt,"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/v4.30.0/en/main_classes/text_generation#transformers.GenerationConfig.from_pretrained"),u(lt,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),u(it,"id","transformers.GenerationMixin"),u(it,"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(it,"href","#transformers.GenerationMixin"),u(Qe,"class","relative group"),u(ys,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.PreTrainedModel"),u(Ms,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),u(bs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.greedy_search"),u(vs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.contrastive_search"),u(ws,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.sample"),u(Ts,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_search"),u(js,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.beam_sample"),u(Js,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.GenerationMixin.group_beam_search"),u(Us,"href","/docs/transformers/v4.30.0/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(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(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(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(Jt,"id","transformers.TFGenerationMixin"),u(Jt,"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(Jt,"href","#transformers.TFGenerationMixin"),u(Ye,"class","relative group"),u(Gs,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.TFPreTrainedModel"),u(ks,"href","/docs/transformers/v4.30.0/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(Gt,"id","transformers.FlaxGenerationMixin"),u(Gt,"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(Gt,"href","#transformers.FlaxGenerationMixin"),u(He,"class","relative group"),u(Zs,"href","/docs/transformers/v4.30.0/en/main_classes/model#transformers.FlaxPreTrainedModel"),u(Bs,"href","/docs/transformers/v4.30.0/en/main_classes/text_generation#transformers.FlaxGenerationMixin.generate"),u(Cs,"href","../generation_strategies"),u(kt,"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(i,M){e(document.head,c),b(i,_,M),b(i,p,M),e(p,d),e(d,f),j(l,f,null),e(p,h),e(p,G),e(G,v),b(i,y,M),b(i,E,M),e(E,Z),e(E,X),e(X,le),e(E,F),b(i,q,M),b(i,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,Pn),e(Pn,Gr),e(Fe,kr),e(Fe,Kn),e(Kn,Er),e(Fe,Zr),e(S,Br),e(S,ze),e(ze,Cr),e(ze,es),e(es,Ir),e(ze,Wr),e(ze,ts),e(ts,Xr),e(ze,Nr),b(i,Fa,M),b(i,nt,M),e(nt,Rr),e(nt,ns),e(ns,Vr),e(nt,$r),b(i,za,M),b(i,st,M),e(st,Sr),e(st,ss),e(ss,Fr),e(st,zr),b(i,La,M),b(i,Le,M),e(Le,ot),e(ot,Fs),j(an,Fs,null),e(Le,Lr),e(Le,zs),e(zs,Ar),b(i,Aa,M),b(i,N,M),j(rn,N,null),e(N,Qr),e(N,ln),e(ln,Yr),e(ln,Ls),e(Ls,Dr),e(ln,Hr),e(N,Or),e(N,R),e(R,ie),e(ie,As),e(As,qr),e(ie,Pr),e(ie,os),e(os,Kr),e(ie,el),e(ie,Qs),e(Qs,tl),e(ie,nl),e(ie,Ys),e(Ys,sl),e(R,ol),e(R,ce),e(ce,Ds),e(Ds,al),e(ce,rl),e(ce,as),e(as,ll),e(ce,il),e(ce,Hs),e(Hs,cl),e(ce,dl),e(ce,Os),e(Os,pl),e(R,ml),e(R,de),e(de,qs),e(qs,gl),e(de,hl),e(de,rs),e(rs,ul),e(de,fl),e(de,Ps),e(Ps,_l),e(de,yl),e(de,Ks),e(Ks,Ml),e(R,bl),e(R,pe),e(pe,eo),e(eo,vl),e(pe,wl),e(pe,ls),e(ls,Tl),e(pe,jl),e(pe,to),e(to,Jl),e(pe,Ul),e(pe,no),e(no,xl),e(R,Gl),e(R,me),e(me,so),e(so,kl),e(me,El),e(me,is),e(is,Zl),e(me,Bl),e(me,oo),e(oo,Cl),e(me,Il),e(me,ao),e(ao,Wl),e(R,Xl),e(R,ge),e(ge,ro),e(ro,Nl),e(ge,Rl),e(ge,cs),e(cs,Vl),e(ge,$l),e(ge,lo),e(lo,Sl),e(ge,Fl),e(ge,io),e(io,zl),e(R,Ll),e(R,he),e(he,co),e(co,Al),e(he,Ql),e(he,ds),e(ds,Yl),e(he,Dl),e(he,po),e(po,Hl),e(he,Ol),e(he,mo),e(mo,ql),e(R,Pl),e(R,ue),e(ue,go),e(go,Kl),e(ue,ei),e(ue,ho),e(ho,ti),e(ue,ni),e(ue,uo),e(uo,si),e(ue,oi),e(ue,fo),e(fo,ai),e(N,ri),e(N,cn),e(cn,li),e(cn,ps),e(ps,ii),e(cn,ci),e(N,di),e(N,Ee),j(dn,Ee,null),e(Ee,pi),e(Ee,pn),e(pn,mi),e(pn,ms),e(ms,gi),e(pn,hi),e(Ee,ui),j(at,Ee,null),e(N,fi),e(N,rt),j(mn,rt,null),e(rt,_i),e(rt,O),e(O,yi),e(O,gs),e(gs,Mi),e(O,bi),e(O,hs),e(hs,vi),e(O,wi),e(O,us),e(us,Ti),e(O,ji),e(O,fs),e(fs,Ji),e(O,Ui),e(N,xi),e(N,lt),j(gn,lt,null),e(lt,Gi),e(lt,Ae),e(Ae,ki),e(Ae,_o),e(_o,Ei),e(Ae,Zi),e(Ae,_s),e(_s,Bi),e(Ae,Ci),b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ze,qc),e(Ze,So),e(So,Pc),e(Ze,Kc),j(ct,Ze,null),e(C,ed),e(C,Be),j(bn,Be,null),e(Be,td),e(Be,Fo),e(Fo,nd),e(Be,sd),j(dt,Be,null),e(C,od),e(C,K),j(vn,K,null),e(K,ad),e(K,wn),e(wn,rd),e(wn,zo),e(zo,ld),e(wn,id),e(K,cd),j(pt,K,null),e(K,dd),j(mt,K,null),e(C,pd),e(C,ee),j(Tn,ee,null),e(ee,md),e(ee,jn),e(jn,gd),e(jn,Lo),e(Lo,hd),e(jn,ud),e(ee,fd),j(gt,ee,null),e(ee,_d),j(ht,ee,null),e(C,yd),e(C,te),j(Jn,te,null),e(te,Md),e(te,Un),e(Un,bd),e(Un,Ao),e(Ao,vd),e(Un,wd),e(te,Td),j(ut,te,null),e(te,jd),j(ft,te,null),e(C,Jd),e(C,ne),j(xn,ne,null),e(ne,Ud),e(ne,Gn),e(Gn,xd),e(Gn,Qo),e(Qo,Gd),e(Gn,kd),e(ne,Ed),j(_t,ne,null),e(ne,Zd),j(yt,ne,null),e(C,Bd),e(C,se),j(kn,se,null),e(se,Cd),e(se,En),e(En,Id),e(En,Yo),e(Yo,Wd),e(En,Xd),e(se,Nd),j(Mt,se,null),e(se,Rd),j(bt,se,null),e(C,Vd),e(C,oe),j(Zn,oe,null),e(oe,$d),e(oe,Bn),e(Bn,Sd),e(Bn,Do),e(Do,Fd),e(Bn,zd),e(oe,Ld),j(vt,oe,null),e(oe,Ad),j(wt,oe,null),e(C,Qd),e(C,ae),j(Cn,ae,null),e(ae,Yd),e(ae,In),e(In,Dd),e(In,Ho),e(Ho,Hd),e(In,Od),e(ae,qd),j(Tt,ae,null),e(ae,Pd),j(jt,ae,null),b(i,Da,M),b(i,Ye,M),e(Ye,Jt),e(Jt,Oo),j(Wn,Oo,null),e(Ye,Kd),e(Ye,qo),e(qo,ep),b(i,Ha,M),b(i,V,M),j(Xn,V,null),e(V,tp),e(V,Nn),e(Nn,np),e(Nn,Gs),e(Gs,sp),e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ge,Mm),e(Ge,Ta),e(Ta,bm),e(Ge,vm),e(Ge,ja),e(ja,wm),e(Oe,Tm),e(Oe,ke),e(ke,Ja),e(Ja,jm),e(ke,Jm),e(ke,Ua),e(Ua,Um),e(ke,xm),e(ke,xa),e(xa,Gm),e(ke,km),e(ke,Ga),e(Ga,Em),e(L,Zm),e(L,Qn),e(Qn,Bm),e(Qn,Cs),e(Cs,Cm),e(Qn,Im),e(L,Wm),e(L,kt),j(Yn,kt,null),e(kt,Xm),e(kt,ka),e(ka,Nm),Pa=!0},p(i,[M]){const Dn={};M&2&&(Dn.$$scope={dirty:M,ctx:i}),at.$set(Dn);const Ea={};M&2&&(Ea.$$scope={dirty:M,ctx:i}),ct.$set(Ea);const Za={};M&2&&(Za.$$scope={dirty:M,ctx:i}),dt.$set(Za);const Ba={};M&2&&(Ba.$$scope={dirty:M,ctx:i}),pt.$set(Ba);const Hn={};M&2&&(Hn.$$scope={dirty:M,ctx:i}),mt.$set(Hn);const Ca={};M&2&&(Ca.$$scope={dirty:M,ctx:i}),gt.$set(Ca);const qe={};M&2&&(qe.$$scope={dirty:M,ctx:i}),ht.$set(qe);const Pe={};M&2&&(Pe.$$scope={dirty:M,ctx:i}),ut.$set(Pe);const Ia={};M&2&&(Ia.$$scope={dirty:M,ctx:i}),ft.$set(Ia);const Wa={};M&2&&(Wa.$$scope={dirty:M,ctx:i}),_t.$set(Wa);const Ke={};M&2&&(Ke.$$scope={dirty:M,ctx:i}),yt.$set(Ke);const Xa={};M&2&&(Xa.$$scope={dirty:M,ctx:i}),Mt.$set(Xa);const Na={};M&2&&(Na.$$scope={dirty:M,ctx:i}),bt.$set(Na);const et={};M&2&&(et.$$scope={dirty:M,ctx:i}),vt.$set(et);const Ra={};M&2&&(Ra.$$scope={dirty:M,ctx:i}),wt.$set(Ra);const Va={};M&2&&(Va.$$scope={dirty:M,ctx:i}),Tt.$set(Va);const On={};M&2&&(On.$$scope={dirty:M,ctx:i}),jt.$set(On);const $a={};M&2&&($a.$$scope={dirty:M,ctx:i}),Ut.$set($a);const qn={};M&2&&(qn.$$scope={dirty:M,ctx:i}),xt.$set(qn)},i(i){Pa||(J(l.$$.fragment,i),J(an.$$.fragment,i),J(rn.$$.fragment,i),J(dn.$$.fragment,i),J(at.$$.fragment,i),J(mn.$$.fragment,i),J(gn.$$.fragment,i),J(hn.$$.fragment,i),J(un.$$.fragment,i),J(Mn.$$.fragment,i),J(ct.$$.fragment,i),J(bn.$$.fragment,i),J(dt.$$.fragment,i),J(vn.$$.fragment,i),J(pt.$$.fragment,i),J(mt.$$.fragment,i),J(Tn.$$.fragment,i),J(gt.$$.fragment,i),J(ht.$$.fragment,i),J(Jn.$$.fragment,i),J(ut.$$.fragment,i),J(ft.$$.fragment,i),J(xn.$$.fragment,i),J(_t.$$.fragment,i),J(yt.$$.fragment,i),J(kn.$$.fragment,i),J(Mt.$$.fragment,i),J(bt.$$.fragment,i),J(Zn.$$.fragment,i),J(vt.$$.fragment,i),J(wt.$$.fragment,i),J(Cn.$$.fragment,i),J(Tt.$$.fragment,i),J(jt.$$.fragment,i),J(Wn.$$.fragment,i),J(Xn.$$.fragment,i),J($n.$$.fragment,i),J(Ut.$$.fragment,i),J(Sn.$$.fragment,i),J(xt.$$.fragment,i),J(Fn.$$.fragment,i),J(zn.$$.fragment,i),J(Yn.$$.fragment,i),Pa=!0)},o(i){U(l.$$.fragment,i),U(an.$$.fragment,i),U(rn.$$.fragment,i),U(dn.$$.fragment,i),U(at.$$.fragment,i),U(mn.$$.fragment,i),U(gn.$$.fragment,i),U(hn.$$.fragment,i),U(un.$$.fragment,i),U(Mn.$$.fragment,i),U(ct.$$.fragment,i),U(bn.$$.fragment,i),U(dt.$$.fragment,i),U(vn.$$.fragment,i),U(pt.$$.fragment,i),U(mt.$$.fragment,i),U(Tn.$$.fragment,i),U(gt.$$.fragment,i),U(ht.$$.fragment,i),U(Jn.$$.fragment,i),U(ut.$$.fragment,i),U(ft.$$.fragment,i),U(xn.$$.fragment,i),U(_t.$$.fragment,i),U(yt.$$.fragment,i),U(kn.$$.fragment,i),U(Mt.$$.fragment,i),U(bt.$$.fragment,i),U(Zn.$$.fragment,i),U(vt.$$.fragment,i),U(wt.$$.fragment,i),U(Cn.$$.fragment,i),U(Tt.$$.fragment,i),U(jt.$$.fragment,i),U(Wn.$$.fragment,i),U(Xn.$$.fragment,i),U($n.$$.fragment,i),U(Ut.$$.fragment,i),U(Sn.$$.fragment,i),U(xt.$$.fragment,i),U(Fn.$$.fragment,i),U(zn.$$.fragment,i),U(Yn.$$.fragment,i),Pa=!1},d(i){t(c),i&&t(_),i&&t(p),x(l),i&&t(y),i&&t(E),i&&t(q),i&&t(S),i&&t(Fa),i&&t(nt),i&&t(za),i&&t(st),i&&t(La),i&&t(Le),x(an),i&&t(Aa),i&&t(N),x(rn),x(dn),x(at),x(mn),x(gn),i&&t(Qa),i&&t(Qe),x(hn),i&&t(Ya),i&&t(C),x(un),x(Mn),x(ct),x(bn),x(dt),x(vn),x(pt),x(mt),x(Tn),x(gt),x(ht),x(Jn),x(ut),x(ft),x(xn),x(_t),x(yt),x(kn),x(Mt),x(bt),x(Zn),x(vt),x(wt),x(Cn),x(Tt),x(jt),i&&t(Da),i&&t(Ye),x(Wn),i&&t(Ha),i&&t(V),x(Xn),x($n),x(Ut),x(Sn),x(xt),i&&t(Oa),i&&t(He),x(Fn),i&&t(qa),i&&t(L),x(zn),x(Yn)}}}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();lu(this,c,Bu,Eu,iu,{})}}export{Vu as default,Zu as metadata};
