import{s as Te,o as je}from"../chunks/scheduler.49e4e380.js";import{S as Ue,i as xe,g as y,s as c,r as k,A as $e,h as g,f as a,c as m,j as ge,u as J,x as $,k as ne,y as Ce,a as r,v as w,t as f,b as ke,d as h,w as T,m as We,n as Ze,p as Je}from"../chunks/index.fb15006d.js";import{T as _e}from"../chunks/Tip.f590f2e1.js";import{C as Y}from"../chunks/CodeBlock.3f4fbe91.js";import{D as we}from"../chunks/DocNotebookDropdown.ff7a6598.js";import{F as ze}from"../chunks/FrameworkSwitchCourse.f837e098.js";import{H as Ve,E as ve}from"../chunks/getInferenceSnippets.52bc9406.js";function Ne(M){let t,i;return t=new we({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(){k(t.$$.fragment)},l(n){J(t.$$.fragment,n)},m(n,b){w(t,n,b),i=!0},i(n){i||(h(t.$$.fragment,n),i=!0)},o(n){f(t.$$.fragment,n),i=!1},d(n){T(t,n)}}}function Ee(M){let t,i;return t=new we({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(){k(t.$$.fragment)},l(n){J(t.$$.fragment,n)},m(n,b){w(t,n,b),i=!0},i(n){i||(h(t.$$.fragment,n),i=!0)},o(n){f(t.$$.fragment,n),i=!1},d(n){T(t,n)}}}function Ae(M){let t,i,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,p,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}}),p=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(){k(t.$$.fragment),i=c(),n=y("p"),n.innerHTML=b,u=c(),k(p.$$.fragment)},l(s){J(t.$$.fragment,s),i=m(s),n=g(s,"P",{"data-svelte-h":!0}),$(n)!=="svelte-1xi50pm"&&(n.innerHTML=b),u=m(s),J(p.$$.fragment,s)},m(s,o){w(t,s,o),r(s,i,o),r(s,n,o),r(s,u,o),w(p,s,o),d=!0},i(s){d||(h(t.$$.fragment,s),h(p.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(p.$$.fragment,s),d=!1},d(s){s&&(a(i),a(n),a(u)),T(t,s),T(p,s)}}}function Be(M){let t,i,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,p,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}}),p=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(){k(t.$$.fragment),i=c(),n=y("p"),n.innerHTML=b,u=c(),k(p.$$.fragment)},l(s){J(t.$$.fragment,s),i=m(s),n=g(s,"P",{"data-svelte-h":!0}),$(n)!=="svelte-j1ycsl"&&(n.innerHTML=b),u=m(s),J(p.$$.fragment,s)},m(s,o){w(t,s,o),r(s,i,o),r(s,n,o),r(s,u,o),w(p,s,o),d=!0},i(s){d||(h(t.$$.fragment,s),h(p.$$.fragment,s),d=!0)},o(s){f(t.$$.fragment,s),f(p.$$.fragment,s),d=!1},d(s){s&&(a(i),a(n),a(u)),T(t,s),T(p,s)}}}function Qe(M){let t;return{c(){t=We("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(i){t=Ze(i,"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(i,n){r(i,t,n)},d(i){i&&a(t)}}}function Fe(M){let t,i,n,b,u,p,d,s,o,j,I,_,re="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.",S,z,ie="Nehmen wir an, wir suchen nach einem französichbasierten Modell, das die “mask filling” Aufgabe kann.",D,C,oe='<img src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter4/camembert.gif" alt="Selecting the Camembert model." width="80%"/>',R,V,ce="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:",L,v,H,N,q,E,me="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:",P,W,pe='<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%"/>',K,A,ue="Du kannst auch den Checkpoint mit der Modell-Architektur direkt instanziieren:",O,U,x,G,Z,ee,B,se,X,te;u=new ze({props:{fw:M[0]}}),d=new Ve({props:{title:"Verwendung vortrainierter Modelle",local:"verwendung-vortrainierter-modelle",headingTag:"h1"}});const de=[Ee,Ne],Q=[];function be(e,l){return e[0]==="pt"?0:1}o=be(M),j=Q[o]=de[o](M),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 fe=[Be,Ae],F=[];function he(e,l){return e[0]==="pt"?0:1}return U=he(M),x=F[U]=fe[U](M),Z=new _e({props:{$$slots:{default:[Qe]},$$scope:{ctx:M}}}),B=new ve({props:{source:"https://github.com/huggingface/course/blob/main/chapters/de/chapter4/2.mdx"}}),{c(){t=y("meta"),i=c(),n=y("p"),b=c(),k(u.$$.fragment),p=c(),k(d.$$.fragment),s=c(),j.c(),I=c(),_=y("p"),_.textContent=re,S=c(),z=y("p"),z.textContent=ie,D=c(),C=y("div"),C.innerHTML=oe,R=c(),V=y("p"),V.innerHTML=ce,L=c(),k(v.$$.fragment),H=c(),k(N.$$.fragment),q=c(),E=y("p"),E.innerHTML=me,P=c(),W=y("div"),W.innerHTML=pe,K=c(),A=y("p"),A.textContent=ue,O=c(),x.c(),G=c(),k(Z.$$.fragment),ee=c(),k(B.$$.fragment),se=c(),X=y("p"),this.h()},l(e){const l=$e("svelte-u9bgzb",document.head);t=g(l,"META",{name:!0,content:!0}),l.forEach(a),i=m(e),n=g(e,"P",{}),ge(n).forEach(a),b=m(e),J(u.$$.fragment,e),p=m(e),J(d.$$.fragment,e),s=m(e),j.l(e),I=m(e),_=g(e,"P",{"data-svelte-h":!0}),$(_)!=="svelte-7y3kng"&&(_.textContent=re),S=m(e),z=g(e,"P",{"data-svelte-h":!0}),$(z)!=="svelte-bbbe5r"&&(z.textContent=ie),D=m(e),C=g(e,"DIV",{class:!0,"data-svelte-h":!0}),$(C)!=="svelte-4k6hvy"&&(C.innerHTML=oe),R=m(e),V=g(e,"P",{"data-svelte-h":!0}),$(V)!=="svelte-qzga3h"&&(V.innerHTML=ce),L=m(e),J(v.$$.fragment,e),H=m(e),J(N.$$.fragment,e),q=m(e),E=g(e,"P",{"data-svelte-h":!0}),$(E)!=="svelte-q2shzx"&&(E.innerHTML=me),P=m(e),W=g(e,"DIV",{class:!0,"data-svelte-h":!0}),$(W)!=="svelte-1cl7xbt"&&(W.innerHTML=pe),K=m(e),A=g(e,"P",{"data-svelte-h":!0}),$(A)!=="svelte-1epaz1v"&&(A.textContent=ue),O=m(e),x.l(e),G=m(e),J(Z.$$.fragment,e),ee=m(e),J(B.$$.fragment,e),se=m(e),X=g(e,"P",{}),ge(X).forEach(a),this.h()},h(){ne(t,"name","hf:doc:metadata"),ne(t,"content",Ie),ne(C,"class","flex justify-center"),ne(W,"class","flex justify-center")},m(e,l){Ce(document.head,t),r(e,i,l),r(e,n,l),r(e,b,l),w(u,e,l),r(e,p,l),w(d,e,l),r(e,s,l),Q[o].m(e,l),r(e,I,l),r(e,_,l),r(e,S,l),r(e,z,l),r(e,D,l),r(e,C,l),r(e,R,l),r(e,V,l),r(e,L,l),w(v,e,l),r(e,H,l),w(N,e,l),r(e,q,l),r(e,E,l),r(e,P,l),r(e,W,l),r(e,K,l),r(e,A,l),r(e,O,l),F[U].m(e,l),r(e,G,l),w(Z,e,l),r(e,ee,l),w(B,e,l),r(e,se,l),r(e,X,l),te=!0},p(e,[l]){const Me={};l&1&&(Me.fw=e[0]),u.$set(Me);let le=o;o=be(e),o!==le&&(Je(),f(Q[le],1,1,()=>{Q[le]=null}),ke(),j=Q[o],j||(j=Q[o]=de[o](e),j.c()),h(j,1),j.m(I.parentNode,I));let ae=U;U=he(e),U!==ae&&(Je(),f(F[ae],1,1,()=>{F[ae]=null}),ke(),x=F[U],x||(x=F[U]=fe[U](e),x.c()),h(x,1),x.m(G.parentNode,G));const ye={};l&2&&(ye.$$scope={dirty:l,ctx:e}),Z.$set(ye)},i(e){te||(h(u.$$.fragment,e),h(d.$$.fragment,e),h(j),h(v.$$.fragment,e),h(N.$$.fragment,e),h(x),h(Z.$$.fragment,e),h(B.$$.fragment,e),te=!0)},o(e){f(u.$$.fragment,e),f(d.$$.fragment,e),f(j),f(v.$$.fragment,e),f(N.$$.fragment,e),f(x),f(Z.$$.fragment,e),f(B.$$.fragment,e),te=!1},d(e){e&&(a(i),a(n),a(b),a(p),a(s),a(I),a(_),a(S),a(z),a(D),a(C),a(R),a(V),a(L),a(H),a(q),a(E),a(P),a(W),a(K),a(A),a(O),a(G),a(ee),a(se),a(X)),a(t),T(u,e),T(d,e),Q[o].d(e),T(v,e),T(N,e),F[U].d(e),T(Z,e),T(B,e)}}}const Ie='{"title":"Verwendung vortrainierter Modelle","local":"verwendung-vortrainierter-modelle","sections":[],"depth":1}';function Ge(M,t,i){let n="pt";return je(()=>{const b=new URLSearchParams(window.location.search);i(0,n=b.get("fw")||"pt")}),[n]}class qe extends Ue{constructor(t){super(),xe(this,t,Ge,Fe,Te,{})}}export{qe as component};
