import{S as Ft,i as Yt,s as Dt,e as i,k as b,w as T,t as l,M as Bt,c as p,d as t,m as g,a as c,x as U,h as r,b as w,G as a,g as m,y as k,q as C,o as Z,B as R,v as qt,L as Vt}from"../../chunks/vendor-hf-doc-builder.js";import{T as ua}from"../../chunks/Tip-hf-doc-builder.js";import{Y as Nt}from"../../chunks/Youtube-hf-doc-builder.js";import{I as za}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as ne}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Xt,M as Wa}from"../../chunks/Markdown-hf-doc-builder.js";function At(z){let s,f,o,u,y;return{c(){s=i("p"),f=l("Consulte a "),o=i("a"),u=l("p\xE1gina de tarefas de classifica\xE7\xE3o de texto"),y=l(" para obter mais informa\xE7\xF5es sobre outras formas de classifica\xE7\xE3o de texto e seus modelos, conjuntos de dados e m\xE9tricas associados."),this.h()},l($){s=p($,"P",{});var _=c(s);f=r(_,"Consulte a "),o=p(_,"A",{href:!0,rel:!0});var J=c(o);u=r(J,"p\xE1gina de tarefas de classifica\xE7\xE3o de texto"),J.forEach(t),y=r(_," para obter mais informa\xE7\xF5es sobre outras formas de classifica\xE7\xE3o de texto e seus modelos, conjuntos de dados e m\xE9tricas associados."),_.forEach(t),this.h()},h(){w(o,"href","https://huggingface.co/tasks/text-classification"),w(o,"rel","nofollow")},m($,_){m($,s,_),a(s,f),a(s,o),a(o,u),a(s,y)},d($){$&&t(s)}}}function Qt(z){let s,f;return s=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer)`}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p:Vt,i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function St(z){let s,f;return s=new Wa({props:{$$slots:{default:[Qt]},$$scope:{ctx:z}}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p(o,u){const y={};u&2&&(y.$$scope={dirty:u,ctx:o}),s.$set(y)},i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function Pt(z){let s,f;return s=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nJTBBJTBBZGF0YV9jb2xsYXRvciUyMCUzRCUyMERhdGFDb2xsYXRvcldpdGhQYWRkaW5nKHRva2VuaXplciUzRHRva2VuaXplciUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DataCollatorWithPadding

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DataCollatorWithPadding(tokenizer=tokenizer, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p:Vt,i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function Ht(z){let s,f;return s=new Wa({props:{$$slots:{default:[Pt]},$$scope:{ctx:z}}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p(o,u){const y={};u&2&&(y.$$scope={dirty:u,ctx:o}),s.$set(y)},i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function Ot(z){let s,f,o,u,y,$,_,J;return{c(){s=i("p"),f=l("Se voc\xEA n\xE3o estiver familiarizado com o fine-tuning de um modelo com o "),o=i("code"),u=l("Trainer"),y=l(", d\xEA uma olhada no tutorial b\xE1sico "),$=i("a"),_=l("aqui"),J=l("!"),this.h()},l(E){s=p(E,"P",{});var j=c(s);f=r(j,"Se voc\xEA n\xE3o estiver familiarizado com o fine-tuning de um modelo com o "),o=p(j,"CODE",{});var x=c(o);u=r(x,"Trainer"),x.forEach(t),y=r(j,", d\xEA uma olhada no tutorial b\xE1sico "),$=p(j,"A",{href:!0});var X=c($);_=r(X,"aqui"),X.forEach(t),J=r(j,"!"),j.forEach(t),this.h()},h(){w($,"href","../training#finetune-with-trainer")},m(E,j){m(E,s,j),a(s,f),a(s,o),a(o,u),a(s,y),a(s,$),a($,_),a(s,J)},d(E){E&&t(s)}}}function Lt(z){let s,f,o,u,y,$,_,J;return{c(){s=i("p"),f=l("O "),o=i("code"),u=l("Trainer"),y=l(" aplicar\xE1 o preenchimento din\xE2mico por padr\xE3o quando voc\xEA definir o argumento "),$=i("code"),_=l("tokenizer"),J=l(" dele. Nesse caso, voc\xEA n\xE3o precisa especificar um data collator explicitamente.")},l(E){s=p(E,"P",{});var j=c(s);f=r(j,"O "),o=p(j,"CODE",{});var x=c(o);u=r(x,"Trainer"),x.forEach(t),y=r(j," aplicar\xE1 o preenchimento din\xE2mico por padr\xE3o quando voc\xEA definir o argumento "),$=p(j,"CODE",{});var X=c($);_=r(X,"tokenizer"),X.forEach(t),J=r(j," dele. Nesse caso, voc\xEA n\xE3o precisa especificar um data collator explicitamente."),j.forEach(t)},m(E,j){m(E,s,j),a(s,f),a(s,o),a(o,u),a(s,y),a(s,$),a($,_),a(s,J)},d(E){E&&t(s)}}}function Kt(z){let s,f,o,u,y,$,_,J,E,j,x,X,H,G,Q,W,se,q,ye,fe,I,ue,N,he,A,$e,V,S,Y,O,L,oe,D,ee,B,be;return _=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMkMlMjBUcmFpbmluZ0FyZ3VtZW50cyUyQyUyMFRyYWluZXIlMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwbnVtX2xhYmVscyUzRDIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification, TrainingArguments, Trainer

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>)`}}),E=new ua({props:{$$slots:{default:[Ot]},$$scope:{ctx:z}}}),D=new ne({props:{code:"dHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKCUwQSUyMCUyMCUyMCUyMG91dHB1dF9kaXIlM0QlMjIuJTJGcmVzdWx0cyUyMiUyQyUwQSUyMCUyMCUyMCUyMGxlYXJuaW5nX3JhdGUlM0QyZS01JTJDJTBBJTIwJTIwJTIwJTIwcGVyX2RldmljZV90cmFpbl9iYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBwZXJfZGV2aWNlX2V2YWxfYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwbnVtX3RyYWluX2Vwb2NocyUzRDUlMkMlMEElMjAlMjAlMjAlMjB3ZWlnaHRfZGVjYXklM0QwLjAxJTJDJTBBKSUwQSUwQXRyYWluZXIlMjAlM0QlMjBUcmFpbmVyKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEbW9kZWwlMkMlMEElMjAlMjAlMjAlMjBhcmdzJTNEdHJhaW5pbmdfYXJncyUyQyUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlM0R0b2tlbml6ZWRfaW1kYiU1QiUyMnRyYWluJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwZXZhbF9kYXRhc2V0JTNEdG9rZW5pemVkX2ltZGIlNUIlMjJ0ZXN0JTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwZGF0YV9jb2xsYXRvciUzRGRhdGFfY29sbGF0b3IlMkMlMEEpJTBBJTBBdHJhaW5lci50cmFpbigp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(
<span class="hljs-meta">... </span>    output_dir=<span class="hljs-string">&quot;./results&quot;</span>,
<span class="hljs-meta">... </span>    learning_rate=<span class="hljs-number">2e-5</span>,
<span class="hljs-meta">... </span>    per_device_train_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    per_device_eval_batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    num_train_epochs=<span class="hljs-number">5</span>,
<span class="hljs-meta">... </span>    weight_decay=<span class="hljs-number">0.01</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer = Trainer(
<span class="hljs-meta">... </span>    model=model,
<span class="hljs-meta">... </span>    args=training_args,
<span class="hljs-meta">... </span>    train_dataset=tokenized_imdb[<span class="hljs-string">&quot;train&quot;</span>],
<span class="hljs-meta">... </span>    eval_dataset=tokenized_imdb[<span class="hljs-string">&quot;test&quot;</span>],
<span class="hljs-meta">... </span>    tokenizer=tokenizer,
<span class="hljs-meta">... </span>    data_collator=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()`}}),B=new ua({props:{$$slots:{default:[Lt]},$$scope:{ctx:z}}}),{c(){s=i("p"),f=l("Carregue o DistilBERT com "),o=i("code"),u=l("AutoModelForSequenceClassification"),y=l(" junto com o n\xFAmero de r\xF3tulos esperados:"),$=b(),T(_.$$.fragment),J=b(),T(E.$$.fragment),j=b(),x=i("p"),X=l("Nesse ponto, restam apenas tr\xEAs passos:"),H=b(),G=i("ol"),Q=i("li"),W=l("Definir seus hiperpar\xE2metros de treinamento em "),se=i("code"),q=l("TrainingArguments"),ye=l("."),fe=b(),I=i("li"),ue=l("Passar os argumentos de treinamento para o "),N=i("code"),he=l("Trainer"),A=l(" junto com o modelo, conjunto de dados, tokenizador e o data collator."),$e=b(),V=i("li"),S=l("Chamar a fun\xE7\xE3o "),Y=i("code"),O=l("train()"),L=l(" para executar o fine-tuning do seu modelo."),oe=b(),T(D.$$.fragment),ee=b(),T(B.$$.fragment)},l(d){s=p(d,"P",{});var M=c(s);f=r(M,"Carregue o DistilBERT com "),o=p(M,"CODE",{});var ae=c(o);u=r(ae,"AutoModelForSequenceClassification"),ae.forEach(t),y=r(M," junto com o n\xFAmero de r\xF3tulos esperados:"),M.forEach(t),$=g(d),U(_.$$.fragment,d),J=g(d),U(E.$$.fragment,d),j=g(d),x=p(d,"P",{});var F=c(x);X=r(F,"Nesse ponto, restam apenas tr\xEAs passos:"),F.forEach(t),H=g(d),G=p(d,"OL",{});var le=c(G);Q=p(le,"LI",{});var P=c(Q);W=r(P,"Definir seus hiperpar\xE2metros de treinamento em "),se=p(P,"CODE",{});var K=c(se);q=r(K,"TrainingArguments"),K.forEach(t),ye=r(P,"."),P.forEach(t),fe=g(le),I=p(le,"LI",{});var ie=c(I);ue=r(ie,"Passar os argumentos de treinamento para o "),N=p(ie,"CODE",{});var pe=c(N);he=r(pe,"Trainer"),pe.forEach(t),A=r(ie," junto com o modelo, conjunto de dados, tokenizador e o data collator."),ie.forEach(t),$e=g(le),V=p(le,"LI",{});var ce=c(V);S=r(ce,"Chamar a fun\xE7\xE3o "),Y=p(ce,"CODE",{});var te=c(Y);O=r(te,"train()"),te.forEach(t),L=r(ce," para executar o fine-tuning do seu modelo."),ce.forEach(t),le.forEach(t),oe=g(d),U(D.$$.fragment,d),ee=g(d),U(B.$$.fragment,d)},m(d,M){m(d,s,M),a(s,f),a(s,o),a(o,u),a(s,y),m(d,$,M),k(_,d,M),m(d,J,M),k(E,d,M),m(d,j,M),m(d,x,M),a(x,X),m(d,H,M),m(d,G,M),a(G,Q),a(Q,W),a(Q,se),a(se,q),a(Q,ye),a(G,fe),a(G,I),a(I,ue),a(I,N),a(N,he),a(I,A),a(G,$e),a(G,V),a(V,S),a(V,Y),a(Y,O),a(V,L),m(d,oe,M),k(D,d,M),m(d,ee,M),k(B,d,M),be=!0},p(d,M){const ae={};M&2&&(ae.$$scope={dirty:M,ctx:d}),E.$set(ae);const F={};M&2&&(F.$$scope={dirty:M,ctx:d}),B.$set(F)},i(d){be||(C(_.$$.fragment,d),C(E.$$.fragment,d),C(D.$$.fragment,d),C(B.$$.fragment,d),be=!0)},o(d){Z(_.$$.fragment,d),Z(E.$$.fragment,d),Z(D.$$.fragment,d),Z(B.$$.fragment,d),be=!1},d(d){d&&t(s),d&&t($),R(_,d),d&&t(J),R(E,d),d&&t(j),d&&t(x),d&&t(H),d&&t(G),d&&t(oe),R(D,d),d&&t(ee),R(B,d)}}}function es(z){let s,f;return s=new Wa({props:{$$slots:{default:[Kt]},$$scope:{ctx:z}}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p(o,u){const y={};u&2&&(y.$$scope={dirty:u,ctx:o}),s.$set(y)},i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function as(z){let s,f,o,u,y;return{c(){s=i("p"),f=l("Se voc\xEA n\xE3o estiver familiarizado com o fine-tuning de um modelo com o Keras, d\xEA uma olhada no tutorial b\xE1sico "),o=i("a"),u=l("aqui"),y=l("!"),this.h()},l($){s=p($,"P",{});var _=c(s);f=r(_,"Se voc\xEA n\xE3o estiver familiarizado com o fine-tuning de um modelo com o Keras, d\xEA uma olhada no tutorial b\xE1sico "),o=p(_,"A",{href:!0});var J=c(o);u=r(J,"aqui"),J.forEach(t),y=r(_,"!"),_.forEach(t),this.h()},h(){w(o,"href","training#finetune-with-keras")},m($,_){m($,s,_),a(s,f),a(s,o),a(o,u),a(s,y)},d($){$&&t(s)}}}function ts(z){let s,f,o,u,y,$,_,J,E,j,x,X,H,G,Q,W,se,q,ye,fe,I,ue,N,he,A,$e,V,S,Y,O,L,oe,D,ee,B,be,d,M,ae,F,le,P,K,ie,pe,ce,te,me;return G=new ne({props:{code:"dGZfdHJhaW5fc2V0JTIwJTNEJTIwdG9rZW5pemVkX2ltZGIlNUIlMjJ0cmFpbiUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCUyMmlucHV0X2lkcyUyMiUyQyUyMCUyMmxhYmVsJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEMTYlMkMlMEElMjAlMjAlMjAlMjBjb2xsYXRlX2ZuJTNEZGF0YV9jb2xsYXRvciUyQyUwQSklMEElMEF0Zl92YWxpZGF0aW9uX3NldCUyMCUzRCUyMHRva2VuaXplZF9pbWRiJTVCJTIydGVzdCUyMiU1RC50b190Zl9kYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGNvbHVtbnMlM0QlNUIlMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCUyMmlucHV0X2lkcyUyMiUyQyUyMCUyMmxhYmVsJTIyJTVEJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDE2JTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_set = tokenized_imdb[<span class="hljs-string">&quot;train&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_validation_set = tokenized_imdb[<span class="hljs-string">&quot;test&quot;</span>].to_tf_dataset(
<span class="hljs-meta">... </span>    columns=[<span class="hljs-string">&quot;attention_mask&quot;</span>, <span class="hljs-string">&quot;input_ids&quot;</span>, <span class="hljs-string">&quot;label&quot;</span>],
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">16</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>)`}}),W=new ua({props:{$$slots:{default:[as]},$$scope:{ctx:z}}}),I=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGNyZWF0ZV9vcHRpbWl6ZXIlMEFpbXBvcnQlMjB0ZW5zb3JmbG93JTIwYXMlMjB0ZiUwQSUwQWJhdGNoX3NpemUlMjAlM0QlMjAxNiUwQW51bV9lcG9jaHMlMjAlM0QlMjA1JTBBYmF0Y2hlc19wZXJfZXBvY2glMjAlM0QlMjBsZW4odG9rZW5pemVkX2ltZGIlNUIlMjJ0cmFpbiUyMiU1RCklMjAlMkYlMkYlMjBiYXRjaF9zaXplJTBBdG90YWxfdHJhaW5fc3RlcHMlMjAlM0QlMjBpbnQoYmF0Y2hlc19wZXJfZXBvY2glMjAqJTIwbnVtX2Vwb2NocyklMEFvcHRpbWl6ZXIlMkMlMjBzY2hlZHVsZSUyMCUzRCUyMGNyZWF0ZV9vcHRpbWl6ZXIoaW5pdF9sciUzRDJlLTUlMkMlMjBudW1fd2FybXVwX3N0ZXBzJTNEMCUyQyUyMG51bV90cmFpbl9zdGVwcyUzRHRvdGFsX3RyYWluX3N0ZXBzKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> create_optimizer
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>batch_size = <span class="hljs-number">16</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">5</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>batches_per_epoch = <span class="hljs-built_in">len</span>(tokenized_imdb[<span class="hljs-string">&quot;train&quot;</span>]) // batch_size
<span class="hljs-meta">&gt;&gt;&gt; </span>total_train_steps = <span class="hljs-built_in">int</span>(batches_per_epoch * num_epochs)
<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer, schedule = create_optimizer(init_lr=<span class="hljs-number">2e-5</span>, num_warmup_steps=<span class="hljs-number">0</span>, num_train_steps=total_train_steps)`}}),Y=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRGQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbiUwQSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0QyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>, num_labels=<span class="hljs-number">2</span>)`}}),M=new ne({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFtb2RlbC5jb21waWxlKG9wdGltaXplciUzRG9wdGltaXplcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(optimizer=optimizer)`}}),te=new ne({props:{code:"bW9kZWwuZml0KHglM0R0Zl90cmFpbl9zZXQlMkMlMjB2YWxpZGF0aW9uX2RhdGElM0R0Zl92YWxpZGF0aW9uX3NldCUyQyUyMGVwb2NocyUzRDMp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(x=tf_train_set, validation_data=tf_validation_set, epochs=<span class="hljs-number">3</span>)'}}),{c(){s=i("p"),f=l("Para executar o fine-tuning de um modelo no TensorFlow, comece convertendo seu conjunto de dados para o formato "),o=i("code"),u=l("tf.data.Dataset"),y=l(" com "),$=i("a"),_=i("code"),J=l("to_tf_dataset"),E=l(". Nessa execu\xE7\xE3o voc\xEA dever\xE1 especificar as entradas e r\xF3tulos (no par\xE2metro "),j=i("code"),x=l("columns"),X=l("), se deseja embaralhar o conjunto de dados, o tamanho do batch e o data collator:"),H=b(),T(G.$$.fragment),Q=b(),T(W.$$.fragment),se=b(),q=i("p"),ye=l("Configure o otimizador e alguns hiperpar\xE2metros de treinamento:"),fe=b(),T(I.$$.fragment),ue=b(),N=i("p"),he=l("Carregue o DistilBERT com "),A=i("code"),$e=l("TFAutoModelForSequenceClassification"),V=l(" junto com o n\xFAmero de r\xF3tulos esperados:"),S=b(),T(Y.$$.fragment),O=b(),L=i("p"),oe=l("Configure o modelo para treinamento com o m\xE9todo "),D=i("a"),ee=i("code"),B=l("compile"),be=l(":"),d=b(),T(M.$$.fragment),ae=b(),F=i("p"),le=l("Chame o m\xE9todo "),P=i("a"),K=i("code"),ie=l("fit"),pe=l(" para executar o fine-tuning do modelo:"),ce=b(),T(te.$$.fragment),this.h()},l(n){s=p(n,"P",{});var v=c(s);f=r(v,"Para executar o fine-tuning de um modelo no TensorFlow, comece convertendo seu conjunto de dados para o formato "),o=p(v,"CODE",{});var ve=c(o);u=r(ve,"tf.data.Dataset"),ve.forEach(t),y=r(v," com "),$=p(v,"A",{href:!0,rel:!0});var qe=c($);_=p(qe,"CODE",{});var Ne=c(_);J=r(Ne,"to_tf_dataset"),Ne.forEach(t),qe.forEach(t),E=r(v,". Nessa execu\xE7\xE3o voc\xEA dever\xE1 especificar as entradas e r\xF3tulos (no par\xE2metro "),j=p(v,"CODE",{});var de=c(j);x=r(de,"columns"),de.forEach(t),X=r(v,"), se deseja embaralhar o conjunto de dados, o tamanho do batch e o data collator:"),v.forEach(t),H=g(n),U(G.$$.fragment,n),Q=g(n),U(W.$$.fragment,n),se=g(n),q=p(n,"P",{});var Je=c(q);ye=r(Je,"Configure o otimizador e alguns hiperpar\xE2metros de treinamento:"),Je.forEach(t),fe=g(n),U(I.$$.fragment,n),ue=g(n),N=p(n,"P",{});var Te=c(N);he=r(Te,"Carregue o DistilBERT com "),A=p(Te,"CODE",{});var Ae=c(A);$e=r(Ae,"TFAutoModelForSequenceClassification"),Ae.forEach(t),V=r(Te," junto com o n\xFAmero de r\xF3tulos esperados:"),Te.forEach(t),S=g(n),U(Y.$$.fragment,n),O=g(n),L=p(n,"P",{});var _e=c(L);oe=r(_e,"Configure o modelo para treinamento com o m\xE9todo "),D=p(_e,"A",{href:!0,rel:!0});var Qe=c(D);ee=p(Qe,"CODE",{});var Se=c(ee);B=r(Se,"compile"),Se.forEach(t),Qe.forEach(t),be=r(_e,":"),_e.forEach(t),d=g(n),U(M.$$.fragment,n),ae=g(n),F=p(n,"P",{});var je=c(F);le=r(je,"Chame o m\xE9todo "),P=p(je,"A",{href:!0,rel:!0});var Pe=c(P);K=p(Pe,"CODE",{});var He=c(K);ie=r(He,"fit"),He.forEach(t),Pe.forEach(t),pe=r(je," para executar o fine-tuning do modelo:"),je.forEach(t),ce=g(n),U(te.$$.fragment,n),this.h()},h(){w($,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.to_tf_dataset"),w($,"rel","nofollow"),w(D,"href","https://keras.io/api/models/model_training_apis/#compile-method"),w(D,"rel","nofollow"),w(P,"href","https://keras.io/api/models/model_training_apis/#fit-method"),w(P,"rel","nofollow")},m(n,v){m(n,s,v),a(s,f),a(s,o),a(o,u),a(s,y),a(s,$),a($,_),a(_,J),a(s,E),a(s,j),a(j,x),a(s,X),m(n,H,v),k(G,n,v),m(n,Q,v),k(W,n,v),m(n,se,v),m(n,q,v),a(q,ye),m(n,fe,v),k(I,n,v),m(n,ue,v),m(n,N,v),a(N,he),a(N,A),a(A,$e),a(N,V),m(n,S,v),k(Y,n,v),m(n,O,v),m(n,L,v),a(L,oe),a(L,D),a(D,ee),a(ee,B),a(L,be),m(n,d,v),k(M,n,v),m(n,ae,v),m(n,F,v),a(F,le),a(F,P),a(P,K),a(K,ie),a(F,pe),m(n,ce,v),k(te,n,v),me=!0},p(n,v){const ve={};v&2&&(ve.$$scope={dirty:v,ctx:n}),W.$set(ve)},i(n){me||(C(G.$$.fragment,n),C(W.$$.fragment,n),C(I.$$.fragment,n),C(Y.$$.fragment,n),C(M.$$.fragment,n),C(te.$$.fragment,n),me=!0)},o(n){Z(G.$$.fragment,n),Z(W.$$.fragment,n),Z(I.$$.fragment,n),Z(Y.$$.fragment,n),Z(M.$$.fragment,n),Z(te.$$.fragment,n),me=!1},d(n){n&&t(s),n&&t(H),R(G,n),n&&t(Q),R(W,n),n&&t(se),n&&t(q),n&&t(fe),R(I,n),n&&t(ue),n&&t(N),n&&t(S),R(Y,n),n&&t(O),n&&t(L),n&&t(d),R(M,n),n&&t(ae),n&&t(F),n&&t(ce),R(te,n)}}}function ss(z){let s,f;return s=new Wa({props:{$$slots:{default:[ts]},$$scope:{ctx:z}}}),{c(){T(s.$$.fragment)},l(o){U(s.$$.fragment,o)},m(o,u){k(s,o,u),f=!0},p(o,u){const y={};u&2&&(y.$$scope={dirty:u,ctx:o}),s.$set(y)},i(o){f||(C(s.$$.fragment,o),f=!0)},o(o){Z(s.$$.fragment,o),f=!1},d(o){R(s,o)}}}function os(z){let s,f,o,u,y,$,_,J;return{c(){s=i("p"),f=l("Para obter um exemplo mais aprofundado de como executar o fine-tuning de um modelo para classifica\xE7\xE3o de texto, d\xEA uma olhada nesse "),o=i("a"),u=l("notebook utilizando PyTorch"),y=l(" ou nesse "),$=i("a"),_=l("notebook utilizando TensorFlow"),J=l("."),this.h()},l(E){s=p(E,"P",{});var j=c(s);f=r(j,"Para obter um exemplo mais aprofundado de como executar o fine-tuning de um modelo para classifica\xE7\xE3o de texto, d\xEA uma olhada nesse "),o=p(j,"A",{href:!0,rel:!0});var x=c(o);u=r(x,"notebook utilizando PyTorch"),x.forEach(t),y=r(j," ou nesse "),$=p(j,"A",{href:!0,rel:!0});var X=c($);_=r(X,"notebook utilizando TensorFlow"),X.forEach(t),J=r(j,"."),j.forEach(t),this.h()},h(){w(o,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification.ipynb"),w(o,"rel","nofollow"),w($,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/examples/text_classification-tf.ipynb"),w($,"rel","nofollow")},m(E,j){m(E,s,j),a(s,f),a(s,o),a(o,u),a(s,y),a(s,$),a($,_),a(s,J)},d(E){E&&t(s)}}}function ls(z){let s,f,o,u,y,$,_,J,E,j,x,X,H,G,Q,W,se,q,ye,fe,I,ue,N,he,A,$e,V,S,Y,O,L,oe,D,ee,B,be,d,M,ae,F,le,P,K,ie,pe,ce,te,me,n,v,ve,qe,Ne,de,Je,Te,Ae,_e,Qe,Se,je,Pe,He,ha,we,Ue,Le,Ie,Ia,Ke,Ga,$a,ke,Xa,ea,Va,Fa,ba,Ge,ga,Ce,Ya,aa,Da,Ba,ya,Xe,_a,ge,qa,Ve,ta,Na,Aa,sa,Qa,Sa,oa,Pa,Ha,ja,Fe,Ma,re,Oa,la,La,Ka,ra,et,at,na,tt,st,ia,ot,lt,va,Ze,wa,Ee,Re,pa,Ye,rt,ca,nt,Ea,xe,Ja,ze,Ta;return $=new za({}),x=new Nt({props:{id:"leNG9fN9FQU"}}),A=new ua({props:{$$slots:{default:[At]},$$scope:{ctx:z}}}),O=new za({}),M=new ne({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBaW1kYiUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJpbWRiJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

<span class="hljs-meta">&gt;&gt;&gt; </span>imdb = load_dataset(<span class="hljs-string">&quot;imdb&quot;</span>)`}}),K=new ne({props:{code:"aW1kYiU1QiUyMnRlc3QlMjIlNUQlNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>imdb[<span class="hljs-string">&quot;test&quot;</span>][<span class="hljs-number">0</span>]
{
    <span class="hljs-string">&quot;label&quot;</span>: <span class="hljs-number">0</span>,
    <span class="hljs-string">&quot;text&quot;</span>: <span class="hljs-string">&quot;I love sci-fi and am willing to put up with a lot. Sci-fi movies/TV are usually underfunded, under-appreciated and misunderstood. I tried to like this, I really did, but it is to good TV sci-fi as Babylon 5 is to Star Trek (the original). Silly prosthetics, cheap cardboard sets, stilted dialogues, CG that doesn&#x27;t match the background, and painfully one-dimensional characters cannot be overcome with a &#x27;sci-fi&#x27; setting. (I&#x27;m sure there are those of you out there who think Babylon 5 is good sci-fi TV. It&#x27;s not. It&#x27;s clich\xE9d and uninspiring.) While US viewers might like emotion and character development, sci-fi is a genre that does not take itself seriously (cf. Star Trek). It may treat important issues, yet not as a serious philosophy. It&#x27;s really difficult to care about the characters here as they are not simply foolish, just missing a spark of life. Their actions and reactions are wooden and predictable, often painful to watch. The makers of Earth KNOW it&#x27;s rubbish as they have to always say \\&quot;Gene Roddenberry&#x27;s Earth...\\&quot; otherwise people would not continue watching. Roddenberry&#x27;s ashes must be turning in their orbit as this dull, cheap, poorly edited (watching it without advert breaks really brings this home) trudging Trabant of a show lumbers into space. Spoiler. So, kill off a main character. And then bring him back as another actor. Jeeez! Dallas all over again.&quot;</span>,
}`}}),Ie=new za({}),Ge=new ne({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert-base-uncased&quot;</span>)`}}),Xe=new ne({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc19mdW5jdGlvbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjB0b2tlbml6ZXIoZXhhbXBsZXMlNUIlMjJ0ZXh0JTIyJTVEJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_function</span>(<span class="hljs-params">examples</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> tokenizer(examples[<span class="hljs-string">&quot;text&quot;</span>], truncation=<span class="hljs-literal">True</span>)`}}),Fe=new ne({props:{code:"dG9rZW5pemVkX2ltZGIlMjAlM0QlMjBpbWRiLm1hcChwcmVwcm9jZXNzX2Z1bmN0aW9uJTJDJTIwYmF0Y2hlZCUzRFRydWUp",highlighted:'tokenized_imdb = imdb.<span class="hljs-built_in">map</span>(preprocess_function, batched=<span class="hljs-literal">True</span>)'}}),Ze=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ht],pytorch:[St]},$$scope:{ctx:z}}}),Ye=new za({}),xe=new Xt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ss],pytorch:[es]},$$scope:{ctx:z}}}),ze=new ua({props:{$$slots:{default:[os]},$$scope:{ctx:z}}}),{c(){s=i("meta"),f=b(),o=i("h1"),u=i("a"),y=i("span"),T($.$$.fragment),_=b(),J=i("span"),E=l("Classifica\xE7\xE3o de texto"),j=b(),T(x.$$.fragment),X=b(),H=i("p"),G=l("A classifica\xE7\xE3o de texto \xE9 uma tarefa comum de NLP que atribui um r\xF3tulo ou classe a um texto. Existem muitas aplica\xE7\xF5es pr\xE1ticas de classifica\xE7\xE3o de texto amplamente utilizadas em produ\xE7\xE3o por algumas das maiores empresas da atualidade. Uma das formas mais populares de classifica\xE7\xE3o de texto \xE9 a an\xE1lise de sentimento, que atribui um r\xF3tulo como positivo, negativo ou neutro a um texto."),Q=b(),W=i("p"),se=l("Este guia mostrar\xE1 como realizar o fine-tuning do "),q=i("a"),ye=l("DistilBERT"),fe=l(" no conjunto de dados "),I=i("a"),ue=l("IMDb"),N=l(" para determinar se a cr\xEDtica de filme \xE9 positiva ou negativa."),he=b(),T(A.$$.fragment),$e=b(),V=i("h2"),S=i("a"),Y=i("span"),T(O.$$.fragment),L=b(),oe=i("span"),D=l("Carregue o conjunto de dados IMDb"),ee=b(),B=i("p"),be=l("Carregue o conjunto de dados IMDb utilizando a biblioteca \u{1F917} Datasets:"),d=b(),T(M.$$.fragment),ae=b(),F=i("p"),le=l("Em seguida, d\xEA uma olhada em um exemplo:"),P=b(),T(K.$$.fragment),ie=b(),pe=i("p"),ce=l("Existem dois campos neste dataset:"),te=b(),me=i("ul"),n=i("li"),v=i("code"),ve=l("text"),qe=l(": uma string contendo o texto da cr\xEDtica do filme."),Ne=b(),de=i("li"),Je=i("code"),Te=l("label"),Ae=l(": um valor que pode ser "),_e=i("code"),Qe=l("0"),Se=l(" para uma cr\xEDtica negativa ou "),je=i("code"),Pe=l("1"),He=l(" para uma cr\xEDtica positiva."),ha=b(),we=i("h2"),Ue=i("a"),Le=i("span"),T(Ie.$$.fragment),Ia=b(),Ke=i("span"),Ga=l("Pr\xE9-processamento dos dados"),$a=b(),ke=i("p"),Xa=l("Carregue o tokenizador do DistilBERT para processar o campo "),ea=i("code"),Va=l("text"),Fa=l(":"),ba=b(),T(Ge.$$.fragment),ga=b(),Ce=i("p"),Ya=l("Crie uma fun\xE7\xE3o de pr\xE9-processamento para tokenizar o campo "),aa=i("code"),Da=l("text"),Ba=l(" e truncar as sequ\xEAncias para que n\xE3o sejam maiores que o comprimento m\xE1ximo de entrada do DistilBERT:"),ya=b(),T(Xe.$$.fragment),_a=b(),ge=i("p"),qa=l("Use a fun\xE7\xE3o "),Ve=i("a"),ta=i("code"),Na=l("map"),Aa=l(" do \u{1F917} Datasets para aplicar a fun\xE7\xE3o de pr\xE9-processamento em todo o conjunto de dados. Voc\xEA pode acelerar a fun\xE7\xE3o "),sa=i("code"),Qa=l("map"),Sa=l(" definindo "),oa=i("code"),Pa=l("batched=True"),Ha=l(" para processar v\xE1rios elementos do conjunto de dados de uma s\xF3 vez:"),ja=b(),T(Fe.$$.fragment),Ma=b(),re=i("p"),Oa=l("Use o "),la=i("code"),La=l("DataCollatorWithPadding"),Ka=l(" para criar um batch de exemplos. Ele tamb\xE9m "),ra=i("em"),et=l("preencher\xE1 dinamicamente"),at=l(" seu texto at\xE9 o comprimento do elemento mais longo em seu batch, para que os exemplos do batch tenham um comprimento uniforme. Embora seja poss\xEDvel preencher seu texto com a fun\xE7\xE3o "),na=i("code"),tt=l("tokenizer"),st=l(" definindo "),ia=i("code"),ot=l("padding=True"),lt=l(", o preenchimento din\xE2mico utilizando um data collator \xE9 mais eficiente."),va=b(),T(Ze.$$.fragment),wa=b(),Ee=i("h2"),Re=i("a"),pa=i("span"),T(Ye.$$.fragment),rt=b(),ca=i("span"),nt=l("Train"),Ea=b(),T(xe.$$.fragment),Ja=b(),T(ze.$$.fragment),this.h()},l(e){const h=Bt('[data-svelte="svelte-1phssyn"]',document.head);s=p(h,"META",{name:!0,content:!0}),h.forEach(t),f=g(e),o=p(e,"H1",{class:!0});var De=c(o);u=p(De,"A",{id:!0,class:!0,href:!0});var ma=c(u);y=p(ma,"SPAN",{});var da=c(y);U($.$$.fragment,da),da.forEach(t),ma.forEach(t),_=g(De),J=p(De,"SPAN",{});var fa=c(J);E=r(fa,"Classifica\xE7\xE3o de texto"),fa.forEach(t),De.forEach(t),j=g(e),U(x.$$.fragment,e),X=g(e),H=p(e,"P",{});var pt=c(H);G=r(pt,"A classifica\xE7\xE3o de texto \xE9 uma tarefa comum de NLP que atribui um r\xF3tulo ou classe a um texto. Existem muitas aplica\xE7\xF5es pr\xE1ticas de classifica\xE7\xE3o de texto amplamente utilizadas em produ\xE7\xE3o por algumas das maiores empresas da atualidade. Uma das formas mais populares de classifica\xE7\xE3o de texto \xE9 a an\xE1lise de sentimento, que atribui um r\xF3tulo como positivo, negativo ou neutro a um texto."),pt.forEach(t),Q=g(e),W=p(e,"P",{});var Oe=c(W);se=r(Oe,"Este guia mostrar\xE1 como realizar o fine-tuning do "),q=p(Oe,"A",{href:!0,rel:!0});var ct=c(q);ye=r(ct,"DistilBERT"),ct.forEach(t),fe=r(Oe," no conjunto de dados "),I=p(Oe,"A",{href:!0,rel:!0});var mt=c(I);ue=r(mt,"IMDb"),mt.forEach(t),N=r(Oe," para determinar se a cr\xEDtica de filme \xE9 positiva ou negativa."),Oe.forEach(t),he=g(e),U(A.$$.fragment,e),$e=g(e),V=p(e,"H2",{class:!0});var Ua=c(V);S=p(Ua,"A",{id:!0,class:!0,href:!0});var dt=c(S);Y=p(dt,"SPAN",{});var ft=c(Y);U(O.$$.fragment,ft),ft.forEach(t),dt.forEach(t),L=g(Ua),oe=p(Ua,"SPAN",{});var ut=c(oe);D=r(ut,"Carregue o conjunto de dados IMDb"),ut.forEach(t),Ua.forEach(t),ee=g(e),B=p(e,"P",{});var ht=c(B);be=r(ht,"Carregue o conjunto de dados IMDb utilizando a biblioteca \u{1F917} Datasets:"),ht.forEach(t),d=g(e),U(M.$$.fragment,e),ae=g(e),F=p(e,"P",{});var $t=c(F);le=r($t,"Em seguida, d\xEA uma olhada em um exemplo:"),$t.forEach(t),P=g(e),U(K.$$.fragment,e),ie=g(e),pe=p(e,"P",{});var bt=c(pe);ce=r(bt,"Existem dois campos neste dataset:"),bt.forEach(t),te=g(e),me=p(e,"UL",{});var ka=c(me);n=p(ka,"LI",{});var it=c(n);v=p(it,"CODE",{});var gt=c(v);ve=r(gt,"text"),gt.forEach(t),qe=r(it,": uma string contendo o texto da cr\xEDtica do filme."),it.forEach(t),Ne=g(ka),de=p(ka,"LI",{});var Be=c(de);Je=p(Be,"CODE",{});var yt=c(Je);Te=r(yt,"label"),yt.forEach(t),Ae=r(Be,": um valor que pode ser "),_e=p(Be,"CODE",{});var _t=c(_e);Qe=r(_t,"0"),_t.forEach(t),Se=r(Be," para uma cr\xEDtica negativa ou "),je=p(Be,"CODE",{});var jt=c(je);Pe=r(jt,"1"),jt.forEach(t),He=r(Be," para uma cr\xEDtica positiva."),Be.forEach(t),ka.forEach(t),ha=g(e),we=p(e,"H2",{class:!0});var Ca=c(we);Ue=p(Ca,"A",{id:!0,class:!0,href:!0});var Mt=c(Ue);Le=p(Mt,"SPAN",{});var vt=c(Le);U(Ie.$$.fragment,vt),vt.forEach(t),Mt.forEach(t),Ia=g(Ca),Ke=p(Ca,"SPAN",{});var wt=c(Ke);Ga=r(wt,"Pr\xE9-processamento dos dados"),wt.forEach(t),Ca.forEach(t),$a=g(e),ke=p(e,"P",{});var Za=c(ke);Xa=r(Za,"Carregue o tokenizador do DistilBERT para processar o campo "),ea=p(Za,"CODE",{});var Et=c(ea);Va=r(Et,"text"),Et.forEach(t),Fa=r(Za,":"),Za.forEach(t),ba=g(e),U(Ge.$$.fragment,e),ga=g(e),Ce=p(e,"P",{});var Ra=c(Ce);Ya=r(Ra,"Crie uma fun\xE7\xE3o de pr\xE9-processamento para tokenizar o campo "),aa=p(Ra,"CODE",{});var Jt=c(aa);Da=r(Jt,"text"),Jt.forEach(t),Ba=r(Ra," e truncar as sequ\xEAncias para que n\xE3o sejam maiores que o comprimento m\xE1ximo de entrada do DistilBERT:"),Ra.forEach(t),ya=g(e),U(Xe.$$.fragment,e),_a=g(e),ge=p(e,"P",{});var We=c(ge);qa=r(We,"Use a fun\xE7\xE3o "),Ve=p(We,"A",{href:!0,rel:!0});var Tt=c(Ve);ta=p(Tt,"CODE",{});var Ut=c(ta);Na=r(Ut,"map"),Ut.forEach(t),Tt.forEach(t),Aa=r(We," do \u{1F917} Datasets para aplicar a fun\xE7\xE3o de pr\xE9-processamento em todo o conjunto de dados. Voc\xEA pode acelerar a fun\xE7\xE3o "),sa=p(We,"CODE",{});var kt=c(sa);Qa=r(kt,"map"),kt.forEach(t),Sa=r(We," definindo "),oa=p(We,"CODE",{});var Ct=c(oa);Pa=r(Ct,"batched=True"),Ct.forEach(t),Ha=r(We," para processar v\xE1rios elementos do conjunto de dados de uma s\xF3 vez:"),We.forEach(t),ja=g(e),U(Fe.$$.fragment,e),Ma=g(e),re=p(e,"P",{});var Me=c(re);Oa=r(Me,"Use o "),la=p(Me,"CODE",{});var Zt=c(la);La=r(Zt,"DataCollatorWithPadding"),Zt.forEach(t),Ka=r(Me," para criar um batch de exemplos. Ele tamb\xE9m "),ra=p(Me,"EM",{});var Rt=c(ra);et=r(Rt,"preencher\xE1 dinamicamente"),Rt.forEach(t),at=r(Me," seu texto at\xE9 o comprimento do elemento mais longo em seu batch, para que os exemplos do batch tenham um comprimento uniforme. Embora seja poss\xEDvel preencher seu texto com a fun\xE7\xE3o "),na=p(Me,"CODE",{});var xt=c(na);tt=r(xt,"tokenizer"),xt.forEach(t),st=r(Me," definindo "),ia=p(Me,"CODE",{});var zt=c(ia);ot=r(zt,"padding=True"),zt.forEach(t),lt=r(Me,", o preenchimento din\xE2mico utilizando um data collator \xE9 mais eficiente."),Me.forEach(t),va=g(e),U(Ze.$$.fragment,e),wa=g(e),Ee=p(e,"H2",{class:!0});var xa=c(Ee);Re=p(xa,"A",{id:!0,class:!0,href:!0});var Wt=c(Re);pa=p(Wt,"SPAN",{});var It=c(pa);U(Ye.$$.fragment,It),It.forEach(t),Wt.forEach(t),rt=g(xa),ca=p(xa,"SPAN",{});var Gt=c(ca);nt=r(Gt,"Train"),Gt.forEach(t),xa.forEach(t),Ea=g(e),U(xe.$$.fragment,e),Ja=g(e),U(ze.$$.fragment,e),this.h()},h(){w(s,"name","hf:doc:metadata"),w(s,"content",JSON.stringify(rs)),w(u,"id","classificao-de-texto"),w(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),w(u,"href","#classificao-de-texto"),w(o,"class","relative group"),w(q,"href","https://huggingface.co/distilbert-base-uncased"),w(q,"rel","nofollow"),w(I,"href","https://huggingface.co/datasets/imdb"),w(I,"rel","nofollow"),w(S,"id","carregue-o-conjunto-de-dados-imdb"),w(S,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),w(S,"href","#carregue-o-conjunto-de-dados-imdb"),w(V,"class","relative group"),w(Ue,"id","prprocessamento-dos-dados"),w(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),w(Ue,"href","#prprocessamento-dos-dados"),w(we,"class","relative group"),w(Ve,"href","https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.map"),w(Ve,"rel","nofollow"),w(Re,"id","train"),w(Re,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),w(Re,"href","#train"),w(Ee,"class","relative group")},m(e,h){a(document.head,s),m(e,f,h),m(e,o,h),a(o,u),a(u,y),k($,y,null),a(o,_),a(o,J),a(J,E),m(e,j,h),k(x,e,h),m(e,X,h),m(e,H,h),a(H,G),m(e,Q,h),m(e,W,h),a(W,se),a(W,q),a(q,ye),a(W,fe),a(W,I),a(I,ue),a(W,N),m(e,he,h),k(A,e,h),m(e,$e,h),m(e,V,h),a(V,S),a(S,Y),k(O,Y,null),a(V,L),a(V,oe),a(oe,D),m(e,ee,h),m(e,B,h),a(B,be),m(e,d,h),k(M,e,h),m(e,ae,h),m(e,F,h),a(F,le),m(e,P,h),k(K,e,h),m(e,ie,h),m(e,pe,h),a(pe,ce),m(e,te,h),m(e,me,h),a(me,n),a(n,v),a(v,ve),a(n,qe),a(me,Ne),a(me,de),a(de,Je),a(Je,Te),a(de,Ae),a(de,_e),a(_e,Qe),a(de,Se),a(de,je),a(je,Pe),a(de,He),m(e,ha,h),m(e,we,h),a(we,Ue),a(Ue,Le),k(Ie,Le,null),a(we,Ia),a(we,Ke),a(Ke,Ga),m(e,$a,h),m(e,ke,h),a(ke,Xa),a(ke,ea),a(ea,Va),a(ke,Fa),m(e,ba,h),k(Ge,e,h),m(e,ga,h),m(e,Ce,h),a(Ce,Ya),a(Ce,aa),a(aa,Da),a(Ce,Ba),m(e,ya,h),k(Xe,e,h),m(e,_a,h),m(e,ge,h),a(ge,qa),a(ge,Ve),a(Ve,ta),a(ta,Na),a(ge,Aa),a(ge,sa),a(sa,Qa),a(ge,Sa),a(ge,oa),a(oa,Pa),a(ge,Ha),m(e,ja,h),k(Fe,e,h),m(e,Ma,h),m(e,re,h),a(re,Oa),a(re,la),a(la,La),a(re,Ka),a(re,ra),a(ra,et),a(re,at),a(re,na),a(na,tt),a(re,st),a(re,ia),a(ia,ot),a(re,lt),m(e,va,h),k(Ze,e,h),m(e,wa,h),m(e,Ee,h),a(Ee,Re),a(Re,pa),k(Ye,pa,null),a(Ee,rt),a(Ee,ca),a(ca,nt),m(e,Ea,h),k(xe,e,h),m(e,Ja,h),k(ze,e,h),Ta=!0},p(e,[h]){const De={};h&2&&(De.$$scope={dirty:h,ctx:e}),A.$set(De);const ma={};h&2&&(ma.$$scope={dirty:h,ctx:e}),Ze.$set(ma);const da={};h&2&&(da.$$scope={dirty:h,ctx:e}),xe.$set(da);const fa={};h&2&&(fa.$$scope={dirty:h,ctx:e}),ze.$set(fa)},i(e){Ta||(C($.$$.fragment,e),C(x.$$.fragment,e),C(A.$$.fragment,e),C(O.$$.fragment,e),C(M.$$.fragment,e),C(K.$$.fragment,e),C(Ie.$$.fragment,e),C(Ge.$$.fragment,e),C(Xe.$$.fragment,e),C(Fe.$$.fragment,e),C(Ze.$$.fragment,e),C(Ye.$$.fragment,e),C(xe.$$.fragment,e),C(ze.$$.fragment,e),Ta=!0)},o(e){Z($.$$.fragment,e),Z(x.$$.fragment,e),Z(A.$$.fragment,e),Z(O.$$.fragment,e),Z(M.$$.fragment,e),Z(K.$$.fragment,e),Z(Ie.$$.fragment,e),Z(Ge.$$.fragment,e),Z(Xe.$$.fragment,e),Z(Fe.$$.fragment,e),Z(Ze.$$.fragment,e),Z(Ye.$$.fragment,e),Z(xe.$$.fragment,e),Z(ze.$$.fragment,e),Ta=!1},d(e){t(s),e&&t(f),e&&t(o),R($),e&&t(j),R(x,e),e&&t(X),e&&t(H),e&&t(Q),e&&t(W),e&&t(he),R(A,e),e&&t($e),e&&t(V),R(O),e&&t(ee),e&&t(B),e&&t(d),R(M,e),e&&t(ae),e&&t(F),e&&t(P),R(K,e),e&&t(ie),e&&t(pe),e&&t(te),e&&t(me),e&&t(ha),e&&t(we),R(Ie),e&&t($a),e&&t(ke),e&&t(ba),R(Ge,e),e&&t(ga),e&&t(Ce),e&&t(ya),R(Xe,e),e&&t(_a),e&&t(ge),e&&t(ja),R(Fe,e),e&&t(Ma),e&&t(re),e&&t(va),R(Ze,e),e&&t(wa),e&&t(Ee),R(Ye),e&&t(Ea),R(xe,e),e&&t(Ja),R(ze,e)}}}const rs={local:"classificao-de-texto",sections:[{local:"carregue-o-conjunto-de-dados-imdb",title:"Carregue o conjunto de dados IMDb"},{local:"prprocessamento-dos-dados",title:"Pr\xE9-processamento dos dados"},{local:"train",title:"Train"}],title:"Classifica\xE7\xE3o de texto"};function ns(z){return qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class us extends Ft{constructor(s){super();Yt(this,s,ns,ls,Dt,{})}}export{us as default,rs as metadata};
