import{S as Ul,i as Fl,s as zl,e as p,k as f,t as o,w as N,M as Wl,c as i,d as t,m,a as n,h as r,x as A,b as c,N as ol,G as l,g as a,y as J,L as Bl,q as L,o as S,B as R,v as Kl}from"../../chunks/vendor-hf-doc-builder.js";import{C as re}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Ql}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";function Vl(rl){let E,$e,P,ot,ke,G,xe,U,rt,ge,F,pe,pt,je,z,it,Pe,W,nt,Ge,q,qe,B,ft,Ie,w,mt,ie,ct,ut,ne,dt,yt,fe,ht,wt,Ce,$,u,bt,me,_t,Et,ce,vt,$t,ue,kt,xt,de,gt,jt,ye,Pt,Gt,qt,v,It,he,Ct,Dt,we,Tt,Ht,De,k,Mt,be,I,Ot,Nt,Te,d,pl,He,K,At,Me,x,Jt,_e,Lt,St,Oe,Q,Rt,Ne,C,Ae,y,il,Je,V,Ut,Le,X,Ft,Se,D,zt,Re,g,Wt,Ee,Bt,Kt,Ue,_,Qt,ve,Vt,Xt,Y,Yt,Zt,Fe,Z,el,ze,T,We,ee,tl,Be,H,Ke,M,Qe,te,ll,Ve,O,Xe,le,sl,Ye,h,nl,Ze,se,al,et;return G=new Ql({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/chapter9/section2.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter9/section2.ipynb"}]}}),q=new re({props:{code:`import gradio as gr


def greet(name):
    return "Hello " + name


demo = gr.Interface(fn=greet, inputs="text", outputs="text")

demo.launch()`,highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr


<span class="hljs-keyword">def</span> <span class="hljs-title function_">greet</span>(<span class="hljs-params">name</span>):
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello &quot;</span> + name


demo = gr.Interface(fn=greet, inputs=<span class="hljs-string">&quot;text&quot;</span>, outputs=<span class="hljs-string">&quot;text&quot;</span>)

demo.launch()`}}),C=new re({props:{code:`import gradio as gr


def greet(name):
    return "Hello " + name


# We instantiate the Textbox class
textbox = gr.Textbox(label="Type your name here:", placeholder="John Doe", lines=2)

gr.Interface(fn=greet, inputs=textbox, outputs="text").launch()`,highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr


<span class="hljs-keyword">def</span> <span class="hljs-title function_">greet</span>(<span class="hljs-params">name</span>):
    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;Hello &quot;</span> + name


<span class="hljs-comment"># We instantiate the Textbox class</span>
textbox = gr.Textbox(label=<span class="hljs-string">&quot;Type your name here:&quot;</span>, placeholder=<span class="hljs-string">&quot;John Doe&quot;</span>, lines=<span class="hljs-number">2</span>)

gr.Interface(fn=greet, inputs=textbox, outputs=<span class="hljs-string">&quot;text&quot;</span>).launch()`}}),T=new re({props:{code:`from transformers import pipeline

model = pipeline("text-generation")


def predict(prompt):
    completion = model(prompt)[0]["generated_text"]
    return completion`,highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

model = pipeline(<span class="hljs-string">&quot;text-generation&quot;</span>)


<span class="hljs-keyword">def</span> <span class="hljs-title function_">predict</span>(<span class="hljs-params">prompt</span>):
    completion = model(prompt)[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;generated_text&quot;</span>]
    <span class="hljs-keyword">return</span> completion`}}),H=new re({props:{code:'predict("My favorite programming language is")',highlighted:'<span class="hljs-function"><span class="hljs-title">predict</span><span class="hljs-params">(<span class="hljs-string">&quot;My favorite programming language is&quot;</span>)</span></span>'}}),M=new re({props:{code:">> My favorite programming language is Haskell. I really enjoyed the Haskell language, but it doesn't have all the features that can be applied to any other language. For example, all it does is compile to a byte array.",highlighted:'&gt;&gt; My favorite programming language <span class="hljs-keyword">is</span> Haskell. I really enjoyed <span class="hljs-keyword">the</span> Haskell language, <span class="hljs-keyword">but</span> <span class="hljs-keyword">it</span> doesn&#x27;t have all <span class="hljs-keyword">the</span> features <span class="hljs-keyword">that</span> can be applied <span class="hljs-keyword">to</span> any other language. For example, all <span class="hljs-keyword">it</span> <span class="hljs-keyword">does</span> <span class="hljs-keyword">is</span> compile <span class="hljs-keyword">to</span> a byte array.'}}),O=new re({props:{code:`import gradio as gr

gr.Interface(fn=predict, inputs="text", outputs="text").launch()`,highlighted:`<span class="hljs-keyword">import</span> gradio <span class="hljs-keyword">as</span> gr

gr.Interface(fn=predict, inputs=<span class="hljs-string">&quot;text&quot;</span>, outputs=<span class="hljs-string">&quot;text&quot;</span>).launch()`}}),{c(){E=p("meta"),$e=f(),P=p("h1"),ot=o("\u6784\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u6F14\u793A"),ke=f(),N(G.$$.fragment),xe=f(),U=p("p"),rt=o("\u8BA9\u6211\u4EEC\u4ECE\u5B89\u88C5 Gradio \u5F00\u59CB\u5427\uFF01 \u7531\u4E8E\u5B83\u662F\u4E00\u4E2A Python \u5305\uFF0C\u53EA\u9700\u8FD0\u884C\uFF1A"),ge=f(),F=p("p"),pe=p("code"),pt=o("$ pip install gradio"),je=f(),z=p("p"),it=o(`\u60A8\u53EF\u4EE5\u5728\u4EFB\u4F55\u5730\u65B9\u8FD0\u884C Gradio\uFF0C\u65E0\u8BBA\u662F\u4ECE\u60A8\u6700\u559C\u6B22\u7684 Python IDE\u3001Jupyter notebook \u8FD8\u662F Google Colab \u{1F92F}\uFF01
\u6240\u4EE5\u65E0\u8BBA\u4F60\u5728\u54EA\u91CC\u8FD0\u884C Python\uFF0C\u90FD\u53EF\u4EE5\u5B89\u88C5 Gradio\uFF01`),Pe=f(),W=p("p"),nt=o("\u8BA9\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u201CHello World\u201D\u793A\u4F8B\u5F00\u59CB\uFF0C\u719F\u6089 Gradio \u8BED\u6CD5\uFF1A"),Ge=f(),N(q.$$.fragment),qe=f(),B=p("p"),ft=o("\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u4E0A\u9762\u7684\u4EE3\u7801\uFF1A"),Ie=f(),w=p("p"),mt=o("-\u9996\u5148\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A\u540D\u4E3A "),ie=p("code"),ct=o("greet()"),ut=o(" \u7684\u51FD\u6570\u3002 \u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u5B83\u662F\u4E00\u4E2A\u5728\u60A8\u7684\u540D\u5B57\u524D\u6DFB\u52A0\u201CHello\u201D\u7684\u7B80\u5355\u51FD\u6570\uFF0C\u4F46\u5B83\u901A\u5E38\u53EF\u4EE5\u662F "),ne=p("em"),dt=o("any"),yt=o(" Python \u51FD\u6570\u3002 \u4F8B\u5982\uFF0C\u5728\u673A\u5668\u5B66\u4E60\u5E94\u7528\u7A0B\u5E8F\u4E2D\uFF0C\u6B64\u51FD\u6570\u5C06"),fe=p("em"),ht=o("\u8C03\u7528\u6A21\u578B\u4EE5\u5BF9\u8F93\u5165\u8FDB\u884C\u9884\u6D4B"),wt=o("\u5E76\u8FD4\u56DE\u8F93\u51FA\u3002"),Ce=f(),$=p("ul"),u=p("li"),bt=o("\u7136\u540E\uFF0C\u6211\u4EEC\u521B\u5EFA\u4E00\u4E2A\u5E26\u6709\u4E09\u4E2A\u53C2\u6570\u7684 Gradio "),me=p("code"),_t=o("Interface"),Et=o("\uFF0C"),ce=p("code"),vt=o("fn"),$t=o("\u3001"),ue=p("code"),kt=o("inputs"),xt=o(" \u548C "),de=p("code"),gt=o("outputs"),jt=o("\u3002 \u8FD9\u4E9B\u53C2\u6570\u5B9A\u4E49\u4E86\u9884\u6D4B\u51FD\u6570\uFF0C\u4EE5\u53CA\u6211\u4EEC\u60F3\u8981\u7684\u8F93\u5165\u548C\u8F93\u51FA\u7EC4\u4EF6\u7684"),ye=p("em"),Pt=o("type"),Gt=o("\u3002 \u5728\u6211\u4EEC\u7684\u4F8B\u5B50\u4E2D\uFF0C\u4E24\u4E2A\u7EC4\u4EF6\u90FD\u662F\u7B80\u5355\u7684\u6587\u672C\u6846\u3002"),qt=f(),v=p("li"),It=o("\u7136\u540E\u6211\u4EEC\u5728\u6211\u4EEC\u521B\u5EFA\u7684 "),he=p("code"),Ct=o("Interface"),Dt=o(" \u4E0A\u8C03\u7528 "),we=p("code"),Tt=o("launch()"),Ht=o(" \u65B9\u6CD5\u3002"),De=f(),k=p("p"),Mt=o("\u5982\u679C\u4F60\u8FD0\u884C\u8FD9\u6BB5\u4EE3\u7801\uFF0C\u4E0B\u9762\u7684\u754C\u9762\u4F1A\u81EA\u52A8\u51FA\u73B0\u5728 Jupyter/Colab notebook \u4E2D\uFF0C\u6216\u8005\u5728\u6D4F\u89C8\u5668\u4E2D\u5F39\u51FA "),be=p("strong"),I=p("a"),Ot=o("http://localhost:7860"),Nt=o(" \u5982\u679C\u8FD0\u884C \u4ECE\u4E00\u4E2A\u811A\u672C\u3002"),Te=f(),d=p("iframe"),He=f(),K=p("p"),At=o("\u7ACB\u5373\u5C1D\u8BD5\u4F7F\u7528\u60A8\u81EA\u5DF1\u7684\u59D3\u540D\u6216\u5176\u4ED6\u8F93\u5165\u6765\u4F7F\u7528\u6B64 GUI\uFF01"),Me=f(),x=p("p"),Jt=o("\u60A8\u4F1A\u6CE8\u610F\u5230\uFF0C\u5728\u8FD9\u4E2A GUI \u4E2D\uFF0CGradio \u81EA\u52A8\u63A8\u65AD\u8F93\u5165\u53C2\u6570\u7684\u540D\u79F0 ("),_e=p("code"),Lt=o("name"),St=o(")\u5E76\u5C06\u5176\u5E94\u7528\u4E3A\u6587\u672C\u6846\u9876\u90E8\u7684\u6807\u7B7E\u3002 \u5982\u679C\u4F60\u60F3\u6539\u53D8\u5B83\u600E\u4E48\u529E\uFF1F\u6216\u8005\uFF0C\u5982\u679C\u60A8\u60F3\u4EE5\u5176\u4ED6\u65B9\u5F0F\u81EA\u5B9A\u4E49\u6587\u672C\u6846\uFF1F \u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u60A8\u53EF\u4EE5\u5B9E\u4F8B\u5316\u4E00\u4E2A\u8868\u793A\u8F93\u5165\u7EC4\u4EF6\u7684\u7C7B\u5BF9\u8C61\u3002"),Oe=f(),Q=p("p"),Rt=o("\u770B\u770B\u4E0B\u9762\u7684\u4F8B\u5B50\uFF1A"),Ne=f(),N(C.$$.fragment),Ae=f(),y=p("iframe"),Je=f(),V=p("p"),Ut=o("\u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u521B\u5EFA\u4E86\u4E00\u4E2A\u5E26\u6709\u6807\u7B7E\u3001\u5360\u4F4D\u7B26\u548C\u4E00\u7EC4\u884C\u6570\u7684\u8F93\u5165\u6587\u672C\u6846\u3002\u60A8\u53EF\u4EE5\u5BF9\u8F93\u51FA\u6587\u672C\u6846\u6267\u884C\u76F8\u540C\u7684\u64CD\u4F5C\uFF0C\u4F46\u6211\u4EEC\u73B0\u5728\u5C06\u5176\u4FDD\u7559\u3002"),Le=f(),X=p("p"),Ft=o("\u6211\u4EEC\u5DF2\u7ECF\u770B\u5230\uFF0C\u53EA\u9700\u51E0\u884C\u4EE3\u7801\uFF0CGradio \u5C31\u53EF\u4EE5\u8BA9\u60A8\u56F4\u7ED5\u4EFB\u4F55\u5177\u6709\u4EFB\u4F55\u7C7B\u578B\u8F93\u5165\u6216\u8F93\u51FA\u7684\u51FD\u6570\u521B\u5EFA\u4E00\u4E2A\u7B80\u5355\u7684\u754C\u9762\u3002 \u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u6587\u672C\u6846\u5F00\u59CB\uFF0C\u4F46\u5728\u63A5\u4E0B\u6765\u7684\u90E8\u5206\u4E2D\uFF0C\u6211\u4EEC\u5C06\u4ECB\u7ECD\u5176\u4ED6\u7C7B\u578B\u7684\u8F93\u5165\u548C\u8F93\u51FA\u3002 \u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u5728 Gradio \u5E94\u7528\u7A0B\u5E8F\u4E2D\u5305\u542B\u4E00\u4E9B NLP\u3002"),Se=f(),D=p("h2"),zt=o("\u{1F916} \u5305\u62EC\u6A21\u578B\u9884\u6D4B"),Re=f(),g=p("p"),Wt=o("\u73B0\u5728\u8BA9\u6211\u4EEC\u6784\u5EFA\u4E00\u4E2A\u7B80\u5355\u7684\u754C\u9762\uFF0C\u8BA9\u60A8\u53EF\u4EE5\u6F14\u793A\u50CF GPT-2 \u8FD9\u6837\u7684"),Ee=p("strong"),Bt=o("\u6587\u672C\u751F\u6210"),Kt=o("\u6A21\u578B\u3002"),Ue=f(),_=p("p"),Qt=o("\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} Transformers \u4E2D\u7684 "),ve=p("code"),Vt=o("pipeline()"),Xt=o(` \u51FD\u6570\u52A0\u8F7D\u6211\u4EEC\u7684\u6A21\u578B\u3002
\u5982\u679C\u60A8\u9700\u8981\u5FEB\u901F\u590D\u4E60\uFF0C\u60A8\u53EF\u4EE5\u8FD4\u56DE\u5230 `),Y=p("a"),Yt=o("\u7B2C 1 \u7AE0\u4E2D\u7684\u90A3\u4E2A\u90E8\u5206"),Zt=o("\u3002"),Fe=f(),Z=p("p"),el=o("\u9996\u5148\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A\u63A5\u53D7\u6587\u672C\u63D0\u793A\u5E76\u8FD4\u56DE\u6587\u672C\u5B8C\u6210\u7684\u9884\u6D4B\u51FD\u6570\uFF1A"),ze=f(),N(T.$$.fragment),We=f(),ee=p("p"),tl=o("\u6B64\u51FD\u6570\u5B8C\u6210\u60A8\u63D0\u4F9B\u7684\u63D0\u793A\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u81EA\u5DF1\u7684\u8F93\u5165\u63D0\u793A\u8FD0\u884C\u5B83\u4EE5\u67E5\u770B\u5B83\u662F\u5982\u4F55\u5DE5\u4F5C\u7684\u3002 \u8FD9\u662F\u4E00\u4E2A\u793A\u4F8B\uFF08\u60A8\u53EF\u80FD\u4F1A\u5F97\u5230\u4E0D\u540C\u7684\u5B8C\u6210\uFF09\uFF1A"),Be=f(),N(H.$$.fragment),Ke=f(),N(M.$$.fragment),Qe=f(),te=p("p"),ll=o("\u73B0\u5728\u6211\u4EEC\u6709\u4E86\u4E00\u4E2A\u751F\u6210\u9884\u6D4B\u7684\u51FD\u6570\uFF0C\u6211\u4EEC\u53EF\u4EE5\u50CF\u4E4B\u524D\u4E00\u6837\u521B\u5EFA\u548C\u542F\u52A8\u4E00\u4E2A\u201C\u63A5\u53E3\u201D\uFF1A"),Ve=f(),N(O.$$.fragment),Xe=f(),le=p("p"),sl=o("\u5C31\u662F\u8FD9\u6837\uFF01 \u60A8\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u6B64\u63A5\u53E3\u4F7F\u7528 GPT-2 \u6A21\u578B\u751F\u6210\u6587\u672C\uFF0C\u5982\u4E0B\u6240\u793A \u{1F92F}."),Ye=f(),h=p("iframe"),Ze=f(),se=p("p"),al=o("\u7EE7\u7EED\u9605\u8BFB\u4EE5\u4E86\u89E3\u5982\u4F55\u4F7F\u7528 Gradio \u6784\u5EFA\u5176\u4ED6\u7C7B\u578B\u7684\u6F14\u793A\uFF01"),this.h()},l(e){const s=Wl('[data-svelte="svelte-1phssyn"]',document.head);E=i(s,"META",{name:!0,content:!0}),s.forEach(t),$e=m(e),P=i(e,"H1",{id:!0});var fl=n(P);ot=r(fl,"\u6784\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u6F14\u793A"),fl.forEach(t),ke=m(e),A(G.$$.fragment,e),xe=m(e),U=i(e,"P",{});var ml=n(U);rt=r(ml,"\u8BA9\u6211\u4EEC\u4ECE\u5B89\u88C5 Gradio \u5F00\u59CB\u5427\uFF01 \u7531\u4E8E\u5B83\u662F\u4E00\u4E2A Python \u5305\uFF0C\u53EA\u9700\u8FD0\u884C\uFF1A"),ml.forEach(t),ge=m(e),F=i(e,"P",{});var cl=n(F);pe=i(cl,"CODE",{});var ul=n(pe);pt=r(ul,"$ pip install gradio"),ul.forEach(t),cl.forEach(t),je=m(e),z=i(e,"P",{});var dl=n(z);it=r(dl,`\u60A8\u53EF\u4EE5\u5728\u4EFB\u4F55\u5730\u65B9\u8FD0\u884C Gradio\uFF0C\u65E0\u8BBA\u662F\u4ECE\u60A8\u6700\u559C\u6B22\u7684 Python IDE\u3001Jupyter notebook \u8FD8\u662F Google Colab \u{1F92F}\uFF01
\u6240\u4EE5\u65E0\u8BBA\u4F60\u5728\u54EA\u91CC\u8FD0\u884C Python\uFF0C\u90FD\u53EF\u4EE5\u5B89\u88C5 Gradio\uFF01`),dl.forEach(t),Pe=m(e),W=i(e,"P",{});var yl=n(W);nt=r(yl,"\u8BA9\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u201CHello World\u201D\u793A\u4F8B\u5F00\u59CB\uFF0C\u719F\u6089 Gradio \u8BED\u6CD5\uFF1A"),yl.forEach(t),Ge=m(e),A(q.$$.fragment,e),qe=m(e),B=i(e,"P",{});var hl=n(B);ft=r(hl,"\u8BA9\u6211\u4EEC\u770B\u4E00\u4E0B\u4E0A\u9762\u7684\u4EE3\u7801\uFF1A"),hl.forEach(t),Ie=m(e),w=i(e,"P",{});var j=n(w);mt=r(j,"-\u9996\u5148\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A\u540D\u4E3A "),ie=i(j,"CODE",{});var wl=n(ie);ct=r(wl,"greet()"),wl.forEach(t),ut=r(j," \u7684\u51FD\u6570\u3002 \u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u5B83\u662F\u4E00\u4E2A\u5728\u60A8\u7684\u540D\u5B57\u524D\u6DFB\u52A0\u201CHello\u201D\u7684\u7B80\u5355\u51FD\u6570\uFF0C\u4F46\u5B83\u901A\u5E38\u53EF\u4EE5\u662F "),ne=i(j,"EM",{});var bl=n(ne);dt=r(bl,"any"),bl.forEach(t),yt=r(j," Python \u51FD\u6570\u3002 \u4F8B\u5982\uFF0C\u5728\u673A\u5668\u5B66\u4E60\u5E94\u7528\u7A0B\u5E8F\u4E2D\uFF0C\u6B64\u51FD\u6570\u5C06"),fe=i(j,"EM",{});var _l=n(fe);ht=r(_l,"\u8C03\u7528\u6A21\u578B\u4EE5\u5BF9\u8F93\u5165\u8FDB\u884C\u9884\u6D4B"),_l.forEach(t),wt=r(j,"\u5E76\u8FD4\u56DE\u8F93\u51FA\u3002"),j.forEach(t),Ce=m(e),$=i(e,"UL",{});var tt=n($);u=i(tt,"LI",{});var b=n(u);bt=r(b,"\u7136\u540E\uFF0C\u6211\u4EEC\u521B\u5EFA\u4E00\u4E2A\u5E26\u6709\u4E09\u4E2A\u53C2\u6570\u7684 Gradio "),me=i(b,"CODE",{});var El=n(me);_t=r(El,"Interface"),El.forEach(t),Et=r(b,"\uFF0C"),ce=i(b,"CODE",{});var vl=n(ce);vt=r(vl,"fn"),vl.forEach(t),$t=r(b,"\u3001"),ue=i(b,"CODE",{});var $l=n(ue);kt=r($l,"inputs"),$l.forEach(t),xt=r(b," \u548C "),de=i(b,"CODE",{});var kl=n(de);gt=r(kl,"outputs"),kl.forEach(t),jt=r(b,"\u3002 \u8FD9\u4E9B\u53C2\u6570\u5B9A\u4E49\u4E86\u9884\u6D4B\u51FD\u6570\uFF0C\u4EE5\u53CA\u6211\u4EEC\u60F3\u8981\u7684\u8F93\u5165\u548C\u8F93\u51FA\u7EC4\u4EF6\u7684"),ye=i(b,"EM",{});var xl=n(ye);Pt=r(xl,"type"),xl.forEach(t),Gt=r(b,"\u3002 \u5728\u6211\u4EEC\u7684\u4F8B\u5B50\u4E2D\uFF0C\u4E24\u4E2A\u7EC4\u4EF6\u90FD\u662F\u7B80\u5355\u7684\u6587\u672C\u6846\u3002"),b.forEach(t),qt=m(tt),v=i(tt,"LI",{});var ae=n(v);It=r(ae,"\u7136\u540E\u6211\u4EEC\u5728\u6211\u4EEC\u521B\u5EFA\u7684 "),he=i(ae,"CODE",{});var gl=n(he);Ct=r(gl,"Interface"),gl.forEach(t),Dt=r(ae," \u4E0A\u8C03\u7528 "),we=i(ae,"CODE",{});var jl=n(we);Tt=r(jl,"launch()"),jl.forEach(t),Ht=r(ae," \u65B9\u6CD5\u3002"),ae.forEach(t),tt.forEach(t),De=m(e),k=i(e,"P",{});var lt=n(k);Mt=r(lt,"\u5982\u679C\u4F60\u8FD0\u884C\u8FD9\u6BB5\u4EE3\u7801\uFF0C\u4E0B\u9762\u7684\u754C\u9762\u4F1A\u81EA\u52A8\u51FA\u73B0\u5728 Jupyter/Colab notebook \u4E2D\uFF0C\u6216\u8005\u5728\u6D4F\u89C8\u5668\u4E2D\u5F39\u51FA "),be=i(lt,"STRONG",{});var Pl=n(be);I=i(Pl,"A",{href:!0,rel:!0});var Gl=n(I);Ot=r(Gl,"http://localhost:7860"),Gl.forEach(t),Pl.forEach(t),Nt=r(lt," \u5982\u679C\u8FD0\u884C \u4ECE\u4E00\u4E2A\u811A\u672C\u3002"),lt.forEach(t),Te=m(e),d=i(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),n(d).forEach(t),He=m(e),K=i(e,"P",{});var ql=n(K);At=r(ql,"\u7ACB\u5373\u5C1D\u8BD5\u4F7F\u7528\u60A8\u81EA\u5DF1\u7684\u59D3\u540D\u6216\u5176\u4ED6\u8F93\u5165\u6765\u4F7F\u7528\u6B64 GUI\uFF01"),ql.forEach(t),Me=m(e),x=i(e,"P",{});var st=n(x);Jt=r(st,"\u60A8\u4F1A\u6CE8\u610F\u5230\uFF0C\u5728\u8FD9\u4E2A GUI \u4E2D\uFF0CGradio \u81EA\u52A8\u63A8\u65AD\u8F93\u5165\u53C2\u6570\u7684\u540D\u79F0 ("),_e=i(st,"CODE",{});var Il=n(_e);Lt=r(Il,"name"),Il.forEach(t),St=r(st,")\u5E76\u5C06\u5176\u5E94\u7528\u4E3A\u6587\u672C\u6846\u9876\u90E8\u7684\u6807\u7B7E\u3002 \u5982\u679C\u4F60\u60F3\u6539\u53D8\u5B83\u600E\u4E48\u529E\uFF1F\u6216\u8005\uFF0C\u5982\u679C\u60A8\u60F3\u4EE5\u5176\u4ED6\u65B9\u5F0F\u81EA\u5B9A\u4E49\u6587\u672C\u6846\uFF1F \u5728\u8FD9\u79CD\u60C5\u51B5\u4E0B\uFF0C\u60A8\u53EF\u4EE5\u5B9E\u4F8B\u5316\u4E00\u4E2A\u8868\u793A\u8F93\u5165\u7EC4\u4EF6\u7684\u7C7B\u5BF9\u8C61\u3002"),st.forEach(t),Oe=m(e),Q=i(e,"P",{});var Cl=n(Q);Rt=r(Cl,"\u770B\u770B\u4E0B\u9762\u7684\u4F8B\u5B50\uFF1A"),Cl.forEach(t),Ne=m(e),A(C.$$.fragment,e),Ae=m(e),y=i(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),n(y).forEach(t),Je=m(e),V=i(e,"P",{});var Dl=n(V);Ut=r(Dl,"\u5728\u8FD9\u91CC\uFF0C\u6211\u4EEC\u521B\u5EFA\u4E86\u4E00\u4E2A\u5E26\u6709\u6807\u7B7E\u3001\u5360\u4F4D\u7B26\u548C\u4E00\u7EC4\u884C\u6570\u7684\u8F93\u5165\u6587\u672C\u6846\u3002\u60A8\u53EF\u4EE5\u5BF9\u8F93\u51FA\u6587\u672C\u6846\u6267\u884C\u76F8\u540C\u7684\u64CD\u4F5C\uFF0C\u4F46\u6211\u4EEC\u73B0\u5728\u5C06\u5176\u4FDD\u7559\u3002"),Dl.forEach(t),Le=m(e),X=i(e,"P",{});var Tl=n(X);Ft=r(Tl,"\u6211\u4EEC\u5DF2\u7ECF\u770B\u5230\uFF0C\u53EA\u9700\u51E0\u884C\u4EE3\u7801\uFF0CGradio \u5C31\u53EF\u4EE5\u8BA9\u60A8\u56F4\u7ED5\u4EFB\u4F55\u5177\u6709\u4EFB\u4F55\u7C7B\u578B\u8F93\u5165\u6216\u8F93\u51FA\u7684\u51FD\u6570\u521B\u5EFA\u4E00\u4E2A\u7B80\u5355\u7684\u754C\u9762\u3002 \u5728\u672C\u8282\u4E2D\uFF0C\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u6587\u672C\u6846\u5F00\u59CB\uFF0C\u4F46\u5728\u63A5\u4E0B\u6765\u7684\u90E8\u5206\u4E2D\uFF0C\u6211\u4EEC\u5C06\u4ECB\u7ECD\u5176\u4ED6\u7C7B\u578B\u7684\u8F93\u5165\u548C\u8F93\u51FA\u3002 \u73B0\u5728\u8BA9\u6211\u4EEC\u770B\u770B\u5728 Gradio \u5E94\u7528\u7A0B\u5E8F\u4E2D\u5305\u542B\u4E00\u4E9B NLP\u3002"),Tl.forEach(t),Se=m(e),D=i(e,"H2",{id:!0});var Hl=n(D);zt=r(Hl,"\u{1F916} \u5305\u62EC\u6A21\u578B\u9884\u6D4B"),Hl.forEach(t),Re=m(e),g=i(e,"P",{});var at=n(g);Wt=r(at,"\u73B0\u5728\u8BA9\u6211\u4EEC\u6784\u5EFA\u4E00\u4E2A\u7B80\u5355\u7684\u754C\u9762\uFF0C\u8BA9\u60A8\u53EF\u4EE5\u6F14\u793A\u50CF GPT-2 \u8FD9\u6837\u7684"),Ee=i(at,"STRONG",{});var Ml=n(Ee);Bt=r(Ml,"\u6587\u672C\u751F\u6210"),Ml.forEach(t),Kt=r(at,"\u6A21\u578B\u3002"),at.forEach(t),Ue=m(e),_=i(e,"P",{});var oe=n(_);Qt=r(oe,"\u6211\u4EEC\u5C06\u4F7F\u7528 \u{1F917} Transformers \u4E2D\u7684 "),ve=i(oe,"CODE",{});var Ol=n(ve);Vt=r(Ol,"pipeline()"),Ol.forEach(t),Xt=r(oe,` \u51FD\u6570\u52A0\u8F7D\u6211\u4EEC\u7684\u6A21\u578B\u3002
\u5982\u679C\u60A8\u9700\u8981\u5FEB\u901F\u590D\u4E60\uFF0C\u60A8\u53EF\u4EE5\u8FD4\u56DE\u5230 `),Y=i(oe,"A",{href:!0});var Nl=n(Y);Yt=r(Nl,"\u7B2C 1 \u7AE0\u4E2D\u7684\u90A3\u4E2A\u90E8\u5206"),Nl.forEach(t),Zt=r(oe,"\u3002"),oe.forEach(t),Fe=m(e),Z=i(e,"P",{});var Al=n(Z);el=r(Al,"\u9996\u5148\uFF0C\u6211\u4EEC\u5B9A\u4E49\u4E00\u4E2A\u63A5\u53D7\u6587\u672C\u63D0\u793A\u5E76\u8FD4\u56DE\u6587\u672C\u5B8C\u6210\u7684\u9884\u6D4B\u51FD\u6570\uFF1A"),Al.forEach(t),ze=m(e),A(T.$$.fragment,e),We=m(e),ee=i(e,"P",{});var Jl=n(ee);tl=r(Jl,"\u6B64\u51FD\u6570\u5B8C\u6210\u60A8\u63D0\u4F9B\u7684\u63D0\u793A\uFF0C\u60A8\u53EF\u4EE5\u4F7F\u7528\u81EA\u5DF1\u7684\u8F93\u5165\u63D0\u793A\u8FD0\u884C\u5B83\u4EE5\u67E5\u770B\u5B83\u662F\u5982\u4F55\u5DE5\u4F5C\u7684\u3002 \u8FD9\u662F\u4E00\u4E2A\u793A\u4F8B\uFF08\u60A8\u53EF\u80FD\u4F1A\u5F97\u5230\u4E0D\u540C\u7684\u5B8C\u6210\uFF09\uFF1A"),Jl.forEach(t),Be=m(e),A(H.$$.fragment,e),Ke=m(e),A(M.$$.fragment,e),Qe=m(e),te=i(e,"P",{});var Ll=n(te);ll=r(Ll,"\u73B0\u5728\u6211\u4EEC\u6709\u4E86\u4E00\u4E2A\u751F\u6210\u9884\u6D4B\u7684\u51FD\u6570\uFF0C\u6211\u4EEC\u53EF\u4EE5\u50CF\u4E4B\u524D\u4E00\u6837\u521B\u5EFA\u548C\u542F\u52A8\u4E00\u4E2A\u201C\u63A5\u53E3\u201D\uFF1A"),Ll.forEach(t),Ve=m(e),A(O.$$.fragment,e),Xe=m(e),le=i(e,"P",{});var Sl=n(le);sl=r(Sl,"\u5C31\u662F\u8FD9\u6837\uFF01 \u60A8\u73B0\u5728\u53EF\u4EE5\u4F7F\u7528\u6B64\u63A5\u53E3\u4F7F\u7528 GPT-2 \u6A21\u578B\u751F\u6210\u6587\u672C\uFF0C\u5982\u4E0B\u6240\u793A \u{1F92F}."),Sl.forEach(t),Ye=m(e),h=i(e,"IFRAME",{src:!0,frameborder:!0,height:!0,title:!0,class:!0,allow:!0,sandbox:!0}),n(h).forEach(t),Ze=m(e),se=i(e,"P",{});var Rl=n(se);al=r(Rl,"\u7EE7\u7EED\u9605\u8BFB\u4EE5\u4E86\u89E3\u5982\u4F55\u4F7F\u7528 Gradio \u6784\u5EFA\u5176\u4ED6\u7C7B\u578B\u7684\u6F14\u793A\uFF01"),Rl.forEach(t),this.h()},h(){c(E,"name","hf:doc:metadata"),c(E,"content",JSON.stringify(Xl)),c(P,"id",""),c(I,"href","http://localhost:7860/"),c(I,"rel","nofollow"),ol(d.src,pl="https://course-demos-hello-world.hf.space")||c(d,"src",pl),c(d,"frameborder","0"),c(d,"height","250"),c(d,"title","Gradio app"),c(d,"class","container p-0 flex-grow space-iframe"),c(d,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),c(d,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),ol(y.src,il="https://course-demos-hello-world-custom.hf.space")||c(y,"src",il),c(y,"frameborder","0"),c(y,"height","300"),c(y,"title","Gradio app"),c(y,"class","container p-0 flex-grow space-iframe"),c(y,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),c(y,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"),c(D,"id",""),c(Y,"href","/course/chapter1/3#text-generation"),ol(h.src,nl="https://course-demos-gpt-2.hf.space")||c(h,"src",nl),c(h,"frameborder","0"),c(h,"height","300"),c(h,"title","Gradio app"),c(h,"class","container p-0 flex-grow space-iframe"),c(h,"allow","accelerometer; ambient-light-sensor; autoplay; battery; camera; document-domain; encrypted-media; fullscreen; geolocation; gyroscope; layout-animations; legacy-image-formats; magnetometer; microphone; midi; oversized-images; payment; picture-in-picture; publickey-credentials-get; sync-xhr; usb; vr ; wake-lock; xr-spatial-tracking"),c(h,"sandbox","allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads")},m(e,s){l(document.head,E),a(e,$e,s),a(e,P,s),l(P,ot),a(e,ke,s),J(G,e,s),a(e,xe,s),a(e,U,s),l(U,rt),a(e,ge,s),a(e,F,s),l(F,pe),l(pe,pt),a(e,je,s),a(e,z,s),l(z,it),a(e,Pe,s),a(e,W,s),l(W,nt),a(e,Ge,s),J(q,e,s),a(e,qe,s),a(e,B,s),l(B,ft),a(e,Ie,s),a(e,w,s),l(w,mt),l(w,ie),l(ie,ct),l(w,ut),l(w,ne),l(ne,dt),l(w,yt),l(w,fe),l(fe,ht),l(w,wt),a(e,Ce,s),a(e,$,s),l($,u),l(u,bt),l(u,me),l(me,_t),l(u,Et),l(u,ce),l(ce,vt),l(u,$t),l(u,ue),l(ue,kt),l(u,xt),l(u,de),l(de,gt),l(u,jt),l(u,ye),l(ye,Pt),l(u,Gt),l($,qt),l($,v),l(v,It),l(v,he),l(he,Ct),l(v,Dt),l(v,we),l(we,Tt),l(v,Ht),a(e,De,s),a(e,k,s),l(k,Mt),l(k,be),l(be,I),l(I,Ot),l(k,Nt),a(e,Te,s),a(e,d,s),a(e,He,s),a(e,K,s),l(K,At),a(e,Me,s),a(e,x,s),l(x,Jt),l(x,_e),l(_e,Lt),l(x,St),a(e,Oe,s),a(e,Q,s),l(Q,Rt),a(e,Ne,s),J(C,e,s),a(e,Ae,s),a(e,y,s),a(e,Je,s),a(e,V,s),l(V,Ut),a(e,Le,s),a(e,X,s),l(X,Ft),a(e,Se,s),a(e,D,s),l(D,zt),a(e,Re,s),a(e,g,s),l(g,Wt),l(g,Ee),l(Ee,Bt),l(g,Kt),a(e,Ue,s),a(e,_,s),l(_,Qt),l(_,ve),l(ve,Vt),l(_,Xt),l(_,Y),l(Y,Yt),l(_,Zt),a(e,Fe,s),a(e,Z,s),l(Z,el),a(e,ze,s),J(T,e,s),a(e,We,s),a(e,ee,s),l(ee,tl),a(e,Be,s),J(H,e,s),a(e,Ke,s),J(M,e,s),a(e,Qe,s),a(e,te,s),l(te,ll),a(e,Ve,s),J(O,e,s),a(e,Xe,s),a(e,le,s),l(le,sl),a(e,Ye,s),a(e,h,s),a(e,Ze,s),a(e,se,s),l(se,al),et=!0},p:Bl,i(e){et||(L(G.$$.fragment,e),L(q.$$.fragment,e),L(C.$$.fragment,e),L(T.$$.fragment,e),L(H.$$.fragment,e),L(M.$$.fragment,e),L(O.$$.fragment,e),et=!0)},o(e){S(G.$$.fragment,e),S(q.$$.fragment,e),S(C.$$.fragment,e),S(T.$$.fragment,e),S(H.$$.fragment,e),S(M.$$.fragment,e),S(O.$$.fragment,e),et=!1},d(e){t(E),e&&t($e),e&&t(P),e&&t(ke),R(G,e),e&&t(xe),e&&t(U),e&&t(ge),e&&t(F),e&&t(je),e&&t(z),e&&t(Pe),e&&t(W),e&&t(Ge),R(q,e),e&&t(qe),e&&t(B),e&&t(Ie),e&&t(w),e&&t(Ce),e&&t($),e&&t(De),e&&t(k),e&&t(Te),e&&t(d),e&&t(He),e&&t(K),e&&t(Me),e&&t(x),e&&t(Oe),e&&t(Q),e&&t(Ne),R(C,e),e&&t(Ae),e&&t(y),e&&t(Je),e&&t(V),e&&t(Le),e&&t(X),e&&t(Se),e&&t(D),e&&t(Re),e&&t(g),e&&t(Ue),e&&t(_),e&&t(Fe),e&&t(Z),e&&t(ze),R(T,e),e&&t(We),e&&t(ee),e&&t(Be),R(H,e),e&&t(Ke),R(M,e),e&&t(Qe),e&&t(te),e&&t(Ve),R(O,e),e&&t(Xe),e&&t(le),e&&t(Ye),e&&t(h),e&&t(Ze),e&&t(se)}}}const Xl={local:"",sections:[{local:"",title:"\u{1F916} \u5305\u62EC\u6A21\u578B\u9884\u6D4B"}],title:"\u6784\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u6F14\u793A"};function Yl(rl){return Kl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ls extends Ul{constructor(E){super();Fl(this,E,Yl,Vl,zl,{})}}export{ls as default,Xl as metadata};
