import{s as re,o as de,n as le}from"../chunks/scheduler.182ea377.js";import{S as fe,i as ue,g as r,s as o,r as C,A as pe,h as d,f as n,c as l,j as O,u as H,x as m,k as K,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 oe}from"../chunks/Heading.16916d63.js";function ce(L){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:le,d(s){s&&n(i)}}}function he(L){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:le,d(s){s&&n(i)}}}function ge(L){let i,u,s,c,$,G,h,U,v,Q='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,b,X="The abstract from the paper is:",N,x,Z="<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,_,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/github/huggingface/notebooks/blob/main/diffusers/reinforcement_learning_with_diffusers.ipynb" rel="nofollow">notebook</a>.',E,w,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>.',I,g,q,P,B,f,M,W,T,ne="Pipeline for value-guided sampling from a diffusion model trained to predict sequences of states.",Y,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.).`,F,D,J;return $=new oe({props:{title:"Value-guided planning",local:"value-guided-planning",headingTag:"h1"}}),h=new se({props:{warning:!0,$$slots:{default:[ce]},$$scope:{ctx:L}}}),g=new se({props:{$$slots:{default:[he]},$$scope:{ctx:L}}}),P=new oe({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=o(),s=r("p"),c=o(),C($.$$.fragment),G=o(),C(h.$$.fragment),U=o(),v=r("p"),v.innerHTML=Q,z=o(),b=r("p"),b.textContent=X,N=o(),x=r("p"),x.innerHTML=Z,A=o(),_=r("p"),_.innerHTML=ee,E=o(),w=r("p"),w.innerHTML=te,I=o(),C(g.$$.fragment),q=o(),C(P.$$.fragment),B=o(),f=r("div"),C(M.$$.fragment),W=o(),T=r("p"),T.textContent=ne,Y=o(),y=r("p"),y.innerHTML=ie,F=o(),D=r("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(n),u=l(e),s=d(e,"P",{}),O(s).forEach(n),c=l(e),H($.$$.fragment,e),G=l(e),H(h.$$.fragment,e),U=l(e),v=d(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-1dguds4"&&(v.innerHTML=Q),z=l(e),b=d(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-1cwsb16"&&(b.textContent=X),N=l(e),x=d(e,"P",{"data-svelte-h":!0}),m(x)!=="svelte-k2slph"&&(x.innerHTML=Z),A=l(e),_=d(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-12zh09v"&&(_.innerHTML=ee),E=l(e),w=d(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-guadao"&&(w.innerHTML=te),I=l(e),H(g.$$.fragment,e),q=l(e),H(P.$$.fragment,e),B=l(e),f=d(e,"DIV",{class:!0});var p=O(f);H(M.$$.fragment,p),W=l(p),T=d(p,"P",{"data-svelte-h":!0}),m(T)!=="svelte-apl1xd"&&(T.textContent=ne),Y=l(p),y=d(p,"P",{"data-svelte-h":!0}),m(y)!=="svelte-496sm0"&&(y.innerHTML=ie),p.forEach(n),F=l(e),D=d(e,"P",{}),O(D).forEach(n),this.h()},h(){K(i,"name","hf:doc:metadata"),K(i,"content",$e),K(f,"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($,e,t),a(e,G,t),V(h,e,t),a(e,U,t),a(e,v,t),a(e,z,t),a(e,b,t),a(e,N,t),a(e,x,t),a(e,A,t),a(e,_,t),a(e,E,t),a(e,w,t),a(e,I,t),V(g,e,t),a(e,q,t),V(P,e,t),a(e,B,t),a(e,f,t),V(M,f,null),k(f,W),k(f,T),k(f,Y),k(f,y),a(e,F,t),a(e,D,t),J=!0},p(e,[t]){const p={};t&2&&(p.$$scope={dirty:t,ctx:e}),h.$set(p);const ae={};t&2&&(ae.$$scope={dirty:t,ctx:e}),g.$set(ae)},i(e){J||(j($.$$.fragment,e),j(h.$$.fragment,e),j(g.$$.fragment,e),j(P.$$.fragment,e),j(M.$$.fragment,e),J=!0)},o(e){R($.$$.fragment,e),R(h.$$.fragment,e),R(g.$$.fragment,e),R(P.$$.fragment,e),R(M.$$.fragment,e),J=!1},d(e){e&&(n(u),n(s),n(c),n(G),n(U),n(v),n(z),n(b),n(N),n(x),n(A),n(_),n(E),n(w),n(I),n(q),n(B),n(f),n(F),n(D)),n(i),S($,e),S(h,e),S(g,e),S(P,e),S(M)}}}const $e='{"title":"Value-guided planning","local":"value-guided-planning","sections":[{"title":"ValueGuidedRLPipeline","local":"diffusers.experimental.ValueGuidedRLPipeline","sections":[],"depth":2}],"depth":1}';function ve(L){return de(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Me extends fe{constructor(i){super(),ue(this,i,ve,ge,re,{})}}export{Me as component};
