import{s as re,o as de,n as oe}from"../chunks/scheduler.182ea377.js";import{S as pe,i as ue,g as r,s as l,r as C,A as fe,h as d,f as n,c as o,j as W,u as H,x as m,k as Y,y as k,a,v as V,d as j,t as R,w as S}from"../chunks/index.abf12888.js";import{T as se}from"../chunks/Tip.230e2334.js";import{D as me}from"../chunks/Docstring.93f6f462.js";import{H as le}from"../chunks/Heading.16916d63.js";function ce(T){let i,u="🧪 This is an experimental pipeline for reinforcement learning!";return{c(){i=r("p"),i.textContent=u},l(s){i=d(s,"P",{"data-svelte-h":!0}),m(i)!=="svelte-13bwjls"&&(i.textContent=u)},m(s,c){a(s,i,c)},p:oe,d(s){s&&n(i)}}}function he(T){let i,u='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){i=r("p"),i.innerHTML=u},l(s){i=d(s,"P",{"data-svelte-h":!0}),m(i)!=="svelte-1wmc0l4"&&(i.innerHTML=u)},m(s,c){a(s,i,c)},p:oe,d(s){s&&n(i)}}}function ge(T){let i,u,s,c,v,G,h,U,$,Z='This pipeline is based on the <a href="https://huggingface.co/papers/2205.09991" rel="nofollow">Planning with Diffusion for Flexible Behavior Synthesis</a> paper by Michael Janner, Yilun Du, Joshua B. Tenenbaum, Sergey Levine.',N,x,K="The abstract from the paper is:",z,b,Q="<em>Model-based reinforcement learning methods often use learning only for the purpose of estimating an approximate dynamics model, offloading the rest of the decision-making work to classical trajectory optimizers. While conceptually simple, this combination has a number of empirical shortcomings, suggesting that learned models may not be well-suited to standard trajectory optimization. In this paper, we consider what it would look like to fold as much of the trajectory optimization pipeline as possible into the modeling problem, such that sampling from the model and planning with it become nearly identical. The core of our technical approach lies in a diffusion probabilistic model that plans by iteratively denoising trajectories. We show how classifier-guided sampling and image inpainting can be reinterpreted as coherent planning strategies, explore the unusual and useful properties of diffusion-based planning methods, and demonstrate the effectiveness of our framework in control settings that emphasize long-horizon decision-making and test-time flexibility.</em>",A,w,ee='You can find additional information about the model on the <a href="https://diffusion-planning.github.io/" rel="nofollow">project page</a>, the <a href="https://github.com/jannerm/diffuser" rel="nofollow">original codebase</a>, or try it out in a demo <a href="https://colab.research.google.com/drive/1rXm8CX4ZdN5qivjJ2lhwhkOmt_m0CvU0#scrollTo=6HXJvhyqcITc&amp;uniqifier=1" rel="nofollow">notebook</a>.',q,_,te='The script to run the model is available <a href="https://github.com/huggingface/diffusers/tree/main/examples/reinforcement_learning" rel="nofollow">here</a>.',E,g,I,P,J,p,M,F,L,ne="Pipeline for value-guided sampling from a diffusion model trained to predict sequences of states.",O,y,ie=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,X,D,B;return v=new le({props:{title:"Value-guided planning",local:"value-guided-planning",headingTag:"h1"}}),h=new se({props:{warning:!0,$$slots:{default:[ce]},$$scope:{ctx:T}}}),g=new se({props:{$$slots:{default:[he]},$$scope:{ctx:T}}}),P=new le({props:{title:"ValueGuidedRLPipeline",local:"diffusers.experimental.ValueGuidedRLPipeline",headingTag:"h2"}}),M=new me({props:{name:"class diffusers.experimental.ValueGuidedRLPipeline",anchor:"diffusers.experimental.ValueGuidedRLPipeline",parameters:[{name:"value_function",val:": UNet1DModel"},{name:"unet",val:": UNet1DModel"},{name:"scheduler",val:": DDPMScheduler"},{name:"env",val:""}],parametersDescription:[{anchor:"diffusers.experimental.ValueGuidedRLPipeline.value_function",description:`<strong>value_function</strong> (<a href="/docs/diffusers/main/en/api/models/unet#diffusers.UNet1DModel">UNet1DModel</a>) &#x2014;
A specialized UNet for fine-tuning trajectories base on reward.`,name:"value_function"},{anchor:"diffusers.experimental.ValueGuidedRLPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet#diffusers.UNet1DModel">UNet1DModel</a>) &#x2014;
UNet architecture to denoise the encoded trajectories.`,name:"unet"},{anchor:"diffusers.experimental.ValueGuidedRLPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded trajectories. Default for this
application is <a href="/docs/diffusers/main/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.experimental.ValueGuidedRLPipeline.env",description:`<strong>env</strong> () &#x2014;
An environment following the OpenAI gym API to act in. For now only Hopper has pretrained models.`,name:"env"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/experimental/rl/value_guided_sampling.py#L25"}}),{c(){i=r("meta"),u=l(),s=r("p"),c=l(),C(v.$$.fragment),G=l(),C(h.$$.fragment),U=l(),$=r("p"),$.innerHTML=Z,N=l(),x=r("p"),x.textContent=K,z=l(),b=r("p"),b.innerHTML=Q,A=l(),w=r("p"),w.innerHTML=ee,q=l(),_=r("p"),_.innerHTML=te,E=l(),C(g.$$.fragment),I=l(),C(P.$$.fragment),J=l(),p=r("div"),C(M.$$.fragment),F=l(),L=r("p"),L.textContent=ne,O=l(),y=r("p"),y.innerHTML=ie,X=l(),D=r("p"),this.h()},l(e){const t=fe("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(n),u=o(e),s=d(e,"P",{}),W(s).forEach(n),c=o(e),H(v.$$.fragment,e),G=o(e),H(h.$$.fragment,e),U=o(e),$=d(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-1dguds4"&&($.innerHTML=Z),N=o(e),x=d(e,"P",{"data-svelte-h":!0}),m(x)!=="svelte-1cwsb16"&&(x.textContent=K),z=o(e),b=d(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-k2slph"&&(b.innerHTML=Q),A=o(e),w=d(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-1fh8mls"&&(w.innerHTML=ee),q=o(e),_=d(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-guadao"&&(_.innerHTML=te),E=o(e),H(g.$$.fragment,e),I=o(e),H(P.$$.fragment,e),J=o(e),p=d(e,"DIV",{class:!0});var f=W(p);H(M.$$.fragment,f),F=o(f),L=d(f,"P",{"data-svelte-h":!0}),m(L)!=="svelte-apl1xd"&&(L.textContent=ne),O=o(f),y=d(f,"P",{"data-svelte-h":!0}),m(y)!=="svelte-496sm0"&&(y.innerHTML=ie),f.forEach(n),X=o(e),D=d(e,"P",{}),W(D).forEach(n),this.h()},h(){Y(i,"name","hf:doc:metadata"),Y(i,"content",ve),Y(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){k(document.head,i),a(e,u,t),a(e,s,t),a(e,c,t),V(v,e,t),a(e,G,t),V(h,e,t),a(e,U,t),a(e,$,t),a(e,N,t),a(e,x,t),a(e,z,t),a(e,b,t),a(e,A,t),a(e,w,t),a(e,q,t),a(e,_,t),a(e,E,t),V(g,e,t),a(e,I,t),V(P,e,t),a(e,J,t),a(e,p,t),V(M,p,null),k(p,F),k(p,L),k(p,O),k(p,y),a(e,X,t),a(e,D,t),B=!0},p(e,[t]){const f={};t&2&&(f.$$scope={dirty:t,ctx:e}),h.$set(f);const ae={};t&2&&(ae.$$scope={dirty:t,ctx:e}),g.$set(ae)},i(e){B||(j(v.$$.fragment,e),j(h.$$.fragment,e),j(g.$$.fragment,e),j(P.$$.fragment,e),j(M.$$.fragment,e),B=!0)},o(e){R(v.$$.fragment,e),R(h.$$.fragment,e),R(g.$$.fragment,e),R(P.$$.fragment,e),R(M.$$.fragment,e),B=!1},d(e){e&&(n(u),n(s),n(c),n(G),n(U),n($),n(N),n(x),n(z),n(b),n(A),n(w),n(q),n(_),n(E),n(I),n(J),n(p),n(X),n(D)),n(i),S(v,e),S(h,e),S(g,e),S(P,e),S(M)}}}const ve='{"title":"Value-guided planning","local":"value-guided-planning","sections":[{"title":"ValueGuidedRLPipeline","local":"diffusers.experimental.ValueGuidedRLPipeline","sections":[],"depth":2}],"depth":1}';function $e(T){return de(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Me extends pe{constructor(i){super(),ue(this,i,$e,ge,re,{})}}export{Me as component};
