import{s as Je,o as we}from"../chunks/scheduler.49e4e380.js";import{S as Te,i as je,g as y,s as m,r as T,A as Ue,h as g,f as a,c as p,j as fe,u as j,x as C,k as se,y as xe,a as i,v as U,t as M,b as ye,d as h,w as x,m as Ce,n as $e,p as ge}from"../chunks/index.fb15006d.js";import{T as We}from"../chunks/Tip.f590f2e1.js";import{C as Y}from"../chunks/CodeBlock.f39e0d63.js";import{D as ke}from"../chunks/DocNotebookDropdown.dd62dcd3.js";import{F as Ze}from"../chunks/FrameworkSwitchCourse.f837e098.js";import{H as _e}from"../chunks/Heading.5d1ab858.js";function ze(f){let t,r;return t=new ke({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/chapter4/section2_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter4/section2_tf.ipynb"}]}}),{c(){T(t.$$.fragment)},l(n){j(t.$$.fragment,n)},m(n,b){U(t,n,b),r=!0},i(n){r||(h(t.$$.fragment,n),r=!0)},o(n){M(t.$$.fragment,n),r=!1},d(n){x(t,n)}}}function Ve(f){let t,r;return t=new ke({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/chapter4/section2_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/chapter4/section2_pt.ipynb"}]}}),{c(){T(t.$$.fragment)},l(n){j(t.$$.fragment,n)},m(n,b){U(t,n,b),r=!0},i(n){r||(h(t.$$.fragment,n),r=!0)},o(n){M(t.$$.fragment,n),r=!1},d(n){x(t,n)}}}function ve(f){let t,r,n,b='Hier empfehlen wir auch, dass man stattdessen die <a href="https://huggingface.co/transformers/model_doc/auto?highlight=auto#auto-classes" rel="nofollow"><code>TFAuto*</code> classes</a> benutzt, da diese architekturunabhängig sind. Das vorherige Code-Beispiel gilt nur für Checkpoints, die in die CamemBERT Architektur zu laden sind, aber mit den <code>TFAuto*</code> Klassen kann man Checkpoints einfach tauschen:',u,c,d;return t=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENhbWVtYmVydFRva2VuaXplciUyQyUyMFRGQ2FtZW1iZXJ0Rm9yTWFza2VkTE0lMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBDYW1lbWJlcnRUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwVEZDYW1lbWJlcnRGb3JNYXNrZWRMTS5mcm9tX3ByZXRyYWluZWQoJTIyY2FtZW1iZXJ0LWJhc2UlMjIp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CamembertTokenizer, TFCamembertForMaskedLM

tokenizer = CamembertTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = TFCamembertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),c=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvck1hc2tlZExNJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyY2FtZW1iZXJ0LWJhc2UlMjIpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvck1hc2tlZExNLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = TFAutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),{c(){T(t.$$.fragment),r=m(),n=y("p"),n.innerHTML=b,u=m(),T(c.$$.fragment)},l(s){j(t.$$.fragment,s),r=p(s),n=g(s,"P",{"data-svelte-h":!0}),C(n)!=="svelte-1xi50pm"&&(n.innerHTML=b),u=p(s),j(c.$$.fragment,s)},m(s,o){U(t,s,o),i(s,r,o),i(s,n,o),i(s,u,o),U(c,s,o),d=!0},i(s){d||(h(t.$$.fragment,s),h(c.$$.fragment,s),d=!0)},o(s){M(t.$$.fragment,s),M(c.$$.fragment,s),d=!1},d(s){s&&(a(r),a(n),a(u)),x(t,s),x(c,s)}}}function Ne(f){let t,r,n,b='Dennoch empfehlen wir, dass man die <a href="https://huggingface.co/transformers/model_doc/auto?highlight=auto#auto-classes" rel="nofollow"><code>Auto*</code> classes</a> stattdessen benutzt, da diese architekturunabhängig sind. Das vorherige Code-Beispiel gilt nur für Checkpoints, die in die CamemBERT Architektur zu laden sind, aber mit den <code>Auto*</code> Klassen kann man Checkpoints ziemlich einfach tauschen:',u,c,d;return t=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMENhbWVtYmVydFRva2VuaXplciUyQyUyMENhbWVtYmVydEZvck1hc2tlZExNJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQ2FtZW1iZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMiklMEFtb2RlbCUyMCUzRCUyMENhbWVtYmVydEZvck1hc2tlZExNLmZyb21fcHJldHJhaW5lZCglMjJjYW1lbWJlcnQtYmFzZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CamembertTokenizer, CamembertForMaskedLM

tokenizer = CamembertTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = CamembertForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),c=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JNYXNrZWRMTSUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yTWFza2VkTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmNhbWVtYmVydC1iYXNlJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)
model = AutoModelForMaskedLM.from_pretrained(<span class="hljs-string">&quot;camembert-base&quot;</span>)`,wrap:!1}}),{c(){T(t.$$.fragment),r=m(),n=y("p"),n.innerHTML=b,u=m(),T(c.$$.fragment)},l(s){j(t.$$.fragment,s),r=p(s),n=g(s,"P",{"data-svelte-h":!0}),C(n)!=="svelte-j1ycsl"&&(n.innerHTML=b),u=p(s),j(c.$$.fragment,s)},m(s,o){U(t,s,o),i(s,r,o),i(s,n,o),i(s,u,o),U(c,s,o),d=!0},i(s){d||(h(t.$$.fragment,s),h(c.$$.fragment,s),d=!0)},o(s){M(t.$$.fragment,s),M(c.$$.fragment,s),d=!1},d(s){s&&(a(r),a(n),a(u)),x(t,s),x(c,s)}}}function Ee(f){let t;return{c(){t=Ce("Wenn du ein vortrainiertes Modell verwendest, prüf erstmal, wie genau das traininert wurde, mit welchen Datensätzen, sowie seine Einschränkungen und Biases. All diese Informationen sollten auf der Modellbeschreibungskarte stehen.")},l(r){t=$e(r,"Wenn du ein vortrainiertes Modell verwendest, prüf erstmal, wie genau das traininert wurde, mit welchen Datensätzen, sowie seine Einschränkungen und Biases. All diese Informationen sollten auf der Modellbeschreibungskarte stehen.")},m(r,n){i(r,t,n)},d(r){r&&a(t)}}}function Ae(f){let t,r,n,b,u,c,d,s,o,k,F,_,le="Der Model Hub erleichtert das Auswählen des passenden Modells, sodass es von downstream Libraries mit wenigen Codezeilen benutzt werden kann. Lass uns anschauen, wie genau man solche Modelle verwendet und wie man der Communinity zurück beitragen kann.",X,z,ae="Nehmen wir an, wir suchen nach einem französichbasierten Modell, das die “mask filling” Aufgabe kann.",S,$,re='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/camembert.gif" alt="Selecting the Camembert model." width="80%"/>',D,V,ie="Wir wählen den <code>camembert-base</code> Checkpoint aus, um es zu auszuprobieren. Das Kennzeichen <code>camembert-base</code> ist alles, was wir brauchen, um loszulegen! Wie in früheren Kapiteln gezeigt wurde, können wir das Modell mit der <code>pipeline()</code> Funktion instanziieren:",R,v,L,N,H,E,oe="So einfach kann man mit einer Pipeline ein Modell laden. Dabei muss man nur darauf achten, den passenden Checkpoint für die gewünschte Aufgabe zu selektieren. Zum Beispiel: Wir laden hier den <code>camembert-base</code> Checkpoint in die <code>fill-mask</code> Pipeline, was schon korrekt ist. Aber würden wir diesen Checkpoint in die <code>text-classification</code> Pipeline laden, wären die Ergebnisse völlig sinnlos, weil der “head” von <code>camembert-base</code> für diese Aufgabe einfach nicht passt! Wir empfehlen, den “Task Selector” auf der Hugging Face Hub Seite zu benutzen, um die richtigen Checkpoints auszuwählen:",q,W,ce='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/tasks.png" alt="The task selector on the web interface." width="80%"/>',P,A,me="Du kannst auch den Checkpoint mit der Modell-Architektur direkt instanziieren:",K,J,w,I,Z,O,G,ee;u=new Ze({props:{fw:f[0]}}),d=new _e({props:{title:"Verwendung vortrainierter Modelle",local:"verwendung-vortrainierter-modelle",headingTag:"h1"}});const pe=[Ve,ze],B=[];function ue(e,l){return e[0]==="pt"?0:1}o=ue(f),k=B[o]=pe[o](f),v=new Y({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBY2FtZW1iZXJ0X2ZpbGxfbWFzayUyMCUzRCUyMHBpcGVsaW5lKCUyMmZpbGwtbWFzayUyMiUyQyUyMG1vZGVsJTNEJTIyY2FtZW1iZXJ0LWJhc2UlMjIpJTBBcmVzdWx0cyUyMCUzRCUyMGNhbWVtYmVydF9maWxsX21hc2soJTIyTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjAlM0NtYXNrJTNFJTIwJTNBKSUyMik=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

camembert_fill_mask = pipeline(<span class="hljs-string">&quot;fill-mask&quot;</span>, model=<span class="hljs-string">&quot;camembert-base&quot;</span>)
results = camembert_fill_mask(<span class="hljs-string">&quot;Le camembert est &lt;mask&gt; :)&quot;</span>)`,wrap:!1}}),N=new Y({props:{code:"JTVCJTBBJTIwJTIwJTdCJ3NlcXVlbmNlJyUzQSUyMCdMZSUyMGNhbWVtYmVydCUyMGVzdCUyMGQlQzMlQTlsaWNpZXV4JTIwJTNBKSclMkMlMjAnc2NvcmUnJTNBJTIwMC40OTA5MTAwNTMyNTMxNzM4MyUyQyUyMCd0b2tlbiclM0ElMjA3MjAwJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnZCVDMyVBOWxpY2lldXgnJTdEJTJDJTIwJTBBJTIwJTIwJTdCJ3NlcXVlbmNlJyUzQSUyMCdMZSUyMGNhbWVtYmVydCUyMGVzdCUyMGV4Y2VsbGVudCUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMTA1NTY5NzQyNjE5OTkxMyUyQyUyMCd0b2tlbiclM0ElMjAyMTgzJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnZXhjZWxsZW50JyU3RCUyQyUyMCUwQSUyMCUyMCU3QidzZXF1ZW5jZSclM0ElMjAnTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjBzdWNjdWxlbnQlMjAlM0EpJyUyQyUyMCdzY29yZSclM0ElMjAwLjAzNDUzMzEzMTg2NzY0NzE3JTJDJTIwJ3Rva2VuJyUzQSUyMDI2MjAyJTJDJTIwJ3Rva2VuX3N0ciclM0ElMjAnc3VjY3VsZW50JyU3RCUyQyUyMCUwQSUyMCUyMCU3QidzZXF1ZW5jZSclM0ElMjAnTGUlMjBjYW1lbWJlcnQlMjBlc3QlMjBtZWlsbGV1ciUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMDMzMDMxNDExNDY4OTgyNyUyQyUyMCd0b2tlbiclM0ElMjA1MjglMkMlMjAndG9rZW5fc3RyJyUzQSUyMCdtZWlsbGV1ciclN0QlMkMlMjAlMEElMjAlMjAlN0Inc2VxdWVuY2UnJTNBJTIwJ0xlJTIwY2FtZW1iZXJ0JTIwZXN0JTIwcGFyZmFpdCUyMCUzQSknJTJDJTIwJ3Njb3JlJyUzQSUyMDAuMDMwMDc2NTAxODkxMDE2OTYlMkMlMjAndG9rZW4nJTNBJTIwMTY1NCUyQyUyMCd0b2tlbl9zdHInJTNBJTIwJ3BhcmZhaXQnJTdEJTBBJTVE",highlighted:`[
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est délicieux :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.49091005325317383</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">7200</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;délicieux&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est excellent :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.1055697426199913</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">2183</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;excellent&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est succulent :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.03453313186764717</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">26202</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;succulent&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est meilleur :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.0330314114689827</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">528</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;meilleur&#x27;</span>}, 
  {<span class="hljs-string">&#x27;sequence&#x27;</span>: <span class="hljs-string">&#x27;Le camembert est parfait :)&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.03007650189101696</span>, <span class="hljs-string">&#x27;token&#x27;</span>: <span class="hljs-number">1654</span>, <span class="hljs-string">&#x27;token_str&#x27;</span>: <span class="hljs-string">&#x27;parfait&#x27;</span>}
]`,wrap:!1}});const de=[Ne,ve],Q=[];function be(e,l){return e[0]==="pt"?0:1}return J=be(f),w=Q[J]=de[J](f),Z=new We({props:{$$slots:{default:[Ee]},$$scope:{ctx:f}}}),{c(){t=y("meta"),r=m(),n=y("p"),b=m(),T(u.$$.fragment),c=m(),T(d.$$.fragment),s=m(),k.c(),F=m(),_=y("p"),_.textContent=le,X=m(),z=y("p"),z.textContent=ae,S=m(),$=y("div"),$.innerHTML=re,D=m(),V=y("p"),V.innerHTML=ie,R=m(),T(v.$$.fragment),L=m(),T(N.$$.fragment),H=m(),E=y("p"),E.innerHTML=oe,q=m(),W=y("div"),W.innerHTML=ce,P=m(),A=y("p"),A.textContent=me,K=m(),w.c(),I=m(),T(Z.$$.fragment),O=m(),G=y("p"),this.h()},l(e){const l=Ue("svelte-u9bgzb",document.head);t=g(l,"META",{name:!0,content:!0}),l.forEach(a),r=p(e),n=g(e,"P",{}),fe(n).forEach(a),b=p(e),j(u.$$.fragment,e),c=p(e),j(d.$$.fragment,e),s=p(e),k.l(e),F=p(e),_=g(e,"P",{"data-svelte-h":!0}),C(_)!=="svelte-7y3kng"&&(_.textContent=le),X=p(e),z=g(e,"P",{"data-svelte-h":!0}),C(z)!=="svelte-bbbe5r"&&(z.textContent=ae),S=p(e),$=g(e,"DIV",{class:!0,"data-svelte-h":!0}),C($)!=="svelte-4k6hvy"&&($.innerHTML=re),D=p(e),V=g(e,"P",{"data-svelte-h":!0}),C(V)!=="svelte-qzga3h"&&(V.innerHTML=ie),R=p(e),j(v.$$.fragment,e),L=p(e),j(N.$$.fragment,e),H=p(e),E=g(e,"P",{"data-svelte-h":!0}),C(E)!=="svelte-q2shzx"&&(E.innerHTML=oe),q=p(e),W=g(e,"DIV",{class:!0,"data-svelte-h":!0}),C(W)!=="svelte-1cl7xbt"&&(W.innerHTML=ce),P=p(e),A=g(e,"P",{"data-svelte-h":!0}),C(A)!=="svelte-1epaz1v"&&(A.textContent=me),K=p(e),w.l(e),I=p(e),j(Z.$$.fragment,e),O=p(e),G=g(e,"P",{}),fe(G).forEach(a),this.h()},h(){se(t,"name","hf:doc:metadata"),se(t,"content",Be),se($,"class","flex justify-center"),se(W,"class","flex justify-center")},m(e,l){xe(document.head,t),i(e,r,l),i(e,n,l),i(e,b,l),U(u,e,l),i(e,c,l),U(d,e,l),i(e,s,l),B[o].m(e,l),i(e,F,l),i(e,_,l),i(e,X,l),i(e,z,l),i(e,S,l),i(e,$,l),i(e,D,l),i(e,V,l),i(e,R,l),U(v,e,l),i(e,L,l),U(N,e,l),i(e,H,l),i(e,E,l),i(e,q,l),i(e,W,l),i(e,P,l),i(e,A,l),i(e,K,l),Q[J].m(e,l),i(e,I,l),U(Z,e,l),i(e,O,l),i(e,G,l),ee=!0},p(e,[l]){const Me={};l&1&&(Me.fw=e[0]),u.$set(Me);let te=o;o=ue(e),o!==te&&(ge(),M(B[te],1,1,()=>{B[te]=null}),ye(),k=B[o],k||(k=B[o]=pe[o](e),k.c()),h(k,1),k.m(F.parentNode,F));let ne=J;J=be(e),J!==ne&&(ge(),M(Q[ne],1,1,()=>{Q[ne]=null}),ye(),w=Q[J],w||(w=Q[J]=de[J](e),w.c()),h(w,1),w.m(I.parentNode,I));const he={};l&2&&(he.$$scope={dirty:l,ctx:e}),Z.$set(he)},i(e){ee||(h(u.$$.fragment,e),h(d.$$.fragment,e),h(k),h(v.$$.fragment,e),h(N.$$.fragment,e),h(w),h(Z.$$.fragment,e),ee=!0)},o(e){M(u.$$.fragment,e),M(d.$$.fragment,e),M(k),M(v.$$.fragment,e),M(N.$$.fragment,e),M(w),M(Z.$$.fragment,e),ee=!1},d(e){e&&(a(r),a(n),a(b),a(c),a(s),a(F),a(_),a(X),a(z),a(S),a($),a(D),a(V),a(R),a(L),a(H),a(E),a(q),a(W),a(P),a(A),a(K),a(I),a(O),a(G)),a(t),x(u,e),x(d,e),B[o].d(e),x(v,e),x(N,e),Q[J].d(e),x(Z,e)}}}const Be='{"title":"Verwendung vortrainierter Modelle","local":"verwendung-vortrainierter-modelle","sections":[],"depth":1}';function Qe(f,t,r){let n="pt";return we(()=>{const b=new URLSearchParams(window.location.search);r(0,n=b.get("fw")||"pt")}),[n]}class Re extends Te{constructor(t){super(),je(this,t,Qe,Ae,Je,{})}}export{Re as component};
