import{s as zi,o as Ci,n as _}from"../chunks/scheduler.36a0863c.js";import{S as Zi,i as Ii,g as r,s,r as m,A as ki,h as p,f as l,c as i,j as $i,u as d,x as c,k as Ui,y as Bi,a as n,v as u,d as M,t as f,w as g}from"../chunks/index.9c13489a.js";import{T as Rt}from"../chunks/Tip.3b06990e.js";import{C as b}from"../chunks/CodeBlock.05d8ec32.js";import{F as xi,M as vi}from"../chunks/Markdown.88297c0b.js";import{H as $,E as _i}from"../chunks/EditOnGithub.e88f2b7b.js";function Wi(w){let a,y,o,j=`Una volta salvato il checkpoint, possiamo esportarlo su ONNX puntando l’argomento <code>--model</code>
del pacchetto <code>transformers.onnx</code> nella directory desiderata:`,T,J,U;return a=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBJTIzJTIwTG9hZCUyMHRva2VuaXplciUyMGFuZCUyMFB5VG9yY2glMjB3ZWlnaHRzJTIwZm9ybSUyMHRoZSUyMEh1YiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFwdF9tb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMjMlMjBTYXZlJTIwdG8lMjBkaXNrJTBBdG9rZW5pemVyLnNhdmVfcHJldHJhaW5lZCglMjJsb2NhbC1wdC1jaGVja3BvaW50JTIyKSUwQXB0X21vZGVsLnNhdmVfcHJldHJhaW5lZCglMjJsb2NhbC1wdC1jaGVja3BvaW50JTIyKQ==",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><span class="hljs-comment"># Load tokenizer and PyTorch weights form the Hub</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Save to disk</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(<span class="hljs-string">&quot;local-pt-checkpoint&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model.save_pretrained(<span class="hljs-string">&quot;local-pt-checkpoint&quot;</span>)`,wrap:!1}}),J=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC1wdC1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/",wrap:!1}}),{c(){m(a.$$.fragment),y=s(),o=r("p"),o.innerHTML=j,T=s(),m(J.$$.fragment)},l(h){d(a.$$.fragment,h),y=i(h),o=p(h,"P",{"data-svelte-h":!0}),c(o)!=="svelte-1rjvspr"&&(o.innerHTML=j),T=i(h),d(J.$$.fragment,h)},m(h,v){u(a,h,v),n(h,y,v),n(h,o,v),n(h,T,v),u(J,h,v),U=!0},p:_,i(h){U||(M(a.$$.fragment,h),M(J.$$.fragment,h),U=!0)},o(h){f(a.$$.fragment,h),f(J.$$.fragment,h),U=!1},d(h){h&&(l(y),l(o),l(T)),g(a,h),g(J,h)}}}function Xi(w){let a,y;return a=new vi({props:{$$slots:{default:[Wi]},$$scope:{ctx:w}}}),{c(){m(a.$$.fragment)},l(o){d(a.$$.fragment,o)},m(o,j){u(a,o,j),y=!0},p(o,j){const T={};j&2&&(T.$$scope={dirty:j,ctx:o}),a.$set(T)},i(o){y||(M(a.$$.fragment,o),y=!0)},o(o){f(a.$$.fragment,o),y=!1},d(o){g(a,o)}}}function Ai(w){let a,y,o,j=`Once the checkpoint is saved, we can export it to ONNX by pointing the <code>--model</code>
argument of the <code>transformers.onnx</code> package to the desired directory:`,T,J,U;return a=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEElMjMlMjBMb2FkJTIwdG9rZW5pemVyJTIwYW5kJTIwVGVuc29yRmxvdyUyMHdlaWdodHMlMjBmcm9tJTIwdGhlJTIwSHViJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXRmX21vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBJTIzJTIwU2F2ZSUyMHRvJTIwZGlzayUwQXRva2VuaXplci5zYXZlX3ByZXRyYWluZWQoJTIybG9jYWwtdGYtY2hlY2twb2ludCUyMiklMEF0Zl9tb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIybG9jYWwtdGYtY2hlY2twb2ludCUyMik=",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><span class="hljs-comment"># Load tokenizer and TensorFlow weights from the Hub</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Save to disk</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer.save_pretrained(<span class="hljs-string">&quot;local-tf-checkpoint&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model.save_pretrained(<span class="hljs-string">&quot;local-tf-checkpoint&quot;</span>)`,wrap:!1}}),J=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC10Zi1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-tf-checkpoint onnx/",wrap:!1}}),{c(){m(a.$$.fragment),y=s(),o=r("p"),o.innerHTML=j,T=s(),m(J.$$.fragment)},l(h){d(a.$$.fragment,h),y=i(h),o=p(h,"P",{"data-svelte-h":!0}),c(o)!=="svelte-128pexq"&&(o.innerHTML=j),T=i(h),d(J.$$.fragment,h)},m(h,v){u(a,h,v),n(h,y,v),n(h,o,v),n(h,T,v),u(J,h,v),U=!0},p:_,i(h){U||(M(a.$$.fragment,h),M(J.$$.fragment,h),U=!0)},o(h){f(a.$$.fragment,h),f(J.$$.fragment,h),U=!1},d(h){h&&(l(y),l(o),l(T)),g(a,h),g(J,h)}}}function Ni(w){let a,y;return a=new vi({props:{$$slots:{default:[Ai]},$$scope:{ctx:w}}}),{c(){m(a.$$.fragment)},l(o){d(a.$$.fragment,o)},m(o,j){u(a,o,j),y=!0},p(o,j){const T={};j&2&&(T.$$scope={dirty:j,ctx:o}),a.$set(T)},i(o){y||(M(a.$$.fragment,o),y=!0)},o(o){f(a.$$.fragment,o),y=!1},d(o){g(a,o)}}}function Gi(w){let a,y=`Le caratteristiche che hanno un suffisso <code>wtih-past</code> (ad es. <code>causal-lm-with-past</code>)
corrispondono a topologie di modello con stati nascosti precalcolati (chiave e valori
nei blocchi di attenzione) che possono essere utilizzati per la decodifica autoregressiva veloce.`;return{c(){a=r("p"),a.innerHTML=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-1on6rqr"&&(a.innerHTML=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Ri(w){let a,y=`Un buon modo per implementare una configurazione ONNX personalizzata è guardare l’implementazione
esistente nel file <code>configuration_&lt;model_name&gt;.py</code> di un’architettura simile.`;return{c(){a=r("p"),a.innerHTML=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-k15enw"&&(a.innerHTML=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Vi(w){let a,y=`Puoi notare che la proprietà <code>inputs</code> per <code>DistilBertOnnxConfig</code> restituisce un
<code>OrdinatoDict</code>. Ciò garantisce che gli input corrispondano alla loro posizione
relativa all’interno del metodo <code>PreTrainedModel.forward()</code> durante il tracciamento del grafico.
Raccomandiamo di usare un <code>OrderedDict</code> per le proprietà <code>inputs</code> e <code>outputs</code>
quando si implementano configurazioni ONNX personalizzate.`;return{c(){a=r("p"),a.innerHTML=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-9pdb1s"&&(a.innerHTML=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Hi(w){let a,y=`Tutte le proprietà e i metodi di base associati a <code>OnnxConfig</code> e le
altre classi di configurazione possono essere sovrascritte se necessario. Guarda
<code>BartOnnxConfig</code> per un esempio avanzato.`;return{c(){a=r("p"),a.innerHTML=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-8je27i"&&(a.innerHTML=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Ei(w){let a,y=`Se il tuo modello è più largo di 2 GB, vedrai che molti file aggiuntivi sono
creati durante l’esportazione. Questo è <em>previsto</em> perché ONNX utilizza <a href="https://developers.google.com/protocol-buffers/" rel="nofollow">Protocol
Buffer</a> per memorizzare il modello e
questi hanno un limite di dimensione 2 GB. Vedi la <a href="https://github.com/onnx/onnx/blob/master/docs/ExternalData.md" rel="nofollow">Documentazione
ONNX</a>
per istruzioni su come caricare modelli con dati esterni.`;return{c(){a=r("p"),a.innerHTML=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-zgeibt"&&(a.innerHTML=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Qi(w){let a,y=`Questo è l’inizio dei nostri esperimenti con TorchScript e stiamo ancora esplorando le sue capacità con
modelli con variable-input-size. È una nostra priorità e approfondiremo le nostre analisi nelle prossime versioni,
con più esempi di codici, un’implementazione più flessibile e benchmark che confrontano i codici basati su Python con quelli compilati con
TorchScript.`;return{c(){a=r("p"),a.textContent=y},l(o){a=p(o,"P",{"data-svelte-h":!0}),c(a)!=="svelte-1puyypy"&&(a.textContent=y)},m(o,j){n(o,a,j)},p:_,d(o){o&&l(a)}}}function Li(w){let a,y,o,j,T,J,U,h=`Se devi implementare 🤗 modelli Transformers in ambienti di produzione, noi
consigliamo di esportarli in un formato serializzato che può essere caricato ed eseguito
su runtime e hardware specializzati. In questa guida ti mostreremo come farlo
esporta 🤗 Modelli Transformers in due formati ampiamente utilizzati: ONNX e TorchScript.`,v,W,ls=`Una volta esportato, un modello può essere ottimizato per l’inferenza tramite tecniche come
la quantizzazione e soppressione. Se sei interessato a ottimizzare i tuoi modelli per l’esecuzione
con la massima efficienza, dai un’occhiata a <a href="https://github.com/huggingface/optimum" rel="nofollow">🤗 Optimum
library</a>.`,Ht,X,Et,A,ns=`Il progetto <a href="http://onnx.ai" rel="nofollow">ONNX (Open Neural Network eXchange)</a> Il progetto onnx è un open
standard che definisce un insieme comune di operatori e un formato di file comune a
rappresentano modelli di deep learning in un’ampia varietà di framework, tra cui
PyTorch e TensorFlow. Quando un modello viene esportato nel formato ONNX, questi
operatori sono usati per costruire un grafico computazionale (often called an
<em>intermediate representation</em>) che rappresenta il flusso di dati attraverso la
rete neurale.`,Qt,N,ss=`Esponendo un grafico con operatori e tipi di dati standardizzati, ONNX rende
più facile passare da un framework all’altro. Ad esempio, un modello allenato in PyTorch può
essere esportato in formato ONNX e quindi importato in TensorFlow (e viceversa).`,Lt,G,is=`🤗 Transformers fornisce un pacchetto <code>transformers.onnx</code> che ti consente di
convertire i checkpoint del modello in un grafico ONNX sfruttando gli oggetti di configurazione.
Questi oggetti di configurazione sono già pronti per una serie di architetture di modelli,
e sono progettati per essere facilmente estensibili ad altre architetture.`,St,R,as="Le configurazioni pronte includono le seguenti architetture:",Ft,V,os="<li>ALBERT</li> <li>BART</li> <li>BEiT</li> <li>BERT</li> <li>BigBird</li> <li>BigBird-Pegasus</li> <li>Blenderbot</li> <li>BlenderbotSmall</li> <li>CamemBERT</li> <li>ConvBERT</li> <li>Data2VecText</li> <li>Data2VecVision</li> <li>DeiT</li> <li>DistilBERT</li> <li>ELECTRA</li> <li>FlauBERT</li> <li>GPT Neo</li> <li>GPT-J</li> <li>I-BERT</li> <li>LayoutLM</li> <li>M2M100</li> <li>Marian</li> <li>mBART</li> <li>MobileBERT</li> <li>OpenAI GPT-2</li> <li>Perceiver</li> <li>PLBart</li> <li>RoBERTa</li> <li>RoFormer</li> <li>SqueezeBERT</li> <li>T5</li> <li>ViT</li> <li>XLM</li> <li>XLM-RoBERTa</li> <li>XLM-RoBERTa-XL</li>",qt,H,rs="Nelle prossime due sezioni, ti mostreremo come:",Yt,E,ps="<li>Esporta un modello supportato usando il pacchetto <code>transformers.onnx</code>.</li> <li>Esporta un modello personalizzato per un’architettura non supportata.</li>",Pt,Q,Dt,L,cs=`Per esportare un modello 🤗 Transformers in ONNX, dovrai prima installarne alcune
dipendenze extra:`,Ot,S,Kt,F,ms="Il pacchetto <code>transformers.onnx</code> può essere usato come modulo Python:",el,q,tl,Y,ds="L’esportazione di un checkpoint utilizzando una configurazione già pronta può essere eseguita come segue:",ll,P,nl,D,us="che dovrebbe mostrare i seguenti log:",sl,O,il,K,Ms=`Questo esporta un grafico ONNX del checkpoint definito dall’argomento <code>--model</code>.
In questo esempio è <code>distilbert/distilbert-base-uncased</code>, ma può essere qualsiasi checkpoint
Hugging Face Hub o uno memorizzato localmente.`,al,ee,fs=`Il file risultante <code>model.onnx</code> può quindi essere eseguito su uno dei <a href="https://onnx.ai/supported-tools.html#deployModel" rel="nofollow">tanti
acceleratori</a> che supportano il
lo standard ONNX. Ad esempio, possiamo caricare ed eseguire il modello con <a href="https://onnxruntime.ai/" rel="nofollow">ONNX
Runtime</a> come segue:`,ol,te,rl,le,gs=`I nomi di output richiesti (cioè <code>[&quot;last_hidden_state&quot;]</code>) possono essere ottenuti
dando un’occhiata alla configurazione ONNX di ogni modello. Ad esempio, per
DistilBERT abbiamo:`,pl,ne,cl,se,hs=`Il processo è identico per i checkpoint TensorFlow sull’hub. Ad esempio, noi
possiamo esportare un checkpoint TensorFlow puro da <a href="https://huggingface.co/keras-io" rel="nofollow">Keras
organizzazione</a> come segue:`,ml,ie,dl,ae,ys=`Per esportare un modello memorizzato localmente, devi disporre dei pesi del modello
e file tokenizer memorizzati in una directory. Ad esempio, possiamo caricare e salvare un
checkpoint come segue:`,ul,z,Ml,oe,fl,re,js=`Ogni configurazione già pronta viene fornita con una serie di <em>caratteristiche</em> che ti consentono di
esportare modelli per diversi tipi di topologie o attività. Come mostrato nella tabella
di seguito, ogni caratteristica è associata a una diversa Auto Class:`,gl,pe,bs="<thead><tr><th>Caratteristica</th> <th>Auto Class</th></tr></thead> <tbody><tr><td><code>causal-lm</code>, <code>causal-lm-with-past</code></td> <td><code>AutoModelForCausalLM</code></td></tr> <tr><td><code>default</code>, <code>default-with-past</code></td> <td><code>AutoModel</code></td></tr> <tr><td><code>masked-lm</code></td> <td><code>AutoModelForMaskedLM</code></td></tr> <tr><td><code>question-answering</code></td> <td><code>AutoModelForQuestionAnswering</code></td></tr> <tr><td><code>seq2seq-lm</code>, <code>seq2seq-lm-with-past</code></td> <td><code>AutoModelForSeq2SeqLM</code></td></tr> <tr><td><code>sequence-classification</code></td> <td><code>AutoModelForSequenceClassification</code></td></tr> <tr><td><code>token-classification</code></td> <td><code>AutoModelForTokenClassification</code></td></tr></tbody>",hl,ce,Ts=`Per ciascuna configurazione, puoi trovare l’elenco delle funzionalità supportate tramite il
<code>FeaturesManager</code>. Ad esempio, per DistilBERT abbiamo:`,yl,me,jl,de,ws=`Puoi quindi passare una di queste funzionalità all’argomento <code>--feature</code> nel
pacchetto <code>transformers.onnx</code>. Ad esempio, per esportare un modello di classificazione del testo
possiamo scegliere un modello ottimizzato dall’Hub ed eseguire:`,bl,ue,Tl,Me,Js="che visualizzerà i seguenti registri:",wl,fe,Jl,ge,$s=`Puoi notare che in questo caso, i nomi di output del modello ottimizzato sono
<code>logits</code> invece di <code>last_hidden_state</code> che abbiamo visto con il
checkpoint <code>distilbert/distilbert-base-uncased</code> precedente. Questo è previsto dal
modello ottimizato visto che ha una testa di e.`,$l,C,Ul,he,vl,ye,Us=`Se desideri esportare un modello la cui architettura non è nativamente supportata dalla
libreria, ci sono tre passaggi principali da seguire:`,zl,je,vs="<li>Implementare una configurazione ONNX personalizzata.</li> <li>Esportare il modello in ONNX.</li> <li>Convalidare gli output di PyTorch e dei modelli esportati.</li>",Cl,be,zs=`In questa sezione, vedremo come DistilBERT è stato implementato per mostrare cosa è
coinvolto in ogni passaggio.`,Zl,Te,Il,we,Cs=`Iniziamo con l’oggetto di configurazione ONNX. Forniamo tre classi
astratte da cui ereditare, a seconda del tipo di archittettura
del modello che desideri esportare:`,kl,Je,Zs="<li>I modelli basati su encoder ereditano da <code>OnnxConfig</code></li> <li>I modelli basati su decoder ereditano da <code>OnnxConfigWithPast</code></li> <li>I modelli encoder-decoder ereditano da<code>OnnxSeq2SeqConfigWithPast</code></li>",Bl,Z,xl,$e,Is=`Poiché DistilBERT è un modello basato su encoder, la sua configurazione eredita da
<code>OnnxConfig</code>:`,_l,Ue,Wl,ve,ks=`Ogni oggetto di configurazione deve implementare la proprietà <code>inputs</code> e restituire una
mappatura, dove ogni chiave corrisponde a un input previsto e ogni valore
indica l’asse di quell’input. Per DistilBERT, possiamo vedere che sono richiesti
due input: <code>input_ids</code> e <code>attention_mask</code>. Questi inputs hanno la stessa forma di
<code>(batch_size, sequence_length)</code> per questo motivo vediamo gli stessi assi usati nella
configurazione.`,Xl,I,Al,ze,Bs=`Dopo aver implementato una configurazione ONNX, è possibile istanziarla
fornendo alla configurazione del modello base come segue:`,Nl,Ce,Gl,Ze,xs=`L’oggetto risultante ha diverse proprietà utili. Ad esempio è possibile visualizzare il
Set operatore ONNX che verrà utilizzato durante l’esportazione:`,Rl,Ie,Vl,ke,_s="È inoltre possibile visualizzare gli output associati al modello come segue:",Hl,Be,El,xe,Ws=`Puoi notare che la proprietà degli output segue la stessa struttura degli input; esso
restituisce un <code>OrderedDict</code> di output con nome e le loro forme. La struttura di output
è legato alla scelta della funzione con cui viene inizializzata la configurazione.
Per impostazione predefinita, la configurazione ONNX viene inizializzata con la funzione ‘predefinita’
che corrisponde all’esportazione di un modello caricato con la classe <code>AutoModel</code>. Se tu
desideri esportare una topologia di modello diversa, è sufficiente fornire una funzionalità diversa a
l’argomento <code>task</code> quando inizializzi la configurazione ONNX. Ad esempio, se
volevamo esportare DistilBERT con una testa di classificazione per sequenze, potremmo
usare:`,Ql,_e,Ll,k,Sl,We,Fl,Xe,Xs=`Una volta implementata la configurazione ONNX, il passaggio successivo consiste nell’esportare il
modello. Qui possiamo usare la funzione <code>export()</code> fornita dal
pacchetto <code>transformers.onnx</code>. Questa funzione prevede la configurazione ONNX, insieme
con il modello base e il tokenizer e il percorso per salvare il file esportato:`,ql,Ae,Yl,Ne,As=`Gli <code>onnx_inputs</code> e <code>onnx_outputs</code> restituiti dalla funzione <code>export()</code> sono
liste di chiavi definite nelle proprietà di <code>input</code> e <code>output</code> della
configurazione. Una volta esportato il modello, puoi verificare che il modello sia ben
formato come segue:`,Pl,Ge,Dl,B,Ol,Re,Kl,Ve,Ns=`Il passaggio finale consiste nel convalidare gli output dal modello di base e quello esportato
corrispondere entro una soglia di tolleranza assoluta. Qui possiamo usare la
Funzione <code>validate_model_outputs()</code> fornita dal pacchetto <code>transformers.onnx</code>
come segue:`,en,He,tn,Ee,Gs=`Questa funzione usa il metodo <code>OnnxConfig.generate_dummy_inputs()</code> per generare
input per il modello di base e quello esportato e la tolleranza assoluta può essere
definita nella configurazione. Generalmente troviamo una corrispondenza numerica nell’intervallo da 1e-6
a 1e-4, anche se è probabile che qualsiasi cosa inferiore a 1e-3 vada bene.`,ln,Qe,nn,Le,Rs=`Stiamo cercando di espandere l’insieme di configurazioni già pronte e di accettare
contributi della community! Se vuoi contribuire con la tua aggiunta
nella libreria, dovrai:`,sn,Se,Vs="<li>Implementare la configurazione ONNX nella corrispondente <code>configuration file _&lt;model_name&gt;.py</code></li> <li>Includere l’architettura del modello e le funzioni corrispondenti in <code>~onnx.features.FeatureManager</code></li> <li>Aggiungere la tua architettura del modello ai test in <code>test_onnx_v2.py</code></li>",an,Fe,Hs=`Scopri come stato contribuito la configurazione per <a href="https://github.com/huggingface/transformers/pull/14868/files" rel="nofollow">IBERT</a> per
avere un’idea di cosa è coinvolto.`,on,qe,rn,x,pn,Ye,Es=`Secondo la documentazione di Pytorch: “TorchScript è un modo per creare modelli serializzabili e ottimizzabili da codice
Pytorch”. I due moduli di Pytorch <a href="https://pytorch.org/docs/stable/jit.html" rel="nofollow">JIT e TRACE</a> consentono allo sviluppatore di esportare
il loro modello da riutilizzare in altri programmi, come i programmi C++ orientati all’efficienza.`,cn,Pe,Qs=`Abbiamo fornito un’interfaccia che consente l’esportazione di modelli 🤗 Transformers in TorchScript in modo che possano essere riutilizzati
in un ambiente diverso rispetto a un programma Python basato su Pytorch. Qui spieghiamo come esportare e utilizzare i nostri modelli utilizzando
TorchScript.`,mn,De,Ls="Esportare un modello richiede due cose:",dn,Oe,Ss="<li>Un passaggio in avanti con input fittizzi.</li> <li>Istanziazione del modello con flag <code>torchscript</code>.</li>",un,Ke,Fs="Queste necessità implicano diverse cose a cui gli sviluppatori dovrebbero prestare attenzione. Questi dettagli mostrati sotto.",Mn,et,fn,tt,qs=`Questo flag è necessario perché la maggior parte dei modelli linguistici in questo repository hanno pesi legati tra il loro
strato “Embedding” e lo strato “Decoding”. TorchScript non consente l’esportazione di modelli che hanno pesi
legati, quindi è necessario prima slegare e clonare i pesi.`,gn,lt,Ys=`Ciò implica che i modelli istanziati con il flag <code>torchscript</code> hanno il loro strato <code>Embedding</code> e strato <code>Decoding</code>
separato, il che significa che non dovrebbero essere addestrati in futuro. L’allenamento de-sincronizza i due
strati, portando a risultati inaspettati.`,hn,nt,Ps=`Questo non è il caso per i modelli che non hanno una testa del modello linguistico, poiché quelli non hanno pesi legati. Questi modelli
può essere esportato in sicurezza senza il flag <code>torchscript</code>.`,yn,st,jn,it,Ds=`Gli input fittizzi sono usati per fare un modello passaggio in avanti . Mentre i valori degli input si propagano attraverso i strati,
Pytorch tiene traccia delle diverse operazioni eseguite su ciascun tensore. Queste operazioni registrate vengono quindi utilizzate per
creare la “traccia” del modello.`,bn,at,Os=`La traccia viene creata relativamente alle dimensioni degli input. È quindi vincolato dalle dimensioni dell’input
fittizio e non funzionerà per altre lunghezze di sequenza o dimensioni batch. Quando si proverà con una dimensione diversa, ci sarà errore
come:`,Tn,ot,Ks="<code>La dimensione espansa del tensore (3) deve corrispondere alla dimensione esistente (7) nella dimensione non singleton 2</code>",wn,rt,ei=`will be raised. Si consiglia pertanto di tracciare il modello con una dimensione di input fittizia grande almeno quanto il più grande
input che verrà fornito al modello durante l’inferenza. È possibile eseguire il padding per riempire i valori mancanti. Il modello
sarà tracciato con una grande dimensione di input, tuttavia, anche le dimensioni della diverse matrici saranno grandi,
risultando in più calcoli.`,Jn,pt,ti=`Si raccomanda di prestare attenzione al numero totale di operazioni eseguite su ciascun input e di seguire da vicino le prestazioni
durante l’esportazione di modelli di sequenza-lunghezza variabili.`,$n,ct,Un,mt,li="Di seguito è riportato un esempio, che mostra come salvare, caricare modelli e come utilizzare la traccia per l’inferenza.",vn,dt,zn,ut,ni=`Questo frammento di codice mostra come usare TorchScript per esportare un <code>BertModel</code>. Qui il <code>BertModel</code> è istanziato secondo
una classe <code>BertConfig</code> e quindi salvato su disco con il nome del file <code>traced_bert.pt</code>`,Cn,Mt,Zn,ft,In,gt,si=`Questo frammento di codice mostra come caricare il <code>BertModel</code> che era stato precedentemente salvato su disco con il nome <code>traced_bert.pt</code>.
Stiamo riutilizzando il <code>dummy_input</code> precedentemente inizializzato.`,kn,ht,Bn,yt,xn,jt,ii="Usare il modello tracciato per l’inferenza è semplice come usare il suo metodo dunder <code>__call__</code>:",_n,bt,Wn,Tt,Xn,wt,ai=`AWS ha introdotto <a href="https://aws.amazon.com/ec2/instance-types/inf1/" rel="nofollow">Amazon EC2 Inf1</a>
famiglia di istanze per l’inferenza di machine learning a basso costo e ad alte prestazioni nel cloud.
Le istanze Inf1 sono alimentate dal chip AWS Inferentia, un acceleratore hardware personalizzato,
specializzato in carichi di lavoro di inferenza di deep learning.
<a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/#" rel="nofollow">AWS Neuron</a>
è l’SDK per Inferentia che supporta il tracciamento e l’ottimizzazione dei modelli transformers per
distribuzione su Inf1. L’SDK Neuron fornisce:`,An,Jt,oi=`<li>API di facile utilizzo con una riga di modifica del codice per tracciare e ottimizzare un modello TorchScript per l’inferenza nel cloud.</li> <li>Ottimizzazioni delle prestazioni pronte all’uso per <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/benchmark/%3E" rel="nofollow">miglioramento dei costi-prestazioni</a></li> <li>Supporto per i modelli di trasformatori HuggingFace costruiti con <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/bert_tutorial/tutorial_pretrained_bert.html" rel="nofollow">PyTorch</a>
o <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/tensorflow/huggingface_bert/huggingface_bert.html" rel="nofollow">TensorFlow</a>.</li>`,Nn,$t,Gn,Ut,ri=`Modelli Transformers basati su architettura <a href="https://huggingface.co/docs/transformers/main/model_doc/bert" rel="nofollow">BERT (Bidirectional Encoder Representations from Transformers)</a>,
o sue varianti come <a href="https://huggingface.co/docs/transformers/main/model_doc/distilbert" rel="nofollow">distilBERT</a>
e <a href="https://huggingface.co/docs/transformers/main/model_doc/roberta" rel="nofollow">roBERTa</a>
funzioneranno meglio su Inf1 per attività non generative come la question answering estrattive,
Classificazione della sequenza, Classificazione dei token. In alternativa, generazione di testo
le attività possono essere adattate per essere eseguite su Inf1, secondo questo <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/src/examples/pytorch/transformers-marianmt.html" rel="nofollow">tutorial AWS Neuron MarianMT</a>.
Ulteriori informazioni sui modelli che possono essere convertiti fuori dagli schemi su Inferentia possono essere
trovati nella <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/models/models-inferentia.html#models-inferentia" rel="nofollow">sezione Model Architecture Fit della documentazione Neuron</a>.`,Rn,vt,Vn,zt,pi="L’utilizzo di AWS Neuron per convertire i modelli richiede le seguenti dipendenze e l’ambiente:",Hn,Ct,ci=`<li>A <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/neuron-guide/neuron-frameworks/pytorch-neuron/index.html#installation-guide" rel="nofollow">Neuron SDK environment</a>,
which comes pre-configured on <a href="https://docs.aws.amazon.com/dlami/latest/devguide/tutorial-inferentia-launching.html" rel="nofollow">AWS Deep Learning AMI</a>.</li>`,En,Zt,Qn,It,mi=`Usando lo stesso script come in <a href="https://huggingface.co/docs/transformers/main/en/serialization#using-torchscript-in-python" rel="nofollow">Usando TorchScipt in Python</a>
per tracciare un “BertModel”, importi l’estensione del framework <code>torch.neuron</code> per accedere
i componenti di Neuron SDK tramite un’API Python.`,Ln,kt,Sn,Bt,di="E modificare solo la riga di codice di traccia",Fn,xt,ui="Da:",qn,_t,Yn,Wt,Mi="A:",Pn,Xt,Dn,At,fi="Questa modifica consente a Neuron SDK di tracciare il modello e ottimizzarlo per l’esecuzione nelle istanze Inf1.",On,Nt,gi=`Per ulteriori informazioni sulle funzionalità, gli strumenti, i tutorial di esempi e gli ultimi aggiornamenti di AWS Neuron SDK,
consultare la <a href="https://awsdocs-neuron.readthedocs-hosted.com/en/latest/index.html" rel="nofollow">documentazione AWS NeuronSDK</a>.`,Kn,Gt,es,Vt,ts;return T=new $({props:{title:"Esporta modelli 🤗 Transformers",local:"esporta-modelli--transformers",headingTag:"h1"}}),X=new $({props:{title:"ONNX",local:"onnx",headingTag:"h2"}}),Q=new $({props:{title:"Esportazione di un modello in ONNX",local:"esportazione-di-un-modello-in-onnx",headingTag:"h3"}}),S=new b({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1Qm9ubnglNUQ=",highlighted:"pip install transformers[onnx]",wrap:!1}}),q=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0taGVscCUwQSUwQXVzYWdlJTNBJTIwSHVnZ2luZyUyMEZhY2UlMjBUcmFuc2Zvcm1lcnMlMjBPTk5YJTIwZXhwb3J0ZXIlMjAlNUItaCU1RCUyMC1tJTIwTU9ERUwlMjAlNUItLWZlYXR1cmUlMjAlN0JjYXVzYWwtbG0lMkMlMjAuLi4lN0QlNUQlMjAlNUItLW9wc2V0JTIwT1BTRVQlNUQlMjAlNUItLWF0b2wlMjBBVE9MJTVEJTIwb3V0cHV0JTBBJTBBcG9zaXRpb25hbCUyMGFyZ3VtZW50cyUzQSUwQSUyMCUyMG91dHB1dCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU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mNlJTIwdG9sZXJhbmNlJTIwd2hlbiUyMHZhbGlkYXRpbmclMjB0aGUlMjBtb2RlbC4=",highlighted:`python -m transformers.onnx --<span class="hljs-built_in">help</span>

usage: Hugging Face Transformers ONNX exporter [-h] -m MODEL [--feature {causal-lm, ...}] [--opset OPSET] [--atol ATOL] output

positional arguments:
  output                Path indicating <span class="hljs-built_in">where</span> to store generated ONNX model.

optional arguments:
  -h, --<span class="hljs-built_in">help</span>            show this <span class="hljs-built_in">help</span> message and <span class="hljs-built_in">exit</span>
  -m MODEL, --model MODEL
                        Model ID on huggingface.co or path on disk to load model from.
  --feature {causal-lm, ...}
                        The <span class="hljs-built_in">type</span> of features to <span class="hljs-built_in">export</span> the model with.
  --opset OPSET         ONNX opset version to <span class="hljs-built_in">export</span> the model with.
  --atol ATOL           Absolute difference tolerance when validating the model.`,wrap:!1}}),P=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjBvbm54JTJG",highlighted:"python -m transformers.onnx --model=distilbert/distilbert-base-uncased onnx/",wrap:!1}}),O=new b({props:{code:"VmFsaWRhdGluZyUyME9OTlglMjBtb2RlbC4uLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0lNUIlRTIlOUMlOTMlNUQlMjBPTk5YJTIwbW9kZWwlMjBvdXRwdXQlMjBuYW1lcyUyMG1hdGNoJTIwcmVmZXJlbmNlJTIwbW9kZWwlMjAoJTdCJ2xhc3RfaGlkZGVuX3N0YXRlJyU3RCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtJTIwVmFsaWRhdGluZyUyME9OTlglMjBNb2RlbCUyMG91dHB1dCUyMCUyMmxhc3RfaGlkZGVuX3N0YXRlJTIyJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMCgyJTJDJTIwOCUyQyUyMDc2OCklMjBtYXRjaGVzJTIwKDIlMkMlMjA4JTJDJTIwNzY4KSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0lNUIlRTIlOUMlOTMlNUQlMjBhbGwlMjB2YWx1ZXMlMjBjbG9zZSUyMChhdG9sJTNBJTIwMWUtMDUpJTBBQWxsJTIwZ29vZCUyQyUyMG1vZGVsJTIwc2F2ZWQlMjBhdCUzQSUyMG9ubnglMkZtb2RlbC5vbm54",highlighted:`Validating ONNX model...
        -[✓] ONNX model output names match reference model ({<span class="hljs-string">&#x27;last_hidden_state&#x27;</span>})
        - Validating ONNX Model output <span class="hljs-string">&quot;last_hidden_state&quot;</span>:
                -[✓] (2, 8, 768) matches (2, 8, 768)
                -[✓] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`,wrap:!1}}),te=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBJbmZlcmVuY2VTZXNzaW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydCUyRmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXNlc3Npb24lMjAlM0QlMjBJbmZlcmVuY2VTZXNzaW9uKCUyMm9ubnglMkZtb2RlbC5vbm54JTIyKSUwQSUyMyUyME9OTlglMjBSdW50aW1lJTIwZXhwZWN0cyUyME51bVB5JTIwYXJyYXlzJTIwYXMlMjBpbnB1dCUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMjJVc2luZyUyMERpc3RpbEJFUlQlMjB3aXRoJTIwT05OWCUyMFJ1bnRpbWUhJTIyJTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJucCUyMiklMEFvdXRwdXRzJTIwJTNEJTIwc2Vzc2lvbi5ydW4ob3V0cHV0X25hbWVzJTNEJTVCJTIybGFzdF9oaWRkZW5fc3RhdGUlMjIlNUQlMkMlMjBpbnB1dF9mZWVkJTNEZGljdChpbnB1dHMpKQ==",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><span class="hljs-keyword">from</span> onnxruntime <span class="hljs-keyword">import</span> InferenceSession

<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>session = InferenceSession(<span class="hljs-string">&quot;onnx/model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># ONNX Runtime expects NumPy arrays as input</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>inputs = tokenizer(<span class="hljs-string">&quot;Using DistilBERT with ONNX Runtime!&quot;</span>, return_tensors=<span class="hljs-string">&quot;np&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>outputs = session.run(output_names=[<span class="hljs-string">&quot;last_hidden_state&quot;</span>], input_feed=<span class="hljs-built_in">dict</span>(inputs))`,wrap:!1}}),ne=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5tb2RlbHMuZGlzdGlsYmVydCUyMGltcG9ydCUyMERpc3RpbEJlcnRDb25maWclMkMlMjBEaXN0aWxCZXJ0T25ueENvbmZpZyUwQSUwQWNvbmZpZyUyMCUzRCUyMERpc3RpbEJlcnRDb25maWcoKSUwQW9ubnhfY29uZmlnJTIwJTNEJTIwRGlzdGlsQmVydE9ubnhDb25maWcoY29uZmlnKSUwQXByaW50KGxpc3Qob25ueF9jb25maWcub3V0cHV0cy5rZXlzKCkpKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.models.distilbert <span class="hljs-keyword">import</span> DistilBertConfig, DistilBertOnnxConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>config = DistilBertConfig()
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config = DistilBertOnnxConfig(config)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(<span class="hljs-built_in">list</span>(onnx_config.outputs.keys()))
[<span class="hljs-string">&quot;last_hidden_state&quot;</span>]`,wrap:!1}}),ie=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RrZXJhcy1pbyUyRnRyYW5zZm9ybWVycy1xYSUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/",wrap:!1}}),z=new xi({props:{pytorch:!0,tensorflow:!0,jax:!1,$$slots:{tensorflow:[Ni],pytorch:[Xi]},$$scope:{ctx:w}}}),oe=new $({props:{title:"Selezione delle caratteristiche per diverse topologie di modello",local:"selezione-delle-caratteristiche-per-diverse-topologie-di-modello",headingTag:"h3"}}),me=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5vbm54LmZlYXR1cmVzJTIwaW1wb3J0JTIwRmVhdHVyZXNNYW5hZ2VyJTBBJTBBZGlzdGlsYmVydF9mZWF0dXJlcyUyMCUzRCUyMGxpc3QoRmVhdHVyZXNNYW5hZ2VyLmdldF9zdXBwb3J0ZWRfZmVhdHVyZXNfZm9yX21vZGVsX3R5cGUoJTIyZGlzdGlsYmVydCUyMikua2V5cygpKSUwQXByaW50KGRpc3RpbGJlcnRfZmVhdHVyZXMp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx.features <span class="hljs-keyword">import</span> FeaturesManager

<span class="hljs-meta">&gt;&gt;&gt; </span>distilbert_features = <span class="hljs-built_in">list</span>(FeaturesManager.get_supported_features_for_model_type(<span class="hljs-string">&quot;distilbert&quot;</span>).keys())
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(distilbert_features)
[<span class="hljs-string">&quot;default&quot;</span>, <span class="hljs-string">&quot;masked-lm&quot;</span>, <span class="hljs-string">&quot;causal-lm&quot;</span>, <span class="hljs-string">&quot;sequence-classification&quot;</span>, <span class="hljs-string">&quot;token-classification&quot;</span>, <span class="hljs-string">&quot;question-answering&quot;</span>]`,wrap:!1}}),ue=new b({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQtZmluZXR1bmVkLXNzdC0yLWVuZ2xpc2glMjAlNUMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtLWZlYXR1cmUlM0RzZXF1ZW5jZS1jbGFzc2lmaWNhdGlvbiUyMG9ubnglMkY=",highlighted:`python -m transformers.onnx --model=distilbert/distilbert-base-uncased-finetuned-sst-2-english \\
                            --feature=sequence-classification onnx/`,wrap:!1}}),fe=new b({props:{code:"VmFsaWRhdGluZyUyME9OTlglMjBtb2RlbC4uLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0lNUIlRTIlOUMlOTMlNUQlMjBPTk5YJTIwbW9kZWwlMjBvdXRwdXQlMjBuYW1lcyUyMG1hdGNoJTIwcmVmZXJlbmNlJTIwbW9kZWwlMjAoJTdCJ2xvZ2l0cyclN0QpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSUyMFZhbGlkYXRpbmclMjBPTk5YJTIwTW9kZWwlMjBvdXRwdXQlMjAlMjJsb2dpdHMlMjIlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAtJTVCJUUyJTlDJTkzJTVEJTIwKDIlMkMlMjAyKSUyMG1hdGNoZXMlMjAoMiUyQyUyMDIpJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwLSU1QiVFMiU5QyU5MyU1RCUyMGFsbCUyMHZhbHVlcyUyMGNsb3NlJTIwKGF0b2wlM0ElMjAxZS0wNSklMEFBbGwlMjBnb29kJTJDJTIwbW9kZWwlMjBzYXZlZCUyMGF0JTNBJTIwb25ueCUyRm1vZGVsLm9ubng=",highlighted:`Validating ONNX model...
        -[✓] ONNX model output names match reference model ({<span class="hljs-string">&#x27;logits&#x27;</span>})
        - Validating ONNX Model output <span class="hljs-string">&quot;logits&quot;</span>:
                -[✓] (2, 2) matches (2, 2)
                -[✓] all values close (atol: 1e-05)
All good, model saved at: onnx/model.onnx`,wrap:!1}}),C=new Rt({props:{$$slots:{default:[Gi]},$$scope:{ctx:w}}}),he=new $({props:{title:"Esportazione di un modello per un’architettura non supportata",local:"esportazione-di-un-modello-per-unarchitettura-non-supportata",headingTag:"h3"}}),Te=new $({props:{title:"Implementazione di una configurazione ONNX personalizzata",local:"implementazione-di-una-configurazione-onnx-personalizzata",headingTag:"h4"}}),Z=new Rt({props:{$$slots:{default:[Ri]},$$scope:{ctx:w}}}),Ue=new b({props:{code:"ZnJvbSUyMHR5cGluZyUyMGltcG9ydCUyME1hcHBpbmclMkMlMjBPcmRlcmVkRGljdCUwQWZyb20lMjB0cmFuc2Zvcm1lcnMub25ueCUyMGltcG9ydCUyME9ubnhDb25maWclMEElMEElMEFjbGFzcyUyMERpc3RpbEJlcnRPbm54Q29uZmlnKE9ubnhDb25maWcpJTNBJTBBJTIwJTIwJTIwJTIwJTQwcHJvcGVydHklMEElMjAlMjAlMjAlMjBkZWYlMjBpbnB1dHMoc2VsZiklMjAtJTNFJTIwTWFwcGluZyU1QnN0ciUyQyUyME1hcHBpbmclNUJpbnQlMkMlMjBzdHIlNUQlNUQlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjByZXR1cm4lMjBPcmRlcmVkRGljdCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAoJTIyaW5wdXRfaWRzJTIyJTJDJTIwJTdCMCUzQSUyMCUyMmJhdGNoJTIyJTJDJTIwMSUzQSUyMCUyMnNlcXVlbmNlJTIyJTdEKSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCglMjJhdHRlbnRpb25fbWFzayUyMiUyQyUyMCU3QjAlM0ElMjAlMjJiYXRjaCUyMiUyQyUyMDElM0ElMjAlMjJzZXF1ZW5jZSUyMiU3RCklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> Mapping, OrderedDict
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> OnnxConfig


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">class</span> <span class="hljs-title class_">DistilBertOnnxConfig</span>(<span class="hljs-title class_ inherited__">OnnxConfig</span>):
<span class="hljs-meta">... </span>    @<span class="hljs-built_in">property</span>
<span class="hljs-meta">... </span>    <span class="hljs-keyword">def</span> <span class="hljs-title function_">inputs</span>(<span class="hljs-params">self</span>) -&gt; Mapping[<span class="hljs-built_in">str</span>, Mapping[<span class="hljs-built_in">int</span>, <span class="hljs-built_in">str</span>]]:
<span class="hljs-meta">... </span>        <span class="hljs-keyword">return</span> OrderedDict(
<span class="hljs-meta">... </span>            [
<span class="hljs-meta">... </span>                (<span class="hljs-string">&quot;input_ids&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>}),
<span class="hljs-meta">... </span>                (<span class="hljs-string">&quot;attention_mask&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>}),
<span class="hljs-meta">... </span>            ]
<span class="hljs-meta">... </span>        )`,wrap:!1}}),I=new Rt({props:{$$slots:{default:[Vi]},$$scope:{ctx:w}}}),Ce=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFjb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBb25ueF9jb25maWclMjAlM0QlMjBEaXN0aWxCZXJ0T25ueENvbmZpZyhjb25maWcp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config = DistilBertOnnxConfig(config)`,wrap:!1}}),Ie=new b({props:{code:"cHJpbnQob25ueF9jb25maWcuZGVmYXVsdF9vbm54X29wc2V0KQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config.default_onnx_opset)
<span class="hljs-number">11</span>`,wrap:!1}}),Be=new b({props:{code:"cHJpbnQob25ueF9jb25maWcub3V0cHV0cyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config.outputs)
OrderedDict([(<span class="hljs-string">&quot;last_hidden_state&quot;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&quot;batch&quot;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&quot;sequence&quot;</span>})])`,wrap:!1}}),_e=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFjb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0JTJGZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBb25ueF9jb25maWdfZm9yX3NlcV9jbGYlMjAlM0QlMjBEaXN0aWxCZXJ0T25ueENvbmZpZyhjb25maWclMkMlMjB0YXNrJTNEJTIyc2VxdWVuY2UtY2xhc3NpZmljYXRpb24lMjIpJTBBcHJpbnQob25ueF9jb25maWdfZm9yX3NlcV9jbGYub3V0cHV0cyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoConfig

<span class="hljs-meta">&gt;&gt;&gt; </span>config = AutoConfig.from_pretrained(<span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config_for_seq_clf = DistilBertOnnxConfig(config, task=<span class="hljs-string">&quot;sequence-classification&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(onnx_config_for_seq_clf.outputs)
OrderedDict([(<span class="hljs-string">&#x27;logits&#x27;</span>, {<span class="hljs-number">0</span>: <span class="hljs-string">&#x27;batch&#x27;</span>})])`,wrap:!1}}),k=new Rt({props:{$$slots:{default:[Hi]},$$scope:{ctx:w}}}),We=new $({props:{title:"Esportazione del modello",local:"esportazione-del-modello",headingTag:"h4"}}),Ae=new b({props:{code:"ZnJvbSUyMHBhdGhsaWIlMjBpbXBvcnQlMjBQYXRoJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5vbm54JTIwaW1wb3J0JTIwZXhwb3J0JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWwlMEElMEFvbm54X3BhdGglMjAlM0QlMjBQYXRoKCUyMm1vZGVsLm9ubnglMjIpJTBBbW9kZWxfY2twdCUyMCUzRCUyMCUyMmRpc3RpbGJlcnQlMkZkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiUwQWJhc2VfbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWwuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NrcHQpJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2twdCklMEElMEFvbm54X2lucHV0cyUyQyUyMG9ubnhfb3V0cHV0cyUyMCUzRCUyMGV4cG9ydCh0b2tlbml6ZXIlMkMlMjBiYXNlX21vZGVsJTJDJTIwb25ueF9jb25maWclMkMlMjBvbm54X2NvbmZpZy5kZWZhdWx0X29ubnhfb3BzZXQlMkMlMjBvbm54X3BhdGgp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> pathlib <span class="hljs-keyword">import</span> Path
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> export
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModel

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_path = Path(<span class="hljs-string">&quot;model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>model_ckpt = <span class="hljs-string">&quot;distilbert/distilbert-base-uncased&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>base_model = AutoModel.from_pretrained(model_ckpt)
<span class="hljs-meta">&gt;&gt;&gt; </span>tokenizer = AutoTokenizer.from_pretrained(model_ckpt)

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_inputs, onnx_outputs = export(tokenizer, base_model, onnx_config, onnx_config.default_onnx_opset, onnx_path)`,wrap:!1}}),Ge=new b({props:{code:"aW1wb3J0JTIwb25ueCUwQSUwQW9ubnhfbW9kZWwlMjAlM0QlMjBvbm54LmxvYWQoJTIybW9kZWwub25ueCUyMiklMEFvbm54LmNoZWNrZXIuY2hlY2tfbW9kZWwob25ueF9tb2RlbCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> onnx

<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_model = onnx.load(<span class="hljs-string">&quot;model.onnx&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx.checker.check_model(onnx_model)`,wrap:!1}}),B=new Rt({props:{$$slots:{default:[Ei]},$$scope:{ctx:w}}}),Re=new $({props:{title:"Convalida degli output del modello",local:"convalida-degli-output-del-modello",headingTag:"h4"}}),He=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycy5vbm54JTIwaW1wb3J0JTIwdmFsaWRhdGVfbW9kZWxfb3V0cHV0cyUwQSUwQXZhbGlkYXRlX21vZGVsX291dHB1dHMoJTBBJTIwJTIwJTIwJTIwb25ueF9jb25maWclMkMlMjB0b2tlbml6ZXIlMkMlMjBiYXNlX21vZGVsJTJDJTIwb25ueF9wYXRoJTJDJTIwb25ueF9vdXRwdXRzJTJDJTIwb25ueF9jb25maWcuYXRvbF9mb3JfdmFsaWRhdGlvbiUwQSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> transformers.onnx <span class="hljs-keyword">import</span> validate_model_outputs

<span class="hljs-meta">&gt;&gt;&gt; </span>validate_model_outputs(
<span class="hljs-meta">... </span>    onnx_config, tokenizer, base_model, onnx_path, onnx_outputs, onnx_config.atol_for_validation
<span class="hljs-meta">... </span>)`,wrap:!1}}),Qe=new $({props:{title:"Contribuire con una nuova configurazione a 🤗 Transformers",local:"contribuire-con-una-nuova-configurazione-a--transformers",headingTag:"h3"}}),qe=new $({props:{title:"TorchScript",local:"torchscript",headingTag:"h2"}}),x=new Rt({props:{$$slots:{default:[Qi]},$$scope:{ctx:w}}}),et=new $({props:{title:"Flag TorchScript e pesi legati",local:"flag-torchscript-e-pesi-legati",headingTag:"h3"}}),st=new $({props:{title:"Input fittizi e standard lengths",local:"input-fittizi-e-standard-lengths",headingTag:"h3"}}),ct=new $({props:{title:"Usare TorchSscript in Python",local:"usare-torchsscript-in-python",headingTag:"h3"}}),dt=new $({props:{title:"Salvare un modello",local:"salvare-un-modello",headingTag:"h4"}}),Mt=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElMEFlbmMlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJnb29nbGUtYmVydCUyRmJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQSUwQSUyMyUyMFRva2VuaXppbmclMjBpbnB1dCUyMHRleHQlMEF0ZXh0JTIwJTNEJTIwJTIyJTVCQ0xTJTVEJTIwV2hvJTIwd2FzJTIwSmltJTIwSGVuc29uJTIwJTNGJTIwJTVCU0VQJTVEJTIwSmltJTIwSGVuc29uJTIwd2FzJTIwYSUyMHB1cHBldGVlciUyMCU1QlNFUCU1RCUyMiUwQXRva2VuaXplZF90ZXh0JTIwJTNEJTIwZW5jLnRva2VuaXplKHRleHQpJTBBJTBBJTIzJTIwTWFza2luZyUyMG9uZSUyMG9mJTIwdGhlJTIwaW5wdXQlMjB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keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel, BertTokenizer, BertConfig
<span class="hljs-keyword">import</span> torch

enc = BertTokenizer.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>)

<span class="hljs-comment"># Tokenizing input text</span>
text = <span class="hljs-string">&quot;[CLS] Who was Jim Henson ? [SEP] Jim Henson was a puppeteer [SEP]&quot;</span>
tokenized_text = enc.tokenize(text)

<span class="hljs-comment"># Masking one of the input tokens</span>
masked_index = <span class="hljs-number">8</span>
tokenized_text[masked_index] = <span class="hljs-string">&quot;[MASK]&quot;</span>
indexed_tokens = enc.convert_tokens_to_ids(tokenized_text)
segments_ids = [<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">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-comment"># Creating a dummy input</span>
tokens_tensor = torch.tensor([indexed_tokens])
segments_tensors = torch.tensor([segments_ids])
dummy_input = [tokens_tensor, segments_tensors]

<span class="hljs-comment"># Initializing the model with the torchscript flag</span>
<span class="hljs-comment"># Flag set to True even though it is not necessary as this model does not have an LM Head.</span>
config = BertConfig(
    vocab_size_or_config_json_file=<span class="hljs-number">32000</span>,
    hidden_size=<span class="hljs-number">768</span>,
    num_hidden_layers=<span class="hljs-number">12</span>,
    num_attention_heads=<span class="hljs-number">12</span>,
    intermediate_size=<span class="hljs-number">3072</span>,
    torchscript=<span class="hljs-literal">True</span>,
)

<span class="hljs-comment"># Instantiating the model</span>
model = BertModel(config)

<span class="hljs-comment"># The model needs to be in evaluation mode</span>
model.<span class="hljs-built_in">eval</span>()

<span class="hljs-comment"># If you are instantiating the model with *from_pretrained* you can also easily set the TorchScript flag</span>
model = BertModel.from_pretrained(<span class="hljs-string">&quot;google-bert/bert-base-uncased&quot;</span>, torchscript=<span class="hljs-literal">True</span>)

<span class="hljs-comment"># Creating the trace</span>
traced_model = torch.jit.trace(model, [tokens_tensor, segments_tensors])
torch.jit.save(traced_model, <span class="hljs-string">&quot;traced_bert.pt&quot;</span>)`,wrap:!1}}),ft=new $({props:{title:"Caricare un modello",local:"caricare-un-modello",headingTag:"h4"}}),ht=new b({props:{code:"bG9hZGVkX21vZGVsJTIwJTNEJTIwdG9yY2guaml0LmxvYWQoJTIydHJhY2VkX2JlcnQucHQlMjIpJTBBbG9hZGVkX21vZGVsLmV2YWwoKSUwQSUwQWFsbF9lbmNvZGVyX2xheWVycyUyQyUyMHBvb2xlZF9vdXRwdXQlMjAlM0QlMjBsb2FkZWRfbW9kZWwoKmR1bW15X2lucHV0KQ==",highlighted:`loaded_model = torch.jit.load(<span class="hljs-string">&quot;traced_bert.pt&quot;</span>)
loaded_model.<span class="hljs-built_in">eval</span>()

all_encoder_layers, pooled_output = loaded_model(*dummy_input)`,wrap:!1}}),yt=new $({props:{title:"Utilizzare un modello tracciato per l’inferenza",local:"utilizzare-un-modello-tracciato-per-linferenza",headingTag:"h4"}}),bt=new b({props:{code:"dHJhY2VkX21vZGVsKHRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzKQ==",highlighted:"traced_model(tokens_tensor, segments_tensors)",wrap:!1}}),Tt=new $({props:{title:"Implementare modelli HuggingFace TorchScript su AWS utilizzando Neuron SDK",local:"implementare-modelli-huggingface-torchscript-su-aws-utilizzando-neuron-sdk",headingTag:"h3"}}),$t=new $({props:{title:"Implicazioni",local:"implicazioni",headingTag:"h4"}}),vt=new $({props:{title:"Dipendenze",local:"dipendenze",headingTag:"h4"}}),Zt=new $({props:{title:"Convertire un modello per AWS Neuron",local:"convertire-un-modello-per-aws-neuron",headingTag:"h4"}}),kt=new b({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjB0b3JjaC5uZXVyb24=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> BertModel, BertTokenizer, BertConfig
<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">import</span> torch.neuron`,wrap:!1}}),_t=new b({props:{code:"dG9yY2guaml0LnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5zX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQp",highlighted:"torch.jit.trace(model, [tokens_tensor, segments_tensors])",wrap:!1}}),Xt=new b({props:{code:"dG9yY2gubmV1cm9uLnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5fdGVuc29yJTJDJTIwc2VnbWVudHNfdGVuc29ycyU1RCk=",highlighted:"torch.neuron.trace(model, [token_tensor, segments_tensors])",wrap:!1}}),Gt=new _i({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/it/serialization.md"}}),{c(){a=r("meta"),y=s(),o=r("p"),j=s(),m(T.$$.fragment),J=s(),U=r("p"),U.textContent=h,v=s(),W=r("p"),W.innerHTML=ls,Ht=s(),m(X.$$.fragment),Et=s(),A=r("p"),A.innerHTML=ns,Qt=s(),N=r("p"),N.textContent=ss,Lt=s(),G=r("p"),G.innerHTML=is,St=s(),R=r("p"),R.textContent=as,Ft=s(),V=r("ul"),V.innerHTML=os,qt=s(),H=r("p"),H.textContent=rs,Yt=s(),E=r("ul"),E.innerHTML=ps,Pt=s(),m(Q.$$.fragment),Dt=s(),L=r("p"),L.textContent=cs,Ot=s(),m(S.$$.fragment),Kt=s(),F=r("p"),F.innerHTML=ms,el=s(),m(q.$$.fragment),tl=s(),Y=r("p"),Y.textContent=ds,ll=s(),m(P.$$.fragment),nl=s(),D=r("p"),D.textContent=us,sl=s(),m(O.$$.fragment),il=s(),K=r("p"),K.innerHTML=Ms,al=s(),ee=r("p"),ee.innerHTML=fs,ol=s(),m(te.$$.fragment),rl=s(),le=r("p"),le.innerHTML=gs,pl=s(),m(ne.$$.fragment),cl=s(),se=r("p"),se.innerHTML=hs,ml=s(),m(ie.$$.fragment),dl=s(),ae=r("p"),ae.textContent=ys,ul=s(),m(z.$$.fragment),Ml=s(),m(oe.$$.fragment),fl=s(),re=r("p"),re.innerHTML=js,gl=s(),pe=r("table"),pe.innerHTML=bs,hl=s(),ce=r("p"),ce.innerHTML=Ts,yl=s(),m(me.$$.fragment),jl=s(),de=r("p"),de.innerHTML=ws,bl=s(),m(ue.$$.fragment),Tl=s(),Me=r("p"),Me.textContent=Js,wl=s(),m(fe.$$.fragment),Jl=s(),ge=r("p"),ge.innerHTML=$s,$l=s(),m(C.$$.fragment),Ul=s(),m(he.$$.fragment),vl=s(),ye=r("p"),ye.textContent=Us,zl=s(),je=r("ol"),je.innerHTML=vs,Cl=s(),be=r("p"),be.textContent=zs,Zl=s(),m(Te.$$.fragment),Il=s(),we=r("p"),we.textContent=Cs,kl=s(),Je=r("ul"),Je.innerHTML=Zs,Bl=s(),m(Z.$$.fragment),xl=s(),$e=r("p"),$e.innerHTML=Is,_l=s(),m(Ue.$$.fragment),Wl=s(),ve=r("p"),ve.innerHTML=ks,Xl=s(),m(I.$$.fragment),Al=s(),ze=r("p"),ze.textContent=Bs,Nl=s(),m(Ce.$$.fragment),Gl=s(),Ze=r("p"),Ze.textContent=xs,Rl=s(),m(Ie.$$.fragment),Vl=s(),ke=r("p"),ke.textContent=_s,Hl=s(),m(Be.$$.fragment),El=s(),xe=r("p"),xe.innerHTML=Ws,Ql=s(),m(_e.$$.fragment),Ll=s(),m(k.$$.fragment),Sl=s(),m(We.$$.fragment),Fl=s(),Xe=r("p"),Xe.innerHTML=Xs,ql=s(),m(Ae.$$.fragment),Yl=s(),Ne=r("p"),Ne.innerHTML=As,Pl=s(),m(Ge.$$.fragment),Dl=s(),m(B.$$.fragment),Ol=s(),m(Re.$$.fragment),Kl=s(),Ve=r("p"),Ve.innerHTML=Ns,en=s(),m(He.$$.fragment),tn=s(),Ee=r("p"),Ee.innerHTML=Gs,ln=s(),m(Qe.$$.fragment),nn=s(),Le=r("p"),Le.textContent=Rs,sn=s(),Se=r("ul"),Se.innerHTML=Vs,an=s(),Fe=r("p"),Fe.innerHTML=Hs,on=s(),m(qe.$$.fragment),rn=s(),m(x.$$.fragment),pn=s(),Ye=r("p"),Ye.innerHTML=Es,cn=s(),Pe=r("p"),Pe.textContent=Qs,mn=s(),De=r("p"),De.textContent=Ls,dn=s(),Oe=r("ul"),Oe.innerHTML=Ss,un=s(),Ke=r("p"),Ke.textContent=Fs,Mn=s(),m(et.$$.fragment),fn=s(),tt=r("p"),tt.textContent=qs,gn=s(),lt=r("p"),lt.innerHTML=Ys,hn=s(),nt=r("p"),nt.innerHTML=Ps,yn=s(),m(st.$$.fragment),jn=s(),it=r("p"),it.textContent=Ds,bn=s(),at=r("p"),at.textContent=Os,Tn=s(),ot=r("p"),ot.innerHTML=Ks,wn=s(),rt=r("p"),rt.textContent=ei,Jn=s(),pt=r("p"),pt.textContent=ti,$n=s(),m(ct.$$.fragment),Un=s(),mt=r("p"),mt.textContent=li,vn=s(),m(dt.$$.fragment),zn=s(),ut=r("p"),ut.innerHTML=ni,Cn=s(),m(Mt.$$.fragment),Zn=s(),m(ft.$$.fragment),In=s(),gt=r("p"),gt.innerHTML=si,kn=s(),m(ht.$$.fragment),Bn=s(),m(yt.$$.fragment),xn=s(),jt=r("p"),jt.innerHTML=ii,_n=s(),m(bt.$$.fragment),Wn=s(),m(Tt.$$.fragment),Xn=s(),wt=r("p"),wt.innerHTML=ai,An=s(),Jt=r("ol"),Jt.innerHTML=oi,Nn=s(),m($t.$$.fragment),Gn=s(),Ut=r("p"),Ut.innerHTML=ri,Rn=s(),m(vt.$$.fragment),Vn=s(),zt=r("p"),zt.textContent=pi,Hn=s(),Ct=r("ul"),Ct.innerHTML=ci,En=s(),m(Zt.$$.fragment),Qn=s(),It=r("p"),It.innerHTML=mi,Ln=s(),m(kt.$$.fragment),Sn=s(),Bt=r("p"),Bt.textContent=di,Fn=s(),xt=r("p"),xt.textContent=ui,qn=s(),m(_t.$$.fragment),Yn=s(),Wt=r("p"),Wt.textContent=Mi,Pn=s(),m(Xt.$$.fragment),Dn=s(),At=r("p"),At.textContent=fi,On=s(),Nt=r("p"),Nt.innerHTML=gi,Kn=s(),m(Gt.$$.fragment),es=s(),Vt=r("p"),this.h()},l(e){const t=ki("svelte-u9bgzb",document.head);a=p(t,"META",{name:!0,content:!0}),t.forEach(l),y=i(e),o=p(e,"P",{}),$i(o).forEach(l),j=i(e),d(T.$$.fragment,e),J=i(e),U=p(e,"P",{"data-svelte-h":!0}),c(U)!=="svelte-do19d6"&&(U.textContent=h),v=i(e),W=p(e,"P",{"data-svelte-h":!0}),c(W)!=="svelte-1f9txfv"&&(W.innerHTML=ls),Ht=i(e),d(X.$$.fragment,e),Et=i(e),A=p(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-1gdh4oo"&&(A.innerHTML=ns),Qt=i(e),N=p(e,"P",{"data-svelte-h":!0}),c(N)!=="svelte-z64a5j"&&(N.textContent=ss),Lt=i(e),G=p(e,"P",{"data-svelte-h":!0}),c(G)!=="svelte-7rl71e"&&(G.innerHTML=is),St=i(e),R=p(e,"P",{"data-svelte-h":!0}),c(R)!=="svelte-sr712u"&&(R.textContent=as),Ft=i(e),V=p(e,"UL",{"data-svelte-h":!0}),c(V)!=="svelte-vozkex"&&(V.innerHTML=os),qt=i(e),H=p(e,"P",{"data-svelte-h":!0}),c(H)!=="svelte-1sn7n41"&&(H.textContent=rs),Yt=i(e),E=p(e,"UL",{"data-svelte-h":!0}),c(E)!=="svelte-1g8hsur"&&(E.innerHTML=ps),Pt=i(e),d(Q.$$.fragment,e),Dt=i(e),L=p(e,"P",{"data-svelte-h":!0}),c(L)!=="svelte-4psczp"&&(L.textContent=cs),Ot=i(e),d(S.$$.fragment,e),Kt=i(e),F=p(e,"P",{"data-svelte-h":!0}),c(F)!=="svelte-1j72zvu"&&(F.innerHTML=ms),el=i(e),d(q.$$.fragment,e),tl=i(e),Y=p(e,"P",{"data-svelte-h":!0}),c(Y)!=="svelte-13jbmoq"&&(Y.textContent=ds),ll=i(e),d(P.$$.fragment,e),nl=i(e),D=p(e,"P",{"data-svelte-h":!0}),c(D)!=="svelte-wxqvf3"&&(D.textContent=us),sl=i(e),d(O.$$.fragment,e),il=i(e),K=p(e,"P",{"data-svelte-h":!0}),c(K)!=="svelte-16irxk2"&&(K.innerHTML=Ms),al=i(e),ee=p(e,"P",{"data-svelte-h":!0}),c(ee)!=="svelte-rdoavc"&&(ee.innerHTML=fs),ol=i(e),d(te.$$.fragment,e),rl=i(e),le=p(e,"P",{"data-svelte-h":!0}),c(le)!=="svelte-1t39lef"&&(le.innerHTML=gs),pl=i(e),d(ne.$$.fragment,e),cl=i(e),se=p(e,"P",{"data-svelte-h":!0}),c(se)!=="svelte-ej8fgq"&&(se.innerHTML=hs),ml=i(e),d(ie.$$.fragment,e),dl=i(e),ae=p(e,"P",{"data-svelte-h":!0}),c(ae)!=="svelte-h5zd9u"&&(ae.textContent=ys),ul=i(e),d(z.$$.fragment,e),Ml=i(e),d(oe.$$.fragment,e),fl=i(e),re=p(e,"P",{"data-svelte-h":!0}),c(re)!=="svelte-ne5myz"&&(re.innerHTML=js),gl=i(e),pe=p(e,"TABLE",{"data-svelte-h":!0}),c(pe)!=="svelte-1n68aa"&&(pe.innerHTML=bs),hl=i(e),ce=p(e,"P",{"data-svelte-h":!0}),c(ce)!=="svelte-6wtiyv"&&(ce.innerHTML=Ts),yl=i(e),d(me.$$.fragment,e),jl=i(e),de=p(e,"P",{"data-svelte-h":!0}),c(de)!=="svelte-3qfl60"&&(de.innerHTML=ws),bl=i(e),d(ue.$$.fragment,e),Tl=i(e),Me=p(e,"P",{"data-svelte-h":!0}),c(Me)!=="svelte-lgu95w"&&(Me.textContent=Js),wl=i(e),d(fe.$$.fragment,e),Jl=i(e),ge=p(e,"P",{"data-svelte-h":!0}),c(ge)!=="svelte-13p6mbz"&&(ge.innerHTML=$s),$l=i(e),d(C.$$.fragment,e),Ul=i(e),d(he.$$.fragment,e),vl=i(e),ye=p(e,"P",{"data-svelte-h":!0}),c(ye)!=="svelte-17r0w1i"&&(ye.textContent=Us),zl=i(e),je=p(e,"OL",{"data-svelte-h":!0}),c(je)!=="svelte-z67jz4"&&(je.innerHTML=vs),Cl=i(e),be=p(e,"P",{"data-svelte-h":!0}),c(be)!=="svelte-10yqqq8"&&(be.textContent=zs),Zl=i(e),d(Te.$$.fragment,e),Il=i(e),we=p(e,"P",{"data-svelte-h":!0}),c(we)!=="svelte-trahak"&&(we.textContent=Cs),kl=i(e),Je=p(e,"UL",{"data-svelte-h":!0}),c(Je)!=="svelte-j9of43"&&(Je.innerHTML=Zs),Bl=i(e),d(Z.$$.fragment,e),xl=i(e),$e=p(e,"P",{"data-svelte-h":!0}),c($e)!=="svelte-1jb3jgn"&&($e.innerHTML=Is),_l=i(e),d(Ue.$$.fragment,e),Wl=i(e),ve=p(e,"P",{"data-svelte-h":!0}),c(ve)!=="svelte-13xj4dt"&&(ve.innerHTML=ks),Xl=i(e),d(I.$$.fragment,e),Al=i(e),ze=p(e,"P",{"data-svelte-h":!0}),c(ze)!=="svelte-w0rck2"&&(ze.textContent=Bs),Nl=i(e),d(Ce.$$.fragment,e),Gl=i(e),Ze=p(e,"P",{"data-svelte-h":!0}),c(Ze)!=="svelte-6wsqkw"&&(Ze.textContent=xs),Rl=i(e),d(Ie.$$.fragment,e),Vl=i(e),ke=p(e,"P",{"data-svelte-h":!0}),c(ke)!=="svelte-1ggtlqz"&&(ke.textContent=_s),Hl=i(e),d(Be.$$.fragment,e),El=i(e),xe=p(e,"P",{"data-svelte-h":!0}),c(xe)!=="svelte-1kn83vw"&&(xe.innerHTML=Ws),Ql=i(e),d(_e.$$.fragment,e),Ll=i(e),d(k.$$.fragment,e),Sl=i(e),d(We.$$.fragment,e),Fl=i(e),Xe=p(e,"P",{"data-svelte-h":!0}),c(Xe)!=="svelte-1ocrgze"&&(Xe.innerHTML=Xs),ql=i(e),d(Ae.$$.fragment,e),Yl=i(e),Ne=p(e,"P",{"data-svelte-h":!0}),c(Ne)!=="svelte-kxw9bj"&&(Ne.innerHTML=As),Pl=i(e),d(Ge.$$.fragment,e),Dl=i(e),d(B.$$.fragment,e),Ol=i(e),d(Re.$$.fragment,e),Kl=i(e),Ve=p(e,"P",{"data-svelte-h":!0}),c(Ve)!=="svelte-zllt9o"&&(Ve.innerHTML=Ns),en=i(e),d(He.$$.fragment,e),tn=i(e),Ee=p(e,"P",{"data-svelte-h":!0}),c(Ee)!=="svelte-1c44gg3"&&(Ee.innerHTML=Gs),ln=i(e),d(Qe.$$.fragment,e),nn=i(e),Le=p(e,"P",{"data-svelte-h":!0}),c(Le)!=="svelte-lrvm1j"&&(Le.textContent=Rs),sn=i(e),Se=p(e,"UL",{"data-svelte-h":!0}),c(Se)!=="svelte-a8pd1a"&&(Se.innerHTML=Vs),an=i(e),Fe=p(e,"P",{"data-svelte-h":!0}),c(Fe)!=="svelte-6wlbs5"&&(Fe.innerHTML=Hs),on=i(e),d(qe.$$.fragment,e),rn=i(e),d(x.$$.fragment,e),pn=i(e),Ye=p(e,"P",{"data-svelte-h":!0}),c(Ye)!=="svelte-wgebc9"&&(Ye.innerHTML=Es),cn=i(e),Pe=p(e,"P",{"data-svelte-h":!0}),c(Pe)!=="svelte-9p2ixq"&&(Pe.textContent=Qs),mn=i(e),De=p(e,"P",{"data-svelte-h":!0}),c(De)!=="svelte-6xn7nf"&&(De.textContent=Ls),dn=i(e),Oe=p(e,"UL",{"data-svelte-h":!0}),c(Oe)!=="svelte-oy2125"&&(Oe.innerHTML=Ss),un=i(e),Ke=p(e,"P",{"data-svelte-h":!0}),c(Ke)!=="svelte-m48voh"&&(Ke.textContent=Fs),Mn=i(e),d(et.$$.fragment,e),fn=i(e),tt=p(e,"P",{"data-svelte-h":!0}),c(tt)!=="svelte-tz9w6u"&&(tt.textContent=qs),gn=i(e),lt=p(e,"P",{"data-svelte-h":!0}),c(lt)!=="svelte-1mq7t8t"&&(lt.innerHTML=Ys),hn=i(e),nt=p(e,"P",{"data-svelte-h":!0}),c(nt)!=="svelte-1jmydvh"&&(nt.innerHTML=Ps),yn=i(e),d(st.$$.fragment,e),jn=i(e),it=p(e,"P",{"data-svelte-h":!0}),c(it)!=="svelte-c132kv"&&(it.textContent=Ds),bn=i(e),at=p(e,"P",{"data-svelte-h":!0}),c(at)!=="svelte-1bggopo"&&(at.textContent=Os),Tn=i(e),ot=p(e,"P",{"data-svelte-h":!0}),c(ot)!=="svelte-vyea1g"&&(ot.innerHTML=Ks),wn=i(e),rt=p(e,"P",{"data-svelte-h":!0}),c(rt)!=="svelte-1yce0u1"&&(rt.textContent=ei),Jn=i(e),pt=p(e,"P",{"data-svelte-h":!0}),c(pt)!=="svelte-1sr04ao"&&(pt.textContent=ti),$n=i(e),d(ct.$$.fragment,e),Un=i(e),mt=p(e,"P",{"data-svelte-h":!0}),c(mt)!=="svelte-q23m3c"&&(mt.textContent=li),vn=i(e),d(dt.$$.fragment,e),zn=i(e),ut=p(e,"P",{"data-svelte-h":!0}),c(ut)!=="svelte-k16qri"&&(ut.innerHTML=ni),Cn=i(e),d(Mt.$$.fragment,e),Zn=i(e),d(ft.$$.fragment,e),In=i(e),gt=p(e,"P",{"data-svelte-h":!0}),c(gt)!=="svelte-wh65i"&&(gt.innerHTML=si),kn=i(e),d(ht.$$.fragment,e),Bn=i(e),d(yt.$$.fragment,e),xn=i(e),jt=p(e,"P",{"data-svelte-h":!0}),c(jt)!=="svelte-1gnslzu"&&(jt.innerHTML=ii),_n=i(e),d(bt.$$.fragment,e),Wn=i(e),d(Tt.$$.fragment,e),Xn=i(e),wt=p(e,"P",{"data-svelte-h":!0}),c(wt)!=="svelte-fjq776"&&(wt.innerHTML=ai),An=i(e),Jt=p(e,"OL",{"data-svelte-h":!0}),c(Jt)!=="svelte-121gcdu"&&(Jt.innerHTML=oi),Nn=i(e),d($t.$$.fragment,e),Gn=i(e),Ut=p(e,"P",{"data-svelte-h":!0}),c(Ut)!=="svelte-nfv9dr"&&(Ut.innerHTML=ri),Rn=i(e),d(vt.$$.fragment,e),Vn=i(e),zt=p(e,"P",{"data-svelte-h":!0}),c(zt)!=="svelte-clfp9m"&&(zt.textContent=pi),Hn=i(e),Ct=p(e,"UL",{"data-svelte-h":!0}),c(Ct)!=="svelte-1yjzy16"&&(Ct.innerHTML=ci),En=i(e),d(Zt.$$.fragment,e),Qn=i(e),It=p(e,"P",{"data-svelte-h":!0}),c(It)!=="svelte-wberyk"&&(It.innerHTML=mi),Ln=i(e),d(kt.$$.fragment,e),Sn=i(e),Bt=p(e,"P",{"data-svelte-h":!0}),c(Bt)!=="svelte-e7n7t3"&&(Bt.textContent=di),Fn=i(e),xt=p(e,"P",{"data-svelte-h":!0}),c(xt)!=="svelte-yedjtf"&&(xt.textContent=ui),qn=i(e),d(_t.$$.fragment,e),Yn=i(e),Wt=p(e,"P",{"data-svelte-h":!0}),c(Wt)!=="svelte-a9ap49"&&(Wt.textContent=Mi),Pn=i(e),d(Xt.$$.fragment,e),Dn=i(e),At=p(e,"P",{"data-svelte-h":!0}),c(At)!=="svelte-1pjct15"&&(At.textContent=fi),On=i(e),Nt=p(e,"P",{"data-svelte-h":!0}),c(Nt)!=="svelte-1do2s1n"&&(Nt.innerHTML=gi),Kn=i(e),d(Gt.$$.fragment,e),es=i(e),Vt=p(e,"P",{}),$i(Vt).forEach(l),this.h()},h(){Ui(a,"name","hf:doc:metadata"),Ui(a,"content",Si)},m(e,t){Bi(document.head,a),n(e,y,t),n(e,o,t),n(e,j,t),u(T,e,t),n(e,J,t),n(e,U,t),n(e,v,t),n(e,W,t),n(e,Ht,t),u(X,e,t),n(e,Et,t),n(e,A,t),n(e,Qt,t),n(e,N,t),n(e,Lt,t),n(e,G,t),n(e,St,t),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t),n(e,On,t),n(e,Nt,t),n(e,Kn,t),u(Gt,e,t),n(e,es,t),n(e,Vt,t),ts=!0},p(e,[t]){const hi={};t&2&&(hi.$$scope={dirty:t,ctx:e}),z.$set(hi);const yi={};t&2&&(yi.$$scope={dirty:t,ctx:e}),C.$set(yi);const ji={};t&2&&(ji.$$scope={dirty:t,ctx:e}),Z.$set(ji);const bi={};t&2&&(bi.$$scope={dirty:t,ctx:e}),I.$set(bi);const Ti={};t&2&&(Ti.$$scope={dirty:t,ctx:e}),k.$set(Ti);const wi={};t&2&&(wi.$$scope={dirty:t,ctx:e}),B.$set(wi);const Ji={};t&2&&(Ji.$$scope={dirty:t,ctx:e}),x.$set(Ji)},i(e){ts||(M(T.$$.fragment,e),M(X.$$.fragment,e),M(Q.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(P.$$.fragment,e),M(O.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(ie.$$.fragment,e),M(z.$$.fragment,e),M(oe.$$.fragment,e),M(me.$$.fragment,e),M(ue.$$.fragment,e),M(fe.$$.fragment,e),M(C.$$.fragment,e),M(he.$$.fragment,e),M(Te.$$.fragment,e),M(Z.$$.fragment,e),M(Ue.$$.fragment,e),M(I.$$.fragment,e),M(Ce.$$.fragment,e),M(Ie.$$.fragment,e),M(Be.$$.fragment,e),M(_e.$$.fragment,e),M(k.$$.fragment,e),M(We.$$.fragment,e),M(Ae.$$.fragment,e),M(Ge.$$.fragment,e),M(B.$$.fragment,e),M(Re.$$.fragment,e),M(He.$$.fragment,e),M(Qe.$$.fragment,e),M(qe.$$.fragment,e),M(x.$$.fragment,e),M(et.$$.fragment,e),M(st.$$.fragment,e),M(ct.$$.fragment,e),M(dt.$$.fragment,e),M(Mt.$$.fragment,e),M(ft.$$.fragment,e),M(ht.$$.fragment,e),M(yt.$$.fragment,e),M(bt.$$.fragment,e),M(Tt.$$.fragment,e),M($t.$$.fragment,e),M(vt.$$.fragment,e),M(Zt.$$.fragment,e),M(kt.$$.fragment,e),M(_t.$$.fragment,e),M(Xt.$$.fragment,e),M(Gt.$$.fragment,e),ts=!0)},o(e){f(T.$$.fragment,e),f(X.$$.fragment,e),f(Q.$$.fragment,e),f(S.$$.fragment,e),f(q.$$.fragment,e),f(P.$$.fragment,e),f(O.$$.fragment,e),f(te.$$.fragment,e),f(ne.$$.fragment,e),f(ie.$$.fragment,e),f(z.$$.fragment,e),f(oe.$$.fragment,e),f(me.$$.fragment,e),f(ue.$$.fragment,e),f(fe.$$.fragment,e),f(C.$$.fragment,e),f(he.$$.fragment,e),f(Te.$$.fragment,e),f(Z.$$.fragment,e),f(Ue.$$.fragment,e),f(I.$$.fragment,e),f(Ce.$$.fragment,e),f(Ie.$$.fragment,e),f(Be.$$.fragment,e),f(_e.$$.fragment,e),f(k.$$.fragment,e),f(We.$$.fragment,e),f(Ae.$$.fragment,e),f(Ge.$$.fragment,e),f(B.$$.fragment,e),f(Re.$$.fragment,e),f(He.$$.fragment,e),f(Qe.$$.fragment,e),f(qe.$$.fragment,e),f(x.$$.fragment,e),f(et.$$.fragment,e),f(st.$$.fragment,e),f(ct.$$.fragment,e),f(dt.$$.fragment,e),f(Mt.$$.fragment,e),f(ft.$$.fragment,e),f(ht.$$.fragment,e),f(yt.$$.fragment,e),f(bt.$$.fragment,e),f(Tt.$$.fragment,e),f($t.$$.fragment,e),f(vt.$$.fragment,e),f(Zt.$$.fragment,e),f(kt.$$.fragment,e),f(_t.$$.fragment,e),f(Xt.$$.fragment,e),f(Gt.$$.fragment,e),ts=!1},d(e){e&&(l(y),l(o),l(j),l(J),l(U),l(v),l(W),l(Ht),l(Et),l(A),l(Qt),l(N),l(Lt),l(G),l(St),l(R),l(Ft),l(V),l(qt),l(H),l(Yt),l(E),l(Pt),l(Dt),l(L),l(Ot),l(Kt),l(F),l(el),l(tl),l(Y),l(ll),l(nl),l(D),l(sl),l(il),l(K),l(al),l(ee),l(ol),l(rl),l(le),l(pl),l(cl),l(se),l(ml),l(dl),l(ae),l(ul),l(Ml),l(fl),l(re),l(gl),l(pe),l(hl),l(ce),l(yl),l(jl),l(de),l(bl),l(Tl),l(Me),l(wl),l(Jl),l(ge),l($l),l(Ul),l(vl),l(ye),l(zl),l(je),l(Cl),l(be),l(Zl),l(Il),l(we),l(kl),l(Je),l(Bl),l(xl),l($e),l(_l),l(Wl),l(ve),l(Xl),l(Al),l(ze),l(Nl),l(Gl),l(Ze),l(Rl),l(Vl),l(ke),l(Hl),l(El),l(xe),l(Ql),l(Ll),l(Sl),l(Fl),l(Xe),l(ql),l(Yl),l(Ne),l(Pl),l(Dl),l(Ol),l(Kl),l(Ve),l(en),l(tn),l(Ee),l(ln),l(nn),l(Le),l(sn),l(Se),l(an),l(Fe),l(on),l(rn),l(pn),l(Ye),l(cn),l(Pe),l(mn),l(De),l(dn),l(Oe),l(un),l(Ke),l(Mn),l(fn),l(tt),l(gn),l(lt),l(hn),l(nt),l(yn),l(jn),l(it),l(bn),l(at),l(Tn),l(ot),l(wn),l(rt),l(Jn),l(pt),l($n),l(Un),l(mt),l(vn),l(zn),l(ut),l(Cn),l(Zn),l(In),l(gt),l(kn),l(Bn),l(xn),l(jt),l(_n),l(Wn),l(Xn),l(wt),l(An),l(Jt),l(Nn),l(Gn),l(Ut),l(Rn),l(Vn),l(zt),l(Hn),l(Ct),l(En),l(Qn),l(It),l(Ln),l(Sn),l(Bt),l(Fn),l(xt),l(qn),l(Yn),l(Wt),l(Pn),l(Dn),l(At),l(On),l(Nt),l(Kn),l(es),l(Vt)),l(a),g(T,e),g(X,e),g(Q,e),g(S,e),g(q,e),g(P,e),g(O,e),g(te,e),g(ne,e),g(ie,e),g(z,e),g(oe,e),g(me,e),g(ue,e),g(fe,e),g(C,e),g(he,e),g(Te,e),g(Z,e),g(Ue,e),g(I,e),g(Ce,e),g(Ie,e),g(Be,e),g(_e,e),g(k,e),g(We,e),g(Ae,e),g(Ge,e),g(B,e),g(Re,e),g(He,e),g(Qe,e),g(qe,e),g(x,e),g(et,e),g(st,e),g(ct,e),g(dt,e),g(Mt,e),g(ft,e),g(ht,e),g(yt,e),g(bt,e),g(Tt,e),g($t,e),g(vt,e),g(Zt,e),g(kt,e),g(_t,e),g(Xt,e),g(Gt,e)}}}const Si='{"title":"Esporta modelli 🤗 Transformers","local":"esporta-modelli--transformers","sections":[{"title":"ONNX","local":"onnx","sections":[{"title":"Esportazione di un modello in ONNX","local":"esportazione-di-un-modello-in-onnx","sections":[],"depth":3},{"title":"Selezione delle caratteristiche per diverse topologie di modello","local":"selezione-delle-caratteristiche-per-diverse-topologie-di-modello","sections":[],"depth":3},{"title":"Esportazione di un modello per un’architettura non supportata","local":"esportazione-di-un-modello-per-unarchitettura-non-supportata","sections":[{"title":"Implementazione di una configurazione ONNX personalizzata","local":"implementazione-di-una-configurazione-onnx-personalizzata","sections":[],"depth":4},{"title":"Esportazione del modello","local":"esportazione-del-modello","sections":[],"depth":4},{"title":"Convalida degli output del modello","local":"convalida-degli-output-del-modello","sections":[],"depth":4}],"depth":3},{"title":"Contribuire con una nuova configurazione a 🤗 Transformers","local":"contribuire-con-una-nuova-configurazione-a--transformers","sections":[],"depth":3}],"depth":2},{"title":"TorchScript","local":"torchscript","sections":[{"title":"Flag TorchScript e pesi legati","local":"flag-torchscript-e-pesi-legati","sections":[],"depth":3},{"title":"Input fittizi e standard lengths","local":"input-fittizi-e-standard-lengths","sections":[],"depth":3},{"title":"Usare TorchSscript in Python","local":"usare-torchsscript-in-python","sections":[{"title":"Salvare un modello","local":"salvare-un-modello","sections":[],"depth":4},{"title":"Caricare un modello","local":"caricare-un-modello","sections":[],"depth":4},{"title":"Utilizzare un modello tracciato per l’inferenza","local":"utilizzare-un-modello-tracciato-per-linferenza","sections":[],"depth":4}],"depth":3},{"title":"Implementare modelli HuggingFace TorchScript su AWS utilizzando Neuron SDK","local":"implementare-modelli-huggingface-torchscript-su-aws-utilizzando-neuron-sdk","sections":[{"title":"Implicazioni","local":"implicazioni","sections":[],"depth":4},{"title":"Dipendenze","local":"dipendenze","sections":[],"depth":4},{"title":"Convertire un modello per AWS Neuron","local":"convertire-un-modello-per-aws-neuron","sections":[],"depth":4}],"depth":3}],"depth":2}],"depth":1}';function Fi(w){return Ci(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ea extends Zi{constructor(a){super(),Ii(this,a,Fi,Li,zi,{})}}export{ea as component};
