import{s as go,o as wo,n as Fl}from"../chunks/scheduler.d586627e.js";import{S as Mo,i as bo,g as l,s as o,u as d,A as vo,h as n,f as t,c as r,j as m,v as h,y as c,k as p,o as i,a as s,w as u,d as f,t as g,x as w}from"../chunks/index.b757c891.js";import{T as Bl}from"../chunks/Tip.4380e997.js";import{Y as bl}from"../chunks/Youtube.cab44801.js";import{I as y}from"../chunks/IconCopyLink.c074b82b.js";import{C as b}from"../chunks/CodeBlock.aa8a1a9b.js";import{D as yo}from"../chunks/DocNotebookDropdown.889126d3.js";function jo(B){let M,j=`Você verá um alerta sobre alguns pesos pré-treinados que não estão sendo utilizados e que alguns pesos estão
sendo inicializados aleatoriamente. Não se preocupe, essa mensagem é completamente normal.
O header/cabeçário pré-treinado do modelo BERT é descartado e substitui-se por um header de classificação
inicializado aleatoriamente. Assim, pode aplicar o fine-tuning a este novo header do modelo em sua tarefa
de classificação de sequências fazendo um transfer learning do modelo pré-treinado.`;return{c(){M=l("p"),M.textContent=j},l(v){M=n(v,"P",{"data-svelte-h":!0}),c(M)!=="svelte-ejxvym"&&(M.textContent=j)},m(v,$){s(v,M,$)},p:Fl,d(v){v&&t(M)}}}function $o(B){let M,j=`O <code>Trainer</code> utiliza <code>DataCollatorWithPadding</code> por padrão, então você não precisa especificar explicitamente um
colador de dados (data collator).`;return{c(){M=l("p"),M.innerHTML=j},l(v){M=n(v,"P",{"data-svelte-h":!0}),c(M)!=="svelte-hfa5bk"&&(M.innerHTML=j)},m(v,$){s(v,M,$)},p:Fl,d(v){v&&t(M)}}}function To(B){let M,j=`Se necessário, você pode obter o acesso gratuito a uma GPU na núvem por meio de um notebook no
<a href="https://colab.research.google.com/" rel="nofollow">Colaboratory</a> ou <a href="https://studiolab.sagemaker.aws/" rel="nofollow">SageMaker StudioLab</a>
se não tiver esse recurso de forma local.`;return{c(){M=l("p"),M.innerHTML=j},l(v){M=n(v,"P",{"data-svelte-h":!0}),c(M)!=="svelte-ivn2a7"&&(M.innerHTML=j)},m(v,$){s(v,M,$)},p:Fl,d(v){v&&t(M)}}}function Jo(B){let M,j,v,$,J,F,na,ne,vl,Wt,Nl="Fine-tuning de um modelo pré-treinado",$a,oe,Ta,re,Al=`O uso de um modelo pré-treinado tem importantes vantagens. Redução do custo computacional, a pegada de carbono, e te
permite utilizar modelos de última geração sem ter que treinar um novo desde o início.
O 🤗 Transformers proporciona acesso a milhares de modelos pré-treinados numa ampla gama de tarefas.
Quando utilizar um modelo pré-treinado, treine-o com um dataset específico para a sua tarefa.
Isto é chamado de fine-tuning, uma técnica de treinamento incrivelmente poderosa. Neste tutorial faremos o fine-tuning
de um modelo pré-treinado com um framework de Deep Learning da sua escolha:`,Ja,ie,Yl="<li>Fine-tuning de um modelo pré-treinado com o 🤗 Transformers <code>Trainer</code>.</li> <li>Fine-tuning de um modelo pré-treinado no TensorFlow com o Keras.</li> <li>Fine-tuning de um modelo pré-treinado em PyTorch nativo.</li>",ka,zt,_a,k,N,oa,pe,yl,Et,Vl="Preparando um dataset",Ca,me,Za,ce,ql=`Antes de aplicar o fine-tuning a um modelo pré-treinado, baixe um dataset e prepare-o para o treinamento.
O tutorial anterior ensinará a processar os dados para o treinamento, e então poderá ter a oportunidade de testar
esse novo conhecimento em algo prático.`,Ua,de,Sl='Comece carregando o dataset <a href="https://huggingface.co/datasets/yelp_review_full" rel="nofollow">Yelp Reviews</a>:',xa,he,Ia,ue,Ll=`Como já sabe, é necessário ter um tokenizador para processar o texto e incluir uma estratégia de padding e truncamento,
para manejar qualquer tamanho varíavel de sequência. Para processar o seu dataset em apenas um passo, utilize o método de
🤗 Datasets <a href="https://huggingface.co/docs/datasets/process.html#map" rel="nofollow"><code>map</code></a> para aplicar uma função de preprocessamento sobre
todo o dataset.`,Ra,fe,Ga,ge,Pl="Se desejar, é possível criar um subconjunto menor do dataset completo para aplicar o fine-tuning e assim reduzir o tempo necessário.",Wa,we,za,Xt,Ea,_,A,ra,Me,jl,Ht,Ql="Fine-tuning com o <code>Trainer</code>",Xa,be,Ha,ve,Dl=`O 🤗 Transformers proporciona uma classe <code>Trainer</code> otimizada para o treinamento de modelos de 🤗 Transformers,
facilitando os primeiros passos do treinamento sem a necessidade de escrever manualmente o seu próprio ciclo.
A API do <code>Trainer</code> suporta um grande conjunto de opções de treinamento e funcionalidades, como o logging,
o gradient accumulation e o mixed precision.`,Ba,ye,Kl=`Comece carregando seu modelo e especifique o número de labels de previsão.
A partir do <a href="https://huggingface.co/datasets/yelp_review_full#data-fields" rel="nofollow">Card Dataset</a> do Yelp Reveiw, que ja
sabemos ter 5 labels usamos o seguinte código:`,Fa,je,Na,Y,Aa,C,V,ia,$e,$l,Bt,Ol="Hiperparâmetros de treinamento",Ya,Te,en=`Em seguida, crie uma classe <code>TrainingArguments</code> que contenha todos os hiperparâmetros que possam ser ajustados, assim
como os indicadores para ativar as diferentes opções de treinamento. Para este tutorial, você pode começar o treinamento
usando os <a href="https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments" rel="nofollow">hiperparámetros</a> padrão,
porém, sinta-se livre para experimentar com eles e encontrar uma configuração ótima.`,Va,Je,tn="Especifique onde salvar os checkpoints do treinamento:",qa,ke,Sa,Z,q,pa,_e,Tl,Ft,an="Métricas",La,Ce,sn=`O <code>Trainer</code> não avalia automaticamente o rendimento do modelo durante o treinamento. Será necessário passar ao
<code>Trainer</code> uma função para calcular e fazer um diagnóstico sobre as métricas. A biblioteca 🤗 Datasets proporciona
uma função de <a href="https://huggingface.co/metrics/accuracy" rel="nofollow"><code>accuracy</code></a> simples que pode ser carregada com a função
<code>load_metric</code> (ver este <a href="https://huggingface.co/docs/datasets/metrics.html" rel="nofollow">tutorial</a> para mais informações):`,Pa,Ze,Qa,Ue,ln=`Defina a função <code>compute</code> dentro de <code>metric</code> para calcular a precisão das suas predições.
Antes de passar as suas predições ao <code>compute</code>, é necessário converter as predições à logits (lembre-se que
todos os modelos de 🤗 Transformers retornam logits).`,Da,xe,Ka,Ie,nn=`Se quiser controlar as suas métricas de avaliação durante o fine-tuning, especifique o parâmetro <code>evaluation_strategy</code>
nos seus argumentos de treinamento para que o modelo considere a métrica de avaliação ao final de cada época:`,Oa,Re,es,U,S,ma,Ge,Jl,Nt,on="Trainer",ts,We,rn="Crie um objeto <code>Trainer</code> com o seu modelo, argumentos de treinamento, conjuntos de dados de treinamento e de teste, e a sua função de avaliação:",as,ze,ss,Ee,pn="Em seguida, aplique o fine-tuning a seu modelo chamado <code>train()</code>:",ls,Xe,ns,At,os,x,L,ca,He,kl,Yt,mn="Fine-tuning com Keras",rs,Be,is,Fe,cn=`Os modelos de 🤗 Transformers também permitem realizar o treinamento com o TensorFlow com a API do Keras.
Contudo, será necessário fazer algumas mudanças antes de realizar o fine-tuning.`,ps,I,P,da,Ne,_l,Vt,dn="Conversão do dataset ao formato do TensorFlow",ms,Ae,hn=`O <code>DefaultDataCollator</code> junta os tensores em um batch para que o modelo possa ser treinado em cima deles.
Assegure-se de especificar os <code>return_tensors</code> para retornar os tensores do TensorFlow:`,cs,Ye,ds,Q,hs,Ve,un=`Em seguida, converta os datasets tokenizados em datasets do TensorFlow com o método
<a href="https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasets.Dataset.to_tf_dataset" rel="nofollow"><code>to_tf_dataset</code></a>.
Especifique suas entradas em <code>columns</code> e seu rótulo em <code>label_cols</code>:`,us,qe,fs,R,D,ha,Se,Cl,qt,fn="Compilação e ajustes",gs,Le,gn="Carregue um modelo do TensorFlow com o número esperado de rótulos:",ws,Pe,Ms,Qe,wn=`A seguir, compile e ajuste o fine-tuning a seu modelo com <a href="https://keras.io/api/models/model_training_apis/" rel="nofollow"><code>fit</code></a> como
faria com qualquer outro modelo do Keras:`,bs,De,vs,St,ys,G,K,ua,Ke,Zl,Lt,Mn="Fine-tune em PyTorch nativo",js,Oe,$s,et,bn=`O <code>Trainer</code> se encarrega do ciclo de treinamento e permite aplicar o fine-tuning a um modelo em uma linha de código apenas.
Para os usuários que preferirem escrever o seu próprio ciclo de treinamento, também é possível aplicar o fine-tuning a um
modelo de 🤗 Transformers em PyTorch nativo.`,Ts,tt,vn=`Neste momento, talvez ocorra a necessidade de reinicar seu notebook ou executar a seguinte linha de código para liberar
memória:`,Js,at,ks,st,yn="Em sequência, faremos um post-processing manual do <code>tokenized_dataset</code> e assim prepará-lo para o treinamento.",_s,T,lt,Pt,jn="Apague a coluna de <code>text</code> porque o modelo não aceita texto cru como entrada:",Ul,nt,xl,ot,Qt,$n="Troque o nome da coluna <code>label</code> para <code>labels</code>, pois o modelo espera um argumento de mesmo nome:",Il,rt,Rl,it,Dt,Tn="Defina o formato do dataset para retornar tensores do PyTorch no lugar de listas:",Gl,pt,Cs,mt,Jn="Em sequência, crie um subconjunto menor do dataset, como foi mostrado anteriormente, para acelerá-lo o fine-tuning.",Zs,ct,Us,W,O,fa,dt,Wl,Kt,kn="DataLoader",xs,ht,_n="Crie um <code>DataLoader</code> para os seus datasets de treinamento e de teste para poder iterar sobre batches de dados:",Is,ut,Rs,ft,Cn="Carregue seu modelo com o número de labels esperados:",Gs,gt,Ws,z,ee,ga,wt,zl,Ot,Zn="Otimização e configuração do Learning Rate",zs,Mt,Un=`Crie um otimizador e um learning rate para aplicar o fine-tuning ao modelo.
Iremos utilizar o otimizador <a href="https://pytorch.org/docs/stable/generated/torch.optim.AdamW.html" rel="nofollow"><code>AdamW</code></a> do PyTorch:`,Es,bt,Xs,vt,xn="Defina o learning rate do <code>Trainer</code>:",Hs,yt,Bs,jt,In=`Por último, especifique o <code>device</code> do ambiente para utilizar uma GPU se tiver acesso à alguma. Caso contrário, o treinamento
em uma CPU pode acabar levando várias horas em vez de minutos.`,Fs,$t,Ns,te,As,Tt,Rn="Perfeito, agora estamos prontos para começar o treinamento! 🥳",Ys,E,ae,wa,Jt,El,ea,Gn="Ciclo de treinamento",Vs,kt,Wn=`Para visualizar melhor o processo de treinamento, utilize a biblioteca <a href="https://tqdm.github.io/" rel="nofollow">tqdm</a> para adicionar
uma barra de progresso sobre o número de passos percorridos no treinamento atual:`,qs,_t,Ss,X,se,Ma,Ct,Xl,ta,zn="Métricas",Ls,Zt,En=`Da mesma forma que é necessário adicionar uma função de avaliação ao <code>Trainer</code>, é necessário fazer o mesmo quando
escrevendo o próprio ciclo de treinamento. Contudo, em vez de calcular e retornar a métrica final de cada época,
você deverá adicionar todos os batches com <a href="https://huggingface.co/docs/datasets/package_reference/main_classes.html?highlight=add_batch#datasets.Metric.add_batch" rel="nofollow"><code>add_batch</code></a>
e calcular a métrica apenas no final.`,Ps,Ut,Qs,aa,Ds,H,le,ba,xt,Hl,sa,Xn="Recursos adicionais",Ks,It,Hn="Para mais exemplos de fine-tuning acesse:",Os,Rt,Bn=`<li><p><a href="https://github.com/huggingface/transformers/tree/main/examples" rel="nofollow">🤗 Transformers Examples</a> inclui scripts
para treinas tarefas comuns de NLP em PyTorch e TensorFlow.</p></li> <li><p><a href="notebooks">🤗 Transformers Notebooks</a> contém vários notebooks sobre como aplicar o fine-tuning a um modelo
para tarefas específicas no PyTorch e TensorFlow.</p></li>`,el,va,tl;return ne=new y({}),oe=new yo({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/pt/training.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/pt/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/pt/tensorflow/training.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/pt/training.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/pt/pytorch/training.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/pt/tensorflow/training.ipynb"}]}}),pe=new y({}),me=new bl({props:{id:"_BZearw7f0w"}}),he=new b({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBZGF0YXNldCUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJ5ZWxwX3Jldmlld19mdWxsJTIyKSUwQWRhdGFzZXQlNUIxMDAlNUQ=",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>dataset = load_dataset(<span class="hljs-string">&quot;yelp_review_full&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>dataset[<span class="hljs-number">100</span>]
{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-number">0</span>,
 <span class="hljs-string">&#x27;text&#x27;</span>: <span class="hljs-string">&#x27;My expectations for McDonalds are t rarely high. But for one to still fail so spectacularly...that takes something special!\\\\nThe cashier took my friends\\&#x27;s order, then promptly ignored me. I had to force myself in front of a cashier who opened his register to wait on the person BEHIND me. I waited over five minutes for a gigantic order that included precisely one kid\\&#x27;s meal. After watching two people who ordered after me be handed their food, I asked where mine was. The manager started yelling at the cashiers for \\\\&quot;serving off their orders\\\\&quot; when they didn\\&#x27;t have their food. But neither cashier was anywhere near those controls, and the manager was the one serving food to customers and clearing the boards.\\\\nThe manager was rude when giving me my order. She didn\\&#x27;t make sure that I had everything ON MY RECEIPT, and never even had the decency to apologize that I felt I was getting poor service.\\\\nI\\&#x27;ve eaten at various McDonalds restaurants for over 30 years. I\\&#x27;ve worked at more than one location. I expect bad days, bad moods, and the occasional mistake. But I have yet to have a decent experience at this store. It will remain a place I avoid unless someone in my party needs to avoid illness from low blood sugar. Perhaps I should go back to the racially biased service of Steak n Shake instead!&#x27;</span>}`,wrap:!1}}),fe=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtY2FzZWQlMjIpJTBBJTBBJTBBZGVmJTIwdG9rZW5pemVfZnVuY3Rpb24oZXhhbXBsZXMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwdG9rZW5pemVyKGV4YW1wbGVzJTVCJTIydGV4dCUyMiU1RCUyQyUyMHBhZGRpbmclM0QlMjJtYXhfbGVuZ3RoJTIyJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUpJTBBJTBBJTBBdG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwZGF0YXNldC5tYXAodG9rZW5pemVfZnVuY3Rpb24lMkMlMjBiYXRjaGVkJTNEVHJ1ZSk=",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;bert-base-cased&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">tokenize_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>], padding=<span class="hljs-string">&quot;max_length&quot;</span>, truncation=<span class="hljs-literal">True</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = dataset.<span class="hljs-built_in">map</span>(tokenize_function, batched=<span class="hljs-literal">True</span>)`,wrap:!1}}),we=new b({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`,wrap:!1}}),Me=new y({}),be=new bl({props:{id:"nvBXf7s7vTI"}}),je=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`,wrap:!1}}),Y=new Bl({props:{$$slots:{default:[jo]},$$scope:{ctx:B}}}),$e=new y({}),ke=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJ0ZXN0X3RyYWluZXIlMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>)`,wrap:!1}}),_e=new y({}),Ze=new b({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9tZXRyaWMlMEElMEFtZXRyaWMlMjAlM0QlMjBsb2FkX21ldHJpYyglMjJhY2N1cmFjeSUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_metric

<span class="hljs-meta">&gt;&gt;&gt; </span>metric = load_metric(<span class="hljs-string">&quot;accuracy&quot;</span>)`,wrap:!1}}),xe=new b({props:{code:"ZGVmJTIwY29tcHV0ZV9tZXRyaWNzKGV2YWxfcHJlZCklM0ElMEElMjAlMjAlMjAlMjBsb2dpdHMlMkMlMjBsYWJlbHMlMjAlM0QlMjBldmFsX3ByZWQlMEElMjAlMjAlMjAlMjBwcmVkaWN0aW9ucyUyMCUzRCUyMG5wLmFyZ21heChsb2dpdHMlMkMlMjBheGlzJTNELTEpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwbWV0cmljLmNvbXB1dGUocHJlZGljdGlvbnMlM0RwcmVkaWN0aW9ucyUyQyUyMHJlZmVyZW5jZXMlM0RsYWJlbHMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">compute_metrics</span>(<span class="hljs-params">eval_pred</span>):
<span class="hljs-meta">... </span>    logits, labels = eval_pred
<span class="hljs-meta">... </span>    predictions = np.argmax(logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> metric.compute(predictions=predictions, references=labels)`,wrap:!1}}),Re=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMFRyYWluaW5nQXJndW1lbnRzJTBBJTBBdHJhaW5pbmdfYXJncyUyMCUzRCUyMFRyYWluaW5nQXJndW1lbnRzKG91dHB1dF9kaXIlM0QlMjJ0ZXN0X3RyYWluZXIlMjIlMkMlMjBldmFsdWF0aW9uX3N0cmF0ZWd5JTNEJTIyZXBvY2glMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TrainingArguments

<span class="hljs-meta">&gt;&gt;&gt; </span>training_args = TrainingArguments(output_dir=<span class="hljs-string">&quot;test_trainer&quot;</span>, evaluation_strategy=<span class="hljs-string">&quot;epoch&quot;</span>)`,wrap:!1}}),Ge=new y({}),ze=new b({props:{code:"dHJhaW5lciUyMCUzRCUyMFRyYWluZXIoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0Rtb2RlbCUyQyUwQSUyMCUyMCUyMCUyMGFyZ3MlM0R0cmFpbmluZ19hcmdzJTJDJTBBJTIwJTIwJTIwJTIwdHJhaW5fZGF0YXNldCUzRHNtYWxsX3RyYWluX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBldmFsX2RhdGFzZXQlM0RzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMEElMjAlMjAlMjAlMjBjb21wdXRlX21ldHJpY3MlM0Rjb21wdXRlX21ldHJpY3MlMkMlMEEp",highlighted:`<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=small_train_dataset,
<span class="hljs-meta">... </span>    eval_dataset=small_eval_dataset,
<span class="hljs-meta">... </span>    compute_metrics=compute_metrics,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Xe=new b({props:{code:"dHJhaW5lci50cmFpbigp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>trainer.train()',wrap:!1}}),He=new y({}),Be=new bl({props:{id:"rnTGBy2ax1c"}}),Ne=new y({}),Ye=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMERlZmF1bHREYXRhQ29sbGF0b3IlMEElMEFkYXRhX2NvbGxhdG9yJTIwJTNEJTIwRGVmYXVsdERhdGFDb2xsYXRvcihyZXR1cm5fdGVuc29ycyUzRCUyMnRmJTIyKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> DefaultDataCollator

<span class="hljs-meta">&gt;&gt;&gt; </span>data_collator = DefaultDataCollator(return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)`,wrap:!1}}),Q=new Bl({props:{$$slots:{default:[$o]},$$scope:{ctx:B}}}),qe=new b({props:{code:"dGZfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHNtYWxsX3RyYWluX2RhdGFzZXQudG9fdGZfZGF0YXNldCglMEElMjAlMjAlMjAlMjBjb2x1bW5zJTNEJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlMkMlMjAlMjJpbnB1dF9pZHMlMjIlMkMlMjAlMjJ0b2tlbl90eXBlX2lkcyUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGxhYmVsX2NvbHMlM0QlMjJsYWJlbHMlMjIlMkMlMEElMjAlMjAlMjAlMjBzaHVmZmxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGNvbGxhdGVfZm4lM0RkYXRhX2NvbGxhdG9yJTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRDglMkMlMEEpJTBBJTBBdGZfdmFsaWRhdGlvbl9kYXRhc2V0JTIwJTNEJTIwc21hbGxfZXZhbF9kYXRhc2V0LnRvX3RmX2RhdGFzZXQoJTBBJTIwJTIwJTIwJTIwY29sdW1ucyUzRCU1QiUyMmF0dGVudGlvbl9tYXNrJTIyJTJDJTIwJTIyaW5wdXRfaWRzJTIyJTJDJTIwJTIydG9rZW5fdHlwZV9pZHMlMjIlNUQlMkMlMEElMjAlMjAlMjAlMjBsYWJlbF9jb2xzJTNEJTIybGFiZWxzJTIyJTJDJTBBJTIwJTIwJTIwJTIwc2h1ZmZsZSUzREZhbHNlJTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGRhdGFfY29sbGF0b3IlMkMlMEElMjAlMjAlMjAlMjBiYXRjaF9zaXplJTNEOCUyQyUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_train_dataset = small_train_dataset.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;token_type_ids&quot;</span>],
<span class="hljs-meta">... </span>    label_cols=<span class="hljs-string">&quot;labels&quot;</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>tf_validation_dataset = small_eval_dataset.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;token_type_ids&quot;</span>],
<span class="hljs-meta">... </span>    label_cols=<span class="hljs-string">&quot;labels&quot;</span>,
<span class="hljs-meta">... </span>    shuffle=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    collate_fn=data_collator,
<span class="hljs-meta">... </span>    batch_size=<span class="hljs-number">8</span>,
<span class="hljs-meta">... </span>)`,wrap:!1}}),Se=new y({}),Pe=new b({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",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><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;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`,wrap:!1}}),De=new b({props:{code:"bW9kZWwuY29tcGlsZSglMEElMjAlMjAlMjAlMjBvcHRpbWl6ZXIlM0R0Zi5rZXJhcy5vcHRpbWl6ZXJzLkFkYW0obGVhcm5pbmdfcmF0ZSUzRDVlLTUpJTJDJTBBJTIwJTIwJTIwJTIwbG9zcyUzRHRmLmtlcmFzLmxvc3Nlcy5TcGFyc2VDYXRlZ29yaWNhbENyb3NzZW50cm9weShmcm9tX2xvZ2l0cyUzRFRydWUpJTJDJTBBJTIwJTIwJTIwJTIwbWV0cmljcyUzRHRmLm1ldHJpY3MuU3BhcnNlQ2F0ZWdvcmljYWxBY2N1cmFjeSgpJTJDJTBBKSUwQSUwQW1vZGVsLmZpdCh0Zl90cmFpbl9kYXRhc2V0JTJDJTIwdmFsaWRhdGlvbl9kYXRhJTNEdGZfdmFsaWRhdGlvbl9kYXRhc2V0JTJDJTIwZXBvY2hzJTNEMyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">compile</span>(
<span class="hljs-meta">... </span>    optimizer=tf.keras.optimizers.Adam(learning_rate=<span class="hljs-number">5e-5</span>),
<span class="hljs-meta">... </span>    loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=<span class="hljs-literal">True</span>),
<span class="hljs-meta">... </span>    metrics=tf.metrics.SparseCategoricalAccuracy(),
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model.fit(tf_train_dataset, validation_data=tf_validation_dataset, epochs=<span class="hljs-number">3</span>)`,wrap:!1}}),Ke=new y({}),Oe=new bl({props:{id:"Dh9CL8fyG80"}}),at=new b({props:{code:"ZGVsJTIwbW9kZWwlMEFkZWwlMjBweXRvcmNoX21vZGVsJTBBZGVsJTIwdHJhaW5lciUwQXRvcmNoLmN1ZGEuZW1wdHlfY2FjaGUoKQ==",highlighted:`<span class="hljs-keyword">del</span> model
<span class="hljs-keyword">del</span> pytorch_model
<span class="hljs-keyword">del</span> trainer
torch.cuda.empty_cache()`,wrap:!1}}),nt=new b({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbW92ZV9jb2x1bW5zKCU1QiUyMnRleHQlMjIlNUQp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.remove_columns([<span class="hljs-string">&quot;text&quot;</span>])',wrap:!1}}),rt=new b({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzJTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzLnJlbmFtZV9jb2x1bW4oJTIybGFiZWwlMjIlMkMlMjAlMjJsYWJlbHMlMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets = tokenized_datasets.rename_column(<span class="hljs-string">&quot;label&quot;</span>, <span class="hljs-string">&quot;labels&quot;</span>)',wrap:!1}}),pt=new b({props:{code:"dG9rZW5pemVkX2RhdGFzZXRzLnNldF9mb3JtYXQoJTIydG9yY2glMjIp",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tokenized_datasets.set_format(<span class="hljs-string">&quot;torch&quot;</span>)',wrap:!1}}),ct=new b({props:{code:"c21hbGxfdHJhaW5fZGF0YXNldCUyMCUzRCUyMHRva2VuaXplZF9kYXRhc2V0cyU1QiUyMnRyYWluJTIyJTVELnNodWZmbGUoc2VlZCUzRDQyKS5zZWxlY3QocmFuZ2UoMTAwMCkpJTBBc21hbGxfZXZhbF9kYXRhc2V0JTIwJTNEJTIwdG9rZW5pemVkX2RhdGFzZXRzJTVCJTIydGVzdCUyMiU1RC5zaHVmZmxlKHNlZWQlM0Q0Mikuc2VsZWN0KHJhbmdlKDEwMDApKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>small_train_dataset = tokenized_datasets[<span class="hljs-string">&quot;train&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>small_eval_dataset = tokenized_datasets[<span class="hljs-string">&quot;test&quot;</span>].shuffle(seed=<span class="hljs-number">42</span>).select(<span class="hljs-built_in">range</span>(<span class="hljs-number">1000</span>))`,wrap:!1}}),dt=new y({}),ut=new b({props:{code:"ZnJvbSUyMHRvcmNoLnV0aWxzLmRhdGElMjBpbXBvcnQlMjBEYXRhTG9hZGVyJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMERhdGFMb2FkZXIoc21hbGxfdHJhaW5fZGF0YXNldCUyQyUyMHNodWZmbGUlM0RUcnVlJTJDJTIwYmF0Y2hfc2l6ZSUzRDgpJTBBZXZhbF9kYXRhbG9hZGVyJTIwJTNEJTIwRGF0YUxvYWRlcihzbWFsbF9ldmFsX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEOCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.utils.data <span class="hljs-keyword">import</span> DataLoader

<span class="hljs-meta">&gt;&gt;&gt; </span>train_dataloader = DataLoader(small_train_dataset, shuffle=<span class="hljs-literal">True</span>, batch_size=<span class="hljs-number">8</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>eval_dataloader = DataLoader(small_eval_dataset, batch_size=<span class="hljs-number">8</span>)`,wrap:!1}}),gt=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS1jYXNlZCUyMiUyQyUyMG51bV9sYWJlbHMlM0Q1KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;bert-base-cased&quot;</span>, num_labels=<span class="hljs-number">5</span>)`,wrap:!1}}),wt=new y({}),bt=new b({props:{code:"ZnJvbSUyMHRvcmNoLm9wdGltJTIwaW1wb3J0JTIwQWRhbVclMEElMEFvcHRpbWl6ZXIlMjAlM0QlMjBBZGFtVyhtb2RlbC5wYXJhbWV0ZXJzKCklMkMlMjBsciUzRDVlLTUp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch.optim <span class="hljs-keyword">import</span> AdamW

<span class="hljs-meta">&gt;&gt;&gt; </span>optimizer = AdamW(model.parameters(), lr=<span class="hljs-number">5e-5</span>)`,wrap:!1}}),yt=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMGdldF9zY2hlZHVsZXIlMEElMEFudW1fZXBvY2hzJTIwJTNEJTIwMyUwQW51bV90cmFpbmluZ19zdGVwcyUyMCUzRCUyMG51bV9lcG9jaHMlMjAqJTIwbGVuKHRyYWluX2RhdGFsb2FkZXIpJTBBbHJfc2NoZWR1bGVyJTIwJTNEJTIwZ2V0X3NjaGVkdWxlciglMEElMjAlMjAlMjAlMjBuYW1lJTNEJTIybGluZWFyJTIyJTJDJTIwb3B0aW1pemVyJTNEb3B0aW1pemVyJTJDJTIwbnVtX3dhcm11cF9zdGVwcyUzRDAlMkMlMjBudW1fdHJhaW5pbmdfc3RlcHMlM0RudW1fdHJhaW5pbmdfc3RlcHMlMEEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> get_scheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>num_epochs = <span class="hljs-number">3</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>num_training_steps = num_epochs * <span class="hljs-built_in">len</span>(train_dataloader)
<span class="hljs-meta">&gt;&gt;&gt; </span>lr_scheduler = get_scheduler(
<span class="hljs-meta">... </span>    name=<span class="hljs-string">&quot;linear&quot;</span>, optimizer=optimizer, num_warmup_steps=<span class="hljs-number">0</span>, num_training_steps=num_training_steps
<span class="hljs-meta">... </span>)`,wrap:!1}}),$t=new b({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMjBpZiUyMHRvcmNoLmN1ZGEuaXNfYXZhaWxhYmxlKCklMjBlbHNlJTIwdG9yY2guZGV2aWNlKCUyMmNwdSUyMiklMEFtb2RlbC50byhkZXZpY2Up",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch

<span class="hljs-meta">&gt;&gt;&gt; </span>device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>) <span class="hljs-keyword">if</span> torch.cuda.is_available() <span class="hljs-keyword">else</span> torch.device(<span class="hljs-string">&quot;cpu&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.to(device)`,wrap:!1}}),te=new Bl({props:{$$slots:{default:[To]},$$scope:{ctx:B}}}),Jt=new y({}),_t=new b({props:{code:"ZnJvbSUyMHRxZG0uYXV0byUyMGltcG9ydCUyMHRxZG0lMEElMEFwcm9ncmVzc19iYXIlMjAlM0QlMjB0cWRtKHJhbmdlKG51bV90cmFpbmluZ19zdGVwcykpJTBBJTBBbW9kZWwudHJhaW4oKSUwQWZvciUyMGVwb2NoJTIwaW4lMjByYW5nZShudW1fZXBvY2hzKSUzQSUwQSUyMCUyMCUyMCUyMGZvciUyMGJhdGNoJTIwaW4lMjB0cmFpbl9kYXRhbG9hZGVyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYmF0Y2glMjAlM0QlMjAlN0JrJTNBJTIwdi50byhkZXZpY2UpJTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGJhdGNoLml0ZW1zKCklN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKipiYXRjaCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBsb3NzJTIwJTNEJTIwb3V0cHV0cy5sb3NzJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbG9zcy5iYWNrd2FyZCgpJTBBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwb3B0aW1pemVyLnN0ZXAoKSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGxyX3NjaGVkdWxlci5zdGVwKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBvcHRpbWl6ZXIuemVyb19ncmFkKCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBwcm9ncmVzc19iYXIudXBkYXRlKDEp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> tqdm.auto <span class="hljs-keyword">import</span> tqdm

<span class="hljs-meta">&gt;&gt;&gt; </span>progress_bar = tqdm(<span class="hljs-built_in">range</span>(num_training_steps))

<span class="hljs-meta">&gt;&gt;&gt; </span>model.train()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> epoch <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(num_epochs):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> train_dataloader:
<span class="hljs-meta">... </span>        batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>        outputs = model(**batch)
<span class="hljs-meta">... </span>        loss = outputs.loss
<span class="hljs-meta">... </span>        loss.backward()

<span class="hljs-meta">... </span>        optimizer.step()
<span class="hljs-meta">... </span>        lr_scheduler.step()
<span class="hljs-meta">... </span>        optimizer.zero_grad()
<span class="hljs-meta">... </span>        progress_bar.update(<span class="hljs-number">1</span>)`,wrap:!1}}),Ct=new y({}),Ut=new b({props:{code:"bWV0cmljJTIwJTNEJTIwbG9hZF9tZXRyaWMoJTIyYWNjdXJhY3klMjIpJTBBbW9kZWwuZXZhbCgpJTBBZm9yJTIwYmF0Y2glMjBpbiUyMGV2YWxfZGF0YWxvYWRlciUzQSUwQSUyMCUyMCUyMCUyMGJhdGNoJTIwJTNEJTIwJTdCayUzQSUyMHYudG8oZGV2aWNlKSUyMGZvciUyMGslMkMlMjB2JTIwaW4lMjBiYXRjaC5pdGVtcygpJTdEJTBBJTIwJTIwJTIwJTIwd2l0aCUyMHRvcmNoLm5vX2dyYWQoKSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmJhdGNoKSUwQSUwQSUyMCUyMCUyMCUyMGxvZ2l0cyUyMCUzRCUyMG91dHB1dHMubG9naXRzJTBBJTIwJTIwJTIwJTIwcHJlZGljdGlvbnMlMjAlM0QlMjB0b3JjaC5hcmdtYXgobG9naXRzJTJDJTIwZGltJTNELTEpJTBBJTIwJTIwJTIwJTIwbWV0cmljLmFkZF9iYXRjaChwcmVkaWN0aW9ucyUzRHByZWRpY3Rpb25zJTJDJTIwcmVmZXJlbmNlcyUzRGJhdGNoJTVCJTIybGFiZWxzJTIyJTVEKSUwQSUwQW1ldHJpYy5jb21wdXRlKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>metric = load_metric(<span class="hljs-string">&quot;accuracy&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model.<span class="hljs-built_in">eval</span>()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> batch <span class="hljs-keyword">in</span> eval_dataloader:
<span class="hljs-meta">... </span>    batch = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> batch.items()}
<span class="hljs-meta">... </span>    <span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>        outputs = model(**batch)

<span class="hljs-meta">... </span>    logits = outputs.logits
<span class="hljs-meta">... </span>    predictions = torch.argmax(logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    metric.add_batch(predictions=predictions, references=batch[<span class="hljs-string">&quot;labels&quot;</span>])

<span class="hljs-meta">&gt;&gt;&gt; </span>metric.compute()`,wrap:!1}}),xt=new y({}),{c(){M=l("meta"),j=o(),v=l("p"),$=o(),J=l("h1"),F=l("a"),na=l("span"),d(ne.$$.fragment),vl=o(),Wt=l("span"),Wt.textContent=Nl,$a=o(),d(oe.$$.fragment),Ta=o(),re=l("p"),re.textContent=Al,Ja=o(),ie=l("ul"),ie.innerHTML=Yl,ka=o(),zt=l("a"),_a=o(),k=l("h2"),N=l("a"),oa=l("span"),d(pe.$$.fragment),yl=o(),Et=l("span"),Et.textContent=Vl,Ca=o(),d(me.$$.fragment),Za=o(),ce=l("p"),ce.textContent=ql,Ua=o(),de=l("p"),de.innerHTML=Sl,xa=o(),d(he.$$.fragment),Ia=o(),ue=l("p"),ue.innerHTML=Ll,Ra=o(),d(fe.$$.fragment),Ga=o(),ge=l("p"),ge.textContent=Pl,Wa=o(),d(we.$$.fragment),za=o(),Xt=l("a"),Ea=o(),_=l("h2"),A=l("a"),ra=l("span"),d(Me.$$.fragment),jl=o(),Ht=l("span"),Ht.innerHTML=Ql,Xa=o(),d(be.$$.fragment),Ha=o(),ve=l("p"),ve.innerHTML=Dl,Ba=o(),ye=l("p"),ye.innerHTML=Kl,Fa=o(),d(je.$$.fragment),Na=o(),d(Y.$$.fragment),Aa=o(),C=l("h3"),V=l("a"),ia=l("span"),d($e.$$.fragment),$l=o(),Bt=l("span"),Bt.textContent=Ol,Ya=o(),Te=l("p"),Te.innerHTML=en,Va=o(),Je=l("p"),Je.textContent=tn,qa=o(),d(ke.$$.fragment),Sa=o(),Z=l("h3"),q=l("a"),pa=l("span"),d(_e.$$.fragment),Tl=o(),Ft=l("span"),Ft.textContent=an,La=o(),Ce=l("p"),Ce.innerHTML=sn,Pa=o(),d(Ze.$$.fragment),Qa=o(),Ue=l("p"),Ue.innerHTML=ln,Da=o(),d(xe.$$.fragment),Ka=o(),Ie=l("p"),Ie.innerHTML=nn,Oa=o(),d(Re.$$.fragment),es=o(),U=l("h3"),S=l("a"),ma=l("span"),d(Ge.$$.fragment),Jl=o(),Nt=l("span"),Nt.textContent=on,ts=o(),We=l("p"),We.innerHTML=rn,as=o(),d(ze.$$.fragment),ss=o(),Ee=l("p"),Ee.innerHTML=pn,ls=o(),d(Xe.$$.fragment),ns=o(),At=l("a"),os=o(),x=l("h2"),L=l("a"),ca=l("span"),d(He.$$.fragment),kl=o(),Yt=l("span"),Yt.textContent=mn,rs=o(),d(Be.$$.fragment),is=o(),Fe=l("p"),Fe.textContent=cn,ps=o(),I=l("h3"),P=l("a"),da=l("span"),d(Ne.$$.fragment),_l=o(),Vt=l("span"),Vt.textContent=dn,ms=o(),Ae=l("p"),Ae.innerHTML=hn,cs=o(),d(Ye.$$.fragment),ds=o(),d(Q.$$.fragment),hs=o(),Ve=l("p"),Ve.innerHTML=un,us=o(),d(qe.$$.fragment),fs=o(),R=l("h3"),D=l("a"),ha=l("span"),d(Se.$$.fragment),Cl=o(),qt=l("span"),qt.textContent=fn,gs=o(),Le=l("p"),Le.textContent=gn,ws=o(),d(Pe.$$.fragment),Ms=o(),Qe=l("p"),Qe.innerHTML=wn,bs=o(),d(De.$$.fragment),vs=o(),St=l("a"),ys=o(),G=l("h2"),K=l("a"),ua=l("span"),d(Ke.$$.fragment),Zl=o(),Lt=l("span"),Lt.textContent=Mn,js=o(),d(Oe.$$.fragment),$s=o(),et=l("p"),et.innerHTML=bn,Ts=o(),tt=l("p"),tt.textContent=vn,Js=o(),d(at.$$.fragment),ks=o(),st=l("p"),st.innerHTML=yn,_s=o(),T=l("ol"),lt=l("li"),Pt=l("p"),Pt.innerHTML=jn,Ul=o(),d(nt.$$.fragment),xl=o(),ot=l("li"),Qt=l("p"),Qt.innerHTML=$n,Il=o(),d(rt.$$.fragment),Rl=o(),it=l("li"),Dt=l("p"),Dt.textContent=Tn,Gl=o(),d(pt.$$.fragment),Cs=o(),mt=l("p"),mt.textContent=Jn,Zs=o(),d(ct.$$.fragment),Us=o(),W=l("h3"),O=l("a"),fa=l("span"),d(dt.$$.fragment),Wl=o(),Kt=l("span"),Kt.textContent=kn,xs=o(),ht=l("p"),ht.innerHTML=_n,Is=o(),d(ut.$$.fragment),Rs=o(),ft=l("p"),ft.textContent=Cn,Gs=o(),d(gt.$$.fragment),Ws=o(),z=l("h3"),ee=l("a"),ga=l("span"),d(wt.$$.fragment),zl=o(),Ot=l("span"),Ot.textContent=Zn,zs=o(),Mt=l("p"),Mt.innerHTML=Un,Es=o(),d(bt.$$.fragment),Xs=o(),vt=l("p"),vt.innerHTML=xn,Hs=o(),d(yt.$$.fragment),Bs=o(),jt=l("p"),jt.innerHTML=In,Fs=o(),d($t.$$.fragment),Ns=o(),d(te.$$.fragment),As=o(),Tt=l("p"),Tt.textContent=Rn,Ys=o(),E=l("h3"),ae=l("a"),wa=l("span"),d(Jt.$$.fragment),El=o(),ea=l("span"),ea.textContent=Gn,Vs=o(),kt=l("p"),kt.innerHTML=Wn,qs=o(),d(_t.$$.fragment),Ss=o(),X=l("h3"),se=l("a"),Ma=l("span"),d(Ct.$$.fragment),Xl=o(),ta=l("span"),ta.textContent=zn,Ls=o(),Zt=l("p"),Zt.innerHTML=En,Ps=o(),d(Ut.$$.fragment),Qs=o(),aa=l("a"),Ds=o(),H=l("h2"),le=l("a"),ba=l("span"),d(xt.$$.fragment),Hl=o(),sa=l("span"),sa.textContent=Xn,Ks=o(),It=l("p"),It.textContent=Hn,Os=o(),Rt=l("ul"),Rt.innerHTML=Bn,el=o(),va=l("p"),this.h()},l(e){const a=vo("svelte-1phssyn",document.head);M=n(a,"META",{name:!0,content:!0}),a.forEach(t),j=r(e),v=n(e,"P",{}),m(v).forEach(t),$=r(e),J=n(e,"H1",{class:!0});var Gt=m(J);F=n(Gt,"A",{id:!0,class:!0,href:!0});var ya=m(F);na=n(ya,"SPAN",{});var ja=m(na);h(ne.$$.fragment,ja),ja.forEach(t),ya.forEach(t),vl=r(Gt),Wt=n(Gt,"SPAN",{"data-svelte-h":!0}),c(Wt)!=="svelte-d4ndyw"&&(Wt.textContent=Nl),Gt.forEach(t),$a=r(e),h(oe.$$.fragment,e),Ta=r(e),re=n(e,"P",{"data-svelte-h":!0}),c(re)!=="svelte-fhi5po"&&(re.textContent=Al),Ja=r(e),ie=n(e,"UL",{"data-svelte-h":!0}),c(ie)!=="svelte-1uar1qx"&&(ie.innerHTML=Yl),ka=r(e),zt=n(e,"A",{id:!0}),m(zt).forEach(t),_a=r(e),k=n(e,"H2",{class:!0});var al=m(k);N=n(al,"A",{id:!0,class:!0,href:!0});var Fn=m(N);oa=n(Fn,"SPAN",{});var Nn=m(oa);h(pe.$$.fragment,Nn),Nn.forEach(t),Fn.forEach(t),yl=r(al),Et=n(al,"SPAN",{"data-svelte-h":!0}),c(Et)!=="svelte-1r8m6w7"&&(Et.textContent=Vl),al.forEach(t),Ca=r(e),h(me.$$.fragment,e),Za=r(e),ce=n(e,"P",{"data-svelte-h":!0}),c(ce)!=="svelte-1opso33"&&(ce.textContent=ql),Ua=r(e),de=n(e,"P",{"data-svelte-h":!0}),c(de)!=="svelte-14tknsg"&&(de.innerHTML=Sl),xa=r(e),h(he.$$.fragment,e),Ia=r(e),ue=n(e,"P",{"data-svelte-h":!0}),c(ue)!=="svelte-1yz72ym"&&(ue.innerHTML=Ll),Ra=r(e),h(fe.$$.fragment,e),Ga=r(e),ge=n(e,"P",{"data-svelte-h":!0}),c(ge)!=="svelte-1cg4wp0"&&(ge.textContent=Pl),Wa=r(e),h(we.$$.fragment,e),za=r(e),Xt=n(e,"A",{id:!0}),m(Xt).forEach(t),Ea=r(e),_=n(e,"H2",{class:!0});var sl=m(_);A=n(sl,"A",{id:!0,class:!0,href:!0});var An=m(A);ra=n(An,"SPAN",{});var Yn=m(ra);h(Me.$$.fragment,Yn),Yn.forEach(t),An.forEach(t),jl=r(sl),Ht=n(sl,"SPAN",{"data-svelte-h":!0}),c(Ht)!=="svelte-15ow5mz"&&(Ht.innerHTML=Ql),sl.forEach(t),Xa=r(e),h(be.$$.fragment,e),Ha=r(e),ve=n(e,"P",{"data-svelte-h":!0}),c(ve)!=="svelte-1j0gwk8"&&(ve.innerHTML=Dl),Ba=r(e),ye=n(e,"P",{"data-svelte-h":!0}),c(ye)!=="svelte-56udk6"&&(ye.innerHTML=Kl),Fa=r(e),h(je.$$.fragment,e),Na=r(e),h(Y.$$.fragment,e),Aa=r(e),C=n(e,"H3",{class:!0});var ll=m(C);V=n(ll,"A",{id:!0,class:!0,href:!0});var Vn=m(V);ia=n(Vn,"SPAN",{});var qn=m(ia);h($e.$$.fragment,qn),qn.forEach(t),Vn.forEach(t),$l=r(ll),Bt=n(ll,"SPAN",{"data-svelte-h":!0}),c(Bt)!=="svelte-guq8u9"&&(Bt.textContent=Ol),ll.forEach(t),Ya=r(e),Te=n(e,"P",{"data-svelte-h":!0}),c(Te)!=="svelte-1vu82s5"&&(Te.innerHTML=en),Va=r(e),Je=n(e,"P",{"data-svelte-h":!0}),c(Je)!=="svelte-fjh0nm"&&(Je.textContent=tn),qa=r(e),h(ke.$$.fragment,e),Sa=r(e),Z=n(e,"H3",{class:!0});var nl=m(Z);q=n(nl,"A",{id:!0,class:!0,href:!0});var Sn=m(q);pa=n(Sn,"SPAN",{});var Ln=m(pa);h(_e.$$.fragment,Ln),Ln.forEach(t),Sn.forEach(t),Tl=r(nl),Ft=n(nl,"SPAN",{"data-svelte-h":!0}),c(Ft)!=="svelte-1ok7mdh"&&(Ft.textContent=an),nl.forEach(t),La=r(e),Ce=n(e,"P",{"data-svelte-h":!0}),c(Ce)!=="svelte-1fpd7i5"&&(Ce.innerHTML=sn),Pa=r(e),h(Ze.$$.fragment,e),Qa=r(e),Ue=n(e,"P",{"data-svelte-h":!0}),c(Ue)!=="svelte-1oopkat"&&(Ue.innerHTML=ln),Da=r(e),h(xe.$$.fragment,e),Ka=r(e),Ie=n(e,"P",{"data-svelte-h":!0}),c(Ie)!=="svelte-k3gxyo"&&(Ie.innerHTML=nn),Oa=r(e),h(Re.$$.fragment,e),es=r(e),U=n(e,"H3",{class:!0});var ol=m(U);S=n(ol,"A",{id:!0,class:!0,href:!0});var Pn=m(S);ma=n(Pn,"SPAN",{});var Qn=m(ma);h(Ge.$$.fragment,Qn),Qn.forEach(t),Pn.forEach(t),Jl=r(ol),Nt=n(ol,"SPAN",{"data-svelte-h":!0}),c(Nt)!=="svelte-1db8bfa"&&(Nt.textContent=on),ol.forEach(t),ts=r(e),We=n(e,"P",{"data-svelte-h":!0}),c(We)!=="svelte-1r3j7rx"&&(We.innerHTML=rn),as=r(e),h(ze.$$.fragment,e),ss=r(e),Ee=n(e,"P",{"data-svelte-h":!0}),c(Ee)!=="svelte-a3f13l"&&(Ee.innerHTML=pn),ls=r(e),h(Xe.$$.fragment,e),ns=r(e),At=n(e,"A",{id:!0}),m(At).forEach(t),os=r(e),x=n(e,"H2",{class:!0});var rl=m(x);L=n(rl,"A",{id:!0,class:!0,href:!0});var Dn=m(L);ca=n(Dn,"SPAN",{});var Kn=m(ca);h(He.$$.fragment,Kn),Kn.forEach(t),Dn.forEach(t),kl=r(rl),Yt=n(rl,"SPAN",{"data-svelte-h":!0}),c(Yt)!=="svelte-ah8vwi"&&(Yt.textContent=mn),rl.forEach(t),rs=r(e),h(Be.$$.fragment,e),is=r(e),Fe=n(e,"P",{"data-svelte-h":!0}),c(Fe)!=="svelte-j16adj"&&(Fe.textContent=cn),ps=r(e),I=n(e,"H3",{class:!0});var il=m(I);P=n(il,"A",{id:!0,class:!0,href:!0});var On=m(P);da=n(On,"SPAN",{});var eo=m(da);h(Ne.$$.fragment,eo),eo.forEach(t),On.forEach(t),_l=r(il),Vt=n(il,"SPAN",{"data-svelte-h":!0}),c(Vt)!=="svelte-1vv90ia"&&(Vt.textContent=dn),il.forEach(t),ms=r(e),Ae=n(e,"P",{"data-svelte-h":!0}),c(Ae)!=="svelte-1gyci2m"&&(Ae.innerHTML=hn),cs=r(e),h(Ye.$$.fragment,e),ds=r(e),h(Q.$$.fragment,e),hs=r(e),Ve=n(e,"P",{"data-svelte-h":!0}),c(Ve)!=="svelte-9k3v0o"&&(Ve.innerHTML=un),us=r(e),h(qe.$$.fragment,e),fs=r(e),R=n(e,"H3",{class:!0});var pl=m(R);D=n(pl,"A",{id:!0,class:!0,href:!0});var to=m(D);ha=n(to,"SPAN",{});var ao=m(ha);h(Se.$$.fragment,ao),ao.forEach(t),to.forEach(t),Cl=r(pl),qt=n(pl,"SPAN",{"data-svelte-h":!0}),c(qt)!=="svelte-1mrjkpb"&&(qt.textContent=fn),pl.forEach(t),gs=r(e),Le=n(e,"P",{"data-svelte-h":!0}),c(Le)!=="svelte-rgss8z"&&(Le.textContent=gn),ws=r(e),h(Pe.$$.fragment,e),Ms=r(e),Qe=n(e,"P",{"data-svelte-h":!0}),c(Qe)!=="svelte-qjchcy"&&(Qe.innerHTML=wn),bs=r(e),h(De.$$.fragment,e),vs=r(e),St=n(e,"A",{id:!0}),m(St).forEach(t),ys=r(e),G=n(e,"H2",{class:!0});var ml=m(G);K=n(ml,"A",{id:!0,class:!0,href:!0});var so=m(K);ua=n(so,"SPAN",{});var lo=m(ua);h(Ke.$$.fragment,lo),lo.forEach(t),so.forEach(t),Zl=r(ml),Lt=n(ml,"SPAN",{"data-svelte-h":!0}),c(Lt)!=="svelte-11r1zm4"&&(Lt.textContent=Mn),ml.forEach(t),js=r(e),h(Oe.$$.fragment,e),$s=r(e),et=n(e,"P",{"data-svelte-h":!0}),c(et)!=="svelte-1q1pzl3"&&(et.innerHTML=bn),Ts=r(e),tt=n(e,"P",{"data-svelte-h":!0}),c(tt)!=="svelte-1abyi5e"&&(tt.textContent=vn),Js=r(e),h(at.$$.fragment,e),ks=r(e),st=n(e,"P",{"data-svelte-h":!0}),c(st)!=="svelte-1a8dyp8"&&(st.innerHTML=yn),_s=r(e),T=n(e,"OL",{});var la=m(T);lt=n(la,"LI",{});var cl=m(lt);Pt=n(cl,"P",{"data-svelte-h":!0}),c(Pt)!=="svelte-n1mzi4"&&(Pt.innerHTML=jn),Ul=r(cl),h(nt.$$.fragment,cl),cl.forEach(t),xl=r(la),ot=n(la,"LI",{});var dl=m(ot);Qt=n(dl,"P",{"data-svelte-h":!0}),c(Qt)!=="svelte-dx24cp"&&(Qt.innerHTML=$n),Il=r(dl),h(rt.$$.fragment,dl),dl.forEach(t),Rl=r(la),it=n(la,"LI",{});var hl=m(it);Dt=n(hl,"P",{"data-svelte-h":!0}),c(Dt)!=="svelte-15zkuau"&&(Dt.textContent=Tn),Gl=r(hl),h(pt.$$.fragment,hl),hl.forEach(t),la.forEach(t),Cs=r(e),mt=n(e,"P",{"data-svelte-h":!0}),c(mt)!=="svelte-x0bqu0"&&(mt.textContent=Jn),Zs=r(e),h(ct.$$.fragment,e),Us=r(e),W=n(e,"H3",{class:!0});var ul=m(W);O=n(ul,"A",{id:!0,class:!0,href:!0});var no=m(O);fa=n(no,"SPAN",{});var oo=m(fa);h(dt.$$.fragment,oo),oo.forEach(t),no.forEach(t),Wl=r(ul),Kt=n(ul,"SPAN",{"data-svelte-h":!0}),c(Kt)!=="svelte-19b0x1w"&&(Kt.textContent=kn),ul.forEach(t),xs=r(e),ht=n(e,"P",{"data-svelte-h":!0}),c(ht)!=="svelte-lg4as"&&(ht.innerHTML=_n),Is=r(e),h(ut.$$.fragment,e),Rs=r(e),ft=n(e,"P",{"data-svelte-h":!0}),c(ft)!=="svelte-1y9asxq"&&(ft.textContent=Cn),Gs=r(e),h(gt.$$.fragment,e),Ws=r(e),z=n(e,"H3",{class:!0});var fl=m(z);ee=n(fl,"A",{id:!0,class:!0,href:!0});var ro=m(ee);ga=n(ro,"SPAN",{});var io=m(ga);h(wt.$$.fragment,io),io.forEach(t),ro.forEach(t),zl=r(fl),Ot=n(fl,"SPAN",{"data-svelte-h":!0}),c(Ot)!=="svelte-xsgdo8"&&(Ot.textContent=Zn),fl.forEach(t),zs=r(e),Mt=n(e,"P",{"data-svelte-h":!0}),c(Mt)!=="svelte-1355v62"&&(Mt.innerHTML=Un),Es=r(e),h(bt.$$.fragment,e),Xs=r(e),vt=n(e,"P",{"data-svelte-h":!0}),c(vt)!=="svelte-61qbj5"&&(vt.innerHTML=xn),Hs=r(e),h(yt.$$.fragment,e),Bs=r(e),jt=n(e,"P",{"data-svelte-h":!0}),c(jt)!=="svelte-794g8f"&&(jt.innerHTML=In),Fs=r(e),h($t.$$.fragment,e),Ns=r(e),h(te.$$.fragment,e),As=r(e),Tt=n(e,"P",{"data-svelte-h":!0}),c(Tt)!=="svelte-10cun9s"&&(Tt.textContent=Rn),Ys=r(e),E=n(e,"H3",{class:!0});var gl=m(E);ae=n(gl,"A",{id:!0,class:!0,href:!0});var po=m(ae);wa=n(po,"SPAN",{});var mo=m(wa);h(Jt.$$.fragment,mo),mo.forEach(t),po.forEach(t),El=r(gl),ea=n(gl,"SPAN",{"data-svelte-h":!0}),c(ea)!=="svelte-kxpx56"&&(ea.textContent=Gn),gl.forEach(t),Vs=r(e),kt=n(e,"P",{"data-svelte-h":!0}),c(kt)!=="svelte-ibqtt9"&&(kt.innerHTML=Wn),qs=r(e),h(_t.$$.fragment,e),Ss=r(e),X=n(e,"H3",{class:!0});var wl=m(X);se=n(wl,"A",{id:!0,class:!0,href:!0});var co=m(se);Ma=n(co,"SPAN",{});var ho=m(Ma);h(Ct.$$.fragment,ho),ho.forEach(t),co.forEach(t),Xl=r(wl),ta=n(wl,"SPAN",{"data-svelte-h":!0}),c(ta)!=="svelte-1ok7mdh"&&(ta.textContent=zn),wl.forEach(t),Ls=r(e),Zt=n(e,"P",{"data-svelte-h":!0}),c(Zt)!=="svelte-1wjbnz3"&&(Zt.innerHTML=En),Ps=r(e),h(Ut.$$.fragment,e),Qs=r(e),aa=n(e,"A",{id:!0}),m(aa).forEach(t),Ds=r(e),H=n(e,"H2",{class:!0});var Ml=m(H);le=n(Ml,"A",{id:!0,class:!0,href:!0});var uo=m(le);ba=n(uo,"SPAN",{});var fo=m(ba);h(xt.$$.fragment,fo),fo.forEach(t),uo.forEach(t),Hl=r(Ml),sa=n(Ml,"SPAN",{"data-svelte-h":!0}),c(sa)!=="svelte-1soiipv"&&(sa.textContent=Xn),Ml.forEach(t),Ks=r(e),It=n(e,"P",{"data-svelte-h":!0}),c(It)!=="svelte-vbn27k"&&(It.textContent=Hn),Os=r(e),Rt=n(e,"UL",{"data-svelte-h":!0}),c(Rt)!=="svelte-1n639bw"&&(Rt.innerHTML=Bn),el=r(e),va=n(e,"P",{}),m(va).forEach(t),this.h()},h(){p(M,"name","hf:doc:metadata"),p(M,"content",JSON.stringify(ko)),p(F,"id","finetuning-de-um-modelo-prtreinado"),p(F,"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"),p(F,"href","#finetuning-de-um-modelo-prtreinado"),p(J,"class","relative group"),p(zt,"id","data-processing"),p(N,"id","preparando-um-dataset"),p(N,"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"),p(N,"href","#preparando-um-dataset"),p(k,"class","relative group"),p(Xt,"id","trainer"),p(A,"id","finetuning-com-o-trainer"),p(A,"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"),p(A,"href","#finetuning-com-o-trainer"),p(_,"class","relative group"),p(V,"id","hiperparmetros-de-treinamento"),p(V,"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"),p(V,"href","#hiperparmetros-de-treinamento"),p(C,"class","relative group"),p(q,"id","mtricas"),p(q,"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"),p(q,"href","#mtricas"),p(Z,"class","relative group"),p(S,"id","trainer"),p(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"),p(S,"href","#trainer"),p(U,"class","relative group"),p(At,"id","keras"),p(L,"id","finetuning-com-keras"),p(L,"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"),p(L,"href","#finetuning-com-keras"),p(x,"class","relative group"),p(P,"id","converso-do-dataset-ao-formato-do-tensorflow"),p(P,"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"),p(P,"href","#converso-do-dataset-ao-formato-do-tensorflow"),p(I,"class","relative group"),p(D,"id","compilao-e-ajustes"),p(D,"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"),p(D,"href","#compilao-e-ajustes"),p(R,"class","relative group"),p(St,"id","pytorch_native"),p(K,"id","finetune-em-pytorch-nativo"),p(K,"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"),p(K,"href","#finetune-em-pytorch-nativo"),p(G,"class","relative group"),p(O,"id","dataloader"),p(O,"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"),p(O,"href","#dataloader"),p(W,"class","relative group"),p(ee,"id","otimizao-e-configurao-do-learning-rate"),p(ee,"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"),p(ee,"href","#otimizao-e-configurao-do-learning-rate"),p(z,"class","relative group"),p(ae,"id","ciclo-de-treinamento"),p(ae,"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"),p(ae,"href","#ciclo-de-treinamento"),p(E,"class","relative group"),p(se,"id","mtricas"),p(se,"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"),p(se,"href","#mtricas"),p(X,"class","relative group"),p(aa,"id","additional-resources"),p(le,"id","recursos-adicionais"),p(le,"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"),p(le,"href","#recursos-adicionais"),p(H,"class","relative group")},m(e,a){i(document.head,M),s(e,j,a),s(e,v,a),s(e,$,a),s(e,J,a),i(J,F),i(F,na),u(ne,na,null),i(J,vl),i(J,Wt),s(e,$a,a),u(oe,e,a),s(e,Ta,a),s(e,re,a),s(e,Ja,a),s(e,ie,a),s(e,ka,a),s(e,zt,a),s(e,_a,a),s(e,k,a),i(k,N),i(N,oa),u(pe,oa,null),i(k,yl),i(k,Et),s(e,Ca,a),u(me,e,a),s(e,Za,a),s(e,ce,a),s(e,Ua,a),s(e,de,a),s(e,xa,a),u(he,e,a),s(e,Ia,a),s(e,ue,a),s(e,Ra,a),u(fe,e,a),s(e,Ga,a),s(e,ge,a),s(e,Wa,a),u(we,e,a),s(e,za,a),s(e,Xt,a),s(e,Ea,a),s(e,_,a),i(_,A),i(A,ra),u(Me,ra,null),i(_,jl),i(_,Ht),s(e,Xa,a),u(be,e,a),s(e,Ha,a),s(e,ve,a),s(e,Ba,a),s(e,ye,a),s(e,Fa,a),u(je,e,a),s(e,Na,a),u(Y,e,a),s(e,Aa,a),s(e,C,a),i(C,V),i(V,ia),u($e,ia,null),i(C,$l),i(C,Bt),s(e,Ya,a),s(e,Te,a),s(e,Va,a),s(e,Je,a),s(e,qa,a),u(ke,e,a),s(e,Sa,a),s(e,Z,a),i(Z,q),i(q,pa),u(_e,pa,null),i(Z,Tl),i(Z,Ft),s(e,La,a),s(e,Ce,a),s(e,Pa,a),u(Ze,e,a),s(e,Qa,a),s(e,Ue,a),s(e,Da,a),u(xe,e,a),s(e,Ka,a),s(e,Ie,a),s(e,Oa,a),u(Re,e,a),s(e,es,a),s(e,U,a),i(U,S),i(S,ma),u(Ge,ma,null),i(U,Jl),i(U,Nt),s(e,ts,a),s(e,We,a),s(e,as,a),u(ze,e,a),s(e,ss,a),s(e,Ee,a),s(e,ls,a),u(Xe,e,a),s(e,ns,a),s(e,At,a),s(e,os,a),s(e,x,a),i(x,L),i(L,ca),u(He,ca,null),i(x,kl),i(x,Yt),s(e,rs,a),u(Be,e,a),s(e,is,a),s(e,Fe,a),s(e,ps,a),s(e,I,a),i(I,P),i(P,da),u(Ne,da,null),i(I,_l),i(I,Vt),s(e,ms,a),s(e,Ae,a),s(e,cs,a),u(Ye,e,a),s(e,ds,a),u(Q,e,a),s(e,hs,a),s(e,Ve,a),s(e,us,a),u(qe,e,a),s(e,fs,a),s(e,R,a),i(R,D),i(D,ha),u(Se,ha,null),i(R,Cl),i(R,qt),s(e,gs,a),s(e,Le,a),s(e,ws,a),u(Pe,e,a),s(e,Ms,a),s(e,Qe,a),s(e,bs,a),u(De,e,a),s(e,vs,a),s(e,St,a),s(e,ys,a),s(e,G,a),i(G,K),i(K,ua),u(Ke,ua,null),i(G,Zl),i(G,Lt),s(e,js,a),u(Oe,e,a),s(e,$s,a),s(e,et,a),s(e,Ts,a),s(e,tt,a),s(e,Js,a),u(at,e,a),s(e,ks,a),s(e,st,a),s(e,_s,a),s(e,T,a),i(T,lt),i(lt,Pt),i(lt,Ul),u(nt,lt,null),i(T,xl),i(T,ot),i(ot,Qt),i(ot,Il),u(rt,ot,null),i(T,Rl),i(T,it),i(it,Dt),i(it,Gl),u(pt,it,null),s(e,Cs,a),s(e,mt,a),s(e,Zs,a),u(ct,e,a),s(e,Us,a),s(e,W,a),i(W,O),i(O,fa),u(dt,fa,null),i(W,Wl),i(W,Kt),s(e,xs,a),s(e,ht,a),s(e,Is,a),u(ut,e,a),s(e,Rs,a),s(e,ft,a),s(e,Gs,a),u(gt,e,a),s(e,Ws,a),s(e,z,a),i(z,ee),i(ee,ga),u(wt,ga,null),i(z,zl),i(z,Ot),s(e,zs,a),s(e,Mt,a),s(e,Es,a),u(bt,e,a),s(e,Xs,a),s(e,vt,a),s(e,Hs,a),u(yt,e,a),s(e,Bs,a),s(e,jt,a),s(e,Fs,a),u($t,e,a),s(e,Ns,a),u(te,e,a),s(e,As,a),s(e,Tt,a),s(e,Ys,a),s(e,E,a),i(E,ae),i(ae,wa),u(Jt,wa,null),i(E,El),i(E,ea),s(e,Vs,a),s(e,kt,a),s(e,qs,a),u(_t,e,a),s(e,Ss,a),s(e,X,a),i(X,se),i(se,Ma),u(Ct,Ma,null),i(X,Xl),i(X,ta),s(e,Ls,a),s(e,Zt,a),s(e,Ps,a),u(Ut,e,a),s(e,Qs,a),s(e,aa,a),s(e,Ds,a),s(e,H,a),i(H,le),i(le,ba),u(xt,ba,null),i(H,Hl),i(H,sa),s(e,Ks,a),s(e,It,a),s(e,Os,a),s(e,Rt,a),s(e,el,a),s(e,va,a),tl=!0},p(e,[a]){const Gt={};a&2&&(Gt.$$scope={dirty:a,ctx:e}),Y.$set(Gt);const ya={};a&2&&(ya.$$scope={dirty:a,ctx:e}),Q.$set(ya);const ja={};a&2&&(ja.$$scope={dirty:a,ctx:e}),te.$set(ja)},i(e){tl||(f(ne.$$.fragment,e),f(oe.$$.fragment,e),f(pe.$$.fragment,e),f(me.$$.fragment,e),f(he.$$.fragment,e),f(fe.$$.fragment,e),f(we.$$.fragment,e),f(Me.$$.fragment,e),f(be.$$.fragment,e),f(je.$$.fragment,e),f(Y.$$.fragment,e),f($e.$$.fragment,e),f(ke.$$.fragment,e),f(_e.$$.fragment,e),f(Ze.$$.fragment,e),f(xe.$$.fragment,e),f(Re.$$.fragment,e),f(Ge.$$.fragment,e),f(ze.$$.fragment,e),f(Xe.$$.fragment,e),f(He.$$.fragment,e),f(Be.$$.fragment,e),f(Ne.$$.fragment,e),f(Ye.$$.fragment,e),f(Q.$$.fragment,e),f(qe.$$.fragment,e),f(Se.$$.fragment,e),f(Pe.$$.fragment,e),f(De.$$.fragment,e),f(Ke.$$.fragment,e),f(Oe.$$.fragment,e),f(at.$$.fragment,e),f(nt.$$.fragment,e),f(rt.$$.fragment,e),f(pt.$$.fragment,e),f(ct.$$.fragment,e),f(dt.$$.fragment,e),f(ut.$$.fragment,e),f(gt.$$.fragment,e),f(wt.$$.fragment,e),f(bt.$$.fragment,e),f(yt.$$.fragment,e),f($t.$$.fragment,e),f(te.$$.fragment,e),f(Jt.$$.fragment,e),f(_t.$$.fragment,e),f(Ct.$$.fragment,e),f(Ut.$$.fragment,e),f(xt.$$.fragment,e),tl=!0)},o(e){g(ne.$$.fragment,e),g(oe.$$.fragment,e),g(pe.$$.fragment,e),g(me.$$.fragment,e),g(he.$$.fragment,e),g(fe.$$.fragment,e),g(we.$$.fragment,e),g(Me.$$.fragment,e),g(be.$$.fragment,e),g(je.$$.fragment,e),g(Y.$$.fragment,e),g($e.$$.fragment,e),g(ke.$$.fragment,e),g(_e.$$.fragment,e),g(Ze.$$.fragment,e),g(xe.$$.fragment,e),g(Re.$$.fragment,e),g(Ge.$$.fragment,e),g(ze.$$.fragment,e),g(Xe.$$.fragment,e),g(He.$$.fragment,e),g(Be.$$.fragment,e),g(Ne.$$.fragment,e),g(Ye.$$.fragment,e),g(Q.$$.fragment,e),g(qe.$$.fragment,e),g(Se.$$.fragment,e),g(Pe.$$.fragment,e),g(De.$$.fragment,e),g(Ke.$$.fragment,e),g(Oe.$$.fragment,e),g(at.$$.fragment,e),g(nt.$$.fragment,e),g(rt.$$.fragment,e),g(pt.$$.fragment,e),g(ct.$$.fragment,e),g(dt.$$.fragment,e),g(ut.$$.fragment,e),g(gt.$$.fragment,e),g(wt.$$.fragment,e),g(bt.$$.fragment,e),g(yt.$$.fragment,e),g($t.$$.fragment,e),g(te.$$.fragment,e),g(Jt.$$.fragment,e),g(_t.$$.fragment,e),g(Ct.$$.fragment,e),g(Ut.$$.fragment,e),g(xt.$$.fragment,e),tl=!1},d(e){e&&(t(j),t(v),t($),t(J),t($a),t(Ta),t(re),t(Ja),t(ie),t(ka),t(zt),t(_a),t(k),t(Ca),t(Za),t(ce),t(Ua),t(de),t(xa),t(Ia),t(ue),t(Ra),t(Ga),t(ge),t(Wa),t(za),t(Xt),t(Ea),t(_),t(Xa),t(Ha),t(ve),t(Ba),t(ye),t(Fa),t(Na),t(Aa),t(C),t(Ya),t(Te),t(Va),t(Je),t(qa),t(Sa),t(Z),t(La),t(Ce),t(Pa),t(Qa),t(Ue),t(Da),t(Ka),t(Ie),t(Oa),t(es),t(U),t(ts),t(We),t(as),t(ss),t(Ee),t(ls),t(ns),t(At),t(os),t(x),t(rs),t(is),t(Fe),t(ps),t(I),t(ms),t(Ae),t(cs),t(ds),t(hs),t(Ve),t(us),t(fs),t(R),t(gs),t(Le),t(ws),t(Ms),t(Qe),t(bs),t(vs),t(St),t(ys),t(G),t(js),t($s),t(et),t(Ts),t(tt),t(Js),t(ks),t(st),t(_s),t(T),t(Cs),t(mt),t(Zs),t(Us),t(W),t(xs),t(ht),t(Is),t(Rs),t(ft),t(Gs),t(Ws),t(z),t(zs),t(Mt),t(Es),t(Xs),t(vt),t(Hs),t(Bs),t(jt),t(Fs),t(Ns),t(As),t(Tt),t(Ys),t(E),t(Vs),t(kt),t(qs),t(Ss),t(X),t(Ls),t(Zt),t(Ps),t(Qs),t(aa),t(Ds),t(H),t(Ks),t(It),t(Os),t(Rt),t(el),t(va)),t(M),w(ne),w(oe,e),w(pe),w(me,e),w(he,e),w(fe,e),w(we,e),w(Me),w(be,e),w(je,e),w(Y,e),w($e),w(ke,e),w(_e),w(Ze,e),w(xe,e),w(Re,e),w(Ge),w(ze,e),w(Xe,e),w(He),w(Be,e),w(Ne),w(Ye,e),w(Q,e),w(qe,e),w(Se),w(Pe,e),w(De,e),w(Ke),w(Oe,e),w(at,e),w(nt),w(rt),w(pt),w(ct,e),w(dt),w(ut,e),w(gt,e),w(wt),w(bt,e),w(yt,e),w($t,e),w(te,e),w(Jt),w(_t,e),w(Ct),w(Ut,e),w(xt)}}}const ko={local:"finetuning-de-um-modelo-prtreinado",sections:[{local:"preparando-um-dataset",title:"Preparando um dataset"},{local:"finetuning-com-o-trainer",sections:[{local:"hiperparmetros-de-treinamento",title:"Hiperparâmetros de treinamento"},{local:"mtricas",title:"Métricas"},{local:"trainer",title:"Trainer"}],title:"Fine-tuning com o `Trainer`"},{local:"finetuning-com-keras",sections:[{local:"converso-do-dataset-ao-formato-do-tensorflow",title:"Conversão do dataset ao formato do TensorFlow"},{local:"compilao-e-ajustes",title:"Compilação e ajustes"}],title:"Fine-tuning com Keras"},{local:"finetune-em-pytorch-nativo",sections:[{local:"dataloader",title:"DataLoader"},{local:"otimizao-e-configurao-do-learning-rate",title:"Otimização e configuração do Learning Rate"},{local:"ciclo-de-treinamento",title:"Ciclo de treinamento"},{local:"mtricas",title:"Métricas"}],title:"Fine-tune em PyTorch nativo"},{local:"recursos-adicionais",title:"Recursos adicionais"}],title:"Fine-tuning de um modelo pré-treinado"};function _o(B){return wo(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Wo extends Mo{constructor(M){super(),bo(this,M,_o,Jo,go,{})}}export{Wo as component};
