import{s as D,o as ee,n as te}from"../chunks/scheduler.25b97de1.js";import{S as ne,i as le,g as r,s as a,r as v,A as se,h as p,f as n,c as o,j as O,u as _,x as U,k as K,y as ae,a as l,v as j,d as k,t as J,w as Z}from"../chunks/index.d9030fc9.js";import{T as oe}from"../chunks/Tip.baa67368.js";import{C as ie}from"../chunks/CodeBlock.e6cd0d95.js";import{H as W,E as re}from"../chunks/EditOnGithub.91d95064.js";function pe(I){let s,u='Refer to <a href="t5">T5’s documentation page</a> for API reference, tips, code examples and notebooks.';return{c(){s=r("p"),s.innerHTML=u},l(i){s=p(i,"P",{"data-svelte-h":!0}),U(s)!=="svelte-qwctac"&&(s.innerHTML=u)},m(i,y){l(i,s,y)},p:te,d(i){i&&n(s)}}}function me(I){let s,u,i,y,c,q,d,F,f,A=`Flan-UL2 is an encoder decoder model based on the T5 architecture. It uses the same configuration as the <a href="ul2">UL2</a> model released earlier last year.
It was fine tuned using the “Flan” prompt tuning and dataset collection. Similar to <code>Flan-T5</code>,  one can directly use FLAN-UL2 weights without finetuning the model:`,G,h,S="According to the original blog here are the notable improvements:",x,g,V=`<li>The original UL2 model was only trained with receptive field of 512, which made it non-ideal for N-shot prompting where N is large.</li> <li>The Flan-UL2 checkpoint uses a receptive field of 2048 which makes it more usable for few-shot in-context learning.</li> <li>The original UL2 model also had mode switch tokens that was rather mandatory to get good performance. However, they were a little cumbersome as this requires often some changes during inference or finetuning. In this update/change, we continue training UL2 20B for an additional 100k steps (with small batch) to forget “mode tokens” before applying Flan instruction tuning. This Flan-UL2 checkpoint does not require mode tokens anymore.
Google has released the following variants:</li>`,B,w,P='The original checkpoints can be found <a href="https://github.com/google-research/t5x/blob/main/docs/models.md#flan-ul2-checkpoints" rel="nofollow">here</a>.',C,T,E,$,Y="The model is pretty heavy (~40GB in half precision) so if you just want to run the model, make sure you load your model in 8bit, and use <code>device_map=&quot;auto&quot;</code> to make sure  you don’t have any OOM issue!",z,M,H,m,R,b,X,L,N;return c=new W({props:{title:"FLAN-UL2",local:"flan-ul2",headingTag:"h1"}}),d=new W({props:{title:"Overview",local:"overview",headingTag:"h2"}}),T=new W({props:{title:"Running on low resource devices",local:"running-on-low-resource-devices",headingTag:"h2"}}),M=new ie({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTSUyQyUyMEF1dG9Ub2tlbml6ZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcTJTZXFMTS5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGZmxhbi11bDIlMjIlMkMlMjBsb2FkX2luXzhiaXQlM0RUcnVlJTJDJTIwZGV2aWNlX21hcCUzRCUyMmF1dG8lMjIpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZ29vZ2xlJTJGZmxhbi11bDIlMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMkElMjBzdGVwJTIwYnklMjBzdGVwJTIwcmVjaXBlJTIwdG8lMjBtYWtlJTIwYm9sb2duZXNlJTIwcGFzdGElM0ElMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyklMEFwcmludCh0b2tlbml6ZXIuYmF0Y2hfZGVjb2RlKG91dHB1dHMlMkMlMjBza2lwX3NwZWNpYWxfdG9rZW5zJTNEVHJ1ZSkp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSeq2SeqLM, AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSeq2SeqLM.from_pretrained(<span class="hljs-string">&quot;google/flan-ul2&quot;</span>, load_in_8bit=<span class="hljs-literal">True</span>, device_map=<span class="hljs-string">&quot;auto&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;google/flan-ul2&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;A step by step recipe to make bolognese pasta:&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = model.generate(**inputs)
<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;In a large skillet, brown the ground beef and onion over medium heat. Add the garlic&#x27;</span>]`,wrap:!1}}),m=new oe({props:{$$slots:{default:[pe]},$$scope:{ctx:I}}}),b=new re({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/flan-ul2.md"}}),{c(){s=r("meta"),u=a(),i=r("p"),y=a(),v(c.$$.fragment),q=a(),v(d.$$.fragment),F=a(),f=r("p"),f.innerHTML=A,G=a(),h=r("p"),h.textContent=S,x=a(),g=r("ul"),g.innerHTML=V,B=a(),w=r("p"),w.innerHTML=P,C=a(),v(T.$$.fragment),E=a(),$=r("p"),$.innerHTML=Y,z=a(),v(M.$$.fragment),H=a(),v(m.$$.fragment),R=a(),v(b.$$.fragment),X=a(),L=r("p"),this.h()},l(e){const t=se("svelte-u9bgzb",document.head);s=p(t,"META",{name:!0,content:!0}),t.forEach(n),u=o(e),i=p(e,"P",{}),O(i).forEach(n),y=o(e),_(c.$$.fragment,e),q=o(e),_(d.$$.fragment,e),F=o(e),f=p(e,"P",{"data-svelte-h":!0}),U(f)!=="svelte-gpwdss"&&(f.innerHTML=A),G=o(e),h=p(e,"P",{"data-svelte-h":!0}),U(h)!=="svelte-10cnwdi"&&(h.textContent=S),x=o(e),g=p(e,"UL",{"data-svelte-h":!0}),U(g)!=="svelte-145gzzg"&&(g.innerHTML=V),B=o(e),w=p(e,"P",{"data-svelte-h":!0}),U(w)!=="svelte-tjdjai"&&(w.innerHTML=P),C=o(e),_(T.$$.fragment,e),E=o(e),$=p(e,"P",{"data-svelte-h":!0}),U($)!=="svelte-1qrqz37"&&($.innerHTML=Y),z=o(e),_(M.$$.fragment,e),H=o(e),_(m.$$.fragment,e),R=o(e),_(b.$$.fragment,e),X=o(e),L=p(e,"P",{}),O(L).forEach(n),this.h()},h(){K(s,"name","hf:doc:metadata"),K(s,"content",ue)},m(e,t){ae(document.head,s),l(e,u,t),l(e,i,t),l(e,y,t),j(c,e,t),l(e,q,t),j(d,e,t),l(e,F,t),l(e,f,t),l(e,G,t),l(e,h,t),l(e,x,t),l(e,g,t),l(e,B,t),l(e,w,t),l(e,C,t),j(T,e,t),l(e,E,t),l(e,$,t),l(e,z,t),j(M,e,t),l(e,H,t),j(m,e,t),l(e,R,t),j(b,e,t),l(e,X,t),l(e,L,t),N=!0},p(e,[t]){const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),m.$set(Q)},i(e){N||(k(c.$$.fragment,e),k(d.$$.fragment,e),k(T.$$.fragment,e),k(M.$$.fragment,e),k(m.$$.fragment,e),k(b.$$.fragment,e),N=!0)},o(e){J(c.$$.fragment,e),J(d.$$.fragment,e),J(T.$$.fragment,e),J(M.$$.fragment,e),J(m.$$.fragment,e),J(b.$$.fragment,e),N=!1},d(e){e&&(n(u),n(i),n(y),n(q),n(F),n(f),n(G),n(h),n(x),n(g),n(B),n(w),n(C),n(E),n($),n(z),n(H),n(R),n(X),n(L)),n(s),Z(c,e),Z(d,e),Z(T,e),Z(M,e),Z(m,e),Z(b,e)}}}const ue='{"title":"FLAN-UL2","local":"flan-ul2","sections":[{"title":"Overview","local":"overview","sections":[],"depth":2},{"title":"Running on low resource devices","local":"running-on-low-resource-devices","sections":[],"depth":2}],"depth":1}';function ce(I){return ee(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Te extends ne{constructor(s){super(),le(this,s,ce,me,D,{})}}export{Te as component};
