import{s as pe,n as fe,o as me}from"../chunks/scheduler.53228c21.js";import{S as ce,i as he,e as l,s as a,c as C,h as ge,a as o,d as i,b as s,f as Z,g as D,j as d,k as H,l as k,m as n,n as V,t as j,o as S,p as U}from"../chunks/index.100fac89.js";import{C as ve}from"../chunks/CopyLLMTxtMenu.b0ff86f3.js";import{D as be}from"../chunks/Docstring.db856a1e.js";import{H as de,E as xe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.136ef3fd.js";function $e(ee){let u,q,y,G,m,R,c,E,p,te="<p>🧪 This is an experimental pipeline for reinforcement learning!</p>",N,h,ie='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.',z,g,ne="The abstract from the paper is:",O,v,ae="<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,b,se='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>.',I,x,le='The script to run the model is available <a href="https://github.com/huggingface/diffusers/tree/main/examples/reinforcement_learning" rel="nofollow">here</a>.',B,f,oe='<p>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-a-pipeline">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.</p>',J,$,X,r,w,W,M,re="Pipeline for value-guided sampling from a diffusion model trained to predict sequences of states.",Y,L,ue=`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.).`,F,_,K,T,Q;return m=new ve({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new de({props:{title:"Value-guided planning",local:"value-guided-planning",headingTag:"h1"}}),$=new de({props:{title:"ValueGuidedRLPipeline",local:"diffusers.experimental.ValueGuidedRLPipeline",headingTag:"h2"}}),w=new be({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"}}),_=new xe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/value_guided_sampling.md"}}),{c(){u=l("meta"),q=a(),y=l("p"),G=a(),C(m.$$.fragment),R=a(),C(c.$$.fragment),E=a(),p=l("blockquote"),p.innerHTML=te,N=a(),h=l("p"),h.innerHTML=ie,z=a(),g=l("p"),g.textContent=ne,O=a(),v=l("p"),v.innerHTML=ae,A=a(),b=l("p"),b.innerHTML=se,I=a(),x=l("p"),x.innerHTML=le,B=a(),f=l("blockquote"),f.innerHTML=oe,J=a(),C($.$$.fragment),X=a(),r=l("div"),C(w.$$.fragment),W=a(),M=l("p"),M.textContent=re,Y=a(),L=l("p"),L.innerHTML=ue,F=a(),C(_.$$.fragment),K=a(),T=l("p"),this.h()},l(e){const t=ge("svelte-u9bgzb",document.head);u=o(t,"META",{name:!0,content:!0}),t.forEach(i),q=s(e),y=o(e,"P",{}),Z(y).forEach(i),G=s(e),D(m.$$.fragment,e),R=s(e),D(c.$$.fragment,e),E=s(e),p=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),d(p)!=="svelte-1yn3rwc"&&(p.innerHTML=te),N=s(e),h=o(e,"P",{"data-svelte-h":!0}),d(h)!=="svelte-1dguds4"&&(h.innerHTML=ie),z=s(e),g=o(e,"P",{"data-svelte-h":!0}),d(g)!=="svelte-1cwsb16"&&(g.textContent=ne),O=s(e),v=o(e,"P",{"data-svelte-h":!0}),d(v)!=="svelte-k2slph"&&(v.innerHTML=ae),A=s(e),b=o(e,"P",{"data-svelte-h":!0}),d(b)!=="svelte-1fh8mls"&&(b.innerHTML=se),I=s(e),x=o(e,"P",{"data-svelte-h":!0}),d(x)!=="svelte-guadao"&&(x.innerHTML=le),B=s(e),f=o(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),d(f)!=="svelte-r1jcqf"&&(f.innerHTML=oe),J=s(e),D($.$$.fragment,e),X=s(e),r=o(e,"DIV",{class:!0});var P=Z(r);D(w.$$.fragment,P),W=s(P),M=o(P,"P",{"data-svelte-h":!0}),d(M)!=="svelte-apl1xd"&&(M.textContent=re),Y=s(P),L=o(P,"P",{"data-svelte-h":!0}),d(L)!=="svelte-496sm0"&&(L.innerHTML=ue),P.forEach(i),F=s(e),D(_.$$.fragment,e),K=s(e),T=o(e,"P",{}),Z(T).forEach(i),this.h()},h(){H(u,"name","hf:doc:metadata"),H(u,"content",we),H(p,"class","warning"),H(f,"class","tip"),H(r,"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,u),n(e,q,t),n(e,y,t),n(e,G,t),V(m,e,t),n(e,R,t),V(c,e,t),n(e,E,t),n(e,p,t),n(e,N,t),n(e,h,t),n(e,z,t),n(e,g,t),n(e,O,t),n(e,v,t),n(e,A,t),n(e,b,t),n(e,I,t),n(e,x,t),n(e,B,t),n(e,f,t),n(e,J,t),V($,e,t),n(e,X,t),n(e,r,t),V(w,r,null),k(r,W),k(r,M),k(r,Y),k(r,L),n(e,F,t),V(_,e,t),n(e,K,t),n(e,T,t),Q=!0},p:fe,i(e){Q||(j(m.$$.fragment,e),j(c.$$.fragment,e),j($.$$.fragment,e),j(w.$$.fragment,e),j(_.$$.fragment,e),Q=!0)},o(e){S(m.$$.fragment,e),S(c.$$.fragment,e),S($.$$.fragment,e),S(w.$$.fragment,e),S(_.$$.fragment,e),Q=!1},d(e){e&&(i(q),i(y),i(G),i(R),i(E),i(p),i(N),i(h),i(z),i(g),i(O),i(v),i(A),i(b),i(I),i(x),i(B),i(f),i(J),i(X),i(r),i(F),i(K),i(T)),i(u),U(m,e),U(c,e),U($,e),U(w),U(_,e)}}}const we='{"title":"Value-guided planning","local":"value-guided-planning","sections":[{"title":"ValueGuidedRLPipeline","local":"diffusers.experimental.ValueGuidedRLPipeline","sections":[],"depth":2}],"depth":1}';function _e(ee){return me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ce extends ce{constructor(u){super(),he(this,u,_e,$e,pe,{})}}export{Ce as component};
