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