import{s as ie,o as ae,n as se}from"../chunks/scheduler.182ea377.js";import{S as oe,i as le,g as l,s,r as N,A as re,h as r,f as n,c as o,j as W,u as A,x as m,k as Y,y as D,a as i,v as E,d as I,t as q,w as B}from"../chunks/index.1ea56653.js";import{H as ne,g as de}from"../chunks/Heading.71ac6e9f.js";import{T as ue}from"../chunks/Tip.67abc998.js";import{D as fe}from"../chunks/Docstring.59aaf0cd.js";function pe(T){let a,c="🧪 This is an experimental pipeline for reinforcement learning!";return{c(){a=l("p"),a.textContent=c},l(d){a=r(d,"P",{"data-svelte-h":!0}),m(a)!=="svelte-13bwjls"&&(a.textContent=c)},m(d,P){i(d,a,P)},p:se,d(d){d&&n(a)}}}function me(T){let a,c,d,P,h,C,p,H,g,O='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.',V,v,K="The abstract from the paper is:",j,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>.",G,x,X='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>.',R,$,Z='The script to run the model is available <a href="https://github.com/huggingface/diffusers/tree/main/examples/reinforcement_learning" rel="nofollow">here</a>.',k,w,S,u,_,F,M,ee="Pipeline for value-guided sampling from a diffusion model trained to predict sequences of states.",J,y,te=`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.).`,U,L,z;return h=new ne({props:{title:"Value-guided planning",local:"value-guided-planning",headingTag:"h1"}}),p=new ue({props:{warning:!0,$$slots:{default:[pe]},$$scope:{ctx:T}}}),w=new ne({props:{title:"ValueGuidedRLPipeline",local:"diffusers.experimental.ValueGuidedRLPipeline",headingTag:"h2"}}),_=new fe({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(){a=l("meta"),c=s(),d=l("p"),P=s(),N(h.$$.fragment),C=s(),N(p.$$.fragment),H=s(),g=l("p"),g.innerHTML=O,V=s(),v=l("p"),v.textContent=K,j=s(),b=l("p"),b.innerHTML=Q,G=s(),x=l("p"),x.innerHTML=X,R=s(),$=l("p"),$.innerHTML=Z,k=s(),N(w.$$.fragment),S=s(),u=l("div"),N(_.$$.fragment),F=s(),M=l("p"),M.textContent=ee,J=s(),y=l("p"),y.innerHTML=te,U=s(),L=l("p"),this.h()},l(e){const t=re("svelte-u9bgzb",document.head);a=r(t,"META",{name:!0,content:!0}),t.forEach(n),c=o(e),d=r(e,"P",{}),W(d).forEach(n),P=o(e),A(h.$$.fragment,e),C=o(e),A(p.$$.fragment,e),H=o(e),g=r(e,"P",{"data-svelte-h":!0}),m(g)!=="svelte-1dguds4"&&(g.innerHTML=O),V=o(e),v=r(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-1cwsb16"&&(v.textContent=K),j=o(e),b=r(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-5lwooz"&&(b.innerHTML=Q),G=o(e),x=r(e,"P",{"data-svelte-h":!0}),m(x)!=="svelte-1llus9j"&&(x.innerHTML=X),R=o(e),$=r(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-guadao"&&($.innerHTML=Z),k=o(e),A(w.$$.fragment,e),S=o(e),u=r(e,"DIV",{class:!0});var f=W(u);A(_.$$.fragment,f),F=o(f),M=r(f,"P",{"data-svelte-h":!0}),m(M)!=="svelte-apl1xd"&&(M.textContent=ee),J=o(f),y=r(f,"P",{"data-svelte-h":!0}),m(y)!=="svelte-496sm0"&&(y.innerHTML=te),f.forEach(n),U=o(e),L=r(e,"P",{}),W(L).forEach(n),this.h()},h(){Y(a,"name","hf:doc:metadata"),Y(a,"content",ce),Y(u,"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){D(document.head,a),i(e,c,t),i(e,d,t),i(e,P,t),E(h,e,t),i(e,C,t),E(p,e,t),i(e,H,t),i(e,g,t),i(e,V,t),i(e,v,t),i(e,j,t),i(e,b,t),i(e,G,t),i(e,x,t),i(e,R,t),i(e,$,t),i(e,k,t),E(w,e,t),i(e,S,t),i(e,u,t),E(_,u,null),D(u,F),D(u,M),D(u,J),D(u,y),i(e,U,t),i(e,L,t),z=!0},p(e,[t]){const f={};t&2&&(f.$$scope={dirty:t,ctx:e}),p.$set(f)},i(e){z||(I(h.$$.fragment,e),I(p.$$.fragment,e),I(w.$$.fragment,e),I(_.$$.fragment,e),z=!0)},o(e){q(h.$$.fragment,e),q(p.$$.fragment,e),q(w.$$.fragment,e),q(_.$$.fragment,e),z=!1},d(e){e&&(n(c),n(d),n(P),n(C),n(H),n(g),n(V),n(v),n(j),n(b),n(G),n(x),n(R),n($),n(k),n(S),n(u),n(U),n(L)),n(a),B(h,e),B(p,e),B(w,e),B(_)}}}const ce='{"title":"Value-guided planning","local":"value-guided-planning","sections":[{"title":"ValueGuidedRLPipeline","local":"diffusers.experimental.ValueGuidedRLPipeline","sections":[],"depth":2}],"depth":1}';function he(T){return ae(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=de}),[]}class we extends oe{constructor(a){super(),le(this,a,he,me,ie,{})}}export{we as component};
