import{S as $l,i as Tl,s as Al,e as s,k as h,w as m,t as r,M as xl,c as o,d as a,m as c,a as n,x as d,h as i,b as u,G as t,g as p,y as g,L as ql,q as f,o as _,B as v,v as Cl}from"../chunks/vendor-hf-doc-builder.js";import{I as x}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as L}from"../chunks/CodeBlock-hf-doc-builder.js";function zl(Fr){let D,qa,F,J,bt,ke,Ys,wt,Bs,Ca,Ue,Ws,za,Q,Us,Xe,Xs,Rs,Ma,q,Et,Re,Ks,Js,jt,Ke,Qs,Vs,$t,Je,Zs,Pa,Qe,eo,Sa,V,to,Tt,ao,so,La,Ve,oo,Da,C,At,no,ro,xt,io,lo,qt,po,Fa,I,Z,Ct,be,ho,zt,co,Ia,z,uo,Ze,mo,go,Mt,fo,_o,Ga,ee,vo,Pt,yo,ko,Oa,we,Na,te,bo,St,wo,Eo,Ha,et,jo,Ya,G,ae,Lt,Ee,$o,Dt,To,Ba,M,Ao,Ft,xo,qo,It,Co,zo,Wa,je,Ua,tt,Mo,Xa,b,at,Gt,Po,So,Lo,st,Ot,Do,Fo,Io,se,Nt,Go,Oo,Ht,No,Ho,Yo,ot,Yt,Bo,Wo,Ra,O,oe,Bt,$e,Uo,Wt,Xo,Ka,nt,Ro,Ja,w,Te,Ko,rt,Jo,Qo,Vo,Ut,Zo,en,N,tn,it,an,sn,Xt,on,nn,rn,H,ln,Rt,pn,hn,Kt,cn,un,Qa,Ae,Va,E,mn,Jt,dn,gn,lt,fn,_n,pt,vn,yn,Za,xe,es,Y,ne,Qt,qe,kn,Vt,bn,ts,j,wn,Zt,En,jn,ea,$n,Tn,Ce,An,xn,as,ht,qn,ss,B,re,ta,ze,Cn,aa,zn,os,y,sa,Mn,Pn,oa,Sn,Ln,na,Dn,Fn,ra,In,Gn,ia,On,Nn,ns,Me,rs,W,ie,la,Pe,Hn,pa,Yn,is,k,Bn,Se,Wn,Un,Le,Xn,Rn,ha,Kn,Jn,ca,Qn,Vn,ls,De,ps,U,le,ua,Fe,Zn,ma,er,hs,ct,tr,cs,pe,ar,da,sr,or,us,Ie,ms,X,he,ga,Ge,nr,fa,rr,ds,ut,ir,gs,ce,lr,_a,pr,hr,fs,Oe,_s,R,ue,va,Ne,cr,ya,ur,vs,P,mr,ka,dr,gr,ba,fr,_r,ys,He,ks,K,me,wa,Ye,vr,Ea,yr,bs,$,kr,Be,br,wr,ja,Er,jr,$a,$r,Tr,ws,We,Es,T,Ar,Ta,xr,qr,Aa,Cr,zr,mt,Mr,Pr,js;return ke=new x({}),be=new x({}),we=new L({props:{code:`from transformers import AutoModelForCausalLM

model = AutoModelForCausalLM.from_pretrained("distilgpt2")
model.generation_config`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;distilgpt2&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.generation_config
GenerationConfig {
    <span class="hljs-string">&quot;_from_model_config&quot;</span>: true,
    <span class="hljs-string">&quot;bos_token_id&quot;</span>: <span class="hljs-number">50256</span>,
    <span class="hljs-string">&quot;eos_token_id&quot;</span>: <span class="hljs-number">50256</span>,
    <span class="hljs-string">&quot;transformers_version&quot;</span>: <span class="hljs-string">&quot;4.26.0.dev0&quot;</span>
}`}}),Ee=new x({}),je=new L({props:{code:"my_model.generate(**inputs, num_beams=4, do_sample=True)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>my_model.generate(**inputs, num_beams=<span class="hljs-number">4</span>, do_sample=<span class="hljs-literal">True</span>)'}}),$e=new x({}),Ae=new L({props:{code:`from transformers import AutoModelForCausalLM, GenerationConfig

model = AutoModelForCausalLM.from_pretrained("my_account/my_model")
generation_config = GenerationConfig(
    max_new_tokens=50, do_sample=True, top_k=50, eos_token_id=model.config.eos_token_id
)
generation_config.save_pretrained("my_account/my_model", push_to_hub=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, GenerationConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(<span class="hljs-string">&quot;my_account/my_model&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config = GenerationConfig(
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">50</span>, do_sample=<span class="hljs-literal">True</span>, top_k=<span class="hljs-number">50</span>, eos_token_id=model.config.eos_token_id
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config.save_pretrained(<span class="hljs-string">&quot;my_account/my_model&quot;</span>, push_to_hub=<span class="hljs-literal">True</span>)`}}),xe=new L({props:{code:`from transformers import AutoModelForSeq2SeqLM, AutoTokenizer, GenerationConfig

tokenizer = AutoTokenizer.from_pretrained("t5-small")
model = AutoModelForSeq2SeqLM.from_pretrained("t5-small")

translation_generation_config = GenerationConfig(
    num_beams=4,
    early_stopping=True,
    decoder_start_token_id=0,
    eos_token_id=model.config.eos_token_id,
    pad_token=model.config.pad_token_id,
)

translation_generation_config.save_pretrained("t5-small", "translation_generation_config.json", push_to_hub=True)

# You could then use the named generation config file to parameterize generation
generation_config = GenerationConfig.from_pretrained("t5-small", "translation_generation_config.json")
inputs = tokenizer("translate English to French: Configuration files are easy to use!", return_tensors="pt")
outputs = model.generate(**inputs, generation_config=generation_config)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True))`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, AutoTokenizer, GenerationConfig

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

<span class="hljs-meta">&gt;&gt;&gt; </span>translation_generation_config = GenerationConfig(
<span class="hljs-meta">... </span>    num_beams=<span class="hljs-number">4</span>,
<span class="hljs-meta">... </span>    early_stopping=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    decoder_start_token_id=<span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>    eos_token_id=model.config.eos_token_id,
<span class="hljs-meta">... </span>    pad_token=model.config.pad_token_id,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>translation_generation_config.save_pretrained(<span class="hljs-string">&quot;t5-small&quot;</span>, <span class="hljs-string">&quot;translation_generation_config.json&quot;</span>, push_to_hub=<span class="hljs-literal">True</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># You could then use the named generation config file to parameterize generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generation_config = GenerationConfig.from_pretrained(<span class="hljs-string">&quot;t5-small&quot;</span>, <span class="hljs-string">&quot;translation_generation_config.json&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;translate English to French: Configuration files are easy to use!&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, generation_config=generation_config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>))
[<span class="hljs-string">&#x27;Les fichiers de configuration sont faciles \xE0 utiliser !&#x27;</span>]`}}),qe=new x({}),ze=new x({}),Me=new L({props:{code:`from transformers import AutoModelForCausalLM, AutoTokenizer

prompt = "I look forward to"
checkpoint = "distilgpt2"

tokenizer = AutoTokenizer.from_pretrained(checkpoint)
inputs = tokenizer(prompt, return_tensors="pt")

model = AutoModelForCausalLM.from_pretrained(checkpoint)
outputs = model.generate(**inputs)
tokenizer.batch_decode(outputs, skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;I look forward to&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;distilgpt2&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs)
<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;I look forward to seeing you all again!\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n&#x27;</span>]`}}),Pe=new x({}),De=new L({props:{code:`from transformers import AutoTokenizer, AutoModelForCausalLM

checkpoint = "gpt2-large"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint)

prompt = "Hugging Face Company is"
inputs = tokenizer(prompt, return_tensors="pt")

outputs = model.generate(**inputs, penalty_alpha=0.6, top_k=4, max_new_tokens=100)
tokenizer.batch_decode(outputs, skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM

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

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Hugging Face Company is&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, penalty_alpha=<span class="hljs-number">0.6</span>, top_k=<span class="hljs-number">4</span>, max_new_tokens=<span class="hljs-number">100</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;Hugging Face Company is a family owned and operated business. \\
We pride ourselves on being the best in the business and our customer service is second to none.\\
\\n\\nIf you have any questions about our products or services, feel free to contact us at any time.\\
 We look forward to hearing from you!&#x27;</span>]`}}),Fe=new x({}),Ie=new L({props:{code:`from transformers import AutoTokenizer, AutoModelForCausalLM

checkpoint = "gpt2-large"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint)

prompt = "Today was an amazing day because"
inputs = tokenizer(prompt, return_tensors="pt")

outputs = model.generate(**inputs, do_sample=True, max_new_tokens=100)
tokenizer.batch_decode(outputs, skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM

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

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;Today was an amazing day because&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, do_sample=<span class="hljs-literal">True</span>, max_new_tokens=<span class="hljs-number">100</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 was an amazing day because we are now in the final stages of our trip to New York City which was very tough. \\
It is a difficult schedule and a challenging part of the year but still worth it. I have been taking things easier and \\
I feel stronger and more motivated to be out there on their tour. Hopefully, that experience is going to help them with \\
their upcoming events which are currently scheduled in Australia.\\n\\nWe love that they are here. They want to make a \\
name for themselves and become famous for what they&#x27;</span>]`}}),Ge=new x({}),Oe=new L({props:{code:`from transformers import AutoModelForCausalLM, AutoTokenizer

prompt = "It is astonishing how one can"
checkpoint = "gpt2-medium"

tokenizer = AutoTokenizer.from_pretrained(checkpoint)
inputs = tokenizer(prompt, return_tensors="pt")

model = AutoModelForCausalLM.from_pretrained(checkpoint)

outputs = model.generate(**inputs, num_beams=5, max_new_tokens=50)
tokenizer.batch_decode(outputs, skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;It is astonishing how one can&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;gpt2-medium&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForCausalLM.from_pretrained(checkpoint)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, num_beams=<span class="hljs-number">5</span>, max_new_tokens=<span class="hljs-number">50</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;It is astonishing how one can have such a profound impact on the lives of so many people in such a short period of \\
time.&quot;\\n\\nHe added: &quot;I am very proud of the work I have been able to do in the last few years.\\n\\n&quot;I have&#x27;</span>]`}}),Ne=new x({}),He=new L({props:{code:`from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

prompt = "translate English to German: The house is wonderful."
checkpoint = "t5-small"

tokenizer = AutoTokenizer.from_pretrained(checkpoint)
inputs = tokenizer(prompt, return_tensors="pt")

model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)

outputs = model.generate(**inputs, num_beams=5, do_sample=True)
tokenizer.decode(outputs[0], skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;translate English to German: The house is wonderful.&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;t5-small&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, num_beams=<span class="hljs-number">5</span>, do_sample=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;Das Haus ist wunderbar.&#x27;</span>`}}),Ye=new x({}),We=new L({props:{code:`from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

checkpoint = "google/pegasus-xsum"
prompt = "The Permaculture Design Principles are a set of universal design principles \\
that can be applied to any location, climate and culture, and they allow us to design \\
the most efficient and sustainable human habitation and food production systems. \\
Permaculture is a design system that encompasses a wide variety of disciplines, such \\
as ecology, landscape design, environmental science and energy conservation, and the \\
Permaculture design principles are drawn from these various disciplines. Each individual \\
design principle itself embodies a complete conceptual framework based on sound \\
scientific principles. When we bring all these separate  principles together, we can \\
create a design system that both looks at whole systems, the parts that these systems \\
consist of, and how those parts interact with each other to create a complex, dynamic, \\
living system. Each design principle serves as a tool that allows us to integrate all \\
the separate parts of a design, referred to as elements, into a functional, synergistic, \\
whole system, where the elements harmoniously interact and work together in the most \\
efficient way possible."

tokenizer = AutoTokenizer.from_pretrained(checkpoint)
inputs = tokenizer(prompt, return_tensors="pt")

model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)

outputs = model.generate(**inputs, num_beams=5, num_beam_groups=5, max_new_tokens=30)
tokenizer.decode(outputs[0], skip_special_tokens=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSeq2SeqLM

<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;google/pegasus-xsum&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;The Permaculture Design Principles are a set of universal design principles \\
&gt;&gt;&gt; that can be applied to any location, climate and culture, and they allow us to design \\
&gt;&gt;&gt; the most efficient and sustainable human habitation and food production systems. \\
&gt;&gt;&gt; Permaculture is a design system that encompasses a wide variety of disciplines, such \\
&gt;&gt;&gt; as ecology, landscape design, environmental science and energy conservation, and the \\
&gt;&gt;&gt; Permaculture design principles are drawn from these various disciplines. Each individual \\
&gt;&gt;&gt; design principle itself embodies a complete conceptual framework based on sound \\
&gt;&gt;&gt; scientific principles. When we bring all these separate  principles together, we can \\
&gt;&gt;&gt; create a design system that both looks at whole systems, the parts that these systems \\
&gt;&gt;&gt; consist of, and how those parts interact with each other to create a complex, dynamic, \\
&gt;&gt;&gt; living system. Each design principle serves as a tool that allows us to integrate all \\
&gt;&gt;&gt; the separate parts of a design, referred to as elements, into a functional, synergistic, \\
&gt;&gt;&gt; whole system, where the elements harmoniously interact and work together in the most \\
&gt;&gt;&gt; efficient way possible.&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint)

<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, num_beams=<span class="hljs-number">5</span>, num_beam_groups=<span class="hljs-number">5</span>, max_new_tokens=<span class="hljs-number">30</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.decode(outputs[<span class="hljs-number">0</span>], skip_special_tokens=<span class="hljs-literal">True</span>)
<span class="hljs-string">&#x27;The Design Principles are a set of universal design principles that can be applied to any location, climate and culture, and they allow us to design the most efficient and sustainable human habitation and food production systems.&#x27;</span>`}}),{c(){D=s("meta"),qa=h(),F=s("h1"),J=s("a"),bt=s("span"),m(ke.$$.fragment),Ys=h(),wt=s("span"),Bs=r("Text generation strategies"),Ca=h(),Ue=s("p"),Ws=r(`Text generation is essential to many NLP tasks, such as open-ended text generation, summarization, translation, and
more. It also plays a role in a variety of mixed-modality applications that have text as an output like speech-to-text
and vision-to-text. Some of the models that can generate text include
GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper.`),za=h(),Q=s("p"),Us=r("Check out a few examples that use "),Xe=s("a"),Xs=r("generate()"),Rs=r(` method to produce
text outputs for different tasks:`),Ma=h(),q=s("ul"),Et=s("li"),Re=s("a"),Ks=r("Text summarization"),Js=h(),jt=s("li"),Ke=s("a"),Qs=r("Image captioning"),Vs=h(),$t=s("li"),Je=s("a"),Zs=r("Audio transcription"),Pa=h(),Qe=s("p"),eo=r(`Note that the inputs to the generate method depend on the model\u2019s modality. They are returned by the model\u2019s preprocessor
class, such as AutoTokenizer or AutoProcessor. If a model\u2019s preprocessor creates more than one kind of input, pass all
the inputs to generate(). You can learn more about the individual model\u2019s preprocessor in the corresponding model\u2019s documentation.`),Sa=h(),V=s("p"),to=r(`The process of selecting output tokens to generate text is known as decoding, and you can customize the decoding strategy
that the `),Tt=s("code"),ao=r("generate()"),so=r(` method will use. Modifying a decoding strategy does not change the values of any trainable parameters.
However, it can have a noticeable impact on the quality of the generated output. It can help reduce repetition in the text
and make it more coherent.`),La=h(),Ve=s("p"),oo=r("This guide describes:"),Da=h(),C=s("ul"),At=s("li"),no=r("default generation configuration"),ro=h(),xt=s("li"),io=r("common decoding strategies and their main parameters"),lo=h(),qt=s("li"),po=r("saving and sharing custom generation configurations with your fine-tuned model on \u{1F917} Hub"),Fa=h(),I=s("h2"),Z=s("a"),Ct=s("span"),m(be.$$.fragment),ho=h(),zt=s("span"),co=r("Default text generation configuration"),Ia=h(),z=s("p"),uo=r(`A decoding strategy for a model is defined in its generation configuration. When using pre-trained models for inference
within a `),Ze=s("a"),mo=r("pipeline()"),go=r(", the models call the "),Mt=s("code"),fo=r("PreTrainedModel.generate()"),_o=r(` method that applies a default generation
configuration under the hood. The default configuration is also used when no custom configuration has been saved with
the model.`),Ga=h(),ee=s("p"),vo=r(`When you load a model explicitly, you can inspect the generation configuration that comes with it through
`),Pt=s("code"),yo=r("model.generation_config"),ko=r(":"),Oa=h(),m(we.$$.fragment),Na=h(),te=s("p"),bo=r("Printing out the "),St=s("code"),wo=r("model.generation_config"),Eo=r(` reveals only the values that are different from the default generation
configuration, and does not list any of the default values.`),Ha=h(),et=s("p"),jo=r(`The default generation configuration limits the size of the output combined with the input prompt to a maximum of 20
tokens to avoid running into resource limitations. The default decoding strategy is greedy search, which is the simplest decoding strategy that picks a token with the highest probability as the next token. For many tasks
and small output sizes this works well. However, when used to generate longer outputs, greedy search can start
producing highly repetitive results.`),Ya=h(),G=s("h2"),ae=s("a"),Lt=s("span"),m(Ee.$$.fragment),$o=h(),Dt=s("span"),To=r("Customize text generation"),Ba=h(),M=s("p"),Ao=r("You can override any "),Ft=s("code"),xo=r("generation_config"),qo=r(" by passing the parameters and their values directly to the "),It=s("code"),Co=r("generate"),zo=r(" method:"),Wa=h(),m(je.$$.fragment),Ua=h(),tt=s("p"),Mo=r(`Even if the default decoding strategy mostly works for your task, you can still tweak a few things. Some of the
commonly adjusted parameters include:`),Xa=h(),b=s("ul"),at=s("li"),Gt=s("code"),Po=r("max_new_tokens"),So=r(`: the maximum number of tokens to generate. In other words, the size of the output sequence, not
including the tokens in the prompt.`),Lo=h(),st=s("li"),Ot=s("code"),Do=r("num_beams"),Fo=r(`: by specifying a number of beams higher than 1, you are effectively switching from greedy search to
beam search. This strategy evaluates several hypotheses at each time step and eventually chooses the hypothesis that
has the overall highest probability for the entire sequence. This has the advantage of identifying high-probability
sequences that start with a lower probability initial tokens and would\u2019ve been ignored by the greedy search.`),Io=h(),se=s("li"),Nt=s("code"),Go=r("do_sample"),Oo=r(": if set to "),Ht=s("code"),No=r("True"),Ho=r(`, this parameter enables decoding strategies such as multinomial sampling, beam-search
multinomial sampling, Top-K sampling and Top-p sampling. All these strategies select the next token from the probability
distribution over the entire vocabulary with various strategy-specific adjustments.`),Yo=h(),ot=s("li"),Yt=s("code"),Bo=r("num_return_sequences"),Wo=r(`: the number of sequence candidates to return for each input. This options is only available for
the decoding strategies that support multiple sequence candidates, e.g. variations of beam search and sampling. Decoding
strategies like greedy search and contrastive search return a single output sequence.`),Ra=h(),O=s("h2"),oe=s("a"),Bt=s("span"),m($e.$$.fragment),Uo=h(),Wt=s("span"),Xo=r("Save a custom decoding strategy with your model"),Ka=h(),nt=s("p"),Ro=r("If you would like to share your fine-tuned model with a specific generation configuration, you can:"),Ja=h(),w=s("ul"),Te=s("li"),Ko=r("Create a "),rt=s("a"),Jo=r("GenerationConfig"),Qo=r(" class instance"),Vo=h(),Ut=s("li"),Zo=r("Specify the decoding strategy parameters"),en=h(),N=s("li"),tn=r("Save your generation configuration with "),it=s("a"),an=r("GenerationConfig.save_pretrained()"),sn=r(", making sure to leave its "),Xt=s("code"),on=r("config_file_name"),nn=r(" argument empty"),rn=h(),H=s("li"),ln=r("Set "),Rt=s("code"),pn=r("push_to_hub"),hn=r(" to "),Kt=s("code"),cn=r("True"),un=r(" to upload your config to the model\u2019s repo"),Qa=h(),m(Ae.$$.fragment),Va=h(),E=s("p"),mn=r("You can also store several generation configurations in a single directory, making use of the "),Jt=s("code"),dn=r("config_file_name"),gn=r(`
argument in `),lt=s("a"),fn=r("GenerationConfig.save_pretrained()"),_n=r(". You can later instantiate them with "),pt=s("a"),vn=r("GenerationConfig.from_pretrained()"),yn=r(`. This is useful if you want to
store several generation configurations for a single model (e.g. one for creative text generation with sampling, and
one for summarization with beam search). You must have the right Hub permissions to add configuration files to a model.`),Za=h(),m(xe.$$.fragment),es=h(),Y=s("h2"),ne=s("a"),Qt=s("span"),m(qe.$$.fragment),kn=h(),Vt=s("span"),bn=r("Decoding strategies"),ts=h(),j=s("p"),wn=r("Certain combinations of the "),Zt=s("code"),En=r("generate()"),jn=r(" parameters, and ultimately "),ea=s("code"),$n=r("generation_config"),Tn=r(`, can be used to enable specific
decoding strategies. If you are new to this concept, we recommend reading `),Ce=s("a"),An=r("this blog post that illustrates how common decoding strategies work"),xn=r("."),as=h(),ht=s("p"),qn=r("Here, we\u2019ll show some of the parameters that control the decoding strategies and illustrate how you can use them."),ss=h(),B=s("h3"),re=s("a"),ta=s("span"),m(ze.$$.fragment),Cn=h(),aa=s("span"),zn=r("Greedy Search"),os=h(),y=s("p"),sa=s("code"),Mn=r("generate"),Pn=r(" uses greedy search decoding by default so you don\u2019t have to pass any parameters to enable it. This means the parameters "),oa=s("code"),Sn=r("num_beams"),Ln=r(" is set to 1 and "),na=s("code"),Dn=r("do_sample=False"),Fn=r(`.
`),ra=s("code"),In=r("do_sample=False"),Gn=r(". Because it is a default strategy, you do not have to pass any parameters to "),ia=s("code"),On=r("generate()"),Nn=r(" method to enable it."),ns=h(),m(Me.$$.fragment),rs=h(),W=s("h3"),ie=s("a"),la=s("span"),m(Pe.$$.fragment),Hn=h(),pa=s("span"),Yn=r("Contrastive search"),is=h(),k=s("p"),Bn=r("The contrastive search decoding strategy was proposed in the 2022 paper "),Se=s("a"),Wn=r("A Contrastive Framework for Neural Text Generation"),Un=r(`.
It demonstrates superior results for generating non-repetitive yet coherent long outputs. To learn how contrastive search
works, check out `),Le=s("a"),Xn=r("this blog post"),Rn=r(`.
The two main parameters that enable and control the behavior of contrastive search are `),ha=s("code"),Kn=r("penalty_alpha"),Jn=r(" and "),ca=s("code"),Qn=r("top_k"),Vn=r(":"),ls=h(),m(De.$$.fragment),ps=h(),U=s("h3"),le=s("a"),ua=s("span"),m(Fe.$$.fragment),Zn=h(),ma=s("span"),er=r("Multinomial sampling"),hs=h(),ct=s("p"),tr=r(`As opposed to greedy search that always chooses a token with the highest probability as the
next token, multinomial sampling randomly selects the next token based on the probability distribution over the entire
vocabulary given by the model. Every token with a non-zero probability has a chance of being selected, thus reducing the
risk of repetition.`),cs=h(),pe=s("p"),ar=r("To enable multinomial sampling set "),da=s("code"),sr=r("do_sample=True"),or=r("."),us=h(),m(Ie.$$.fragment),ms=h(),X=s("h3"),he=s("a"),ga=s("span"),m(Ge.$$.fragment),nr=h(),fa=s("span"),rr=r("Beam-search decoding"),ds=h(),ut=s("p"),ir=r(`Unlike greedy search, beam-search decoding keeps several hypotheses at each time step and eventually chooses
the hypothesis that has the overall highest probability for the entire sequence. This has the advantage of identifying high-probability
sequences that start with lower probability initial tokens and would\u2019ve been ignored by the greedy search.`),gs=h(),ce=s("p"),lr=r("To enable this decoding strategy, specify the "),_a=s("code"),pr=r("num_beams"),hr=r(" (aka number of hypotheses to keep track of) that is greater than 1."),fs=h(),m(Oe.$$.fragment),_s=h(),R=s("h3"),ue=s("a"),va=s("span"),m(Ne.$$.fragment),cr=h(),ya=s("span"),ur=r("Beam-search multinomial sampling"),vs=h(),P=s("p"),mr=r(`As the name implies, this decoding strategy combines beam search with multinomial sampling. You need to specify
the `),ka=s("code"),dr=r("num_beams"),gr=r(" greater than 1, and set "),ba=s("code"),fr=r("do_sample=True"),_r=r(" to use this decoding strategy."),ys=h(),m(He.$$.fragment),ks=h(),K=s("h3"),me=s("a"),wa=s("span"),m(Ye.$$.fragment),vr=h(),Ea=s("span"),yr=r("Diverse beam search decoding"),bs=h(),$=s("p"),kr=r(`The diverse beam search decoding strategy is an extension of the beam search strategy that allows for generating a more diverse
set of beam sequences to choose from. To learn how it works, refer to `),Be=s("a"),br=r("Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models"),wr=r(`.
This approach has two main parameters: `),ja=s("code"),Er=r("num_beams"),jr=r(" and "),$a=s("code"),$r=r("num_beam_groups"),Tr=r(`.
The groups are selected to ensure they are distinct enough compared to the others, and regular beam search is used within each group.`),ws=h(),m(We.$$.fragment),Es=h(),T=s("p"),Ar=r(`This guide illustrates the main parameters that enable various decoding strategies. More advanced parameters exist for the
`),Ta=s("code"),xr=r("generate"),qr=r(" method, which gives you even further control over the "),Aa=s("code"),Cr=r("generate"),zr=r(` method\u2019s behavior.
For the complete list of the available parameters, refer to the `),mt=s("a"),Mr=r("API documentation"),Pr=r("."),this.h()},l(e){const l=xl('[data-svelte="svelte-1phssyn"]',document.head);D=o(l,"META",{name:!0,content:!0}),l.forEach(a),qa=c(e),F=o(e,"H1",{class:!0});var $s=n(F);J=o($s,"A",{id:!0,class:!0,href:!0});var Ir=n(J);bt=o(Ir,"SPAN",{});var Gr=n(bt);d(ke.$$.fragment,Gr),Gr.forEach(a),Ir.forEach(a),Ys=c($s),wt=o($s,"SPAN",{});var Or=n(wt);Bs=i(Or,"Text generation strategies"),Or.forEach(a),$s.forEach(a),Ca=c(e),Ue=o(e,"P",{});var Nr=n(Ue);Ws=i(Nr,`Text generation is essential to many NLP tasks, such as open-ended text generation, summarization, translation, and
more. It also plays a role in a variety of mixed-modality applications that have text as an output like speech-to-text
and vision-to-text. Some of the models that can generate text include
GPT2, XLNet, OpenAI GPT, CTRL, TransformerXL, XLM, Bart, T5, GIT, Whisper.`),Nr.forEach(a),za=c(e),Q=o(e,"P",{});var Ts=n(Q);Us=i(Ts,"Check out a few examples that use "),Xe=o(Ts,"A",{href:!0});var Hr=n(Xe);Xs=i(Hr,"generate()"),Hr.forEach(a),Rs=i(Ts,` method to produce
text outputs for different tasks:`),Ts.forEach(a),Ma=c(e),q=o(e,"UL",{});var dt=n(q);Et=o(dt,"LI",{});var Yr=n(Et);Re=o(Yr,"A",{href:!0});var Br=n(Re);Ks=i(Br,"Text summarization"),Br.forEach(a),Yr.forEach(a),Js=c(dt),jt=o(dt,"LI",{});var Wr=n(jt);Ke=o(Wr,"A",{href:!0});var Ur=n(Ke);Qs=i(Ur,"Image captioning"),Ur.forEach(a),Wr.forEach(a),Vs=c(dt),$t=o(dt,"LI",{});var Xr=n($t);Je=o(Xr,"A",{href:!0});var Rr=n(Je);Zs=i(Rr,"Audio transcription"),Rr.forEach(a),Xr.forEach(a),dt.forEach(a),Pa=c(e),Qe=o(e,"P",{});var Kr=n(Qe);eo=i(Kr,`Note that the inputs to the generate method depend on the model\u2019s modality. They are returned by the model\u2019s preprocessor
class, such as AutoTokenizer or AutoProcessor. If a model\u2019s preprocessor creates more than one kind of input, pass all
the inputs to generate(). You can learn more about the individual model\u2019s preprocessor in the corresponding model\u2019s documentation.`),Kr.forEach(a),Sa=c(e),V=o(e,"P",{});var As=n(V);to=i(As,`The process of selecting output tokens to generate text is known as decoding, and you can customize the decoding strategy
that the `),Tt=o(As,"CODE",{});var Jr=n(Tt);ao=i(Jr,"generate()"),Jr.forEach(a),so=i(As,` method will use. Modifying a decoding strategy does not change the values of any trainable parameters.
However, it can have a noticeable impact on the quality of the generated output. It can help reduce repetition in the text
and make it more coherent.`),As.forEach(a),La=c(e),Ve=o(e,"P",{});var Qr=n(Ve);oo=i(Qr,"This guide describes:"),Qr.forEach(a),Da=c(e),C=o(e,"UL",{});var gt=n(C);At=o(gt,"LI",{});var Vr=n(At);no=i(Vr,"default generation configuration"),Vr.forEach(a),ro=c(gt),xt=o(gt,"LI",{});var Zr=n(xt);io=i(Zr,"common decoding strategies and their main parameters"),Zr.forEach(a),lo=c(gt),qt=o(gt,"LI",{});var ei=n(qt);po=i(ei,"saving and sharing custom generation configurations with your fine-tuned model on \u{1F917} Hub"),ei.forEach(a),gt.forEach(a),Fa=c(e),I=o(e,"H2",{class:!0});var xs=n(I);Z=o(xs,"A",{id:!0,class:!0,href:!0});var ti=n(Z);Ct=o(ti,"SPAN",{});var ai=n(Ct);d(be.$$.fragment,ai),ai.forEach(a),ti.forEach(a),ho=c(xs),zt=o(xs,"SPAN",{});var si=n(zt);co=i(si,"Default text generation configuration"),si.forEach(a),xs.forEach(a),Ia=c(e),z=o(e,"P",{});var ft=n(z);uo=i(ft,`A decoding strategy for a model is defined in its generation configuration. When using pre-trained models for inference
within a `),Ze=o(ft,"A",{href:!0});var oi=n(Ze);mo=i(oi,"pipeline()"),oi.forEach(a),go=i(ft,", the models call the "),Mt=o(ft,"CODE",{});var ni=n(Mt);fo=i(ni,"PreTrainedModel.generate()"),ni.forEach(a),_o=i(ft,` method that applies a default generation
configuration under the hood. The default configuration is also used when no custom configuration has been saved with
the model.`),ft.forEach(a),Ga=c(e),ee=o(e,"P",{});var qs=n(ee);vo=i(qs,`When you load a model explicitly, you can inspect the generation configuration that comes with it through
`),Pt=o(qs,"CODE",{});var ri=n(Pt);yo=i(ri,"model.generation_config"),ri.forEach(a),ko=i(qs,":"),qs.forEach(a),Oa=c(e),d(we.$$.fragment,e),Na=c(e),te=o(e,"P",{});var Cs=n(te);bo=i(Cs,"Printing out the "),St=o(Cs,"CODE",{});var ii=n(St);wo=i(ii,"model.generation_config"),ii.forEach(a),Eo=i(Cs,` reveals only the values that are different from the default generation
configuration, and does not list any of the default values.`),Cs.forEach(a),Ha=c(e),et=o(e,"P",{});var li=n(et);jo=i(li,`The default generation configuration limits the size of the output combined with the input prompt to a maximum of 20
tokens to avoid running into resource limitations. The default decoding strategy is greedy search, which is the simplest decoding strategy that picks a token with the highest probability as the next token. For many tasks
and small output sizes this works well. However, when used to generate longer outputs, greedy search can start
producing highly repetitive results.`),li.forEach(a),Ya=c(e),G=o(e,"H2",{class:!0});var zs=n(G);ae=o(zs,"A",{id:!0,class:!0,href:!0});var pi=n(ae);Lt=o(pi,"SPAN",{});var hi=n(Lt);d(Ee.$$.fragment,hi),hi.forEach(a),pi.forEach(a),$o=c(zs),Dt=o(zs,"SPAN",{});var ci=n(Dt);To=i(ci,"Customize text generation"),ci.forEach(a),zs.forEach(a),Ba=c(e),M=o(e,"P",{});var _t=n(M);Ao=i(_t,"You can override any "),Ft=o(_t,"CODE",{});var ui=n(Ft);xo=i(ui,"generation_config"),ui.forEach(a),qo=i(_t," by passing the parameters and their values directly to the "),It=o(_t,"CODE",{});var mi=n(It);Co=i(mi,"generate"),mi.forEach(a),zo=i(_t," method:"),_t.forEach(a),Wa=c(e),d(je.$$.fragment,e),Ua=c(e),tt=o(e,"P",{});var di=n(tt);Mo=i(di,`Even if the default decoding strategy mostly works for your task, you can still tweak a few things. Some of the
commonly adjusted parameters include:`),di.forEach(a),Xa=c(e),b=o(e,"UL",{});var de=n(b);at=o(de,"LI",{});var Sr=n(at);Gt=o(Sr,"CODE",{});var gi=n(Gt);Po=i(gi,"max_new_tokens"),gi.forEach(a),So=i(Sr,`: the maximum number of tokens to generate. In other words, the size of the output sequence, not
including the tokens in the prompt.`),Sr.forEach(a),Lo=c(de),st=o(de,"LI",{});var Lr=n(st);Ot=o(Lr,"CODE",{});var fi=n(Ot);Do=i(fi,"num_beams"),fi.forEach(a),Fo=i(Lr,`: by specifying a number of beams higher than 1, you are effectively switching from greedy search to
beam search. This strategy evaluates several hypotheses at each time step and eventually chooses the hypothesis that
has the overall highest probability for the entire sequence. This has the advantage of identifying high-probability
sequences that start with a lower probability initial tokens and would\u2019ve been ignored by the greedy search.`),Lr.forEach(a),Io=c(de),se=o(de,"LI",{});var xa=n(se);Nt=o(xa,"CODE",{});var _i=n(Nt);Go=i(_i,"do_sample"),_i.forEach(a),Oo=i(xa,": if set to "),Ht=o(xa,"CODE",{});var vi=n(Ht);No=i(vi,"True"),vi.forEach(a),Ho=i(xa,`, this parameter enables decoding strategies such as multinomial sampling, beam-search
multinomial sampling, Top-K sampling and Top-p sampling. All these strategies select the next token from the probability
distribution over the entire vocabulary with various strategy-specific adjustments.`),xa.forEach(a),Yo=c(de),ot=o(de,"LI",{});var Dr=n(ot);Yt=o(Dr,"CODE",{});var yi=n(Yt);Bo=i(yi,"num_return_sequences"),yi.forEach(a),Wo=i(Dr,`: the number of sequence candidates to return for each input. This options is only available for
the decoding strategies that support multiple sequence candidates, e.g. variations of beam search and sampling. Decoding
strategies like greedy search and contrastive search return a single output sequence.`),Dr.forEach(a),de.forEach(a),Ra=c(e),O=o(e,"H2",{class:!0});var Ms=n(O);oe=o(Ms,"A",{id:!0,class:!0,href:!0});var ki=n(oe);Bt=o(ki,"SPAN",{});var bi=n(Bt);d($e.$$.fragment,bi),bi.forEach(a),ki.forEach(a),Uo=c(Ms),Wt=o(Ms,"SPAN",{});var wi=n(Wt);Xo=i(wi,"Save a custom decoding strategy with your model"),wi.forEach(a),Ms.forEach(a),Ka=c(e),nt=o(e,"P",{});var Ei=n(nt);Ro=i(Ei,"If you would like to share your fine-tuned model with a specific generation configuration, you can:"),Ei.forEach(a),Ja=c(e),w=o(e,"UL",{});var ge=n(w);Te=o(ge,"LI",{});var Ps=n(Te);Ko=i(Ps,"Create a "),rt=o(Ps,"A",{href:!0});var ji=n(rt);Jo=i(ji,"GenerationConfig"),ji.forEach(a),Qo=i(Ps," class instance"),Ps.forEach(a),Vo=c(ge),Ut=o(ge,"LI",{});var $i=n(Ut);Zo=i($i,"Specify the decoding strategy parameters"),$i.forEach(a),en=c(ge),N=o(ge,"LI",{});var vt=n(N);tn=i(vt,"Save your generation configuration with "),it=o(vt,"A",{href:!0});var Ti=n(it);an=i(Ti,"GenerationConfig.save_pretrained()"),Ti.forEach(a),sn=i(vt,", making sure to leave its "),Xt=o(vt,"CODE",{});var Ai=n(Xt);on=i(Ai,"config_file_name"),Ai.forEach(a),nn=i(vt," argument empty"),vt.forEach(a),rn=c(ge),H=o(ge,"LI",{});var yt=n(H);ln=i(yt,"Set "),Rt=o(yt,"CODE",{});var xi=n(Rt);pn=i(xi,"push_to_hub"),xi.forEach(a),hn=i(yt," to "),Kt=o(yt,"CODE",{});var qi=n(Kt);cn=i(qi,"True"),qi.forEach(a),un=i(yt," to upload your config to the model\u2019s repo"),yt.forEach(a),ge.forEach(a),Qa=c(e),d(Ae.$$.fragment,e),Va=c(e),E=o(e,"P",{});var fe=n(E);mn=i(fe,"You can also store several generation configurations in a single directory, making use of the "),Jt=o(fe,"CODE",{});var Ci=n(Jt);dn=i(Ci,"config_file_name"),Ci.forEach(a),gn=i(fe,`
argument in `),lt=o(fe,"A",{href:!0});var zi=n(lt);fn=i(zi,"GenerationConfig.save_pretrained()"),zi.forEach(a),_n=i(fe,". You can later instantiate them with "),pt=o(fe,"A",{href:!0});var Mi=n(pt);vn=i(Mi,"GenerationConfig.from_pretrained()"),Mi.forEach(a),yn=i(fe,`. This is useful if you want to
store several generation configurations for a single model (e.g. one for creative text generation with sampling, and
one for summarization with beam search). You must have the right Hub permissions to add configuration files to a model.`),fe.forEach(a),Za=c(e),d(xe.$$.fragment,e),es=c(e),Y=o(e,"H2",{class:!0});var Ss=n(Y);ne=o(Ss,"A",{id:!0,class:!0,href:!0});var Pi=n(ne);Qt=o(Pi,"SPAN",{});var Si=n(Qt);d(qe.$$.fragment,Si),Si.forEach(a),Pi.forEach(a),kn=c(Ss),Vt=o(Ss,"SPAN",{});var Li=n(Vt);bn=i(Li,"Decoding strategies"),Li.forEach(a),Ss.forEach(a),ts=c(e),j=o(e,"P",{});var _e=n(j);wn=i(_e,"Certain combinations of the "),Zt=o(_e,"CODE",{});var Di=n(Zt);En=i(Di,"generate()"),Di.forEach(a),jn=i(_e," parameters, and ultimately "),ea=o(_e,"CODE",{});var Fi=n(ea);$n=i(Fi,"generation_config"),Fi.forEach(a),Tn=i(_e,`, can be used to enable specific
decoding strategies. If you are new to this concept, we recommend reading `),Ce=o(_e,"A",{href:!0,rel:!0});var Ii=n(Ce);An=i(Ii,"this blog post that illustrates how common decoding strategies work"),Ii.forEach(a),xn=i(_e,"."),_e.forEach(a),as=c(e),ht=o(e,"P",{});var Gi=n(ht);qn=i(Gi,"Here, we\u2019ll show some of the parameters that control the decoding strategies and illustrate how you can use them."),Gi.forEach(a),ss=c(e),B=o(e,"H3",{class:!0});var Ls=n(B);re=o(Ls,"A",{id:!0,class:!0,href:!0});var Oi=n(re);ta=o(Oi,"SPAN",{});var Ni=n(ta);d(ze.$$.fragment,Ni),Ni.forEach(a),Oi.forEach(a),Cn=c(Ls),aa=o(Ls,"SPAN",{});var Hi=n(aa);zn=i(Hi,"Greedy Search"),Hi.forEach(a),Ls.forEach(a),os=c(e),y=o(e,"P",{});var A=n(y);sa=o(A,"CODE",{});var Yi=n(sa);Mn=i(Yi,"generate"),Yi.forEach(a),Pn=i(A," uses greedy search decoding by default so you don\u2019t have to pass any parameters to enable it. This means the parameters "),oa=o(A,"CODE",{});var Bi=n(oa);Sn=i(Bi,"num_beams"),Bi.forEach(a),Ln=i(A," is set to 1 and "),na=o(A,"CODE",{});var Wi=n(na);Dn=i(Wi,"do_sample=False"),Wi.forEach(a),Fn=i(A,`.
`),ra=o(A,"CODE",{});var Ui=n(ra);In=i(Ui,"do_sample=False"),Ui.forEach(a),Gn=i(A,". Because it is a default strategy, you do not have to pass any parameters to "),ia=o(A,"CODE",{});var Xi=n(ia);On=i(Xi,"generate()"),Xi.forEach(a),Nn=i(A," method to enable it."),A.forEach(a),ns=c(e),d(Me.$$.fragment,e),rs=c(e),W=o(e,"H3",{class:!0});var Ds=n(W);ie=o(Ds,"A",{id:!0,class:!0,href:!0});var Ri=n(ie);la=o(Ri,"SPAN",{});var Ki=n(la);d(Pe.$$.fragment,Ki),Ki.forEach(a),Ri.forEach(a),Hn=c(Ds),pa=o(Ds,"SPAN",{});var Ji=n(pa);Yn=i(Ji,"Contrastive search"),Ji.forEach(a),Ds.forEach(a),is=c(e),k=o(e,"P",{});var S=n(k);Bn=i(S,"The contrastive search decoding strategy was proposed in the 2022 paper "),Se=o(S,"A",{href:!0,rel:!0});var Qi=n(Se);Wn=i(Qi,"A Contrastive Framework for Neural Text Generation"),Qi.forEach(a),Un=i(S,`.
It demonstrates superior results for generating non-repetitive yet coherent long outputs. To learn how contrastive search
works, check out `),Le=o(S,"A",{href:!0,rel:!0});var Vi=n(Le);Xn=i(Vi,"this blog post"),Vi.forEach(a),Rn=i(S,`.
The two main parameters that enable and control the behavior of contrastive search are `),ha=o(S,"CODE",{});var Zi=n(ha);Kn=i(Zi,"penalty_alpha"),Zi.forEach(a),Jn=i(S," and "),ca=o(S,"CODE",{});var el=n(ca);Qn=i(el,"top_k"),el.forEach(a),Vn=i(S,":"),S.forEach(a),ls=c(e),d(De.$$.fragment,e),ps=c(e),U=o(e,"H3",{class:!0});var Fs=n(U);le=o(Fs,"A",{id:!0,class:!0,href:!0});var tl=n(le);ua=o(tl,"SPAN",{});var al=n(ua);d(Fe.$$.fragment,al),al.forEach(a),tl.forEach(a),Zn=c(Fs),ma=o(Fs,"SPAN",{});var sl=n(ma);er=i(sl,"Multinomial sampling"),sl.forEach(a),Fs.forEach(a),hs=c(e),ct=o(e,"P",{});var ol=n(ct);tr=i(ol,`As opposed to greedy search that always chooses a token with the highest probability as the
next token, multinomial sampling randomly selects the next token based on the probability distribution over the entire
vocabulary given by the model. Every token with a non-zero probability has a chance of being selected, thus reducing the
risk of repetition.`),ol.forEach(a),cs=c(e),pe=o(e,"P",{});var Is=n(pe);ar=i(Is,"To enable multinomial sampling set "),da=o(Is,"CODE",{});var nl=n(da);sr=i(nl,"do_sample=True"),nl.forEach(a),or=i(Is,"."),Is.forEach(a),us=c(e),d(Ie.$$.fragment,e),ms=c(e),X=o(e,"H3",{class:!0});var Gs=n(X);he=o(Gs,"A",{id:!0,class:!0,href:!0});var rl=n(he);ga=o(rl,"SPAN",{});var il=n(ga);d(Ge.$$.fragment,il),il.forEach(a),rl.forEach(a),nr=c(Gs),fa=o(Gs,"SPAN",{});var ll=n(fa);rr=i(ll,"Beam-search decoding"),ll.forEach(a),Gs.forEach(a),ds=c(e),ut=o(e,"P",{});var pl=n(ut);ir=i(pl,`Unlike greedy search, beam-search decoding keeps several hypotheses at each time step and eventually chooses
the hypothesis that has the overall highest probability for the entire sequence. This has the advantage of identifying high-probability
sequences that start with lower probability initial tokens and would\u2019ve been ignored by the greedy search.`),pl.forEach(a),gs=c(e),ce=o(e,"P",{});var Os=n(ce);lr=i(Os,"To enable this decoding strategy, specify the "),_a=o(Os,"CODE",{});var hl=n(_a);pr=i(hl,"num_beams"),hl.forEach(a),hr=i(Os," (aka number of hypotheses to keep track of) that is greater than 1."),Os.forEach(a),fs=c(e),d(Oe.$$.fragment,e),_s=c(e),R=o(e,"H3",{class:!0});var Ns=n(R);ue=o(Ns,"A",{id:!0,class:!0,href:!0});var cl=n(ue);va=o(cl,"SPAN",{});var ul=n(va);d(Ne.$$.fragment,ul),ul.forEach(a),cl.forEach(a),cr=c(Ns),ya=o(Ns,"SPAN",{});var ml=n(ya);ur=i(ml,"Beam-search multinomial sampling"),ml.forEach(a),Ns.forEach(a),vs=c(e),P=o(e,"P",{});var kt=n(P);mr=i(kt,`As the name implies, this decoding strategy combines beam search with multinomial sampling. You need to specify
the `),ka=o(kt,"CODE",{});var dl=n(ka);dr=i(dl,"num_beams"),dl.forEach(a),gr=i(kt," greater than 1, and set "),ba=o(kt,"CODE",{});var gl=n(ba);fr=i(gl,"do_sample=True"),gl.forEach(a),_r=i(kt," to use this decoding strategy."),kt.forEach(a),ys=c(e),d(He.$$.fragment,e),ks=c(e),K=o(e,"H3",{class:!0});var Hs=n(K);me=o(Hs,"A",{id:!0,class:!0,href:!0});var fl=n(me);wa=o(fl,"SPAN",{});var _l=n(wa);d(Ye.$$.fragment,_l),_l.forEach(a),fl.forEach(a),vr=c(Hs),Ea=o(Hs,"SPAN",{});var vl=n(Ea);yr=i(vl,"Diverse beam search decoding"),vl.forEach(a),Hs.forEach(a),bs=c(e),$=o(e,"P",{});var ve=n($);kr=i(ve,`The diverse beam search decoding strategy is an extension of the beam search strategy that allows for generating a more diverse
set of beam sequences to choose from. To learn how it works, refer to `),Be=o(ve,"A",{href:!0,rel:!0});var yl=n(Be);br=i(yl,"Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models"),yl.forEach(a),wr=i(ve,`.
This approach has two main parameters: `),ja=o(ve,"CODE",{});var kl=n(ja);Er=i(kl,"num_beams"),kl.forEach(a),jr=i(ve," and "),$a=o(ve,"CODE",{});var bl=n($a);$r=i(bl,"num_beam_groups"),bl.forEach(a),Tr=i(ve,`.
The groups are selected to ensure they are distinct enough compared to the others, and regular beam search is used within each group.`),ve.forEach(a),ws=c(e),d(We.$$.fragment,e),Es=c(e),T=o(e,"P",{});var ye=n(T);Ar=i(ye,`This guide illustrates the main parameters that enable various decoding strategies. More advanced parameters exist for the
`),Ta=o(ye,"CODE",{});var wl=n(Ta);xr=i(wl,"generate"),wl.forEach(a),qr=i(ye," method, which gives you even further control over the "),Aa=o(ye,"CODE",{});var El=n(Aa);Cr=i(El,"generate"),El.forEach(a),zr=i(ye,` method\u2019s behavior.
For the complete list of the available parameters, refer to the `),mt=o(ye,"A",{href:!0});var jl=n(mt);Mr=i(jl,"API documentation"),jl.forEach(a),Pr=i(ye,"."),ye.forEach(a),this.h()},h(){u(D,"name","hf:doc:metadata"),u(D,"content",JSON.stringify(Ml)),u(J,"id","text-generation-strategies"),u(J,"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(J,"href","#text-generation-strategies"),u(F,"class","relative group"),u(Xe,"href","/docs/transformers/v4.27.1/en/main_classes/text_generation#transformers.GenerationMixin.generate"),u(Re,"href","./tasks/summarization#inference"),u(Ke,"href","./model_doc/git#transformers.GitForCausalLM.forward.example"),u(Je,"href","./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example"),u(Z,"id","default-text-generation-configuration"),u(Z,"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(Z,"href","#default-text-generation-configuration"),u(I,"class","relative group"),u(Ze,"href","/docs/transformers/v4.27.1/en/main_classes/pipelines#transformers.pipeline"),u(ae,"id","customize-text-generation"),u(ae,"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(ae,"href","#customize-text-generation"),u(G,"class","relative group"),u(oe,"id","save-a-custom-decoding-strategy-with-your-model"),u(oe,"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(oe,"href","#save-a-custom-decoding-strategy-with-your-model"),u(O,"class","relative group"),u(rt,"href","/docs/transformers/v4.27.1/en/main_classes/text_generation#transformers.GenerationConfig"),u(it,"href","/docs/transformers/v4.27.1/en/main_classes/text_generation#transformers.GenerationConfig.save_pretrained"),u(lt,"href","/docs/transformers/v4.27.1/en/main_classes/text_generation#transformers.GenerationConfig.save_pretrained"),u(pt,"href","/docs/transformers/v4.27.1/en/main_classes/text_generation#transformers.GenerationConfig.from_pretrained"),u(ne,"id","decoding-strategies"),u(ne,"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(ne,"href","#decoding-strategies"),u(Y,"class","relative group"),u(Ce,"href","https://huggingface.co/blog/how-to-generate"),u(Ce,"rel","nofollow"),u(re,"id","greedy-search"),u(re,"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(re,"href","#greedy-search"),u(B,"class","relative group"),u(ie,"id","contrastive-search"),u(ie,"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(ie,"href","#contrastive-search"),u(W,"class","relative group"),u(Se,"href","https://arxiv.org/abs/2202.06417"),u(Se,"rel","nofollow"),u(Le,"href","https://huggingface.co/blog/introducing-csearch"),u(Le,"rel","nofollow"),u(le,"id","multinomial-sampling"),u(le,"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(le,"href","#multinomial-sampling"),u(U,"class","relative group"),u(he,"id","beamsearch-decoding"),u(he,"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(he,"href","#beamsearch-decoding"),u(X,"class","relative group"),u(ue,"id","beamsearch-multinomial-sampling"),u(ue,"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(ue,"href","#beamsearch-multinomial-sampling"),u(R,"class","relative group"),u(me,"id","diverse-beam-search-decoding"),u(me,"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(me,"href","#diverse-beam-search-decoding"),u(K,"class","relative group"),u(Be,"href","https://arxiv.org/pdf/1610.02424.pdf"),u(Be,"rel","nofollow"),u(mt,"href","./main_classes/text_generation.mdx")},m(e,l){t(document.head,D),p(e,qa,l),p(e,F,l),t(F,J),t(J,bt),g(ke,bt,null),t(F,Ys),t(F,wt),t(wt,Bs),p(e,Ca,l),p(e,Ue,l),t(Ue,Ws),p(e,za,l),p(e,Q,l),t(Q,Us),t(Q,Xe),t(Xe,Xs),t(Q,Rs),p(e,Ma,l),p(e,q,l),t(q,Et),t(Et,Re),t(Re,Ks),t(q,Js),t(q,jt),t(jt,Ke),t(Ke,Qs),t(q,Vs),t(q,$t),t($t,Je),t(Je,Zs),p(e,Pa,l),p(e,Qe,l),t(Qe,eo),p(e,Sa,l),p(e,V,l),t(V,to),t(V,Tt),t(Tt,ao),t(V,so),p(e,La,l),p(e,Ve,l),t(Ve,oo),p(e,Da,l),p(e,C,l),t(C,At),t(At,no),t(C,ro),t(C,xt),t(xt,io),t(C,lo),t(C,qt),t(qt,po),p(e,Fa,l),p(e,I,l),t(I,Z),t(Z,Ct),g(be,Ct,null),t(I,ho),t(I,zt),t(zt,co),p(e,Ia,l),p(e,z,l),t(z,uo),t(z,Ze),t(Ze,mo),t(z,go),t(z,Mt),t(Mt,fo),t(z,_o),p(e,Ga,l),p(e,ee,l),t(ee,vo),t(ee,Pt),t(Pt,yo),t(ee,ko),p(e,Oa,l),g(we,e,l),p(e,Na,l),p(e,te,l),t(te,bo),t(te,St),t(St,wo),t(te,Eo),p(e,Ha,l),p(e,et,l),t(et,jo),p(e,Ya,l),p(e,G,l),t(G,ae),t(ae,Lt),g(Ee,Lt,null),t(G,$o),t(G,Dt),t(Dt,To),p(e,Ba,l),p(e,M,l),t(M,Ao),t(M,Ft),t(Ft,xo),t(M,qo),t(M,It),t(It,Co),t(M,zo),p(e,Wa,l),g(je,e,l),p(e,Ua,l),p(e,tt,l),t(tt,Mo),p(e,Xa,l),p(e,b,l),t(b,at),t(at,Gt),t(Gt,Po),t(at,So),t(b,Lo),t(b,st),t(st,Ot),t(Ot,Do),t(st,Fo),t(b,Io),t(b,se),t(se,Nt),t(Nt,Go),t(se,Oo),t(se,Ht),t(Ht,No),t(se,Ho),t(b,Yo),t(b,ot),t(ot,Yt),t(Yt,Bo),t(ot,Wo),p(e,Ra,l),p(e,O,l),t(O,oe),t(oe,Bt),g($e,Bt,null),t(O,Uo),t(O,Wt),t(Wt,Xo),p(e,Ka,l),p(e,nt,l),t(nt,Ro),p(e,Ja,l),p(e,w,l),t(w,Te),t(Te,Ko),t(Te,rt),t(rt,Jo),t(Te,Qo),t(w,Vo),t(w,Ut),t(Ut,Zo),t(w,en),t(w,N),t(N,tn),t(N,it),t(it,an),t(N,sn),t(N,Xt),t(Xt,on),t(N,nn),t(w,rn),t(w,H),t(H,ln),t(H,Rt),t(Rt,pn),t(H,hn),t(H,Kt),t(Kt,cn),t(H,un),p(e,Qa,l),g(Ae,e,l),p(e,Va,l),p(e,E,l),t(E,mn),t(E,Jt),t(Jt,dn),t(E,gn),t(E,lt),t(lt,fn),t(E,_n),t(E,pt),t(pt,vn),t(E,yn),p(e,Za,l),g(xe,e,l),p(e,es,l),p(e,Y,l),t(Y,ne),t(ne,Qt),g(qe,Qt,null),t(Y,kn),t(Y,Vt),t(Vt,bn),p(e,ts,l),p(e,j,l),t(j,wn),t(j,Zt),t(Zt,En),t(j,jn),t(j,ea),t(ea,$n),t(j,Tn),t(j,Ce),t(Ce,An),t(j,xn),p(e,as,l),p(e,ht,l),t(ht,qn),p(e,ss,l),p(e,B,l),t(B,re),t(re,ta),g(ze,ta,null),t(B,Cn),t(B,aa),t(aa,zn),p(e,os,l),p(e,y,l),t(y,sa),t(sa,Mn),t(y,Pn),t(y,oa),t(oa,Sn),t(y,Ln),t(y,na),t(na,Dn),t(y,Fn),t(y,ra),t(ra,In),t(y,Gn),t(y,ia),t(ia,On),t(y,Nn),p(e,ns,l),g(Me,e,l),p(e,rs,l),p(e,W,l),t(W,ie),t(ie,la),g(Pe,la,null),t(W,Hn),t(W,pa),t(pa,Yn),p(e,is,l),p(e,k,l),t(k,Bn),t(k,Se),t(Se,Wn),t(k,Un),t(k,Le),t(Le,Xn),t(k,Rn),t(k,ha),t(ha,Kn),t(k,Jn),t(k,ca),t(ca,Qn),t(k,Vn),p(e,ls,l),g(De,e,l),p(e,ps,l),p(e,U,l),t(U,le),t(le,ua),g(Fe,ua,null),t(U,Zn),t(U,ma),t(ma,er),p(e,hs,l),p(e,ct,l),t(ct,tr),p(e,cs,l),p(e,pe,l),t(pe,ar),t(pe,da),t(da,sr),t(pe,or),p(e,us,l),g(Ie,e,l),p(e,ms,l),p(e,X,l),t(X,he),t(he,ga),g(Ge,ga,null),t(X,nr),t(X,fa),t(fa,rr),p(e,ds,l),p(e,ut,l),t(ut,ir),p(e,gs,l),p(e,ce,l),t(ce,lr),t(ce,_a),t(_a,pr),t(ce,hr),p(e,fs,l),g(Oe,e,l),p(e,_s,l),p(e,R,l),t(R,ue),t(ue,va),g(Ne,va,null),t(R,cr),t(R,ya),t(ya,ur),p(e,vs,l),p(e,P,l),t(P,mr),t(P,ka),t(ka,dr),t(P,gr),t(P,ba),t(ba,fr),t(P,_r),p(e,ys,l),g(He,e,l),p(e,ks,l),p(e,K,l),t(K,me),t(me,wa),g(Ye,wa,null),t(K,vr),t(K,Ea),t(Ea,yr),p(e,bs,l),p(e,$,l),t($,kr),t($,Be),t(Be,br),t($,wr),t($,ja),t(ja,Er),t($,jr),t($,$a),t($a,$r),t($,Tr),p(e,ws,l),g(We,e,l),p(e,Es,l),p(e,T,l),t(T,Ar),t(T,Ta),t(Ta,xr),t(T,qr),t(T,Aa),t(Aa,Cr),t(T,zr),t(T,mt),t(mt,Mr),t(T,Pr),js=!0},p:ql,i(e){js||(f(ke.$$.fragment,e),f(be.$$.fragment,e),f(we.$$.fragment,e),f(Ee.$$.fragment,e),f(je.$$.fragment,e),f($e.$$.fragment,e),f(Ae.$$.fragment,e),f(xe.$$.fragment,e),f(qe.$$.fragment,e),f(ze.$$.fragment,e),f(Me.$$.fragment,e),f(Pe.$$.fragment,e),f(De.$$.fragment,e),f(Fe.$$.fragment,e),f(Ie.$$.fragment,e),f(Ge.$$.fragment,e),f(Oe.$$.fragment,e),f(Ne.$$.fragment,e),f(He.$$.fragment,e),f(Ye.$$.fragment,e),f(We.$$.fragment,e),js=!0)},o(e){_(ke.$$.fragment,e),_(be.$$.fragment,e),_(we.$$.fragment,e),_(Ee.$$.fragment,e),_(je.$$.fragment,e),_($e.$$.fragment,e),_(Ae.$$.fragment,e),_(xe.$$.fragment,e),_(qe.$$.fragment,e),_(ze.$$.fragment,e),_(Me.$$.fragment,e),_(Pe.$$.fragment,e),_(De.$$.fragment,e),_(Fe.$$.fragment,e),_(Ie.$$.fragment,e),_(Ge.$$.fragment,e),_(Oe.$$.fragment,e),_(Ne.$$.fragment,e),_(He.$$.fragment,e),_(Ye.$$.fragment,e),_(We.$$.fragment,e),js=!1},d(e){a(D),e&&a(qa),e&&a(F),v(ke),e&&a(Ca),e&&a(Ue),e&&a(za),e&&a(Q),e&&a(Ma),e&&a(q),e&&a(Pa),e&&a(Qe),e&&a(Sa),e&&a(V),e&&a(La),e&&a(Ve),e&&a(Da),e&&a(C),e&&a(Fa),e&&a(I),v(be),e&&a(Ia),e&&a(z),e&&a(Ga),e&&a(ee),e&&a(Oa),v(we,e),e&&a(Na),e&&a(te),e&&a(Ha),e&&a(et),e&&a(Ya),e&&a(G),v(Ee),e&&a(Ba),e&&a(M),e&&a(Wa),v(je,e),e&&a(Ua),e&&a(tt),e&&a(Xa),e&&a(b),e&&a(Ra),e&&a(O),v($e),e&&a(Ka),e&&a(nt),e&&a(Ja),e&&a(w),e&&a(Qa),v(Ae,e),e&&a(Va),e&&a(E),e&&a(Za),v(xe,e),e&&a(es),e&&a(Y),v(qe),e&&a(ts),e&&a(j),e&&a(as),e&&a(ht),e&&a(ss),e&&a(B),v(ze),e&&a(os),e&&a(y),e&&a(ns),v(Me,e),e&&a(rs),e&&a(W),v(Pe),e&&a(is),e&&a(k),e&&a(ls),v(De,e),e&&a(ps),e&&a(U),v(Fe),e&&a(hs),e&&a(ct),e&&a(cs),e&&a(pe),e&&a(us),v(Ie,e),e&&a(ms),e&&a(X),v(Ge),e&&a(ds),e&&a(ut),e&&a(gs),e&&a(ce),e&&a(fs),v(Oe,e),e&&a(_s),e&&a(R),v(Ne),e&&a(vs),e&&a(P),e&&a(ys),v(He,e),e&&a(ks),e&&a(K),v(Ye),e&&a(bs),e&&a($),e&&a(ws),v(We,e),e&&a(Es),e&&a(T)}}}const Ml={local:"text-generation-strategies",sections:[{local:"default-text-generation-configuration",title:"Default text generation configuration"},{local:"customize-text-generation",title:"Customize text generation"},{local:"save-a-custom-decoding-strategy-with-your-model",title:"Save a custom decoding strategy with your model"},{local:"decoding-strategies",sections:[{local:"greedy-search",title:"Greedy Search"},{local:"contrastive-search",title:"Contrastive search"},{local:"multinomial-sampling",title:"Multinomial sampling"},{local:"beamsearch-decoding",title:"Beam-search decoding"},{local:"beamsearch-multinomial-sampling",title:"Beam-search multinomial sampling"},{local:"diverse-beam-search-decoding",title:"Diverse beam search decoding"}],title:"Decoding strategies"}],title:"Text generation strategies"};function Pl(Fr){return Cl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fl extends $l{constructor(D){super();Tl(this,D,Pl,zl,Al,{})}}export{Fl as default,Ml as metadata};
