import{S as yc,i as bc,s as vc,e as l,k as c,w as m,t as s,M as wc,c as o,d as a,m as h,a as r,x as u,h as n,b as d,G as t,g as p,y as g,q as f,o as y,B as b,v as Mc}from"../chunks/vendor-hf-doc-builder.js";import{T as Tc}from"../chunks/Tip-hf-doc-builder.js";import{I as _}from"../chunks/IconCopyLink-hf-doc-builder.js";import{C as U}from"../chunks/CodeBlock-hf-doc-builder.js";function Jc(hs){let w,se;return{c(){w=l("p"),se=s("The API for the streamer classes is still under development and may change in the future.")},l(T){w=o(T,"P",{});var j=r(w);se=n(j,"The API for the streamer classes is still under development and may change in the future."),j.forEach(a)},m(T,j){p(T,w,j),t(w,se)},d(T){T&&a(w)}}}function kc(hs){let w,se,T,j,Yt,Ge,$n,Qt,Fn,ds,ht,xn,ms,ne,Yn,dt,Qn,An,us,I,At,mt,Sn,Hn,St,ut,qn,Dn,Ht,gt,Ln,gs,ft,Pn,fs,le,Kn,qt,On,el,ys,yt,tl,bs,V,Dt,al,sl,Lt,nl,ll,Pt,ol,vs,Y,oe,Kt,Xe,rl,Ot,il,ws,C,pl,bt,cl,hl,ea,dl,ml,Ms,re,ul,ta,gl,fl,Ts,Be,Js,ie,yl,aa,bl,vl,ks,vt,wl,js,Q,pe,sa,Ie,Ml,na,Tl,_s,N,Jl,la,kl,jl,oa,_l,Ul,Us,Ve,Zs,wt,Zl,Es,Z,Mt,ra,El,Wl,Gl,Tt,ia,Xl,Bl,Il,ce,pa,Vl,Cl,ca,Nl,Rl,zl,Jt,ha,$l,Fl,Ws,A,he,da,Ce,xl,ma,Yl,Gs,kt,Ql,Xs,E,Ne,Al,jt,Sl,Hl,ql,ua,Dl,Ll,S,Pl,_t,Kl,Ol,ga,eo,to,ao,H,so,fa,no,lo,ya,oo,ro,Bs,Re,Is,W,io,ba,po,co,Ut,ho,mo,Zt,uo,go,Vs,ze,Cs,q,de,va,$e,fo,wa,yo,Ns,v,bo,Ma,vo,wo,Ta,Mo,To,Ja,Jo,ko,ka,jo,_o,ja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</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>
}`}}),Ie=new _({}),Ve=new U({props:{code:"bXlfbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBudW1fYmVhbXMlM0Q0JTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSk=",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>)'}}),Ce=new _({}),Re=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwR2VuZXJhdGlvbkNvbmZpZyUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMm15X2FjY291bnQlMkZteV9tb2RlbCUyMiklMEFnZW5lcmF0aW9uX2NvbmZpZyUyMCUzRCUyMEdlbmVyYXRpb25Db25maWcoJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0Q1MCUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjB0b3BfayUzRDUwJTJDJTIwZW9zX3Rva2VuX2lkJTNEbW9kZWwuY29uZmlnLmVvc190b2tlbl9pZCUwQSklMEFnZW5lcmF0aW9uX2NvbmZpZy5zYXZlX3ByZXRyYWluZWQoJTIybXlfYWNjb3VudCUyRm15X21vZGVsJTIyJTJDJTIwcHVzaF90b19odWIlM0RUcnVlKQ==",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>)`}}),ze=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBHZW5lcmF0aW9uQ29uZmlnJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIydDUtc21hbGwlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKCUyMnQ1LXNtYWxsJTIyKSUwQSUwQXRyYW5zbGF0aW9uX2dlbmVyYXRpb25fY29uZmlnJTIwJTNEJTIwR2VuZXJhdGlvbkNvbmZpZyglMEElMjAlMjAlMjAlMjBudW1fYmVhbXMlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwZWFybHlfc3RvcHBpbmclM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwZGVjb2Rlcl9zdGFydF90b2tlbl9pZCUzRDAlMkMlMEElMjAlMjAlMjAlMjBlb3NfdG9rZW5faWQlM0Rtb2RlbC5jb25maWcu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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>]`}}),$e=new _({}),me=new Tc({props:{warning:!0,$$slots:{default:[Jc]},$$scope:{ctx:hs}}}),Fe=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUyQyUyMFRleHRTdHJlYW1lciUwQSUwQXRvayUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmdwdDIlMjIpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ3B0MiUyMiklMEFpbnB1dHMlMjAlM0QlMjB0b2soJTVCJTIyQW4lMjBpbmNyZWFzaW5nJTIwc2VxdWVuY2UlM0ElMjBvbmUlMkMlMjIlNUQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQXN0cmVhbWVyJTIwJTNEJTIwVGV4dFN0cmVhbWVyKHRvayklMEElMEElMjMlMjBEZXNwaXRlJTIwcmV0dXJuaW5nJTIwdGhlJTIwdXN1YWwlMjBvdXRwdXQlMkMlMjB0aGUlMjBzdHJlYW1lciUyMHdpbGwlMjBhbHNvJTIwcHJpbnQlMjB0aGUlMjBnZW5lcmF0ZWQlMjB0ZXh0JTIwdG8lMjBzdGRvdXQuJTBBXyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwc3RyZWFtZXIlM0RzdHJlYW1lciUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMjAp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForCausalLM, AutoTokenizer, TextStreamer

<span class="hljs-meta">&gt;&gt;&gt; </span>tok = 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>inputs = tok([<span class="hljs-string">&quot;An increasing sequence: one,&quot;</span>], return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>streamer = TextStreamer(tok)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Despite returning the usual output, the streamer will also print the generated text to stdout.</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>_ = model.generate(**inputs, streamer=streamer, max_new_tokens=<span class="hljs-number">20</span>)
An increasing sequence: one, two, three, four, five, six, seven, eight, nine, ten, eleven,`}}),xe=new _({}),Qe=new _({}),Ae=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkklMjBsb29rJTIwZm9yd2FyZCUyMHRvJTIyJTBBY2hlY2twb2ludCUyMCUzRCUyMCUyMmRpc3RpbGdwdDIlMjIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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>]`}}),Se=new _({}),De=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJncHQyLWxhcmdlJTIyJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkh1Z2dpbmclMjBGYWNlJTIwQ29tcGFueSUyMGlzJTIyJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwcGVuYWx0eV9hbHBoYSUzRDAuNiUyQyUyMHRvcF9rJTNENCUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTAwKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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>]`}}),Le=new _({}),Pe=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJncHQyLWxhcmdlJTIyJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNLmZyb21fcHJldHJhaW5lZChjaGVja3BvaW50KSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMlRvZGF5JTIwd2FzJTIwYW4lMjBhbWF6aW5nJTIwZGF5JTIwYmVjYXVzZSUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihwcm9tcHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMGRvX3NhbXBsZSUzRFRydWUlMkMlMjBudW1fYmVhbXMlM0QxJTJDJTIwbWF4X25ld190b2tlbnMlM0QxMDApJTBBdG9rZW5pemVyLmJhdGNoX2RlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",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>, num_beams=<span class="hljs-number">1</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>]`}}),Ke=new _({}),Oe=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkl0JTIwaXMlMjBhc3RvbmlzaGluZyUyMGhvdyUyMG9uZSUyMGNhbiUyMiUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJncHQyLW1lZGl1bSUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBudW1fYmVhbXMlM0Q1JTJDJTIwbWF4X25ld190b2tlbnMlM0Q1MCklMEF0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSk=",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>]`}}),et=new _({}),tt=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0lMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJ0cmFuc2xhdGUlMjBFbmdsaXNoJTIwdG8lMjBHZXJtYW4lM0ElMjBUaGUlMjBob3VzZSUyMGlzJTIwd29uZGVyZnVsLiUyMiUwQWNoZWNrcG9pbnQlMjAlM0QlMjAlMjJ0NS1zbWFsbCUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JTZXEyU2VxTE0uZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwbnVtX2JlYW1zJTNENSUyQyUyMGRvX3NhbXBsZSUzRFRydWUpJTBBdG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTVCMCU1RCUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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>`}}),at=new _({}),nt=new U({props:{code:"ZnJvbSUyMHRy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c3lzdGVtJTJDJTIwd2hlcmUlMjB0aGUlMjBlbGVtZW50cyUyMGhhcm1vbmlvdXNseSUyMGludGVyYWN0JTIwYW5kJTIwd29yayUyMHRvZ2V0aGVyJTIwaW4lMjB0aGUlMjBtb3N0JTIwJTVDJTBBZWZmaWNpZW50JTIwd2F5JTIwcG9zc2libGUuJTIyJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocHJvbXB0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJwdCUyMiklMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEElMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwuZ2VuZXJhdGUoKippbnB1dHMlMkMlMjBudW1fYmVhbXMlM0Q1JTJDJTIwbnVtX2JlYW1fZ3JvdXBzJTNENSUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMzAlMkMlMjBkaXZlcnNpdHlfcGVuYWx0eSUzRDEuMCklMEF0b2tlbml6ZXIuZGVjb2RlKG91dHB1dHMlNUIwJTVEJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUp",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>, diversity_penalty=<span class="hljs-number">1.0</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 aim of this project is to create a new type of living system, one that is more sustainable and efficient than the current one.&#x27;</span>`}}),lt=new _({}),rt=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkFsaWNlJTIwYW5kJTIwQm9iJTIyJTBBY2hlY2twb2ludCUyMCUzRCUyMCUyMkVsZXV0aGVyQUklMkZweXRoaWEtMS40Yi1kZWR1cGVkJTIyJTBBYXNzaXN0YW50X2NoZWNrcG9pbnQlMjAlM0QlMjAlMjJFbGV1dGhlckFJJTJGcHl0aGlhLTE2MG0tZGVkdXBlZCUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFhc3Npc3RhbnRfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoYXNzaXN0YW50X2NoZWNrcG9pbnQpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwYXNzaXN0YW50X21vZGVsJTNEYXNzaXN0YW50X21vZGVsKSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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;Alice and Bob&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;EleutherAI/pythia-1.4b-deduped&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>assistant_checkpoint = <span class="hljs-string">&quot;EleutherAI/pythia-160m-deduped&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>assistant_model = AutoModelForCausalLM.from_pretrained(assistant_checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, assistant_model=assistant_model)
<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;Alice and Bob are sitting in a bar. Alice is drinking a beer and Bob is drinking a&#x27;</span>]`}}),it=new U({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvckNhdXNhbExNJTJDJTIwQXV0b1Rva2VuaXplciUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkFsaWNlJTIwYW5kJTIwQm9iJTIyJTBBY2hlY2twb2ludCUyMCUzRCUyMCUyMkVsZXV0aGVyQUklMkZweXRoaWEtMS40Yi1kZWR1cGVkJTIyJTBBYXNzaXN0YW50X2NoZWNrcG9pbnQlMjAlM0QlMjAlMjJFbGV1dGhlckFJJTJGcHl0aGlhLTE2MG0tZGVkdXBlZCUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGNoZWNrcG9pbnQpJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoY2hlY2twb2ludCklMEFhc3Npc3RhbnRfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoYXNzaXN0YW50X2NoZWNrcG9pbnQpJTBBb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTIwYXNzaXN0YW50X21vZGVsJTNEYXNzaXN0YW50X21vZGVsJTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRlbXBlcmF0dXJlJTNEMC41KSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",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;Alice and Bob&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>checkpoint = <span class="hljs-string">&quot;EleutherAI/pythia-1.4b-deduped&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>assistant_checkpoint = <span class="hljs-string">&quot;EleutherAI/pythia-160m-deduped&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>assistant_model = AutoModelForCausalLM.from_pretrained(assistant_checkpoint)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs, assistant_model=assistant_model, do_sample=<span class="hljs-literal">True</span>, temperature=<span class="hljs-number">0.5</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;Alice and Bob are sitting on the sofa. Alice says, &#x27;I&#x27;m going to my room&quot;</span>]`}}),{c(){w=l("meta"),se=c(),T=l("h1"),j=l("a"),Yt=l("span"),m(Ge.$$.fragment),$n=c(),Qt=l("span"),Fn=s("Text generation strategies"),ds=c(),ht=l("p"),xn=s(`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.`),ms=c(),ne=l("p"),Yn=s("Check out a few examples that use "),dt=l("a"),Qn=s("generate()"),An=s(` method to produce
text outputs for different tasks:`),us=c(),I=l("ul"),At=l("li"),mt=l("a"),Sn=s("Text summarization"),Hn=c(),St=l("li"),ut=l("a"),qn=s("Image captioning"),Dn=c(),Ht=l("li"),gt=l("a"),Ln=s("Audio transcription"),gs=c(),ft=l("p"),Pn=s(`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.`),fs=c(),le=l("p"),Kn=s(`The process of selecting output tokens to generate text is known as decoding, and you can customize the decoding strategy
that the `),qt=l("code"),On=s("generate()"),el=s(` 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.`),ys=c(),yt=l("p"),tl=s("This guide describes:"),bs=c(),V=l("ul"),Dt=l("li"),al=s("default generation configuration"),sl=c(),Lt=l("li"),nl=s("common decoding strategies and their main parameters"),ll=c(),Pt=l("li"),ol=s("saving and sharing custom generation configurations with your fine-tuned model on \u{1F917} Hub"),vs=c(),Y=l("h2"),oe=l("a"),Kt=l("span"),m(Xe.$$.fragment),rl=c(),Ot=l("span"),il=s("Default text generation configuration"),ws=c(),C=l("p"),pl=s(`A decoding strategy for a model is defined in its generation configuration. When using pre-trained models for inference
within a `),bt=l("a"),cl=s("pipeline()"),hl=s(", the models call the "),ea=l("code"),dl=s("PreTrainedModel.generate()"),ml=s(` 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.`),Ms=c(),re=l("p"),ul=s(`When you load a model explicitly, you can inspect the generation configuration that comes with it through
`),ta=l("code"),gl=s("model.generation_config"),fl=s(":"),Ts=c(),m(Be.$$.fragment),Js=c(),ie=l("p"),yl=s("Printing out the "),aa=l("code"),bl=s("model.generation_config"),vl=s(` reveals only the values that are different from the default generation
configuration, and does not list any of the default values.`),ks=c(),vt=l("p"),wl=s(`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.`),js=c(),Q=l("h2"),pe=l("a"),sa=l("span"),m(Ie.$$.fragment),Ml=c(),na=l("span"),Tl=s("Customize text generation"),_s=c(),N=l("p"),Jl=s("You can override any "),la=l("code"),kl=s("generation_config"),jl=s(" by passing the parameters and their values directly to the "),oa=l("code"),_l=s("generate"),Ul=s(" method:"),Us=c(),m(Ve.$$.fragment),Zs=c(),wt=l("p"),Zl=s(`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:`),Es=c(),Z=l("ul"),Mt=l("li"),ra=l("code"),El=s("max_new_tokens"),Wl=s(`: the maximum number of tokens to generate. In other words, the size of the output sequence, not
including the tokens in the prompt.`),Gl=c(),Tt=l("li"),ia=l("code"),Xl=s("num_beams"),Bl=s(`: 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.`),Il=c(),ce=l("li"),pa=l("code"),Vl=s("do_sample"),Cl=s(": if set to "),ca=l("code"),Nl=s("True"),Rl=s(`, 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.`),zl=c(),Jt=l("li"),ha=l("code"),$l=s("num_return_sequences"),Fl=s(`: 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.`),Ws=c(),A=l("h2"),he=l("a"),da=l("span"),m(Ce.$$.fragment),xl=c(),ma=l("span"),Yl=s("Save a custom decoding strategy with your model"),Gs=c(),kt=l("p"),Ql=s("If you would like to share your fine-tuned model with a specific generation configuration, you can:"),Xs=c(),E=l("ul"),Ne=l("li"),Al=s("Create a "),jt=l("a"),Sl=s("GenerationConfig"),Hl=s(" class instance"),ql=c(),ua=l("li"),Dl=s("Specify the decoding strategy parameters"),Ll=c(),S=l("li"),Pl=s("Save your generation configuration with "),_t=l("a"),Kl=s("GenerationConfig.save_pretrained()"),Ol=s(", making sure to leave its "),ga=l("code"),eo=s("config_file_name"),to=s(" argument empty"),ao=c(),H=l("li"),so=s("Set "),fa=l("code"),no=s("push_to_hub"),lo=s(" to "),ya=l("code"),oo=s("True"),ro=s(" to upload your config to the model\u2019s repo"),Bs=c(),m(Re.$$.fragment),Is=c(),W=l("p"),io=s("You can also store several generation configurations in a single directory, making use of the "),ba=l("code"),po=s("config_file_name"),co=s(`
argument in `),Ut=l("a"),ho=s("GenerationConfig.save_pretrained()"),mo=s(". You can later instantiate them with "),Zt=l("a"),uo=s("GenerationConfig.from_pretrained()"),go=s(`. 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.`),Vs=c(),m(ze.$$.fragment),Cs=c(),q=l("h2"),de=l("a"),va=l("span"),m($e.$$.fragment),fo=c(),wa=l("span"),yo=s("Streaming"),Ns=c(),v=l("p"),bo=s("The "),Ma=l("code"),vo=s("generate()"),wo=s(" supports streaming, through its "),Ta=l("code"),Mo=s("streamer"),To=s(" input. The "),Ja=l("code"),Jo=s("streamer"),ko=s(` input is compatible any instance
from a class that has the following methods: `),ka=l("code"),jo=s("put()"),_o=s(" and "),ja=l("code"),Uo=s("end()"),Zo=s(". Internally, "),_a=l("code"),Eo=s("put()"),Wo=s(` is used to push new tokens and
`),Ua=l("code"),Go=s("end()"),Xo=s(" is used to flag the end of text generation."),Rs=c(),m(me.$$.fragment),zs=c(),R=l("p"),Bo=s(`In practice, you can craft your own streaming class for all sorts of purposes! We also have basic streaming classes
ready for you to use. For example, you can use the `),Et=l("a"),Io=s("TextStreamer"),Vo=s(" class to stream the output of "),Za=l("code"),Co=s("generate()"),No=s(` into
your screen, one word at a time:`),$s=c(),m(Fe.$$.fragment),Fs=c(),D=l("h2"),ue=l("a"),Ea=l("span"),m(xe.$$.fragment),Ro=c(),Wa=l("span"),zo=s("Decoding strategies"),xs=c(),G=l("p"),$o=s("Certain combinations of the "),Ga=l("code"),Fo=s("generate()"),xo=s(" parameters, and ultimately "),Xa=l("code"),Yo=s("generation_config"),Qo=s(`, can be used to enable specific
decoding strategies. If you are new to this concept, we recommend reading `),Ye=l("a"),Ao=s("this blog post that illustrates how common decoding strategies work"),So=s("."),Ys=c(),Wt=l("p"),Ho=s("Here, we\u2019ll show some of the parameters that control the decoding strategies and illustrate how you can use them."),Qs=c(),L=l("h3"),ge=l("a"),Ba=l("span"),m(Qe.$$.fragment),qo=c(),Ia=l("span"),Do=s("Greedy Search"),As=c(),B=l("p"),Va=l("code"),Lo=s("generate"),Po=s(" uses greedy search decoding by default so you don\u2019t have to pass any parameters to enable it. This means the parameters "),Ca=l("code"),Ko=s("num_beams"),Oo=s(" is set to 1 and "),Na=l("code"),er=s("do_sample=False"),tr=s("."),Ss=c(),m(Ae.$$.fragment),Hs=c(),P=l("h3"),fe=l("a"),Ra=l("span"),m(Se.$$.fragment),ar=c(),za=l("span"),sr=s("Contrastive search"),qs=c(),J=l("p"),nr=s("The contrastive search decoding strategy was proposed in the 2022 paper "),He=l("a"),lr=s("A Contrastive Framework for Neural Text Generation"),or=s(`.
It demonstrates superior results for generating non-repetitive yet coherent long outputs. To learn how contrastive search
works, check out `),qe=l("a"),rr=s("this blog post"),ir=s(`.
The two main parameters that enable and control the behavior of contrastive search are `),$a=l("code"),pr=s("penalty_alpha"),cr=s(" and "),Fa=l("code"),hr=s("top_k"),dr=s(":"),Ds=c(),m(De.$$.fragment),Ls=c(),K=l("h3"),ye=l("a"),xa=l("span"),m(Le.$$.fragment),mr=c(),Ya=l("span"),ur=s("Multinomial sampling"),Ps=c(),Gt=l("p"),gr=s(`As opposed to greedy search that always chooses a token with the highest probability as the
next token, multinomial sampling (also called ancestral 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.`),Ks=c(),z=l("p"),fr=s("To enable multinomial sampling set "),Qa=l("code"),yr=s("do_sample=True"),br=s(" and "),Aa=l("code"),vr=s("num_beams=1"),wr=s("."),Os=c(),m(Pe.$$.fragment),en=c(),O=l("h3"),be=l("a"),Sa=l("span"),m(Ke.$$.fragment),Mr=c(),Ha=l("span"),Tr=s("Beam-search decoding"),tn=c(),Xt=l("p"),Jr=s(`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.`),an=c(),ve=l("p"),kr=s("To enable this decoding strategy, specify the "),qa=l("code"),jr=s("num_beams"),_r=s(" (aka number of hypotheses to keep track of) that is greater than 1."),sn=c(),m(Oe.$$.fragment),nn=c(),ee=l("h3"),we=l("a"),Da=l("span"),m(et.$$.fragment),Ur=c(),La=l("span"),Zr=s("Beam-search multinomial sampling"),ln=c(),$=l("p"),Er=s(`As the name implies, this decoding strategy combines beam search with multinomial sampling. You need to specify
the `),Pa=l("code"),Wr=s("num_beams"),Gr=s(" greater than 1, and set "),Ka=l("code"),Xr=s("do_sample=True"),Br=s(" to use this decoding strategy."),on=c(),m(tt.$$.fragment),rn=c(),te=l("h3"),Me=l("a"),Oa=l("span"),m(at.$$.fragment),Ir=c(),es=l("span"),Vr=s("Diverse beam search decoding"),pn=c(),k=l("p"),Cr=s(`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 `),st=l("a"),Nr=s("Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models"),Rr=s(`.
This approach has three main parameters: `),ts=l("code"),zr=s("num_beams"),$r=s(", "),as=l("code"),Fr=s("num_beam_groups"),xr=s(", and "),ss=l("code"),Yr=s("diversity_penalty"),Qr=s(`.
The diversily penalty ensures the outputs are distinct across groups, and beam search is used within each group.`),cn=c(),m(nt.$$.fragment),hn=c(),X=l("p"),Ar=s(`This guide illustrates the main parameters that enable various decoding strategies. More advanced parameters exist for the
`),ns=l("code"),Sr=s("generate"),Hr=s(" method, which gives you even further control over the "),ls=l("code"),qr=s("generate"),Dr=s(` method\u2019s behavior.
For the complete list of the available parameters, refer to the `),Bt=l("a"),Lr=s("API documentation"),Pr=s("."),dn=c(),ae=l("h3"),Te=l("a"),os=l("span"),m(lt.$$.fragment),Kr=c(),rs=l("span"),Or=s("Assisted Decoding"),mn=c(),Je=l("p"),ei=s(`Assisted decoding is a modification of the decoding strategies above that uses an assistant model with the same
tokenizer (ideally a much smaller model) to greedily generate a few candidate tokens. The main model then validates
the candidate tokens in a single forward pass, which speeds up the decoding process. Currently, only greedy search
and sampling are supported with assisted decoding, and doesn\u2019t support batched inputs. To learn more about assisted
decoding, check `),ot=l("a"),ti=s("this blog post"),ai=s("."),un=c(),ke=l("p"),si=s("To enable assisted decoding, set the "),is=l("code"),ni=s("assistant_model"),li=s(" argument with a model."),gn=c(),m(rt.$$.fragment),fn=c(),je=l("p"),oi=s("When using assisted decoding with sampling methods, you can use the "),ps=l("code"),ri=s("temperarure"),ii=s(` argument to control the randomness
just like in multinomial sampling. However, in assisted decoding, reducing the temperature will help improving latency.`),yn=c(),m(it.$$.fragment),this.h()},l(e){const i=wc('[data-svelte="svelte-1phssyn"]',document.head);w=o(i,"META",{name:!0,content:!0}),i.forEach(a),se=h(e),T=o(e,"H1",{class:!0});var pt=r(T);j=o(pt,"A",{id:!0,class:!0,href:!0});var di=r(j);Yt=o(di,"SPAN",{});var mi=r(Yt);u(Ge.$$.fragment,mi),mi.forEach(a),di.forEach(a),$n=h(pt),Qt=o(pt,"SPAN",{});var ui=r(Qt);Fn=n(ui,"Text generation strategies"),ui.forEach(a),pt.forEach(a),ds=h(e),ht=o(e,"P",{});var gi=r(ht);xn=n(gi,`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.`),gi.forEach(a),ms=h(e),ne=o(e,"P",{});var vn=r(ne);Yn=n(vn,"Check out a few examples that use "),dt=o(vn,"A",{href:!0});var fi=r(dt);Qn=n(fi,"generate()"),fi.forEach(a),An=n(vn,` method to produce
text outputs for different tasks:`),vn.forEach(a),us=h(e),I=o(e,"UL",{});var It=r(I);At=o(It,"LI",{});var yi=r(At);mt=o(yi,"A",{href:!0});var bi=r(mt);Sn=n(bi,"Text summarization"),bi.forEach(a),yi.forEach(a),Hn=h(It),St=o(It,"LI",{});var vi=r(St);ut=o(vi,"A",{href:!0});var wi=r(ut);qn=n(wi,"Image captioning"),wi.forEach(a),vi.forEach(a),Dn=h(It),Ht=o(It,"LI",{});var Mi=r(Ht);gt=o(Mi,"A",{href:!0});var Ti=r(gt);Ln=n(Ti,"Audio transcription"),Ti.forEach(a),Mi.forEach(a),It.forEach(a),gs=h(e),ft=o(e,"P",{});var Ji=r(ft);Pn=n(Ji,`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.`),Ji.forEach(a),fs=h(e),le=o(e,"P",{});var wn=r(le);Kn=n(wn,`The process of selecting output tokens to generate text is known as decoding, and you can customize the decoding strategy
that the `),qt=o(wn,"CODE",{});var ki=r(qt);On=n(ki,"generate()"),ki.forEach(a),el=n(wn,` 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.`),wn.forEach(a),ys=h(e),yt=o(e,"P",{});var ji=r(yt);tl=n(ji,"This guide describes:"),ji.forEach(a),bs=h(e),V=o(e,"UL",{});var Vt=r(V);Dt=o(Vt,"LI",{});var _i=r(Dt);al=n(_i,"default generation configuration"),_i.forEach(a),sl=h(Vt),Lt=o(Vt,"LI",{});var Ui=r(Lt);nl=n(Ui,"common decoding strategies and their main parameters"),Ui.forEach(a),ll=h(Vt),Pt=o(Vt,"LI",{});var Zi=r(Pt);ol=n(Zi,"saving and sharing custom generation configurations with your fine-tuned model on \u{1F917} Hub"),Zi.forEach(a),Vt.forEach(a),vs=h(e),Y=o(e,"H2",{class:!0});var Mn=r(Y);oe=o(Mn,"A",{id:!0,class:!0,href:!0});var Ei=r(oe);Kt=o(Ei,"SPAN",{});var Wi=r(Kt);u(Xe.$$.fragment,Wi),Wi.forEach(a),Ei.forEach(a),rl=h(Mn),Ot=o(Mn,"SPAN",{});var Gi=r(Ot);il=n(Gi,"Default text generation configuration"),Gi.forEach(a),Mn.forEach(a),ws=h(e),C=o(e,"P",{});var Ct=r(C);pl=n(Ct,`A decoding strategy for a model is defined in its generation configuration. When using pre-trained models for inference
within a `),bt=o(Ct,"A",{href:!0});var Xi=r(bt);cl=n(Xi,"pipeline()"),Xi.forEach(a),hl=n(Ct,", the models call the "),ea=o(Ct,"CODE",{});var Bi=r(ea);dl=n(Bi,"PreTrainedModel.generate()"),Bi.forEach(a),ml=n(Ct,` 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.`),Ct.forEach(a),Ms=h(e),re=o(e,"P",{});var Tn=r(re);ul=n(Tn,`When you load a model explicitly, you can inspect the generation configuration that comes with it through
`),ta=o(Tn,"CODE",{});var Ii=r(ta);gl=n(Ii,"model.generation_config"),Ii.forEach(a),fl=n(Tn,":"),Tn.forEach(a),Ts=h(e),u(Be.$$.fragment,e),Js=h(e),ie=o(e,"P",{});var Jn=r(ie);yl=n(Jn,"Printing out the "),aa=o(Jn,"CODE",{});var Vi=r(aa);bl=n(Vi,"model.generation_config"),Vi.forEach(a),vl=n(Jn,` reveals only the values that are different from the default generation
configuration, and does not list any of the default values.`),Jn.forEach(a),ks=h(e),vt=o(e,"P",{});var Ci=r(vt);wl=n(Ci,`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.`),Ci.forEach(a),js=h(e),Q=o(e,"H2",{class:!0});var kn=r(Q);pe=o(kn,"A",{id:!0,class:!0,href:!0});var Ni=r(pe);sa=o(Ni,"SPAN",{});var Ri=r(sa);u(Ie.$$.fragment,Ri),Ri.forEach(a),Ni.forEach(a),Ml=h(kn),na=o(kn,"SPAN",{});var zi=r(na);Tl=n(zi,"Customize text generation"),zi.forEach(a),kn.forEach(a),_s=h(e),N=o(e,"P",{});var Nt=r(N);Jl=n(Nt,"You can override any "),la=o(Nt,"CODE",{});var $i=r(la);kl=n($i,"generation_config"),$i.forEach(a),jl=n(Nt," by passing the parameters and their values directly to the "),oa=o(Nt,"CODE",{});var Fi=r(oa);_l=n(Fi,"generate"),Fi.forEach(a),Ul=n(Nt," method:"),Nt.forEach(a),Us=h(e),u(Ve.$$.fragment,e),Zs=h(e),wt=o(e,"P",{});var xi=r(wt);Zl=n(xi,`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:`),xi.forEach(a),Es=h(e),Z=o(e,"UL",{});var _e=r(Z);Mt=o(_e,"LI",{});var pi=r(Mt);ra=o(pi,"CODE",{});var Yi=r(ra);El=n(Yi,"max_new_tokens"),Yi.forEach(a),Wl=n(pi,`: the maximum number of tokens to generate. In other words, the size of the output sequence, not
including the tokens in the prompt.`),pi.forEach(a),Gl=h(_e),Tt=o(_e,"LI",{});var ci=r(Tt);ia=o(ci,"CODE",{});var Qi=r(ia);Xl=n(Qi,"num_beams"),Qi.forEach(a),Bl=n(ci,`: 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.`),ci.forEach(a),Il=h(_e),ce=o(_e,"LI",{});var cs=r(ce);pa=o(cs,"CODE",{});var Ai=r(pa);Vl=n(Ai,"do_sample"),Ai.forEach(a),Cl=n(cs,": if set to "),ca=o(cs,"CODE",{});var Si=r(ca);Nl=n(Si,"True"),Si.forEach(a),Rl=n(cs,`, 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.`),cs.forEach(a),zl=h(_e),Jt=o(_e,"LI",{});var hi=r(Jt);ha=o(hi,"CODE",{});var Hi=r(ha);$l=n(Hi,"num_return_sequences"),Hi.forEach(a),Fl=n(hi,`: 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.`),hi.forEach(a),_e.forEach(a),Ws=h(e),A=o(e,"H2",{class:!0});var jn=r(A);he=o(jn,"A",{id:!0,class:!0,href:!0});var qi=r(he);da=o(qi,"SPAN",{});var Di=r(da);u(Ce.$$.fragment,Di),Di.forEach(a),qi.forEach(a),xl=h(jn),ma=o(jn,"SPAN",{});var Li=r(ma);Yl=n(Li,"Save a custom decoding strategy with your model"),Li.forEach(a),jn.forEach(a),Gs=h(e),kt=o(e,"P",{});var Pi=r(kt);Ql=n(Pi,"If you would like to share your fine-tuned model with a specific generation configuration, you can:"),Pi.forEach(a),Xs=h(e),E=o(e,"UL",{});var Ue=r(E);Ne=o(Ue,"LI",{});var _n=r(Ne);Al=n(_n,"Create a "),jt=o(_n,"A",{href:!0});var Ki=r(jt);Sl=n(Ki,"GenerationConfig"),Ki.forEach(a),Hl=n(_n," class instance"),_n.forEach(a),ql=h(Ue),ua=o(Ue,"LI",{});var Oi=r(ua);Dl=n(Oi,"Specify the decoding strategy parameters"),Oi.forEach(a),Ll=h(Ue),S=o(Ue,"LI",{});var Rt=r(S);Pl=n(Rt,"Save your generation configuration with "),_t=o(Rt,"A",{href:!0});var ep=r(_t);Kl=n(ep,"GenerationConfig.save_pretrained()"),ep.forEach(a),Ol=n(Rt,", making sure to leave its "),ga=o(Rt,"CODE",{});var tp=r(ga);eo=n(tp,"config_file_name"),tp.forEach(a),to=n(Rt," argument empty"),Rt.forEach(a),ao=h(Ue),H=o(Ue,"LI",{});var zt=r(H);so=n(zt,"Set "),fa=o(zt,"CODE",{});var ap=r(fa);no=n(ap,"push_to_hub"),ap.forEach(a),lo=n(zt," to "),ya=o(zt,"CODE",{});var sp=r(ya);oo=n(sp,"True"),sp.forEach(a),ro=n(zt," to upload your config to the model\u2019s repo"),zt.forEach(a),Ue.forEach(a),Bs=h(e),u(Re.$$.fragment,e),Is=h(e),W=o(e,"P",{});var Ze=r(W);io=n(Ze,"You can also store several generation configurations in a single directory, making use of the "),ba=o(Ze,"CODE",{});var np=r(ba);po=n(np,"config_file_name"),np.forEach(a),co=n(Ze,`
argument in `),Ut=o(Ze,"A",{href:!0});var lp=r(Ut);ho=n(lp,"GenerationConfig.save_pretrained()"),lp.forEach(a),mo=n(Ze,". You can later instantiate them with "),Zt=o(Ze,"A",{href:!0});var op=r(Zt);uo=n(op,"GenerationConfig.from_pretrained()"),op.forEach(a),go=n(Ze,`. 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.`),Ze.forEach(a),Vs=h(e),u(ze.$$.fragment,e),Cs=h(e),q=o(e,"H2",{class:!0});var Un=r(q);de=o(Un,"A",{id:!0,class:!0,href:!0});var rp=r(de);va=o(rp,"SPAN",{});var ip=r(va);u($e.$$.fragment,ip),ip.forEach(a),rp.forEach(a),fo=h(Un),wa=o(Un,"SPAN",{});var pp=r(wa);yo=n(pp,"Streaming"),pp.forEach(a),Un.forEach(a),Ns=h(e),v=o(e,"P",{});var M=r(v);bo=n(M,"The "),Ma=o(M,"CODE",{});var cp=r(Ma);vo=n(cp,"generate()"),cp.forEach(a),wo=n(M," supports streaming, through its "),Ta=o(M,"CODE",{});var hp=r(Ta);Mo=n(hp,"streamer"),hp.forEach(a),To=n(M," input. The "),Ja=o(M,"CODE",{});var dp=r(Ja);Jo=n(dp,"streamer"),dp.forEach(a),ko=n(M,` input is compatible any instance
from a class that has the following methods: `),ka=o(M,"CODE",{});var mp=r(ka);jo=n(mp,"put()"),mp.forEach(a),_o=n(M," and "),ja=o(M,"CODE",{});var up=r(ja);Uo=n(up,"end()"),up.forEach(a),Zo=n(M,". Internally, "),_a=o(M,"CODE",{});var gp=r(_a);Eo=n(gp,"put()"),gp.forEach(a),Wo=n(M,` is used to push new tokens and
`),Ua=o(M,"CODE",{});var fp=r(Ua);Go=n(fp,"end()"),fp.forEach(a),Xo=n(M," is used to flag the end of text generation."),M.forEach(a),Rs=h(e),u(me.$$.fragment,e),zs=h(e),R=o(e,"P",{});var $t=r(R);Bo=n($t,`In practice, you can craft your own streaming class for all sorts of purposes! We also have basic streaming classes
ready for you to use. For example, you can use the `),Et=o($t,"A",{href:!0});var yp=r(Et);Io=n(yp,"TextStreamer"),yp.forEach(a),Vo=n($t," class to stream the output of "),Za=o($t,"CODE",{});var bp=r(Za);Co=n(bp,"generate()"),bp.forEach(a),No=n($t,` into
your screen, one word at a time:`),$t.forEach(a),$s=h(e),u(Fe.$$.fragment,e),Fs=h(e),D=o(e,"H2",{class:!0});var Zn=r(D);ue=o(Zn,"A",{id:!0,class:!0,href:!0});var vp=r(ue);Ea=o(vp,"SPAN",{});var wp=r(Ea);u(xe.$$.fragment,wp),wp.forEach(a),vp.forEach(a),Ro=h(Zn),Wa=o(Zn,"SPAN",{});var Mp=r(Wa);zo=n(Mp,"Decoding strategies"),Mp.forEach(a),Zn.forEach(a),xs=h(e),G=o(e,"P",{});var Ee=r(G);$o=n(Ee,"Certain combinations of the "),Ga=o(Ee,"CODE",{});var Tp=r(Ga);Fo=n(Tp,"generate()"),Tp.forEach(a),xo=n(Ee," parameters, and ultimately "),Xa=o(Ee,"CODE",{});var Jp=r(Xa);Yo=n(Jp,"generation_config"),Jp.forEach(a),Qo=n(Ee,`, can be used to enable specific
decoding strategies. If you are new to this concept, we recommend reading `),Ye=o(Ee,"A",{href:!0,rel:!0});var kp=r(Ye);Ao=n(kp,"this blog post that illustrates how common decoding strategies work"),kp.forEach(a),So=n(Ee,"."),Ee.forEach(a),Ys=h(e),Wt=o(e,"P",{});var jp=r(Wt);Ho=n(jp,"Here, we\u2019ll show some of the parameters that control the decoding strategies and illustrate how you can use them."),jp.forEach(a),Qs=h(e),L=o(e,"H3",{class:!0});var En=r(L);ge=o(En,"A",{id:!0,class:!0,href:!0});var _p=r(ge);Ba=o(_p,"SPAN",{});var Up=r(Ba);u(Qe.$$.fragment,Up),Up.forEach(a),_p.forEach(a),qo=h(En),Ia=o(En,"SPAN",{});var Zp=r(Ia);Do=n(Zp,"Greedy Search"),Zp.forEach(a),En.forEach(a),As=h(e),B=o(e,"P",{});var ct=r(B);Va=o(ct,"CODE",{});var Ep=r(Va);Lo=n(Ep,"generate"),Ep.forEach(a),Po=n(ct," uses greedy search decoding by default so you don\u2019t have to pass any parameters to enable it. This means the parameters "),Ca=o(ct,"CODE",{});var Wp=r(Ca);Ko=n(Wp,"num_beams"),Wp.forEach(a),Oo=n(ct," is set to 1 and "),Na=o(ct,"CODE",{});var Gp=r(Na);er=n(Gp,"do_sample=False"),Gp.forEach(a),tr=n(ct,"."),ct.forEach(a),Ss=h(e),u(Ae.$$.fragment,e),Hs=h(e),P=o(e,"H3",{class:!0});var Wn=r(P);fe=o(Wn,"A",{id:!0,class:!0,href:!0});var Xp=r(fe);Ra=o(Xp,"SPAN",{});var Bp=r(Ra);u(Se.$$.fragment,Bp),Bp.forEach(a),Xp.forEach(a),ar=h(Wn),za=o(Wn,"SPAN",{});var Ip=r(za);sr=n(Ip,"Contrastive search"),Ip.forEach(a),Wn.forEach(a),qs=h(e),J=o(e,"P",{});var F=r(J);nr=n(F,"The contrastive search decoding strategy was proposed in the 2022 paper "),He=o(F,"A",{href:!0,rel:!0});var Vp=r(He);lr=n(Vp,"A Contrastive Framework for Neural Text Generation"),Vp.forEach(a),or=n(F,`.
It demonstrates superior results for generating non-repetitive yet coherent long outputs. To learn how contrastive search
works, check out `),qe=o(F,"A",{href:!0,rel:!0});var Cp=r(qe);rr=n(Cp,"this blog post"),Cp.forEach(a),ir=n(F,`.
The two main parameters that enable and control the behavior of contrastive search are `),$a=o(F,"CODE",{});var Np=r($a);pr=n(Np,"penalty_alpha"),Np.forEach(a),cr=n(F," and "),Fa=o(F,"CODE",{});var Rp=r(Fa);hr=n(Rp,"top_k"),Rp.forEach(a),dr=n(F,":"),F.forEach(a),Ds=h(e),u(De.$$.fragment,e),Ls=h(e),K=o(e,"H3",{class:!0});var Gn=r(K);ye=o(Gn,"A",{id:!0,class:!0,href:!0});var zp=r(ye);xa=o(zp,"SPAN",{});var $p=r(xa);u(Le.$$.fragment,$p),$p.forEach(a),zp.forEach(a),mr=h(Gn),Ya=o(Gn,"SPAN",{});var Fp=r(Ya);ur=n(Fp,"Multinomial sampling"),Fp.forEach(a),Gn.forEach(a),Ps=h(e),Gt=o(e,"P",{});var xp=r(Gt);gr=n(xp,`As opposed to greedy search that always chooses a token with the highest probability as the
next token, multinomial sampling (also called ancestral 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.`),xp.forEach(a),Ks=h(e),z=o(e,"P",{});var Ft=r(z);fr=n(Ft,"To enable multinomial sampling set "),Qa=o(Ft,"CODE",{});var Yp=r(Qa);yr=n(Yp,"do_sample=True"),Yp.forEach(a),br=n(Ft," and "),Aa=o(Ft,"CODE",{});var Qp=r(Aa);vr=n(Qp,"num_beams=1"),Qp.forEach(a),wr=n(Ft,"."),Ft.forEach(a),Os=h(e),u(Pe.$$.fragment,e),en=h(e),O=o(e,"H3",{class:!0});var Xn=r(O);be=o(Xn,"A",{id:!0,class:!0,href:!0});var Ap=r(be);Sa=o(Ap,"SPAN",{});var Sp=r(Sa);u(Ke.$$.fragment,Sp),Sp.forEach(a),Ap.forEach(a),Mr=h(Xn),Ha=o(Xn,"SPAN",{});var Hp=r(Ha);Tr=n(Hp,"Beam-search decoding"),Hp.forEach(a),Xn.forEach(a),tn=h(e),Xt=o(e,"P",{});var qp=r(Xt);Jr=n(qp,`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.`),qp.forEach(a),an=h(e),ve=o(e,"P",{});var Bn=r(ve);kr=n(Bn,"To enable this decoding strategy, specify the "),qa=o(Bn,"CODE",{});var Dp=r(qa);jr=n(Dp,"num_beams"),Dp.forEach(a),_r=n(Bn," (aka number of hypotheses to keep track of) that is greater than 1."),Bn.forEach(a),sn=h(e),u(Oe.$$.fragment,e),nn=h(e),ee=o(e,"H3",{class:!0});var In=r(ee);we=o(In,"A",{id:!0,class:!0,href:!0});var Lp=r(we);Da=o(Lp,"SPAN",{});var Pp=r(Da);u(et.$$.fragment,Pp),Pp.forEach(a),Lp.forEach(a),Ur=h(In),La=o(In,"SPAN",{});var Kp=r(La);Zr=n(Kp,"Beam-search multinomial sampling"),Kp.forEach(a),In.forEach(a),ln=h(e),$=o(e,"P",{});var xt=r($);Er=n(xt,`As the name implies, this decoding strategy combines beam search with multinomial sampling. You need to specify
the `),Pa=o(xt,"CODE",{});var Op=r(Pa);Wr=n(Op,"num_beams"),Op.forEach(a),Gr=n(xt," greater than 1, and set "),Ka=o(xt,"CODE",{});var ec=r(Ka);Xr=n(ec,"do_sample=True"),ec.forEach(a),Br=n(xt," to use this decoding strategy."),xt.forEach(a),on=h(e),u(tt.$$.fragment,e),rn=h(e),te=o(e,"H3",{class:!0});var Vn=r(te);Me=o(Vn,"A",{id:!0,class:!0,href:!0});var tc=r(Me);Oa=o(tc,"SPAN",{});var ac=r(Oa);u(at.$$.fragment,ac),ac.forEach(a),tc.forEach(a),Ir=h(Vn),es=o(Vn,"SPAN",{});var sc=r(es);Vr=n(sc,"Diverse beam search decoding"),sc.forEach(a),Vn.forEach(a),pn=h(e),k=o(e,"P",{});var x=r(k);Cr=n(x,`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 `),st=o(x,"A",{href:!0,rel:!0});var nc=r(st);Nr=n(nc,"Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models"),nc.forEach(a),Rr=n(x,`.
This approach has three main parameters: `),ts=o(x,"CODE",{});var lc=r(ts);zr=n(lc,"num_beams"),lc.forEach(a),$r=n(x,", "),as=o(x,"CODE",{});var oc=r(as);Fr=n(oc,"num_beam_groups"),oc.forEach(a),xr=n(x,", and "),ss=o(x,"CODE",{});var rc=r(ss);Yr=n(rc,"diversity_penalty"),rc.forEach(a),Qr=n(x,`.
The diversily penalty ensures the outputs are distinct across groups, and beam search is used within each group.`),x.forEach(a),cn=h(e),u(nt.$$.fragment,e),hn=h(e),X=o(e,"P",{});var We=r(X);Ar=n(We,`This guide illustrates the main parameters that enable various decoding strategies. More advanced parameters exist for the
`),ns=o(We,"CODE",{});var ic=r(ns);Sr=n(ic,"generate"),ic.forEach(a),Hr=n(We," method, which gives you even further control over the "),ls=o(We,"CODE",{});var pc=r(ls);qr=n(pc,"generate"),pc.forEach(a),Dr=n(We,` method\u2019s behavior.
For the complete list of the available parameters, refer to the `),Bt=o(We,"A",{href:!0});var cc=r(Bt);Lr=n(cc,"API documentation"),cc.forEach(a),Pr=n(We,"."),We.forEach(a),dn=h(e),ae=o(e,"H3",{class:!0});var Cn=r(ae);Te=o(Cn,"A",{id:!0,class:!0,href:!0});var hc=r(Te);os=o(hc,"SPAN",{});var dc=r(os);u(lt.$$.fragment,dc),dc.forEach(a),hc.forEach(a),Kr=h(Cn),rs=o(Cn,"SPAN",{});var mc=r(rs);Or=n(mc,"Assisted Decoding"),mc.forEach(a),Cn.forEach(a),mn=h(e),Je=o(e,"P",{});var Nn=r(Je);ei=n(Nn,`Assisted decoding is a modification of the decoding strategies above that uses an assistant model with the same
tokenizer (ideally a much smaller model) to greedily generate a few candidate tokens. The main model then validates
the candidate tokens in a single forward pass, which speeds up the decoding process. Currently, only greedy search
and sampling are supported with assisted decoding, and doesn\u2019t support batched inputs. To learn more about assisted
decoding, check `),ot=o(Nn,"A",{href:!0,rel:!0});var uc=r(ot);ti=n(uc,"this blog post"),uc.forEach(a),ai=n(Nn,"."),Nn.forEach(a),un=h(e),ke=o(e,"P",{});var Rn=r(ke);si=n(Rn,"To enable assisted decoding, set the "),is=o(Rn,"CODE",{});var gc=r(is);ni=n(gc,"assistant_model"),gc.forEach(a),li=n(Rn," argument with a model."),Rn.forEach(a),gn=h(e),u(rt.$$.fragment,e),fn=h(e),je=o(e,"P",{});var zn=r(je);oi=n(zn,"When using assisted decoding with sampling methods, you can use the "),ps=o(zn,"CODE",{});var fc=r(ps);ri=n(fc,"temperarure"),fc.forEach(a),ii=n(zn,` argument to control the randomness
just like in multinomial sampling. However, in assisted decoding, reducing the temperature will help improving latency.`),zn.forEach(a),yn=h(e),u(it.$$.fragment,e),this.h()},h(){d(w,"name","hf:doc:metadata"),d(w,"content",JSON.stringify(jc)),d(j,"id","text-generation-strategies"),d(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"),d(j,"href","#text-generation-strategies"),d(T,"class","relative group"),d(dt,"href","/docs/transformers/v4.32.0/en/main_classes/text_generation#transformers.GenerationMixin.generate"),d(mt,"href","./tasks/summarization#inference"),d(ut,"href","./model_doc/git#transformers.GitForCausalLM.forward.example"),d(gt,"href","./model_doc/whisper#transformers.WhisperForConditionalGeneration.forward.example"),d(oe,"id","default-text-generation-configuration"),d(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"),d(oe,"href","#default-text-generation-configuration"),d(Y,"class","relative group"),d(bt,"href","/docs/transformers/v4.32.0/en/main_classes/pipelines#transformers.pipeline"),d(pe,"id","customize-text-generation"),d(pe,"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"),d(pe,"href","#customize-text-generation"),d(Q,"class","relative group"),d(he,"id","save-a-custom-decoding-strategy-with-your-model"),d(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"),d(he,"href","#save-a-custom-decoding-strategy-with-your-model"),d(A,"class","relative group"),d(jt,"href","/docs/transformers/v4.32.0/en/main_classes/text_generation#transformers.GenerationConfig"),d(_t,"href","/docs/transformers/v4.32.0/en/main_classes/text_generation#transformers.GenerationConfig.save_pretrained"),d(Ut,"href","/docs/transformers/v4.32.0/en/main_classes/text_generation#transformers.GenerationConfig.save_pretrained"),d(Zt,"href","/docs/transformers/v4.32.0/en/main_classes/text_generation#transformers.GenerationConfig.from_pretrained"),d(de,"id","streaming"),d(de,"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"),d(de,"href","#streaming"),d(q,"class","relative group"),d(Et,"href","/docs/transformers/v4.32.0/en/internal/generation_utils#transformers.TextStreamer"),d(ue,"id","decoding-strategies"),d(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"),d(ue,"href","#decoding-strategies"),d(D,"class","relative group"),d(Ye,"href","https://huggingface.co/blog/how-to-generate"),d(Ye,"rel","nofollow"),d(ge,"id","greedy-search"),d(ge,"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"),d(ge,"href","#greedy-search"),d(L,"class","relative group"),d(fe,"id","contrastive-search"),d(fe,"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"),d(fe,"href","#contrastive-search"),d(P,"class","relative group"),d(He,"href","https://arxiv.org/abs/2202.06417"),d(He,"rel","nofollow"),d(qe,"href","https://huggingface.co/blog/introducing-csearch"),d(qe,"rel","nofollow"),d(ye,"id","multinomial-sampling"),d(ye,"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"),d(ye,"href","#multinomial-sampling"),d(K,"class","relative group"),d(be,"id","beamsearch-decoding"),d(be,"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"),d(be,"href","#beamsearch-decoding"),d(O,"class","relative group"),d(we,"id","beamsearch-multinomial-sampling"),d(we,"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"),d(we,"href","#beamsearch-multinomial-sampling"),d(ee,"class","relative group"),d(Me,"id","diverse-beam-search-decoding"),d(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"),d(Me,"href","#diverse-beam-search-decoding"),d(te,"class","relative group"),d(st,"href","https://arxiv.org/pdf/1610.02424.pdf"),d(st,"rel","nofollow"),d(Bt,"href","./main_classes/text_generation.md"),d(Te,"id","assisted-decoding"),d(Te,"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"),d(Te,"href","#assisted-decoding"),d(ae,"class","relative group"),d(ot,"href","https://huggingface.co/blog/assisted-generation"),d(ot,"rel","nofollow")},m(e,i){t(document.head,w),p(e,se,i),p(e,T,i),t(T,j),t(j,Yt),g(Ge,Yt,null),t(T,$n),t(T,Qt),t(Qt,Fn),p(e,ds,i),p(e,ht,i),t(ht,xn),p(e,ms,i),p(e,ne,i),t(ne,Yn),t(ne,dt),t(dt,Qn),t(ne,An),p(e,us,i),p(e,I,i),t(I,At),t(At,mt),t(mt,Sn),t(I,Hn),t(I,St),t(St,ut),t(ut,qn),t(I,Dn),t(I,Ht),t(Ht,gt),t(gt,Ln),p(e,gs,i),p(e,ft,i),t(ft,Pn),p(e,fs,i),p(e,le,i),t(le,Kn),t(le,qt),t(qt,On),t(le,el),p(e,ys,i),p(e,yt,i),t(yt,tl),p(e,bs,i),p(e,V,i),t(V,Dt),t(Dt,al),t(V,sl),t(V,Lt),t(Lt,nl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Ds,i),g(De,e,i),p(e,Ls,i),p(e,K,i),t(K,ye),t(ye,xa),g(Le,xa,null),t(K,mr),t(K,Ya),t(Ya,ur),p(e,Ps,i),p(e,Gt,i),t(Gt,gr),p(e,Ks,i),p(e,z,i),t(z,fr),t(z,Qa),t(Qa,yr),t(z,br),t(z,Aa),t(Aa,vr),t(z,wr),p(e,Os,i),g(Pe,e,i),p(e,en,i),p(e,O,i),t(O,be),t(be,Sa),g(Ke,Sa,null),t(O,Mr),t(O,Ha),t(Ha,Tr),p(e,tn,i),p(e,Xt,i),t(Xt,Jr),p(e,an,i),p(e,ve,i),t(ve,kr),t(ve,qa),t(qa,jr),t(ve,_r),p(e,sn,i),g(Oe,e,i),p(e,nn,i),p(e,ee,i),t(ee,we),t(we,Da),g(et,Da,null),t(ee,Ur),t(ee,La),t(La,Zr),p(e,ln,i),p(e,$,i),t($,Er),t($,Pa),t(Pa,Wr),t($,Gr),t($,Ka),t(Ka,Xr),t($,Br),p(e,on,i),g(tt,e,i),p(e,rn,i),p(e,te,i),t(te,Me),t(Me,Oa),g(at,Oa,null),t(te,Ir),t(te,es),t(es,Vr),p(e,pn,i),p(e,k,i),t(k,Cr),t(k,st),t(st,Nr),t(k,Rr),t(k,ts),t(ts,zr),t(k,$r),t(k,as),t(as,Fr),t(k,xr),t(k,ss),t(ss,Yr),t(k,Qr),p(e,cn,i),g(nt,e,i),p(e,hn,i),p(e,X,i),t(X,Ar),t(X,ns),t(ns,Sr),t(X,Hr),t(X,ls),t(ls,qr),t(X,Dr),t(X,Bt),t(Bt,Lr),t(X,Pr),p(e,dn,i),p(e,ae,i),t(ae,Te),t(Te,os),g(lt,os,null),t(ae,Kr),t(ae,rs),t(rs,Or),p(e,mn,i),p(e,Je,i),t(Je,ei),t(Je,ot),t(ot,ti),t(Je,ai),p(e,un,i),p(e,ke,i),t(ke,si),t(ke,is),t(is,ni),t(ke,li),p(e,gn,i),g(rt,e,i),p(e,fn,i),p(e,je,i),t(je,oi),t(je,ps),t(ps,ri),t(je,ii),p(e,yn,i),g(it,e,i),bn=!0},p(e,[i]){const pt={};i&2&&(pt.$$scope={dirty:i,ctx:e}),me.$set(pt)},i(e){bn||(f(Ge.$$.fragment,e),f(Xe.$$.fragment,e),f(Be.$$.fragment,e),f(Ie.$$.fragment,e),f(Ve.$$.fragment,e),f(Ce.$$.fragment,e),f(Re.$$.fragment,e),f(ze.$$.fragment,e),f($e.$$.fragment,e),f(me.$$.fragment,e),f(Fe.$$.fragment,e),f(xe.$$.fragment,e),f(Qe.$$.fragment,e),f(Ae.$$.fragment,e),f(Se.$$.fragment,e),f(De.$$.fragment,e),f(Le.$$.fragment,e),f(Pe.$$.fragment,e),f(Ke.$$.fragment,e),f(Oe.$$.fragment,e),f(et.$$.fragment,e),f(tt.$$.fragment,e),f(at.$$.fragment,e),f(nt.$$.fragment,e),f(lt.$$.fragment,e),f(rt.$$.fragment,e),f(it.$$.fragment,e),bn=!0)},o(e){y(Ge.$$.fragment,e),y(Xe.$$.fragment,e),y(Be.$$.fragment,e),y(Ie.$$.fragment,e),y(Ve.$$.fragment,e),y(Ce.$$.fragment,e),y(Re.$$.fragment,e),y(ze.$$.fragment,e),y($e.$$.fragment,e),y(me.$$.fragment,e),y(Fe.$$.fragment,e),y(xe.$$.fragment,e),y(Qe.$$.fragment,e),y(Ae.$$.fragment,e),y(Se.$$.fragment,e),y(De.$$.fragment,e),y(Le.$$.fragment,e),y(Pe.$$.fragment,e),y(Ke.$$.fragment,e),y(Oe.$$.fragment,e),y(et.$$.fragment,e),y(tt.$$.fragment,e),y(at.$$.fragment,e),y(nt.$$.fragment,e),y(lt.$$.fragment,e),y(rt.$$.fragment,e),y(it.$$.fragment,e),bn=!1},d(e){a(w),e&&a(se),e&&a(T),b(Ge),e&&a(ds),e&&a(ht),e&&a(ms),e&&a(ne),e&&a(us),e&&a(I),e&&a(gs),e&&a(ft),e&&a(fs),e&&a(le),e&&a(ys),e&&a(yt),e&&a(bs),e&&a(V),e&&a(vs),e&&a(Y),b(Xe),e&&a(ws),e&&a(C),e&&a(Ms),e&&a(re),e&&a(Ts),b(Be,e),e&&a(Js),e&&a(ie),e&&a(ks),e&&a(vt),e&&a(js),e&&a(Q),b(Ie),e&&a(_s),e&&a(N),e&&a(Us),b(Ve,e),e&&a(Zs),e&&a(wt),e&&a(Es),e&&a(Z),e&&a(Ws),e&&a(A),b(Ce),e&&a(Gs),e&&a(kt),e&&a(Xs),e&&a(E),e&&a(Bs),b(Re,e),e&&a(Is),e&&a(W),e&&a(Vs),b(ze,e),e&&a(Cs),e&&a(q),b($e),e&&a(Ns),e&&a(v),e&&a(Rs),b(me,e),e&&a(zs),e&&a(R),e&&a($s),b(Fe,e),e&&a(Fs),e&&a(D),b(xe),e&&a(xs),e&&a(G),e&&a(Ys),e&&a(Wt),e&&a(Qs),e&&a(L),b(Qe),e&&a(As),e&&a(B),e&&a(Ss),b(Ae,e),e&&a(Hs),e&&a(P),b(Se),e&&a(qs),e&&a(J),e&&a(Ds),b(De,e),e&&a(Ls),e&&a(K),b(Le),e&&a(Ps),e&&a(Gt),e&&a(Ks),e&&a(z),e&&a(Os),b(Pe,e),e&&a(en),e&&a(O),b(Ke),e&&a(tn),e&&a(Xt),e&&a(an),e&&a(ve),e&&a(sn),b(Oe,e),e&&a(nn),e&&a(ee),b(et),e&&a(ln),e&&a($),e&&a(on),b(tt,e),e&&a(rn),e&&a(te),b(at),e&&a(pn),e&&a(k),e&&a(cn),b(nt,e),e&&a(hn),e&&a(X),e&&a(dn),e&&a(ae),b(lt),e&&a(mn),e&&a(Je),e&&a(un),e&&a(ke),e&&a(gn),b(rt,e),e&&a(fn),e&&a(je),e&&a(yn),b(it,e)}}}const jc={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:"streaming",title:"Streaming"},{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"},{local:"assisted-decoding",title:"Assisted Decoding"}],title:"Decoding strategies"}],title:"Text generation strategies"};function _c(hs){return Mc(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gc extends yc{constructor(w){super();bc(this,w,_c,kc,vc,{})}}export{Gc as default,jc as metadata};
