import{S as Rp,i as Wp,s as Gp,e as l,k as m,w as b,t as r,M as Vp,c as i,d as t,m as $,a as p,x as E,h as n,b as q,F as a,g as c,y as k,q as j,o as w,B as y,v as Yp,L as xe}from"../chunks/vendor-a50a4eac.js";import{T as bt}from"../chunks/Tip-52f026d5.js";import{Y as Hp}from"../chunks/Youtube-9f2aaf44.js";import{I as $a,C as L}from"../chunks/CodeBlock-7a5ed917.js";import{D as Bp}from"../chunks/DocNotebookDropdown-46484535.js";import{F as vt,M as ge}from"../chunks/Markdown-299a2be6.js";function Jp(z){let s,d;return{c(){s=l("p"),d=r(`Todos los ejemplos de c\xF3digo presentados en la documentaci\xF3n tienen un bot\xF3n arriba a la izquierda para elegir entre Pytorch y TensorFlow.
Si no fuese as\xED, se espera que el c\xF3digo funcione para ambos backends sin ning\xFAn cambio.`)},l(o){s=i(o,"P",{});var f=p(s);d=n(f,`Todos los ejemplos de c\xF3digo presentados en la documentaci\xF3n tienen un bot\xF3n arriba a la izquierda para elegir entre Pytorch y TensorFlow.
Si no fuese as\xED, se espera que el c\xF3digo funcione para ambos backends sin ning\xFAn cambio.`),f.forEach(t)},m(o,f){c(o,s,f),a(s,d)},d(o){o&&t(s)}}}function Qp(z){let s,d,o,f,h,g,C,D;return{c(){s=l("p"),d=r("Para m\xE1s detalles acerca del "),o=l("code"),f=r("pipeline()"),h=r(" y tareas asociadas, consulta la documentaci\xF3n "),g=l("a"),C=r("aqu\xED"),D=r("."),this.h()},l(x){s=i(x,"P",{});var P=p(s);d=n(P,"Para m\xE1s detalles acerca del "),o=i(P,"CODE",{});var M=p(o);f=n(M,"pipeline()"),M.forEach(t),h=n(P," y tareas asociadas, consulta la documentaci\xF3n "),g=i(P,"A",{href:!0});var T=p(g);C=n(T,"aqu\xED"),T.forEach(t),D=n(P,"."),P.forEach(t),this.h()},h(){q(g,"href","./main_classes/pipelines")},m(x,P){c(x,s,P),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D)},d(x){x&&t(s)}}}function Kp(z){let s,d;return s=new L({props:{code:"pip install torch",highlighted:"pip install torch"}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function Zp(z){let s,d;return s=new ge({props:{$$slots:{default:[Kp]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function Xp(z){let s,d;return s=new L({props:{code:"pip install tensorflow",highlighted:"pip install tensorflow"}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function eu(z){let s,d;return s=new ge({props:{$$slots:{default:[Xp]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function au(z){let s,d,o,f,h,g,C,D,x,P,M;return P=new L({props:{code:`from transformers import AutoTokenizer, AutoModelForSequenceClassification

model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = AutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),{c(){s=l("p"),d=r("Usa "),o=l("code"),f=r("AutoModelForSequenceClassification"),h=r(" y [\u2018AutoTokenizer\u2019] para cargar un modelo preentrenado y un tokenizador asociado (m\xE1s en un "),g=l("code"),C=r("AutoClass"),D=r(" debajo):"),x=m(),b(P.$$.fragment)},l(T){s=i(T,"P",{});var S=p(s);d=n(S,"Usa "),o=i(S,"CODE",{});var R=p(o);f=n(R,"AutoModelForSequenceClassification"),R.forEach(t),h=n(S," y [\u2018AutoTokenizer\u2019] para cargar un modelo preentrenado y un tokenizador asociado (m\xE1s en un "),g=i(S,"CODE",{});var I=p(g);C=n(I,"AutoClass"),I.forEach(t),D=n(S," debajo):"),S.forEach(t),x=$(T),E(P.$$.fragment,T)},m(T,S){c(T,s,S),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D),c(T,x,S),k(P,T,S),M=!0},p:xe,i(T){M||(j(P.$$.fragment,T),M=!0)},o(T){w(P.$$.fragment,T),M=!1},d(T){T&&t(s),T&&t(x),y(P,T)}}}function tu(z){let s,d;return s=new ge({props:{$$slots:{default:[au]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function su(z){let s,d,o,f,h,g,C,D,x,P,M;return P=new L({props:{code:`from transformers import AutoTokenizer, TFAutoModelForSequenceClassification

model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForSequenceClassification

<span class="hljs-meta">&gt;&gt;&gt; </span>model = TFAutoModelForSequenceClassification.from_pretrained(model_name)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),{c(){s=l("p"),d=r("Usa "),o=l("code"),f=r("TFAutoModelForSequenceClassification"),h=r(" y [\u2018AutoTokenizer\u2019] para cargar un modelo preentrenado y un tokenizador asociado (m\xE1s en un "),g=l("code"),C=r("TFAutoClass"),D=r(" debajo):"),x=m(),b(P.$$.fragment)},l(T){s=i(T,"P",{});var S=p(s);d=n(S,"Usa "),o=i(S,"CODE",{});var R=p(o);f=n(R,"TFAutoModelForSequenceClassification"),R.forEach(t),h=n(S," y [\u2018AutoTokenizer\u2019] para cargar un modelo preentrenado y un tokenizador asociado (m\xE1s en un "),g=i(S,"CODE",{});var I=p(g);C=n(I,"TFAutoClass"),I.forEach(t),D=n(S," debajo):"),S.forEach(t),x=$(T),E(P.$$.fragment,T)},m(T,S){c(T,s,S),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D),c(T,x,S),k(P,T,S),M=!0},p:xe,i(T){M||(j(P.$$.fragment,T),M=!0)},o(T){w(P.$$.fragment,T),M=!1},d(T){T&&t(s),T&&t(x),y(P,T)}}}function ou(z){let s,d;return s=new ge({props:{$$slots:{default:[su]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function ru(z){let s,d;return s=new L({props:{code:`pt_batch = tokenizer(
    ["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."],
    padding=True,
    truncation=True,
    max_length=512,
    return_tensors="pt",
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;pt&quot;</span>,
<span class="hljs-meta">... </span>)`}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function nu(z){let s,d;return s=new ge({props:{$$slots:{default:[ru]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function lu(z){let s,d;return s=new L({props:{code:`tf_batch = tokenizer(
    ["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."],
    padding=True,
    truncation=True,
    max_length=512,
    return_tensors="tf",
)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_batch = tokenizer(
<span class="hljs-meta">... </span>    [<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>],
<span class="hljs-meta">... </span>    padding=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    truncation=<span class="hljs-literal">True</span>,
<span class="hljs-meta">... </span>    max_length=<span class="hljs-number">512</span>,
<span class="hljs-meta">... </span>    return_tensors=<span class="hljs-string">&quot;tf&quot;</span>,
<span class="hljs-meta">... </span>)`}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function iu(z){let s,d;return s=new ge({props:{$$slots:{default:[lu]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function pu(z){let s,d,o,f,h,g,C,D;return{c(){s=l("p"),d=r("Ve el "),o=l("a"),f=r("task summary"),h=r(" para revisar qu\xE9 clase del "),g=l("code"),C=r("AutoModel"),D=r(" deber\xEDas usar para cada tarea."),this.h()},l(x){s=i(x,"P",{});var P=p(s);d=n(P,"Ve el "),o=i(P,"A",{href:!0});var M=p(o);f=n(M,"task summary"),M.forEach(t),h=n(P," para revisar qu\xE9 clase del "),g=i(P,"CODE",{});var T=p(g);C=n(T,"AutoModel"),T.forEach(t),D=n(P," deber\xEDas usar para cada tarea."),P.forEach(t),this.h()},h(){q(o,"href","./task_summary")},m(x,P){c(x,s,P),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D)},d(x){x&&t(s)}}}function uu(z){let s,d,o,f,h,g,C,D,x,P,M,T,S,R,I,U,_,O,V,H,B,Y,ae,J,W,ee,Q,K,fe,oe,$e,re,te,ne,he,A,F,le;return U=new L({props:{code:`from transformers import AutoModelForSequenceClassification

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
pt_model = AutoModelForSequenceClassification.from_pretrained(model_name)`,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_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(model_name)`}}),O=new bt({props:{$$slots:{default:[pu]},$$scope:{ctx:z}}}),ee=new L({props:{code:"pt_outputs = pt_model(**pt_batch)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_outputs = pt_model(**pt_batch)'}}),F=new L({props:{code:`from torch import nn

pt_predictions = nn.functional.softmax(pt_outputs.logits, dim=-1)
print(pt_predictions)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> nn

<span class="hljs-meta">&gt;&gt;&gt; </span>pt_predictions = nn.functional.softmax(pt_outputs.logits, dim=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(pt_predictions)
tensor([[<span class="hljs-number">0.0021</span>, <span class="hljs-number">0.0018</span>, <span class="hljs-number">0.0115</span>, <span class="hljs-number">0.2121</span>, <span class="hljs-number">0.7725</span>],
        [<span class="hljs-number">0.2084</span>, <span class="hljs-number">0.1826</span>, <span class="hljs-number">0.1969</span>, <span class="hljs-number">0.1755</span>, <span class="hljs-number">0.2365</span>]], grad_fn=&lt;SoftmaxBackward0&gt;)`}}),{c(){s=l("p"),d=r("\u{1F917} Transformers provee una forma simple y unificada de cargar tus instancias preentrenadas. Esto significa que puedes cargar un "),o=l("code"),f=r("AutoModel"),h=r(" como cargar\xEDas un "),g=l("code"),C=r("AutoTokenizer"),D=r(". La \xFAnica diferencia es seleccionar el "),x=l("code"),P=r("AutoModel"),M=r(" correcto para la tarea. Ya que est\xE1s clasificando texto, o secuencias, carga "),T=l("code"),S=r("AutoModelForSequenceClassification"),R=r(":"),I=m(),b(U.$$.fragment),_=m(),b(O.$$.fragment),V=m(),H=l("p"),B=r("Ahora puedes pasar tu lote (batch) preprocesado de inputs directamente al modelo. Solo tienes que desempacar el diccionario a\xF1adiendo "),Y=l("code"),ae=r("**"),J=r(":"),W=m(),b(ee.$$.fragment),Q=m(),K=l("p"),fe=r("El modelo producir\xE1 las activaciones finales en el atributo "),oe=l("code"),$e=r("logits"),re=r(". Aplica la funci\xF3n softmax a "),te=l("code"),ne=r("logits"),he=r(" para obtener las probabilidades:"),A=m(),b(F.$$.fragment)},l(v){s=i(v,"P",{});var N=p(s);d=n(N,"\u{1F917} Transformers provee una forma simple y unificada de cargar tus instancias preentrenadas. Esto significa que puedes cargar un "),o=i(N,"CODE",{});var pe=p(o);f=n(pe,"AutoModel"),pe.forEach(t),h=n(N," como cargar\xEDas un "),g=i(N,"CODE",{});var Pe=p(g);C=n(Pe,"AutoTokenizer"),Pe.forEach(t),D=n(N,". La \xFAnica diferencia es seleccionar el "),x=i(N,"CODE",{});var me=p(x);P=n(me,"AutoModel"),me.forEach(t),M=n(N," correcto para la tarea. Ya que est\xE1s clasificando texto, o secuencias, carga "),T=i(N,"CODE",{});var ve=p(T);S=n(ve,"AutoModelForSequenceClassification"),ve.forEach(t),R=n(N,":"),N.forEach(t),I=$(v),E(U.$$.fragment,v),_=$(v),E(O.$$.fragment,v),V=$(v),H=i(v,"P",{});var ie=p(H);B=n(ie,"Ahora puedes pasar tu lote (batch) preprocesado de inputs directamente al modelo. Solo tienes que desempacar el diccionario a\xF1adiendo "),Y=i(ie,"CODE",{});var Le=p(Y);ae=n(Le,"**"),Le.forEach(t),J=n(ie,":"),ie.forEach(t),W=$(v),E(ee.$$.fragment,v),Q=$(v),K=i(v,"P",{});var be=p(K);fe=n(be,"El modelo producir\xE1 las activaciones finales en el atributo "),oe=i(be,"CODE",{});var Ja=p(oe);$e=n(Ja,"logits"),Ja.forEach(t),re=n(be,". Aplica la funci\xF3n softmax a "),te=i(be,"CODE",{});var ha=p(te);ne=n(ha,"logits"),ha.forEach(t),he=n(be," para obtener las probabilidades:"),be.forEach(t),A=$(v),E(F.$$.fragment,v)},m(v,N){c(v,s,N),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D),a(s,x),a(x,P),a(s,M),a(s,T),a(T,S),a(s,R),c(v,I,N),k(U,v,N),c(v,_,N),k(O,v,N),c(v,V,N),c(v,H,N),a(H,B),a(H,Y),a(Y,ae),a(H,J),c(v,W,N),k(ee,v,N),c(v,Q,N),c(v,K,N),a(K,fe),a(K,oe),a(oe,$e),a(K,re),a(K,te),a(te,ne),a(K,he),c(v,A,N),k(F,v,N),le=!0},p(v,N){const pe={};N&2&&(pe.$$scope={dirty:N,ctx:v}),O.$set(pe)},i(v){le||(j(U.$$.fragment,v),j(O.$$.fragment,v),j(ee.$$.fragment,v),j(F.$$.fragment,v),le=!0)},o(v){w(U.$$.fragment,v),w(O.$$.fragment,v),w(ee.$$.fragment,v),w(F.$$.fragment,v),le=!1},d(v){v&&t(s),v&&t(I),y(U,v),v&&t(_),y(O,v),v&&t(V),v&&t(H),v&&t(W),y(ee,v),v&&t(Q),v&&t(K),v&&t(A),y(F,v)}}}function cu(z){let s,d;return s=new ge({props:{$$slots:{default:[uu]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function du(z){let s;return{c(){s=r("Ve el [task summary](./task_summary) para revisar qu\xE9 clase del `AutoModel`\n  deber\xEDas usar para cada tarea.")},l(d){s=n(d,"Ve el [task summary](./task_summary) para revisar qu\xE9 clase del `AutoModel`\n  deber\xEDas usar para cada tarea.")},m(d,o){c(d,s,o)},d(d){d&&t(s)}}}function fu(z){let s,d,o,f,h,g,C,D,x,P,M,T,S,R,I,U,_,O,V,H,B,Y,ae,J,W,ee,Q,K,fe,oe,$e,re,te,ne,he;return U=new L({props:{code:`from transformers import TFAutoModelForSequenceClassification

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
tf_model = TFAutoModelForSequenceClassification.from_pretrained(model_name)`,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_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(model_name)`}}),O=new bt({props:{$$slots:{default:[du]},$$scope:{ctx:z}}}),ae=new L({props:{code:"tf_outputs = tf_model(tf_batch)",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_outputs = tf_model(tf_batch)'}}),ne=new L({props:{code:`import tensorflow as tf

tf_predictions = tf.nn.softmax(tf_outputs.logits, axis=-1)
print(tf.math.round(tf_predictions * 10**4) / 10**4)`,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>tf_predictions = tf.nn.softmax(tf_outputs.logits, axis=-<span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(tf.math.<span class="hljs-built_in">round</span>(tf_predictions * <span class="hljs-number">10</span>**<span class="hljs-number">4</span>) / <span class="hljs-number">10</span>**<span class="hljs-number">4</span>)
tf.Tensor(
[[<span class="hljs-number">0.0021</span> <span class="hljs-number">0.0018</span> <span class="hljs-number">0.0116</span> <span class="hljs-number">0.2121</span> <span class="hljs-number">0.7725</span>]
 [<span class="hljs-number">0.2084</span> <span class="hljs-number">0.1826</span> <span class="hljs-number">0.1969</span> <span class="hljs-number">0.1755</span>  <span class="hljs-number">0.2365</span>]], shape=(<span class="hljs-number">2</span>, <span class="hljs-number">5</span>), dtype=float32)`}}),{c(){s=l("p"),d=r("\u{1F917} Transformers provee una forma simple y unificada de cargar tus instancias preentrenadas. Esto significa que puedes cargar un "),o=l("code"),f=r("TFAutoModel"),h=r(" como cargar\xEDas un "),g=l("code"),C=r("AutoTokenizer"),D=r(". La \xFAnica diferencia es seleccionar el "),x=l("code"),P=r("TFAutoModel"),M=r(" correcto para la tarea. Ya que est\xE1s clasificando texto, o secuencias, carga "),T=l("code"),S=r("TFAutoModelForSequenceClassification"),R=r(":"),I=m(),b(U.$$.fragment),_=m(),b(O.$$.fragment),V=m(),H=l("p"),B=r("Ahora puedes pasar tu lote preprocesado de inputs directamente al modelo pasando las llaves del diccionario directamente a los tensores:"),Y=m(),b(ae.$$.fragment),J=m(),W=l("p"),ee=r("El modelo producir\xE1 las activaciones finales en el atributo "),Q=l("code"),K=r("logits"),fe=r(". Aplica la funci\xF3n softmax a "),oe=l("code"),$e=r("logits"),re=r(" para obtener las probabilidades:"),te=m(),b(ne.$$.fragment)},l(A){s=i(A,"P",{});var F=p(s);d=n(F,"\u{1F917} Transformers provee una forma simple y unificada de cargar tus instancias preentrenadas. Esto significa que puedes cargar un "),o=i(F,"CODE",{});var le=p(o);f=n(le,"TFAutoModel"),le.forEach(t),h=n(F," como cargar\xEDas un "),g=i(F,"CODE",{});var v=p(g);C=n(v,"AutoTokenizer"),v.forEach(t),D=n(F,". La \xFAnica diferencia es seleccionar el "),x=i(F,"CODE",{});var N=p(x);P=n(N,"TFAutoModel"),N.forEach(t),M=n(F," correcto para la tarea. Ya que est\xE1s clasificando texto, o secuencias, carga "),T=i(F,"CODE",{});var pe=p(T);S=n(pe,"TFAutoModelForSequenceClassification"),pe.forEach(t),R=n(F,":"),F.forEach(t),I=$(A),E(U.$$.fragment,A),_=$(A),E(O.$$.fragment,A),V=$(A),H=i(A,"P",{});var Pe=p(H);B=n(Pe,"Ahora puedes pasar tu lote preprocesado de inputs directamente al modelo pasando las llaves del diccionario directamente a los tensores:"),Pe.forEach(t),Y=$(A),E(ae.$$.fragment,A),J=$(A),W=i(A,"P",{});var me=p(W);ee=n(me,"El modelo producir\xE1 las activaciones finales en el atributo "),Q=i(me,"CODE",{});var ve=p(Q);K=n(ve,"logits"),ve.forEach(t),fe=n(me,". Aplica la funci\xF3n softmax a "),oe=i(me,"CODE",{});var ie=p(oe);$e=n(ie,"logits"),ie.forEach(t),re=n(me," para obtener las probabilidades:"),me.forEach(t),te=$(A),E(ne.$$.fragment,A)},m(A,F){c(A,s,F),a(s,d),a(s,o),a(o,f),a(s,h),a(s,g),a(g,C),a(s,D),a(s,x),a(x,P),a(s,M),a(s,T),a(T,S),a(s,R),c(A,I,F),k(U,A,F),c(A,_,F),k(O,A,F),c(A,V,F),c(A,H,F),a(H,B),c(A,Y,F),k(ae,A,F),c(A,J,F),c(A,W,F),a(W,ee),a(W,Q),a(Q,K),a(W,fe),a(W,oe),a(oe,$e),a(W,re),c(A,te,F),k(ne,A,F),he=!0},p(A,F){const le={};F&2&&(le.$$scope={dirty:F,ctx:A}),O.$set(le)},i(A){he||(j(U.$$.fragment,A),j(O.$$.fragment,A),j(ae.$$.fragment,A),j(ne.$$.fragment,A),he=!0)},o(A){w(U.$$.fragment,A),w(O.$$.fragment,A),w(ae.$$.fragment,A),w(ne.$$.fragment,A),he=!1},d(A){A&&t(s),A&&t(I),y(U,A),A&&t(_),y(O,A),A&&t(V),A&&t(H),A&&t(Y),y(ae,A),A&&t(J),A&&t(W),A&&t(te),y(ne,A)}}}function mu(z){let s,d;return s=new ge({props:{$$slots:{default:[fu]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function $u(z){let s,d,o,f,h;return{c(){s=l("p"),d=r("Todos los modelos de \u{1F917} Transformers (PyTorch o TensorFlow) producir\xE1n los tensores "),o=l("em"),f=r("antes"),h=r(` de la funci\xF3n de activaci\xF3n
final (como softmax) porque la funci\xF3n de activaci\xF3n final es com\xFAnmente fusionada con la p\xE9rdida.`)},l(g){s=i(g,"P",{});var C=p(s);d=n(C,"Todos los modelos de \u{1F917} Transformers (PyTorch o TensorFlow) producir\xE1n los tensores "),o=i(C,"EM",{});var D=p(o);f=n(D,"antes"),D.forEach(t),h=n(C,` de la funci\xF3n de activaci\xF3n
final (como softmax) porque la funci\xF3n de activaci\xF3n final es com\xFAnmente fusionada con la p\xE9rdida.`),C.forEach(t)},m(g,C){c(g,s,C),a(s,d),a(s,o),a(o,f),a(s,h)},d(g){g&&t(s)}}}function hu(z){let s,d,o,f,h;return{c(){s=l("p"),d=r(`Los outputs del modelo de \u{1F917} Transformers son dataclasses especiales por lo que sus atributos pueden ser completados en un IDE.
Los outputs del modelo tambi\xE9n se comportan como tuplas o diccionarios (e.g., puedes indexar con un entero, un slice o una cadena) en cuyo caso los atributos que son `),o=l("code"),f=r("None"),h=r(" son ignorados.")},l(g){s=i(g,"P",{});var C=p(s);d=n(C,`Los outputs del modelo de \u{1F917} Transformers son dataclasses especiales por lo que sus atributos pueden ser completados en un IDE.
Los outputs del modelo tambi\xE9n se comportan como tuplas o diccionarios (e.g., puedes indexar con un entero, un slice o una cadena) en cuyo caso los atributos que son `),o=i(C,"CODE",{});var D=p(o);f=n(D,"None"),D.forEach(t),h=n(C," son ignorados."),C.forEach(t)},m(g,C){c(g,s,C),a(s,d),a(s,o),a(o,f),a(s,h)},d(g){g&&t(s)}}}function _u(z){let s,d,o,f,h,g,C,D,x,P,M,T,S,R,I,U;return C=new L({props:{code:`pt_save_directory = "./pt_save_pretrained"
tokenizer.save_pretrained(pt_save_directory)
pt_model.save_pretrained(pt_save_directory)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pt_save_directory = <span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(pt_save_directory)`}}),I=new L({props:{code:'pt_model = AutoModelForSequenceClassification.from_pretrained("./pt_save_pretrained")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./pt_save_pretrained&quot;</span>)'}}),{c(){s=l("p"),d=r("Una vez que tu modelo est\xE9 fine-tuned puedes guardarlo con tu tokenizador usando "),o=l("code"),f=r("PreTrainedModel.save_pretrained()"),h=r(":"),g=m(),b(C.$$.fragment),D=m(),x=l("p"),P=r("Cuando quieras usar el modelo otra vez c\xE1rgalo con "),M=l("code"),T=r("PreTrainedModel.from_pretrained()"),S=r(":"),R=m(),b(I.$$.fragment)},l(_){s=i(_,"P",{});var O=p(s);d=n(O,"Una vez que tu modelo est\xE9 fine-tuned puedes guardarlo con tu tokenizador usando "),o=i(O,"CODE",{});var V=p(o);f=n(V,"PreTrainedModel.save_pretrained()"),V.forEach(t),h=n(O,":"),O.forEach(t),g=$(_),E(C.$$.fragment,_),D=$(_),x=i(_,"P",{});var H=p(x);P=n(H,"Cuando quieras usar el modelo otra vez c\xE1rgalo con "),M=i(H,"CODE",{});var B=p(M);T=n(B,"PreTrainedModel.from_pretrained()"),B.forEach(t),S=n(H,":"),H.forEach(t),R=$(_),E(I.$$.fragment,_)},m(_,O){c(_,s,O),a(s,d),a(s,o),a(o,f),a(s,h),c(_,g,O),k(C,_,O),c(_,D,O),c(_,x,O),a(x,P),a(x,M),a(M,T),a(x,S),c(_,R,O),k(I,_,O),U=!0},p:xe,i(_){U||(j(C.$$.fragment,_),j(I.$$.fragment,_),U=!0)},o(_){w(C.$$.fragment,_),w(I.$$.fragment,_),U=!1},d(_){_&&t(s),_&&t(g),y(C,_),_&&t(D),_&&t(x),_&&t(R),y(I,_)}}}function gu(z){let s,d;return s=new ge({props:{$$slots:{default:[_u]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function vu(z){let s,d,o,f,h,g,C,D,x,P,M,T,S,R,I,U;return C=new L({props:{code:`tf_save_directory = "./tf_save_pretrained"
tokenizer.save_pretrained(tf_save_directory)
tf_model.save_pretrained(tf_save_directory)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>tf_save_directory = <span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(tf_save_directory)`}}),I=new L({props:{code:'tf_model = TFAutoModelForSequenceClassification.from_pretrained("./tf_save_pretrained")',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;./tf_save_pretrained&quot;</span>)'}}),{c(){s=l("p"),d=r("Una vez que tu modelo est\xE9 fine-tuned puedes guardarlo con tu tokenizador usando "),o=l("code"),f=r("TFPreTrainedModel.save_pretrained()"),h=r(":"),g=m(),b(C.$$.fragment),D=m(),x=l("p"),P=r("Cuando quieras usar el modelo otra vez c\xE1rgalo con "),M=l("code"),T=r("TFPreTrainedModel.from_pretrained()"),S=r(":"),R=m(),b(I.$$.fragment)},l(_){s=i(_,"P",{});var O=p(s);d=n(O,"Una vez que tu modelo est\xE9 fine-tuned puedes guardarlo con tu tokenizador usando "),o=i(O,"CODE",{});var V=p(o);f=n(V,"TFPreTrainedModel.save_pretrained()"),V.forEach(t),h=n(O,":"),O.forEach(t),g=$(_),E(C.$$.fragment,_),D=$(_),x=i(_,"P",{});var H=p(x);P=n(H,"Cuando quieras usar el modelo otra vez c\xE1rgalo con "),M=i(H,"CODE",{});var B=p(M);T=n(B,"TFPreTrainedModel.from_pretrained()"),B.forEach(t),S=n(H,":"),H.forEach(t),R=$(_),E(I.$$.fragment,_)},m(_,O){c(_,s,O),a(s,d),a(s,o),a(o,f),a(s,h),c(_,g,O),k(C,_,O),c(_,D,O),c(_,x,O),a(x,P),a(x,M),a(M,T),a(x,S),c(_,R,O),k(I,_,O),U=!0},p:xe,i(_){U||(j(C.$$.fragment,_),j(I.$$.fragment,_),U=!0)},o(_){w(C.$$.fragment,_),w(I.$$.fragment,_),U=!1},d(_){_&&t(s),_&&t(g),y(C,_),_&&t(D),_&&t(x),_&&t(R),y(I,_)}}}function bu(z){let s,d;return s=new ge({props:{$$slots:{default:[vu]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function Eu(z){let s,d;return s=new L({props:{code:`from transformers import AutoModel

tokenizer = AutoTokenizer.from_pretrained(tf_save_directory)
pt_model = AutoModelForSequenceClassification.from_pretrained(tf_save_directory, from_tf=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(tf_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(tf_save_directory, from_tf=<span class="hljs-literal">True</span>)`}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function ku(z){let s,d;return s=new ge({props:{$$slots:{default:[Eu]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function ju(z){let s,d;return s=new L({props:{code:`from transformers import TFAutoModel

tokenizer = AutoTokenizer.from_pretrained(pt_save_directory)
tf_model = TFAutoModelForSequenceClassification.from_pretrained(pt_save_directory, from_pt=True)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> TFAutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(pt_save_directory)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(pt_save_directory, from_pt=<span class="hljs-literal">True</span>)`}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p:xe,i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function wu(z){let s,d;return s=new ge({props:{$$slots:{default:[ju]},$$scope:{ctx:z}}}),{c(){b(s.$$.fragment)},l(o){E(s.$$.fragment,o)},m(o,f){k(s,o,f),d=!0},p(o,f){const h={};f&2&&(h.$$scope={dirty:f,ctx:o}),s.$set(h)},i(o){d||(j(s.$$.fragment,o),d=!0)},o(o){w(s.$$.fragment,o),d=!1},d(o){y(s,o)}}}function yu(z){let s,d,o,f,h,g,C,D,x,P,M,T,S,R,I,U,_,O,V,H,B,Y,ae,J,W,ee,Q,K,fe,oe,$e,re,te,ne,he,A,F,le,v,N,pe,Pe,me,ve,ie,Le,be,Ja,ha,G,Et,sr,or,kt,rr,nr,jt,lr,ir,wt,pr,ur,yt,cr,dr,qt,fr,mr,At,$r,hr,Tt,_r,Ps,_a,Ct,gr,vr,Os,Ee,zt,br,Er,xt,kr,jr,Pt,wr,Ss,ga,Ot,yr,qr,Ds,Ue,St,Ar,Tr,Dt,Cr,Ms,He,Fs,Oe,Re,Mt,va,zr,Ft,xr,Is,We,Pr,It,Or,Sr,Ns,Qa,Dr,Ls,Ge,Us,Ve,Mr,Nt,Fr,Ir,Hs,ba,Rs,ke,Nr,Ea,Lr,Ur,Lt,Hr,Rr,Ws,ka,Gs,Ye,Wr,Ut,Gr,Vr,Vs,ja,Ys,je,Yr,Ht,Br,Jr,wa,Qr,Kr,Bs,ya,Js,_e,Zr,Rt,Xr,en,Wt,an,tn,Gt,sn,on,Qs,qa,Ks,we,rn,Aa,nn,ln,Ta,pn,un,Zs,Ca,Xs,Be,cn,Vt,dn,fn,eo,za,ao,Je,mn,Yt,$n,hn,to,xa,so,Qe,_n,Ka,gn,vn,oo,Se,Ke,Bt,Pa,bn,Jt,En,ro,ue,kn,Qt,jn,wn,Oa,yn,qn,Kt,An,Tn,Sa,Cn,zn,no,Da,lo,Ze,io,ye,xn,Zt,Pn,On,Xt,Sn,Dn,po,Ma,uo,qe,Mn,Za,Fn,In,Xa,Nn,Ln,co,De,Xe,es,Fa,Un,as,Hn,fo,Ia,mo,Z,Rn,ts,Wn,Gn,ss,Vn,Yn,os,Bn,Jn,et,Qn,Kn,rs,Zn,Xn,ns,el,al,$o,Ae,tl,ls,sl,ol,is,rl,nl,ho,Me,ea,ps,Na,ll,us,il,_o,Te,pl,cs,ul,cl,at,dl,fl,go,aa,ml,ds,$l,hl,vo,La,bo,ta,_l,fs,gl,vl,Eo,tt,bl,ko,Ua,jo,st,El,wo,sa,ot,rt,kl,jl,wl,nt,lt,yl,ql,yo,oa,Al,ms,Tl,Cl,qo,ra,Ao,na,zl,it,xl,Pl,To,Fe,la,$s,Ha,Ol,hs,Sl,Co,ia,zo,pa,xo,X,Dl,Ra,_s,Ml,Fl,Wa,gs,Il,Nl,vs,Ll,Ul,bs,Hl,Rl,Ga,Wl,Gl,pt,Vl,Yl,Po,ua,Oo,Ie,ca,Es,Va,Bl,ks,Jl,So,da,Do,Ce,Ql,js,Kl,Zl,ws,Xl,ei,Mo,fa,Fo;return g=new $a({}),M=new Bp({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/es/quicktour.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/es/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/es/tensorflow/quicktour.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/es/quicktour.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/es/pytorch/quicktour.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/es/tensorflow/quicktour.ipynb"}]}}),Y=new bt({props:{$$slots:{default:[Jp]},$$scope:{ctx:z}}}),Q=new $a({}),F=new Hp({props:{id:"tiZFewofSLM"}}),He=new bt({props:{$$slots:{default:[Qp]},$$scope:{ctx:z}}}),va=new $a({}),Ge=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[eu],pytorch:[Zp]},$$scope:{ctx:z}}}),ba=new L({props:{code:`from transformers import pipeline

classifier = pipeline("sentiment-analysis")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>)`}}),ka=new L({props:{code:'classifier("We are very happy to show you the \u{1F917} Transformers library.")',highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;POSITIVE&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.9998</span>}]`}}),ja=new L({props:{code:`results = classifier(["We are very happy to show you the \u{1F917} Transformers library.", "We hope you don't hate it."])
for result in results:
    print(f"label: {result['label']}, with score: {round(result['score'], 4)}")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>results = classifier([<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>, <span class="hljs-string">&quot;We hope you don&#x27;t hate it.&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> result <span class="hljs-keyword">in</span> results:
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;label: <span class="hljs-subst">{result[<span class="hljs-string">&#x27;label&#x27;</span>]}</span>, with score: <span class="hljs-subst">{<span class="hljs-built_in">round</span>(result[<span class="hljs-string">&#x27;score&#x27;</span>], <span class="hljs-number">4</span>)}</span>&quot;</span>)
label: POSITIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.9998</span>
label: NEGATIVE, <span class="hljs-keyword">with</span> score: <span class="hljs-number">0.5309</span>`}}),ya=new L({props:{code:"pip install datasets",highlighted:"pip install datasets"}}),qa=new L({props:{code:`import torch
from transformers import pipeline

speech_recognizer = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h", device=0)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>speech_recognizer = pipeline(<span class="hljs-string">&quot;automatic-speech-recognition&quot;</span>, model=<span class="hljs-string">&quot;facebook/wav2vec2-base-960h&quot;</span>, device=<span class="hljs-number">0</span>)`}}),Ca=new L({props:{code:`from datasets import load_dataset, Audio

dataset = load_dataset("PolyAI/minds14", name="en-US", split="train")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset, Audio

<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = load_dataset(<span class="hljs-string">&quot;PolyAI/minds14&quot;</span>, name=<span class="hljs-string">&quot;en-US&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)`}}),za=new L({props:{code:'dataset = dataset.cast_column("audio", Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>dataset = dataset.cast_column(<span class="hljs-string">&quot;audio&quot;</span>, Audio(sampling_rate=speech_recognizer.feature_extractor.sampling_rate))'}}),xa=new L({props:{code:`result = speech_recognizer(dataset[:4]["audio"])
print([d["text"] for d in result])`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>result = speech_recognizer(dataset[:<span class="hljs-number">4</span>][<span class="hljs-string">&quot;audio&quot;</span>])
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>([d[<span class="hljs-string">&quot;text&quot;</span>] <span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> result])
[<span class="hljs-string">&#x27;I WOULD LIKE TO SET UP A JOINT ACCOUNT WITH MY PARTNER HOW DO I PROCEED WITH DOING THAT&#x27;</span>, <span class="hljs-string">&quot;FONDERING HOW I&#x27;D SET UP A JOIN TO HET WITH MY WIFE AND WHERE THE AP MIGHT BE&quot;</span>, <span class="hljs-string">&quot;I I&#x27;D LIKE TOY SET UP A JOINT ACCOUNT WITH MY PARTNER I&#x27;M NOT SEEING THE OPTION TO DO IT ON THE APSO I CALLED IN TO GET SOME HELP CAN I JUST DO IT OVER THE PHONE WITH YOU AND GIVE YOU THE INFORMATION OR SHOULD I DO IT IN THE AP AND I&#x27;M MISSING SOMETHING UQUETTE HAD PREFERRED TO JUST DO IT OVER THE PHONE OF POSSIBLE THINGS&quot;</span>, <span class="hljs-string">&#x27;HOW DO I TURN A JOIN A COUNT&#x27;</span>]`}}),Pa=new $a({}),Da=new L({props:{code:'model_name = "nlptown/bert-base-multilingual-uncased-sentiment"',highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>'}}),Ze=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[ou],pytorch:[tu]},$$scope:{ctx:z}}}),Ma=new L({props:{code:`classifier = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)
classifier("Nous sommes tr\xE8s heureux de vous pr\xE9senter la biblioth\xE8que \u{1F917} Transformers.")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>classifier = pipeline(<span class="hljs-string">&quot;sentiment-analysis&quot;</span>, model=model, tokenizer=tokenizer)
<span class="hljs-meta">&gt;&gt;&gt; </span>classifier(<span class="hljs-string">&quot;Nous sommes tr\xE8s heureux de vous pr\xE9senter la biblioth\xE8que \u{1F917} Transformers.&quot;</span>)
[{<span class="hljs-string">&#x27;label&#x27;</span>: <span class="hljs-string">&#x27;5 stars&#x27;</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.7273</span>}]`}}),Fa=new $a({}),Ia=new Hp({props:{id:"AhChOFRegn4"}}),Na=new $a({}),La=new L({props:{code:`from transformers import AutoTokenizer

model_name = "nlptown/bert-base-multilingual-uncased-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_name)`,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>model_name = <span class="hljs-string">&quot;nlptown/bert-base-multilingual-uncased-sentiment&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_name)`}}),Ua=new L({props:{code:`encoding = tokenizer("We are very happy to show you the \u{1F917} Transformers library.")
print(encoding)`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>encoding = tokenizer(<span class="hljs-string">&quot;We are very happy to show you the \u{1F917} Transformers library.&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(encoding)
{<span class="hljs-string">&#x27;input_ids&#x27;</span>: [<span class="hljs-number">101</span>, <span class="hljs-number">11312</span>, <span class="hljs-number">10320</span>, <span class="hljs-number">12495</span>, <span class="hljs-number">19308</span>, <span class="hljs-number">10114</span>, <span class="hljs-number">11391</span>, <span class="hljs-number">10855</span>, <span class="hljs-number">10103</span>, <span class="hljs-number">100</span>, <span class="hljs-number">58263</span>, <span class="hljs-number">13299</span>, <span class="hljs-number">119</span>, <span class="hljs-number">102</span>],
 <span class="hljs-string">&#x27;token_type_ids&#x27;</span>: [<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>],
 <span class="hljs-string">&#x27;attention_mask&#x27;</span>: [<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>]}`}}),ra=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[iu],pytorch:[nu]},$$scope:{ctx:z}}}),Ha=new $a({}),ia=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[mu],pytorch:[cu]},$$scope:{ctx:z}}}),pa=new bt({props:{$$slots:{default:[$u]},$$scope:{ctx:z}}}),ua=new bt({props:{$$slots:{default:[hu]},$$scope:{ctx:z}}}),Va=new $a({}),da=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[bu],pytorch:[gu]},$$scope:{ctx:z}}}),fa=new vt({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[wu],pytorch:[ku]},$$scope:{ctx:z}}}),{c(){s=l("meta"),d=m(),o=l("h1"),f=l("a"),h=l("span"),b(g.$$.fragment),C=m(),D=l("span"),x=r("Quick tour"),P=m(),b(M.$$.fragment),T=m(),S=l("p"),R=r("\xA1Entra en marcha con los \u{1F917} Transformers! Comienza usando "),I=l("code"),U=r("pipeline()"),_=r(" para una inferencia veloz, carga un modelo preentrenado y un tokenizador con una "),O=l("a"),V=r("AutoClass"),H=r(" para resolver tu tarea de texto, visi\xF3n o audio."),B=m(),b(Y.$$.fragment),ae=m(),J=l("h2"),W=l("a"),ee=l("span"),b(Q.$$.fragment),K=m(),fe=l("span"),oe=r("Pipeline"),$e=m(),re=l("p"),te=l("code"),ne=r("pipeline()"),he=r(" es la forma m\xE1s f\xE1cil de usar un modelo preentrenado para una tarea dada."),A=m(),b(F.$$.fragment),le=m(),v=l("p"),N=r("El "),pe=l("code"),Pe=r("pipeline()"),me=r(" soporta muchas tareas comunes listas para usar:"),ve=m(),ie=l("p"),Le=l("strong"),be=r("Texto"),Ja=r(":"),ha=m(),G=l("ul"),Et=l("li"),sr=r("An\xE1lisis de Sentimientos: clasifica la polaridad de un texto dado."),or=m(),kt=l("li"),rr=r("Generaci\xF3n de texto (solo en ingl\xE9s): genera texto a partir de un input dado."),nr=m(),jt=l("li"),lr=r("Name entity recognition (NER): etiqueta cada palabra con la entidad que representa (persona, fecha, ubicaci\xF3n, etc.)."),ir=m(),wt=l("li"),pr=r("Responder preguntas: extrae la respuesta del contexto dado un contexto y una pregunta."),ur=m(),yt=l("li"),cr=r("Fill-mask: rellena el espacio faltante dado un texto con palabras enmascaradas."),dr=m(),qt=l("li"),fr=r("Summarization: genera un resumen de una secuencia larga de texto o un documento."),mr=m(),At=l("li"),$r=r("Traducci\xF3n: traduce un texto a otro idioma."),hr=m(),Tt=l("li"),_r=r("Extracci\xF3n de caracter\xEDsticas: crea una representaci\xF3n tensorial del texto."),Ps=m(),_a=l("p"),Ct=l("strong"),gr=r("Imagen"),vr=r(":"),Os=m(),Ee=l("ul"),zt=l("li"),br=r("Clasificaci\xF3n de im\xE1genes: clasifica una imagen."),Er=m(),xt=l("li"),kr=r("Segmentaci\xF3n de im\xE1genes: clasifica cada pixel de una imagen."),jr=m(),Pt=l("li"),wr=r("Detecci\xF3n de objetos: detecta objetos dentro de una imagen."),Ss=m(),ga=l("p"),Ot=l("strong"),yr=r("Audio"),qr=r(":"),Ds=m(),Ue=l("ul"),St=l("li"),Ar=r("Clasificaci\xF3n de audios: asigna una etiqueta a un segmento de audio."),Tr=m(),Dt=l("li"),Cr=r("Automatic speech recognition (ASR): transcribe datos de audio a un texto."),Ms=m(),b(He.$$.fragment),Fs=m(),Oe=l("h3"),Re=l("a"),Mt=l("span"),b(va.$$.fragment),zr=m(),Ft=l("span"),xr=r("Uso del Pipeline"),Is=m(),We=l("p"),Pr=r("En el siguiente ejemplo, usar\xE1s el "),It=l("code"),Or=r("pipeline()"),Sr=r(" para an\xE1lisis de sentimiento."),Ns=m(),Qa=l("p"),Dr=r("Instala las siguientes dependencias si a\xFAn no lo has hecho:"),Ls=m(),b(Ge.$$.fragment),Us=m(),Ve=l("p"),Mr=r("Importa "),Nt=l("code"),Fr=r("pipeline()"),Ir=r(" y especifica la tarea que deseas completar:"),Hs=m(),b(ba.$$.fragment),Rs=m(),ke=l("p"),Nr=r("El pipeline descarga y almacena en cach\xE9 un "),Ea=l("a"),Lr=r("modelo preentrenado"),Ur=r(" por defecto y tokeniza para an\xE1lisis de sentimiento. Ahora puedes usar "),Lt=l("code"),Hr=r("classifier"),Rr=r(" en tu texto objetivo:"),Ws=m(),b(ka.$$.fragment),Gs=m(),Ye=l("p"),Wr=r("Para m\xE1s de un enunciado entrega una lista de frases al "),Ut=l("code"),Gr=r("pipeline()"),Vr=r(" que devolver\xE1 una lista de diccionarios:"),Vs=m(),b(ja.$$.fragment),Ys=m(),je=l("p"),Yr=r("El "),Ht=l("code"),Br=r("pipeline()"),Jr=r(" tambi\xE9n puede iterar sobre un dataset entero. Comienza instalando la biblioteca "),wa=l("a"),Qr=r("\u{1F917} Datasets"),Kr=r(":"),Bs=m(),b(ya.$$.fragment),Js=m(),_e=l("p"),Zr=r("Crea un "),Rt=l("code"),Xr=r("pipeline()"),en=r(" con la tarea que deseas resolver y el modelo que quieres usar. Coloca el par\xE1metro "),Wt=l("code"),an=r("device"),tn=r(" a "),Gt=l("code"),sn=r("0"),on=r(" para poner los tensores en un dispositivo CUDA:"),Qs=m(),b(qa.$$.fragment),Ks=m(),we=l("p"),rn=r("A continuaci\xF3n, carga el dataset (ve \u{1F917} Datasets "),Aa=l("a"),nn=r("Quick Start"),ln=r(" para m\xE1s detalles) sobre el que quisieras iterar. Por ejemplo, vamos a cargar el dataset "),Ta=l("a"),pn=r("MInDS-14"),un=r(":"),Zs=m(),b(Ca.$$.fragment),Xs=m(),Be=l("p"),cn=r("Debemos asegurarnos de que la frecuencia de muestreo del conjunto de datos coincide con la frecuencia de muestreo con la que se entren\xF3 "),Vt=l("code"),dn=r("facebook/wav2vec2-base-960h"),fn=r("."),eo=m(),b(za.$$.fragment),ao=m(),Je=l("p"),mn=r("Los archivos de audio se cargan y remuestrean autom\xE1ticamente cuando se llama a la columna "),Yt=l("code"),$n=r('"audio"'),hn=r(`.
Extraigamos las matrices de forma de onda cruda de las primeras 4 muestras y pas\xE9mosla como una lista al pipeline:`),to=m(),b(xa.$$.fragment),so=m(),Qe=l("p"),_n=r("Para un dataset m\xE1s grande, donde los inputs son de mayor tama\xF1o (como en habla/audio o visi\xF3n), querr\xE1s pasar un generador en lugar de una lista que carga todos los inputs en memoria. Ve la "),Ka=l("a"),gn=r("documentaci\xF3n del pipeline"),vn=r(" para m\xE1s informaci\xF3n."),oo=m(),Se=l("h3"),Ke=l("a"),Bt=l("span"),b(Pa.$$.fragment),bn=m(),Jt=l("span"),En=r("Use otro modelo y otro tokenizador en el pipeline"),ro=m(),ue=l("p"),kn=r("El "),Qt=l("code"),jn=r("pipeline()"),wn=r(" puede adaptarse a cualquier modelo del "),Oa=l("a"),yn=r("Model Hub"),qn=r(" haciendo m\xE1s f\xE1cil adaptar el "),Kt=l("code"),An=r("pipeline()"),Tn=r(" para otros casos de uso. Por ejemplo, si quisieras un modelo capaz de manejar texto en franc\xE9s, usa los tags en el Model Hub para filtrar entre los modelos apropiados. El resultado mejor filtrado devuelve un "),Sa=l("a"),Cn=r("modelo BERT"),zn=r(" multilingual fine-tuned para el an\xE1lisis de sentimiento. Genial, \xA1vamos a usar este modelo!"),no=m(),b(Da.$$.fragment),lo=m(),b(Ze.$$.fragment),io=m(),ye=l("p"),xn=r("Despu\xE9s puedes especificar el modelo y el tokenizador en el "),Zt=l("code"),Pn=r("pipeline()"),On=r(", y aplicar el "),Xt=l("code"),Sn=r("classifier"),Dn=r(" en tu texto objetivo:"),po=m(),b(Ma.$$.fragment),uo=m(),qe=l("p"),Mn=r("Si no pudieras encontrar el modelo para tu caso respectivo de uso necesitar\xE1s ajustar un modelo preentrenado a tus datos. Mira nuestro "),Za=l("a"),Fn=r("tutorial de fine-tuning"),In=r(" para aprender c\xF3mo. Finalmente, despu\xE9s de que has ajustado tu modelo preentrenado, \xA1por favor considera compartirlo (ve el tutorial "),Xa=l("a"),Nn=r("aqu\xED"),Ln=r(") con la comunidad en el Model Hub para democratizar el NLP! \u{1F917}"),co=m(),De=l("h2"),Xe=l("a"),es=l("span"),b(Fa.$$.fragment),Un=m(),as=l("span"),Hn=r("AutoClass"),fo=m(),b(Ia.$$.fragment),mo=m(),Z=l("p"),Rn=r("Debajo del cap\xF3, las clases "),ts=l("code"),Wn=r("AutoModelForSequenceClassification"),Gn=r(" y "),ss=l("code"),Vn=r("AutoTokenizer"),Yn=r(" trabajan juntas para dar poder al "),os=l("code"),Bn=r("pipeline()"),Jn=r(". Una "),et=l("a"),Qn=r("AutoClass"),Kn=r(" es un atajo que autom\xE1ticamente recupera la arquitectura de un modelo preentrenado con su nombre o el path. S\xF3lo necesitar\xE1s seleccionar el "),rs=l("code"),Zn=r("AutoClass"),Xn=r(" apropiado para tu tarea y tu tokenizador asociado con "),ns=l("code"),el=r("AutoTokenizer"),al=r("."),$o=m(),Ae=l("p"),tl=r("Regresemos a nuestro ejemplo y veamos c\xF3mo puedes usar el "),ls=l("code"),sl=r("AutoClass"),ol=r(" para reproducir los resultados del "),is=l("code"),rl=r("pipeline()"),nl=r("."),ho=m(),Me=l("h3"),ea=l("a"),ps=l("span"),b(Na.$$.fragment),ll=m(),us=l("span"),il=r("AutoTokenizer"),_o=m(),Te=l("p"),pl=r("Un tokenizador es responsable de procesar el texto a un formato que sea entendible para el modelo. Primero, el tokenizador separar\xE1 el texto en palabras llamadas "),cs=l("em"),ul=r("tokens"),cl=r(". Hay m\xFAltiples reglas que gobiernan el proceso de tokenizaci\xF3n incluyendo el c\xF3mo separar una palabra y en qu\xE9 nivel (aprende m\xE1s sobre tokenizaci\xF3n "),at=l("a"),dl=r("aqu\xED"),fl=r("). Lo m\xE1s importante es recordar que necesitar\xE1s instanciar el tokenizador con el mismo nombre del modelo para asegurar que est\xE1s usando las mismas reglas de tokenizaci\xF3n con las que el modelo fue preentrenado."),go=m(),aa=l("p"),ml=r("Carga un tokenizador con "),ds=l("code"),$l=r("AutoTokenizer"),hl=r(":"),vo=m(),b(La.$$.fragment),bo=m(),ta=l("p"),_l=r("Despu\xE9s, el tokenizador convierte los tokens a n\xFAmeros para construir un tensor que servir\xE1 como input para el modelo. Esto es conocido como el "),fs=l("em"),gl=r("vocabulario"),vl=r(" del modelo."),Eo=m(),tt=l("p"),bl=r("Pasa tu texto al tokenizador:"),ko=m(),b(Ua.$$.fragment),jo=m(),st=l("p"),El=r("El tokenizador devolver\xE1 un diccionario conteniendo:"),wo=m(),sa=l("ul"),ot=l("li"),rt=l("a"),kl=r("input_ids"),jl=r(": representaciones num\xE9ricas de los tokens."),wl=m(),nt=l("li"),lt=l("a"),yl=r("atttention_mask"),ql=r(": indica cu\xE1les tokens deben ser atendidos."),yo=m(),oa=l("p"),Al=r("Como con el "),ms=l("code"),Tl=r("pipeline()"),Cl=r(", el tokenizador aceptar\xE1 una lista de inputs. Adem\xE1s, el tokenizador tambi\xE9n puede rellenar (pad, en ingl\xE9s) y truncar el texto para devolver un lote (batch, en ingl\xE9s) de longitud uniforme:"),qo=m(),b(ra.$$.fragment),Ao=m(),na=l("p"),zl=r("Lee el tutorial de "),it=l("a"),xl=r("preprocessing"),Pl=r(" para m\xE1s detalles acerca de la tokenizaci\xF3n."),To=m(),Fe=l("h3"),la=l("a"),$s=l("span"),b(Ha.$$.fragment),Ol=m(),hs=l("span"),Sl=r("AutoModel"),Co=m(),b(ia.$$.fragment),zo=m(),b(pa.$$.fragment),xo=m(),X=l("p"),Dl=r("Los modelos son "),Ra=l("a"),_s=l("code"),Ml=r("torch.nn.Module"),Fl=r(" o "),Wa=l("a"),gs=l("code"),Il=r("tf.keras.Model"),Nl=r(" est\xE1ndares as\xED que podr\xE1s usarlos en tu training loop usual. Sin embargo, para facilitar las cosas, \u{1F917} Transformers provee una clase "),vs=l("code"),Ll=r("Trainer"),Ul=r(" para PyTorch que a\xF1ade funcionalidades para entrenamiento distribuido, precici\xF3n mixta, y m\xE1s. Para TensorFlow, puedes usar el m\xE9todo "),bs=l("code"),Hl=r("fit"),Rl=r(" desde "),Ga=l("a"),Wl=r("Keras"),Gl=r(". Consulta el "),pt=l("a"),Vl=r("tutorial de entrenamiento"),Yl=r(" para m\xE1s detalles."),Po=m(),b(ua.$$.fragment),Oo=m(),Ie=l("h3"),ca=l("a"),Es=l("span"),b(Va.$$.fragment),Bl=m(),ks=l("span"),Jl=r("Guarda un modelo"),So=m(),b(da.$$.fragment),Do=m(),Ce=l("p"),Ql=r("Una caracter\xEDstica particularmente cool de \u{1F917} Transformers es la habilidad de guardar el modelo y cargarlo como un modelo de PyTorch o TensorFlow. El par\xE1metro "),js=l("code"),Kl=r("from_pt"),Zl=r(" o "),ws=l("code"),Xl=r("from_tf"),ei=r(" puede convertir el modelo de un framework al otro:"),Mo=m(),b(fa.$$.fragment),this.h()},l(e){const u=Vp('[data-svelte="svelte-1phssyn"]',document.head);s=i(u,"META",{name:!0,content:!0}),u.forEach(t),d=$(e),o=i(e,"H1",{class:!0});var Ya=p(o);f=i(Ya,"A",{id:!0,class:!0,href:!0});var ys=p(f);h=i(ys,"SPAN",{});var qs=p(h);E(g.$$.fragment,qs),qs.forEach(t),ys.forEach(t),C=$(Ya),D=i(Ya,"SPAN",{});var As=p(D);x=n(As,"Quick tour"),As.forEach(t),Ya.forEach(t),P=$(e),E(M.$$.fragment,e),T=$(e),S=i(e,"P",{});var Ne=p(S);R=n(Ne,"\xA1Entra en marcha con los \u{1F917} Transformers! Comienza usando "),I=i(Ne,"CODE",{});var Ts=p(I);U=n(Ts,"pipeline()"),Ts.forEach(t),_=n(Ne," para una inferencia veloz, carga un modelo preentrenado y un tokenizador con una "),O=i(Ne,"A",{href:!0});var Cs=p(O);V=n(Cs,"AutoClass"),Cs.forEach(t),H=n(Ne," para resolver tu tarea de texto, visi\xF3n o audio."),Ne.forEach(t),B=$(e),E(Y.$$.fragment,e),ae=$(e),J=i(e,"H2",{class:!0});var Ba=p(J);W=i(Ba,"A",{id:!0,class:!0,href:!0});var zs=p(W);ee=i(zs,"SPAN",{});var xs=p(ee);E(Q.$$.fragment,xs),xs.forEach(t),zs.forEach(t),K=$(Ba),fe=i(Ba,"SPAN",{});var li=p(fe);oe=n(li,"Pipeline"),li.forEach(t),Ba.forEach(t),$e=$(e),re=i(e,"P",{});var ai=p(re);te=i(ai,"CODE",{});var ii=p(te);ne=n(ii,"pipeline()"),ii.forEach(t),he=n(ai," es la forma m\xE1s f\xE1cil de usar un modelo preentrenado para una tarea dada."),ai.forEach(t),A=$(e),E(F.$$.fragment,e),le=$(e),v=i(e,"P",{});var Io=p(v);N=n(Io,"El "),pe=i(Io,"CODE",{});var pi=p(pe);Pe=n(pi,"pipeline()"),pi.forEach(t),me=n(Io," soporta muchas tareas comunes listas para usar:"),Io.forEach(t),ve=$(e),ie=i(e,"P",{});var ti=p(ie);Le=i(ti,"STRONG",{});var ui=p(Le);be=n(ui,"Texto"),ui.forEach(t),Ja=n(ti,":"),ti.forEach(t),ha=$(e),G=i(e,"UL",{});var se=p(G);Et=i(se,"LI",{});var ci=p(Et);sr=n(ci,"An\xE1lisis de Sentimientos: clasifica la polaridad de un texto dado."),ci.forEach(t),or=$(se),kt=i(se,"LI",{});var di=p(kt);rr=n(di,"Generaci\xF3n de texto (solo en ingl\xE9s): genera texto a partir de un input dado."),di.forEach(t),nr=$(se),jt=i(se,"LI",{});var fi=p(jt);lr=n(fi,"Name entity recognition (NER): etiqueta cada palabra con la entidad que representa (persona, fecha, ubicaci\xF3n, etc.)."),fi.forEach(t),ir=$(se),wt=i(se,"LI",{});var mi=p(wt);pr=n(mi,"Responder preguntas: extrae la respuesta del contexto dado un contexto y una pregunta."),mi.forEach(t),ur=$(se),yt=i(se,"LI",{});var $i=p(yt);cr=n($i,"Fill-mask: rellena el espacio faltante dado un texto con palabras enmascaradas."),$i.forEach(t),dr=$(se),qt=i(se,"LI",{});var hi=p(qt);fr=n(hi,"Summarization: genera un resumen de una secuencia larga de texto o un documento."),hi.forEach(t),mr=$(se),At=i(se,"LI",{});var _i=p(At);$r=n(_i,"Traducci\xF3n: traduce un texto a otro idioma."),_i.forEach(t),hr=$(se),Tt=i(se,"LI",{});var gi=p(Tt);_r=n(gi,"Extracci\xF3n de caracter\xEDsticas: crea una representaci\xF3n tensorial del texto."),gi.forEach(t),se.forEach(t),Ps=$(e),_a=i(e,"P",{});var si=p(_a);Ct=i(si,"STRONG",{});var vi=p(Ct);gr=n(vi,"Imagen"),vi.forEach(t),vr=n(si,":"),si.forEach(t),Os=$(e),Ee=i(e,"UL",{});var ut=p(Ee);zt=i(ut,"LI",{});var bi=p(zt);br=n(bi,"Clasificaci\xF3n de im\xE1genes: clasifica una imagen."),bi.forEach(t),Er=$(ut),xt=i(ut,"LI",{});var Ei=p(xt);kr=n(Ei,"Segmentaci\xF3n de im\xE1genes: clasifica cada pixel de una imagen."),Ei.forEach(t),jr=$(ut),Pt=i(ut,"LI",{});var ki=p(Pt);wr=n(ki,"Detecci\xF3n de objetos: detecta objetos dentro de una imagen."),ki.forEach(t),ut.forEach(t),Ss=$(e),ga=i(e,"P",{});var oi=p(ga);Ot=i(oi,"STRONG",{});var ji=p(Ot);yr=n(ji,"Audio"),ji.forEach(t),qr=n(oi,":"),oi.forEach(t),Ds=$(e),Ue=i(e,"UL",{});var No=p(Ue);St=i(No,"LI",{});var wi=p(St);Ar=n(wi,"Clasificaci\xF3n de audios: asigna una etiqueta a un segmento de audio."),wi.forEach(t),Tr=$(No),Dt=i(No,"LI",{});var yi=p(Dt);Cr=n(yi,"Automatic speech recognition (ASR): transcribe datos de audio a un texto."),yi.forEach(t),No.forEach(t),Ms=$(e),E(He.$$.fragment,e),Fs=$(e),Oe=i(e,"H3",{class:!0});var Lo=p(Oe);Re=i(Lo,"A",{id:!0,class:!0,href:!0});var qi=p(Re);Mt=i(qi,"SPAN",{});var Ai=p(Mt);E(va.$$.fragment,Ai),Ai.forEach(t),qi.forEach(t),zr=$(Lo),Ft=i(Lo,"SPAN",{});var Ti=p(Ft);xr=n(Ti,"Uso del Pipeline"),Ti.forEach(t),Lo.forEach(t),Is=$(e),We=i(e,"P",{});var Uo=p(We);Pr=n(Uo,"En el siguiente ejemplo, usar\xE1s el "),It=i(Uo,"CODE",{});var Ci=p(It);Or=n(Ci,"pipeline()"),Ci.forEach(t),Sr=n(Uo," para an\xE1lisis de sentimiento."),Uo.forEach(t),Ns=$(e),Qa=i(e,"P",{});var zi=p(Qa);Dr=n(zi,"Instala las siguientes dependencias si a\xFAn no lo has hecho:"),zi.forEach(t),Ls=$(e),E(Ge.$$.fragment,e),Us=$(e),Ve=i(e,"P",{});var Ho=p(Ve);Mr=n(Ho,"Importa "),Nt=i(Ho,"CODE",{});var xi=p(Nt);Fr=n(xi,"pipeline()"),xi.forEach(t),Ir=n(Ho," y especifica la tarea que deseas completar:"),Ho.forEach(t),Hs=$(e),E(ba.$$.fragment,e),Rs=$(e),ke=i(e,"P",{});var ct=p(ke);Nr=n(ct,"El pipeline descarga y almacena en cach\xE9 un "),Ea=i(ct,"A",{href:!0,rel:!0});var Pi=p(Ea);Lr=n(Pi,"modelo preentrenado"),Pi.forEach(t),Ur=n(ct," por defecto y tokeniza para an\xE1lisis de sentimiento. Ahora puedes usar "),Lt=i(ct,"CODE",{});var Oi=p(Lt);Hr=n(Oi,"classifier"),Oi.forEach(t),Rr=n(ct," en tu texto objetivo:"),ct.forEach(t),Ws=$(e),E(ka.$$.fragment,e),Gs=$(e),Ye=i(e,"P",{});var Ro=p(Ye);Wr=n(Ro,"Para m\xE1s de un enunciado entrega una lista de frases al "),Ut=i(Ro,"CODE",{});var Si=p(Ut);Gr=n(Si,"pipeline()"),Si.forEach(t),Vr=n(Ro," que devolver\xE1 una lista de diccionarios:"),Ro.forEach(t),Vs=$(e),E(ja.$$.fragment,e),Ys=$(e),je=i(e,"P",{});var dt=p(je);Yr=n(dt,"El "),Ht=i(dt,"CODE",{});var Di=p(Ht);Br=n(Di,"pipeline()"),Di.forEach(t),Jr=n(dt," tambi\xE9n puede iterar sobre un dataset entero. Comienza instalando la biblioteca "),wa=i(dt,"A",{href:!0,rel:!0});var Mi=p(wa);Qr=n(Mi,"\u{1F917} Datasets"),Mi.forEach(t),Kr=n(dt,":"),dt.forEach(t),Bs=$(e),E(ya.$$.fragment,e),Js=$(e),_e=i(e,"P",{});var ma=p(_e);Zr=n(ma,"Crea un "),Rt=i(ma,"CODE",{});var Fi=p(Rt);Xr=n(Fi,"pipeline()"),Fi.forEach(t),en=n(ma," con la tarea que deseas resolver y el modelo que quieres usar. Coloca el par\xE1metro "),Wt=i(ma,"CODE",{});var Ii=p(Wt);an=n(Ii,"device"),Ii.forEach(t),tn=n(ma," a "),Gt=i(ma,"CODE",{});var Ni=p(Gt);sn=n(Ni,"0"),Ni.forEach(t),on=n(ma," para poner los tensores en un dispositivo CUDA:"),ma.forEach(t),Qs=$(e),E(qa.$$.fragment,e),Ks=$(e),we=i(e,"P",{});var ft=p(we);rn=n(ft,"A continuaci\xF3n, carga el dataset (ve \u{1F917} Datasets "),Aa=i(ft,"A",{href:!0,rel:!0});var Li=p(Aa);nn=n(Li,"Quick Start"),Li.forEach(t),ln=n(ft," para m\xE1s detalles) sobre el que quisieras iterar. Por ejemplo, vamos a cargar el dataset "),Ta=i(ft,"A",{href:!0,rel:!0});var Ui=p(Ta);pn=n(Ui,"MInDS-14"),Ui.forEach(t),un=n(ft,":"),ft.forEach(t),Zs=$(e),E(Ca.$$.fragment,e),Xs=$(e),Be=i(e,"P",{});var Wo=p(Be);cn=n(Wo,"Debemos asegurarnos de que la frecuencia de muestreo del conjunto de datos coincide con la frecuencia de muestreo con la que se entren\xF3 "),Vt=i(Wo,"CODE",{});var Hi=p(Vt);dn=n(Hi,"facebook/wav2vec2-base-960h"),Hi.forEach(t),fn=n(Wo,"."),Wo.forEach(t),eo=$(e),E(za.$$.fragment,e),ao=$(e),Je=i(e,"P",{});var Go=p(Je);mn=n(Go,"Los archivos de audio se cargan y remuestrean autom\xE1ticamente cuando se llama a la columna "),Yt=i(Go,"CODE",{});var Ri=p(Yt);$n=n(Ri,'"audio"'),Ri.forEach(t),hn=n(Go,`.
Extraigamos las matrices de forma de onda cruda de las primeras 4 muestras y pas\xE9mosla como una lista al pipeline:`),Go.forEach(t),to=$(e),E(xa.$$.fragment,e),so=$(e),Qe=i(e,"P",{});var Vo=p(Qe);_n=n(Vo,"Para un dataset m\xE1s grande, donde los inputs son de mayor tama\xF1o (como en habla/audio o visi\xF3n), querr\xE1s pasar un generador en lugar de una lista que carga todos los inputs en memoria. Ve la "),Ka=i(Vo,"A",{href:!0});var Wi=p(Ka);gn=n(Wi,"documentaci\xF3n del pipeline"),Wi.forEach(t),vn=n(Vo," para m\xE1s informaci\xF3n."),Vo.forEach(t),oo=$(e),Se=i(e,"H3",{class:!0});var Yo=p(Se);Ke=i(Yo,"A",{id:!0,class:!0,href:!0});var Gi=p(Ke);Bt=i(Gi,"SPAN",{});var Vi=p(Bt);E(Pa.$$.fragment,Vi),Vi.forEach(t),Gi.forEach(t),bn=$(Yo),Jt=i(Yo,"SPAN",{});var Yi=p(Jt);En=n(Yi,"Use otro modelo y otro tokenizador en el pipeline"),Yi.forEach(t),Yo.forEach(t),ro=$(e),ue=i(e,"P",{});var ze=p(ue);kn=n(ze,"El "),Qt=i(ze,"CODE",{});var Bi=p(Qt);jn=n(Bi,"pipeline()"),Bi.forEach(t),wn=n(ze," puede adaptarse a cualquier modelo del "),Oa=i(ze,"A",{href:!0,rel:!0});var Ji=p(Oa);yn=n(Ji,"Model Hub"),Ji.forEach(t),qn=n(ze," haciendo m\xE1s f\xE1cil adaptar el "),Kt=i(ze,"CODE",{});var Qi=p(Kt);An=n(Qi,"pipeline()"),Qi.forEach(t),Tn=n(ze," para otros casos de uso. Por ejemplo, si quisieras un modelo capaz de manejar texto en franc\xE9s, usa los tags en el Model Hub para filtrar entre los modelos apropiados. El resultado mejor filtrado devuelve un "),Sa=i(ze,"A",{href:!0,rel:!0});var Ki=p(Sa);Cn=n(Ki,"modelo BERT"),Ki.forEach(t),zn=n(ze," multilingual fine-tuned para el an\xE1lisis de sentimiento. Genial, \xA1vamos a usar este modelo!"),ze.forEach(t),no=$(e),E(Da.$$.fragment,e),lo=$(e),E(Ze.$$.fragment,e),io=$(e),ye=i(e,"P",{});var mt=p(ye);xn=n(mt,"Despu\xE9s puedes especificar el modelo y el tokenizador en el "),Zt=i(mt,"CODE",{});var Zi=p(Zt);Pn=n(Zi,"pipeline()"),Zi.forEach(t),On=n(mt,", y aplicar el "),Xt=i(mt,"CODE",{});var Xi=p(Xt);Sn=n(Xi,"classifier"),Xi.forEach(t),Dn=n(mt," en tu texto objetivo:"),mt.forEach(t),po=$(e),E(Ma.$$.fragment,e),uo=$(e),qe=i(e,"P",{});var $t=p(qe);Mn=n($t,"Si no pudieras encontrar el modelo para tu caso respectivo de uso necesitar\xE1s ajustar un modelo preentrenado a tus datos. Mira nuestro "),Za=i($t,"A",{href:!0});var ep=p(Za);Fn=n(ep,"tutorial de fine-tuning"),ep.forEach(t),In=n($t," para aprender c\xF3mo. Finalmente, despu\xE9s de que has ajustado tu modelo preentrenado, \xA1por favor considera compartirlo (ve el tutorial "),Xa=i($t,"A",{href:!0});var ap=p(Xa);Nn=n(ap,"aqu\xED"),ap.forEach(t),Ln=n($t,") con la comunidad en el Model Hub para democratizar el NLP! \u{1F917}"),$t.forEach(t),co=$(e),De=i(e,"H2",{class:!0});var Bo=p(De);Xe=i(Bo,"A",{id:!0,class:!0,href:!0});var tp=p(Xe);es=i(tp,"SPAN",{});var sp=p(es);E(Fa.$$.fragment,sp),sp.forEach(t),tp.forEach(t),Un=$(Bo),as=i(Bo,"SPAN",{});var op=p(as);Hn=n(op,"AutoClass"),op.forEach(t),Bo.forEach(t),fo=$(e),E(Ia.$$.fragment,e),mo=$(e),Z=i(e,"P",{});var ce=p(Z);Rn=n(ce,"Debajo del cap\xF3, las clases "),ts=i(ce,"CODE",{});var rp=p(ts);Wn=n(rp,"AutoModelForSequenceClassification"),rp.forEach(t),Gn=n(ce," y "),ss=i(ce,"CODE",{});var np=p(ss);Vn=n(np,"AutoTokenizer"),np.forEach(t),Yn=n(ce," trabajan juntas para dar poder al "),os=i(ce,"CODE",{});var lp=p(os);Bn=n(lp,"pipeline()"),lp.forEach(t),Jn=n(ce,". Una "),et=i(ce,"A",{href:!0});var ip=p(et);Qn=n(ip,"AutoClass"),ip.forEach(t),Kn=n(ce," es un atajo que autom\xE1ticamente recupera la arquitectura de un modelo preentrenado con su nombre o el path. S\xF3lo necesitar\xE1s seleccionar el "),rs=i(ce,"CODE",{});var pp=p(rs);Zn=n(pp,"AutoClass"),pp.forEach(t),Xn=n(ce," apropiado para tu tarea y tu tokenizador asociado con "),ns=i(ce,"CODE",{});var up=p(ns);el=n(up,"AutoTokenizer"),up.forEach(t),al=n(ce,"."),ce.forEach(t),$o=$(e),Ae=i(e,"P",{});var ht=p(Ae);tl=n(ht,"Regresemos a nuestro ejemplo y veamos c\xF3mo puedes usar el "),ls=i(ht,"CODE",{});var cp=p(ls);sl=n(cp,"AutoClass"),cp.forEach(t),ol=n(ht," para reproducir los resultados del "),is=i(ht,"CODE",{});var dp=p(is);rl=n(dp,"pipeline()"),dp.forEach(t),nl=n(ht,"."),ht.forEach(t),ho=$(e),Me=i(e,"H3",{class:!0});var Jo=p(Me);ea=i(Jo,"A",{id:!0,class:!0,href:!0});var fp=p(ea);ps=i(fp,"SPAN",{});var mp=p(ps);E(Na.$$.fragment,mp),mp.forEach(t),fp.forEach(t),ll=$(Jo),us=i(Jo,"SPAN",{});var $p=p(us);il=n($p,"AutoTokenizer"),$p.forEach(t),Jo.forEach(t),_o=$(e),Te=i(e,"P",{});var _t=p(Te);pl=n(_t,"Un tokenizador es responsable de procesar el texto a un formato que sea entendible para el modelo. Primero, el tokenizador separar\xE1 el texto en palabras llamadas "),cs=i(_t,"EM",{});var hp=p(cs);ul=n(hp,"tokens"),hp.forEach(t),cl=n(_t,". Hay m\xFAltiples reglas que gobiernan el proceso de tokenizaci\xF3n incluyendo el c\xF3mo separar una palabra y en qu\xE9 nivel (aprende m\xE1s sobre tokenizaci\xF3n "),at=i(_t,"A",{href:!0});var _p=p(at);dl=n(_p,"aqu\xED"),_p.forEach(t),fl=n(_t,"). Lo m\xE1s importante es recordar que necesitar\xE1s instanciar el tokenizador con el mismo nombre del modelo para asegurar que est\xE1s usando las mismas reglas de tokenizaci\xF3n con las que el modelo fue preentrenado."),_t.forEach(t),go=$(e),aa=i(e,"P",{});var Qo=p(aa);ml=n(Qo,"Carga un tokenizador con "),ds=i(Qo,"CODE",{});var gp=p(ds);$l=n(gp,"AutoTokenizer"),gp.forEach(t),hl=n(Qo,":"),Qo.forEach(t),vo=$(e),E(La.$$.fragment,e),bo=$(e),ta=i(e,"P",{});var Ko=p(ta);_l=n(Ko,"Despu\xE9s, el tokenizador convierte los tokens a n\xFAmeros para construir un tensor que servir\xE1 como input para el modelo. Esto es conocido como el "),fs=i(Ko,"EM",{});var vp=p(fs);gl=n(vp,"vocabulario"),vp.forEach(t),vl=n(Ko," del modelo."),Ko.forEach(t),Eo=$(e),tt=i(e,"P",{});var bp=p(tt);bl=n(bp,"Pasa tu texto al tokenizador:"),bp.forEach(t),ko=$(e),E(Ua.$$.fragment,e),jo=$(e),st=i(e,"P",{});var Ep=p(st);El=n(Ep,"El tokenizador devolver\xE1 un diccionario conteniendo:"),Ep.forEach(t),wo=$(e),sa=i(e,"UL",{});var Zo=p(sa);ot=i(Zo,"LI",{});var ri=p(ot);rt=i(ri,"A",{href:!0});var kp=p(rt);kl=n(kp,"input_ids"),kp.forEach(t),jl=n(ri,": representaciones num\xE9ricas de los tokens."),ri.forEach(t),wl=$(Zo),nt=i(Zo,"LI",{});var ni=p(nt);lt=i(ni,"A",{href:!0});var jp=p(lt);yl=n(jp,"atttention_mask"),jp.forEach(t),ql=n(ni,": indica cu\xE1les tokens deben ser atendidos."),ni.forEach(t),Zo.forEach(t),yo=$(e),oa=i(e,"P",{});var Xo=p(oa);Al=n(Xo,"Como con el "),ms=i(Xo,"CODE",{});var wp=p(ms);Tl=n(wp,"pipeline()"),wp.forEach(t),Cl=n(Xo,", el tokenizador aceptar\xE1 una lista de inputs. Adem\xE1s, el tokenizador tambi\xE9n puede rellenar (pad, en ingl\xE9s) y truncar el texto para devolver un lote (batch, en ingl\xE9s) de longitud uniforme:"),Xo.forEach(t),qo=$(e),E(ra.$$.fragment,e),Ao=$(e),na=i(e,"P",{});var er=p(na);zl=n(er,"Lee el tutorial de "),it=i(er,"A",{href:!0});var yp=p(it);xl=n(yp,"preprocessing"),yp.forEach(t),Pl=n(er," para m\xE1s detalles acerca de la tokenizaci\xF3n."),er.forEach(t),To=$(e),Fe=i(e,"H3",{class:!0});var ar=p(Fe);la=i(ar,"A",{id:!0,class:!0,href:!0});var qp=p(la);$s=i(qp,"SPAN",{});var Ap=p($s);E(Ha.$$.fragment,Ap),Ap.forEach(t),qp.forEach(t),Ol=$(ar),hs=i(ar,"SPAN",{});var Tp=p(hs);Sl=n(Tp,"AutoModel"),Tp.forEach(t),ar.forEach(t),Co=$(e),E(ia.$$.fragment,e),zo=$(e),E(pa.$$.fragment,e),xo=$(e),X=i(e,"P",{});var de=p(X);Dl=n(de,"Los modelos son "),Ra=i(de,"A",{href:!0,rel:!0});var Cp=p(Ra);_s=i(Cp,"CODE",{});var zp=p(_s);Ml=n(zp,"torch.nn.Module"),zp.forEach(t),Cp.forEach(t),Fl=n(de," o "),Wa=i(de,"A",{href:!0,rel:!0});var xp=p(Wa);gs=i(xp,"CODE",{});var Pp=p(gs);Il=n(Pp,"tf.keras.Model"),Pp.forEach(t),xp.forEach(t),Nl=n(de," est\xE1ndares as\xED que podr\xE1s usarlos en tu training loop usual. Sin embargo, para facilitar las cosas, \u{1F917} Transformers provee una clase "),vs=i(de,"CODE",{});var Op=p(vs);Ll=n(Op,"Trainer"),Op.forEach(t),Ul=n(de," para PyTorch que a\xF1ade funcionalidades para entrenamiento distribuido, precici\xF3n mixta, y m\xE1s. Para TensorFlow, puedes usar el m\xE9todo "),bs=i(de,"CODE",{});var Sp=p(bs);Hl=n(Sp,"fit"),Sp.forEach(t),Rl=n(de," desde "),Ga=i(de,"A",{href:!0,rel:!0});var Dp=p(Ga);Wl=n(Dp,"Keras"),Dp.forEach(t),Gl=n(de,". Consulta el "),pt=i(de,"A",{href:!0});var Mp=p(pt);Vl=n(Mp,"tutorial de entrenamiento"),Mp.forEach(t),Yl=n(de," para m\xE1s detalles."),de.forEach(t),Po=$(e),E(ua.$$.fragment,e),Oo=$(e),Ie=i(e,"H3",{class:!0});var tr=p(Ie);ca=i(tr,"A",{id:!0,class:!0,href:!0});var Fp=p(ca);Es=i(Fp,"SPAN",{});var Ip=p(Es);E(Va.$$.fragment,Ip),Ip.forEach(t),Fp.forEach(t),Bl=$(tr),ks=i(tr,"SPAN",{});var Np=p(ks);Jl=n(Np,"Guarda un modelo"),Np.forEach(t),tr.forEach(t),So=$(e),E(da.$$.fragment,e),Do=$(e),Ce=i(e,"P",{});var gt=p(Ce);Ql=n(gt,"Una caracter\xEDstica particularmente cool de \u{1F917} Transformers es la habilidad de guardar el modelo y cargarlo como un modelo de PyTorch o TensorFlow. El par\xE1metro "),js=i(gt,"CODE",{});var Lp=p(js);Kl=n(Lp,"from_pt"),Lp.forEach(t),Zl=n(gt," o "),ws=i(gt,"CODE",{});var Up=p(ws);Xl=n(Up,"from_tf"),Up.forEach(t),ei=n(gt," puede convertir el modelo de un framework al otro:"),gt.forEach(t),Mo=$(e),E(fa.$$.fragment,e),this.h()},h(){q(s,"name","hf:doc:metadata"),q(s,"content",JSON.stringify(qu)),q(f,"id","quick-tour"),q(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"),q(f,"href","#quick-tour"),q(o,"class","relative group"),q(O,"href","./model_doc/auto"),q(W,"id","pipeline"),q(W,"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"),q(W,"href","#pipeline"),q(J,"class","relative group"),q(Re,"id","uso-del-pipeline"),q(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"),q(Re,"href","#uso-del-pipeline"),q(Oe,"class","relative group"),q(Ea,"href","https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english"),q(Ea,"rel","nofollow"),q(wa,"href","https://huggingface.co/docs/datasets/"),q(wa,"rel","nofollow"),q(Aa,"href","https://huggingface.co/docs/datasets/quickstart.html"),q(Aa,"rel","nofollow"),q(Ta,"href","https://huggingface.co/datasets/PolyAI/minds14"),q(Ta,"rel","nofollow"),q(Ka,"href","./main_classes/pipelines"),q(Ke,"id","use-otro-modelo-y-otro-tokenizador-en-el-pipeline"),q(Ke,"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"),q(Ke,"href","#use-otro-modelo-y-otro-tokenizador-en-el-pipeline"),q(Se,"class","relative group"),q(Oa,"href","https://huggingface.co/models"),q(Oa,"rel","nofollow"),q(Sa,"href","https://huggingface.co/nlptown/bert-base-multilingual-uncased-sentiment"),q(Sa,"rel","nofollow"),q(Za,"href","./training"),q(Xa,"href","./model_sharing"),q(Xe,"id","autoclass"),q(Xe,"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"),q(Xe,"href","#autoclass"),q(De,"class","relative group"),q(et,"href","./model_doc/auto"),q(ea,"id","autotokenizer"),q(ea,"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"),q(ea,"href","#autotokenizer"),q(Me,"class","relative group"),q(at,"href","./tokenizer_summary"),q(rt,"href","./glossary#input-ids"),q(lt,"href",".glossary#attention-mask"),q(it,"href","./preprocessing"),q(la,"id","automodel"),q(la,"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"),q(la,"href","#automodel"),q(Fe,"class","relative group"),q(Ra,"href","https://pytorch.org/docs/stable/nn.html#torch.nn.Module"),q(Ra,"rel","nofollow"),q(Wa,"href","https://www.tensorflow.org/api_docs/python/tf/keras/Model"),q(Wa,"rel","nofollow"),q(Ga,"href","https://keras.io/"),q(Ga,"rel","nofollow"),q(pt,"href","./training"),q(ca,"id","guarda-un-modelo"),q(ca,"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"),q(ca,"href","#guarda-un-modelo"),q(Ie,"class","relative group")},m(e,u){a(document.head,s),c(e,d,u),c(e,o,u),a(o,f),a(f,h),k(g,h,null),a(o,C),a(o,D),a(D,x),c(e,P,u),k(M,e,u),c(e,T,u),c(e,S,u),a(S,R),a(S,I),a(I,U),a(S,_),a(S,O),a(O,V),a(S,H),c(e,B,u),k(Y,e,u),c(e,ae,u),c(e,J,u),a(J,W),a(W,ee),k(Q,ee,null),a(J,K),a(J,fe),a(fe,oe),c(e,$e,u),c(e,re,u),a(re,te),a(te,ne),a(re,he),c(e,A,u),k(F,e,u),c(e,le,u),c(e,v,u),a(v,N),a(v,pe),a(pe,Pe),a(v,me),c(e,ve,u),c(e,ie,u),a(ie,Le),a(Le,be),a(ie,Ja),c(e,ha,u),c(e,G,u),a(G,Et),a(Et,sr),a(G,or),a(G,kt),a(kt,rr),a(G,nr),a(G,jt),a(jt,lr),a(G,ir),a(G,wt),a(wt,pr),a(G,ur),a(G,yt),a(yt,cr),a(G,dr),a(G,qt),a(qt,fr),a(G,mr),a(G,At),a(At,$r),a(G,hr),a(G,Tt),a(Tt,_r),c(e,Ps,u),c(e,_a,u),a(_a,Ct),a(Ct,gr),a(_a,vr),c(e,Os,u),c(e,Ee,u),a(Ee,zt),a(zt,br),a(Ee,Er),a(Ee,xt),a(xt,kr),a(Ee,jr),a(Ee,Pt),a(Pt,wr),c(e,Ss,u),c(e,ga,u),a(ga,Ot),a(Ot,yr),a(ga,qr),c(e,Ds,u),c(e,Ue,u),a(Ue,St),a(St,Ar),a(Ue,Tr),a(Ue,Dt),a(Dt,Cr),c(e,Ms,u),k(He,e,u),c(e,Fs,u),c(e,Oe,u),a(Oe,Re),a(Re,Mt),k(va,Mt,null),a(Oe,zr),a(Oe,Ft),a(Ft,xr),c(e,Is,u),c(e,We,u),a(We,Pr),a(We,It),a(It,Or),a(We,Sr),c(e,Ns,u),c(e,Qa,u),a(Qa,Dr),c(e,Ls,u),k(Ge,e,u),c(e,Us,u),c(e,Ve,u),a(Ve,Mr),a(Ve,Nt),a(Nt,Fr),a(Ve,Ir),c(e,Hs,u),k(ba,e,u),c(e,Rs,u),c(e,ke,u),a(ke,Nr),a(ke,Ea),a(Ea,Lr),a(ke,Ur),a(ke,Lt),a(Lt,Hr),a(ke,Rr),c(e,Ws,u),k(ka,e,u),c(e,Gs,u),c(e,Ye,u),a(Ye,Wr),a(Ye,Ut),a(Ut,Gr),a(Ye,Vr),c(e,Vs,u),k(ja,e,u),c(e,Ys,u),c(e,je,u),a(je,Yr),a(je,Ht),a(Ht,Br),a(je,Jr),a(je,wa),a(wa,Qr),a(je,Kr),c(e,Bs,u),k(ya,e,u),c(e,Js,u),c(e,_e,u),a(_e,Zr),a(_e,Rt),a(Rt,Xr),a(_e,en),a(_e,Wt),a(Wt,an),a(_e,tn),a(_e,Gt),a(Gt,sn),a(_e,on),c(e,Qs,u),k(qa,e,u),c(e,Ks,u),c(e,we,u),a(we,rn),a(we,Aa),a(Aa,nn),a(we,ln),a(we,Ta),a(Ta,pn),a(we,un),c(e,Zs,u),k(Ca,e,u),c(e,Xs,u),c(e,Be,u),a(Be,cn),a(Be,Vt),a(Vt,dn),a(Be,fn),c(e,eo,u),k(za,e,u),c(e,ao,u),c(e,Je,u),a(Je,mn),a(Je,Yt),a(Yt,$n),a(Je,hn),c(e,to,u),k(xa,e,u),c(e,so,u),c(e,Qe,u),a(Qe,_n),a(Qe,Ka),a(Ka,gn),a(Qe,vn),c(e,oo,u),c(e,Se,u),a(Se,Ke),a(Ke,Bt),k(Pa,Bt,null),a(Se,bn),a(Se,Jt),a(Jt,En),c(e,ro,u),c(e,ue,u),a(ue,kn),a(ue,Qt),a(Qt,jn),a(ue,wn),a(ue,Oa),a(Oa,yn),a(ue,qn),a(ue,Kt),a(Kt,An),a(ue,Tn),a(ue,Sa),a(Sa,Cn),a(ue,zn),c(e,no,u),k(Da,e,u),c(e,lo,u),k(Ze,e,u),c(e,io,u),c(e,ye,u),a(ye,xn),a(ye,Zt),a(Zt,Pn),a(ye,On),a(ye,Xt),a(Xt,Sn),a(ye,Dn),c(e,po,u),k(Ma,e,u),c(e,uo,u),c(e,qe,u),a(qe,Mn),a(qe,Za),a(Za,Fn),a(qe,In),a(qe,Xa),a(Xa,Nn),a(qe,Ln),c(e,co,u),c(e,De,u),a(De,Xe),a(Xe,es),k(Fa,es,null),a(De,Un),a(De,as),a(as,Hn),c(e,fo,u),k(Ia,e,u),c(e,mo,u),c(e,Z,u),a(Z,Rn),a(Z,ts),a(ts,Wn),a(Z,Gn),a(Z,ss),a(ss,Vn),a(Z,Yn),a(Z,os),a(os,Bn),a(Z,Jn),a(Z,et),a(et,Qn),a(Z,Kn),a(Z,rs),a(rs,Zn),a(Z,Xn),a(Z,ns),a(ns,el),a(Z,al),c(e,$o,u),c(e,Ae,u),a(Ae,tl),a(Ae,ls),a(ls,sl),a(Ae,ol),a(Ae,is),a(is,rl),a(Ae,nl),c(e,ho,u),c(e,Me,u),a(Me,ea),a(ea,ps),k(Na,ps,null),a(Me,ll),a(Me,us),a(us,il),c(e,_o,u),c(e,Te,u),a(Te,pl),a(Te,cs),a(cs,ul),a(Te,cl),a(Te,at),a(at,dl),a(Te,fl),c(e,go,u),c(e,aa,u),a(aa,ml),a(aa,ds),a(ds,$l),a(aa,hl),c(e,vo,u),k(La,e,u),c(e,bo,u),c(e,ta,u),a(ta,_l),a(ta,fs),a(fs,gl),a(ta,vl),c(e,Eo,u),c(e,tt,u),a(tt,bl),c(e,ko,u),k(Ua,e,u),c(e,jo,u),c(e,st,u),a(st,El),c(e,wo,u),c(e,sa,u),a(sa,ot),a(ot,rt),a(rt,kl),a(ot,jl),a(sa,wl),a(sa,nt),a(nt,lt),a(lt,yl),a(nt,ql),c(e,yo,u),c(e,oa,u),a(oa,Al),a(oa,ms),a(ms,Tl),a(oa,Cl),c(e,qo,u),k(ra,e,u),c(e,Ao,u),c(e,na,u),a(na,zl),a(na,it),a(it,xl),a(na,Pl),c(e,To,u),c(e,Fe,u),a(Fe,la),a(la,$s),k(Ha,$s,null),a(Fe,Ol),a(Fe,hs),a(hs,Sl),c(e,Co,u),k(ia,e,u),c(e,zo,u),k(pa,e,u),c(e,xo,u),c(e,X,u),a(X,Dl),a(X,Ra),a(Ra,_s),a(_s,Ml),a(X,Fl),a(X,Wa),a(Wa,gs),a(gs,Il),a(X,Nl),a(X,vs),a(vs,Ll),a(X,Ul),a(X,bs),a(bs,Hl),a(X,Rl),a(X,Ga),a(Ga,Wl),a(X,Gl),a(X,pt),a(pt,Vl),a(X,Yl),c(e,Po,u),k(ua,e,u),c(e,Oo,u),c(e,Ie,u),a(Ie,ca),a(ca,Es),k(Va,Es,null),a(Ie,Bl),a(Ie,ks),a(ks,Jl),c(e,So,u),k(da,e,u),c(e,Do,u),c(e,Ce,u),a(Ce,Ql),a(Ce,js),a(js,Kl),a(Ce,Zl),a(Ce,ws),a(ws,Xl),a(Ce,ei),c(e,Mo,u),k(fa,e,u),Fo=!0},p(e,[u]){const Ya={};u&2&&(Ya.$$scope={dirty:u,ctx:e}),Y.$set(Ya);const ys={};u&2&&(ys.$$scope={dirty:u,ctx:e}),He.$set(ys);const qs={};u&2&&(qs.$$scope={dirty:u,ctx:e}),Ge.$set(qs);const As={};u&2&&(As.$$scope={dirty:u,ctx:e}),Ze.$set(As);const Ne={};u&2&&(Ne.$$scope={dirty:u,ctx:e}),ra.$set(Ne);const Ts={};u&2&&(Ts.$$scope={dirty:u,ctx:e}),ia.$set(Ts);const Cs={};u&2&&(Cs.$$scope={dirty:u,ctx:e}),pa.$set(Cs);const Ba={};u&2&&(Ba.$$scope={dirty:u,ctx:e}),ua.$set(Ba);const zs={};u&2&&(zs.$$scope={dirty:u,ctx:e}),da.$set(zs);const xs={};u&2&&(xs.$$scope={dirty:u,ctx:e}),fa.$set(xs)},i(e){Fo||(j(g.$$.fragment,e),j(M.$$.fragment,e),j(Y.$$.fragment,e),j(Q.$$.fragment,e),j(F.$$.fragment,e),j(He.$$.fragment,e),j(va.$$.fragment,e),j(Ge.$$.fragment,e),j(ba.$$.fragment,e),j(ka.$$.fragment,e),j(ja.$$.fragment,e),j(ya.$$.fragment,e),j(qa.$$.fragment,e),j(Ca.$$.fragment,e),j(za.$$.fragment,e),j(xa.$$.fragment,e),j(Pa.$$.fragment,e),j(Da.$$.fragment,e),j(Ze.$$.fragment,e),j(Ma.$$.fragment,e),j(Fa.$$.fragment,e),j(Ia.$$.fragment,e),j(Na.$$.fragment,e),j(La.$$.fragment,e),j(Ua.$$.fragment,e),j(ra.$$.fragment,e),j(Ha.$$.fragment,e),j(ia.$$.fragment,e),j(pa.$$.fragment,e),j(ua.$$.fragment,e),j(Va.$$.fragment,e),j(da.$$.fragment,e),j(fa.$$.fragment,e),Fo=!0)},o(e){w(g.$$.fragment,e),w(M.$$.fragment,e),w(Y.$$.fragment,e),w(Q.$$.fragment,e),w(F.$$.fragment,e),w(He.$$.fragment,e),w(va.$$.fragment,e),w(Ge.$$.fragment,e),w(ba.$$.fragment,e),w(ka.$$.fragment,e),w(ja.$$.fragment,e),w(ya.$$.fragment,e),w(qa.$$.fragment,e),w(Ca.$$.fragment,e),w(za.$$.fragment,e),w(xa.$$.fragment,e),w(Pa.$$.fragment,e),w(Da.$$.fragment,e),w(Ze.$$.fragment,e),w(Ma.$$.fragment,e),w(Fa.$$.fragment,e),w(Ia.$$.fragment,e),w(Na.$$.fragment,e),w(La.$$.fragment,e),w(Ua.$$.fragment,e),w(ra.$$.fragment,e),w(Ha.$$.fragment,e),w(ia.$$.fragment,e),w(pa.$$.fragment,e),w(ua.$$.fragment,e),w(Va.$$.fragment,e),w(da.$$.fragment,e),w(fa.$$.fragment,e),Fo=!1},d(e){t(s),e&&t(d),e&&t(o),y(g),e&&t(P),y(M,e),e&&t(T),e&&t(S),e&&t(B),y(Y,e),e&&t(ae),e&&t(J),y(Q),e&&t($e),e&&t(re),e&&t(A),y(F,e),e&&t(le),e&&t(v),e&&t(ve),e&&t(ie),e&&t(ha),e&&t(G),e&&t(Ps),e&&t(_a),e&&t(Os),e&&t(Ee),e&&t(Ss),e&&t(ga),e&&t(Ds),e&&t(Ue),e&&t(Ms),y(He,e),e&&t(Fs),e&&t(Oe),y(va),e&&t(Is),e&&t(We),e&&t(Ns),e&&t(Qa),e&&t(Ls),y(Ge,e),e&&t(Us),e&&t(Ve),e&&t(Hs),y(ba,e),e&&t(Rs),e&&t(ke),e&&t(Ws),y(ka,e),e&&t(Gs),e&&t(Ye),e&&t(Vs),y(ja,e),e&&t(Ys),e&&t(je),e&&t(Bs),y(ya,e),e&&t(Js),e&&t(_e),e&&t(Qs),y(qa,e),e&&t(Ks),e&&t(we),e&&t(Zs),y(Ca,e),e&&t(Xs),e&&t(Be),e&&t(eo),y(za,e),e&&t(ao),e&&t(Je),e&&t(to),y(xa,e),e&&t(so),e&&t(Qe),e&&t(oo),e&&t(Se),y(Pa),e&&t(ro),e&&t(ue),e&&t(no),y(Da,e),e&&t(lo),y(Ze,e),e&&t(io),e&&t(ye),e&&t(po),y(Ma,e),e&&t(uo),e&&t(qe),e&&t(co),e&&t(De),y(Fa),e&&t(fo),y(Ia,e),e&&t(mo),e&&t(Z),e&&t($o),e&&t(Ae),e&&t(ho),e&&t(Me),y(Na),e&&t(_o),e&&t(Te),e&&t(go),e&&t(aa),e&&t(vo),y(La,e),e&&t(bo),e&&t(ta),e&&t(Eo),e&&t(tt),e&&t(ko),y(Ua,e),e&&t(jo),e&&t(st),e&&t(wo),e&&t(sa),e&&t(yo),e&&t(oa),e&&t(qo),y(ra,e),e&&t(Ao),e&&t(na),e&&t(To),e&&t(Fe),y(Ha),e&&t(Co),y(ia,e),e&&t(zo),y(pa,e),e&&t(xo),e&&t(X),e&&t(Po),y(ua,e),e&&t(Oo),e&&t(Ie),y(Va),e&&t(So),y(da,e),e&&t(Do),e&&t(Ce),e&&t(Mo),y(fa,e)}}}const qu={local:"quick-tour",sections:[{local:"pipeline",sections:[{local:"uso-del-pipeline",title:"Uso del Pipeline"},{local:"use-otro-modelo-y-otro-tokenizador-en-el-pipeline",title:"Use otro modelo y otro tokenizador en el pipeline"}],title:"Pipeline"},{local:"autoclass",sections:[{local:"autotokenizer",title:"AutoTokenizer"},{local:"automodel",title:"AutoModel"},{local:"guarda-un-modelo",title:"Guarda un modelo"}],title:"AutoClass"}],title:"Quick tour"};function Au(z){return Yp(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Su extends Rp{constructor(s){super();Wp(this,s,Au,yu,Gp,{})}}export{Su as default,qu as metadata};
