import{s as Ji,o as vi,n as x}from"../chunks/scheduler.36a0863c.js";import{S as zi,i as Zi,g as o,s,r as m,A as Wi,h as r,f as l,c as i,j as Ui,u as d,x as c,k as $i,y as Ii,a as n,v as u,d as M,t as f,w as y}from"../chunks/index.9c13489a.js";import{T as At}from"../chunks/Tip.3b06990e.js";import{C as j}from"../chunks/CodeBlock.05d8ec32.js";import{F as _i,M as Ci}from"../chunks/Markdown.88297c0b.js";import{H as $}from"../chunks/Heading.7a254a62.js";function ki(w){let a,g,p,b=`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,U,C;return a=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JTZXF1ZW5jZUNsYXNzaWZpY2F0aW9uJTBBJTBBJTIzJTIwTG9hZCUyMHRva2VuaXplciUyMGFuZCUyMFB5VG9yY2glMjB3ZWlnaHRzJTIwZm9ybSUyMHRoZSUyMEh1YiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQXB0X21vZGVsJTIwJTNEJTIwQXV0b01vZGVsRm9yU2VxdWVuY2VDbGFzc2lmaWNhdGlvbi5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBJTIzJTIwU2F2ZSUyMHRvJTIwZGlzayUwQXRva2VuaXplci5zYXZlX3ByZXRyYWluZWQoJTIybG9jYWwtcHQtY2hlY2twb2ludCUyMiklMEFwdF9tb2RlbC5zYXZlX3ByZXRyYWluZWQoJTIybG9jYWwtcHQtY2hlY2twb2ludCUyMik=",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-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pt_model = AutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;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}}),U=new j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC1wdC1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-pt-checkpoint onnx/",wrap:!1}}),{c(){m(a.$$.fragment),g=s(),p=o("p"),p.innerHTML=b,T=s(),m(U.$$.fragment)},l(h){d(a.$$.fragment,h),g=i(h),p=r(h,"P",{"data-svelte-h":!0}),c(p)!=="svelte-1rjvspr"&&(p.innerHTML=b),T=i(h),d(U.$$.fragment,h)},m(h,J){u(a,h,J),n(h,g,J),n(h,p,J),n(h,T,J),u(U,h,J),C=!0},p:x,i(h){C||(M(a.$$.fragment,h),M(U.$$.fragment,h),C=!0)},o(h){f(a.$$.fragment,h),f(U.$$.fragment,h),C=!1},d(h){h&&(l(g),l(p),l(T)),y(a,h),y(U,h)}}}function xi(w){let a,g;return a=new Ci({props:{$$slots:{default:[ki]},$$scope:{ctx:w}}}),{c(){m(a.$$.fragment)},l(p){d(a.$$.fragment,p)},m(p,b){u(a,p,b),g=!0},p(p,b){const T={};b&2&&(T.$$scope={dirty:b,ctx:p}),a.$set(T)},i(p){g||(M(a.$$.fragment,p),g=!0)},o(p){f(a.$$.fragment,p),g=!1},d(p){y(a,p)}}}function Bi(w){let a,g,p,b=`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,U,C;return a=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24lMEElMEElMjMlMjBMb2FkJTIwdG9rZW5pemVyJTIwYW5kJTIwVGVuc29yRmxvdyUyMHdlaWdodHMlMjBmcm9tJTIwdGhlJTIwSHViJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBdGZfbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbEZvclNlcXVlbmNlQ2xhc3NpZmljYXRpb24uZnJvbV9wcmV0cmFpbmVkKCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyKSUwQSUyMyUyMFNhdmUlMjB0byUyMGRpc2slMEF0b2tlbml6ZXIuc2F2ZV9wcmV0cmFpbmVkKCUyMmxvY2FsLXRmLWNoZWNrcG9pbnQlMjIpJTBBdGZfbW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmxvY2FsLXRmLWNoZWNrcG9pbnQlMjIp",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-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>tf_model = TFAutoModelForSequenceClassification.from_pretrained(<span class="hljs-string">&quot;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}}),U=new j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0Rsb2NhbC10Zi1jaGVja3BvaW50JTIwb25ueCUyRg==",highlighted:"python -m transformers.onnx --model=local-tf-checkpoint onnx/",wrap:!1}}),{c(){m(a.$$.fragment),g=s(),p=o("p"),p.innerHTML=b,T=s(),m(U.$$.fragment)},l(h){d(a.$$.fragment,h),g=i(h),p=r(h,"P",{"data-svelte-h":!0}),c(p)!=="svelte-128pexq"&&(p.innerHTML=b),T=i(h),d(U.$$.fragment,h)},m(h,J){u(a,h,J),n(h,g,J),n(h,p,J),n(h,T,J),u(U,h,J),C=!0},p:x,i(h){C||(M(a.$$.fragment,h),M(U.$$.fragment,h),C=!0)},o(h){f(a.$$.fragment,h),f(U.$$.fragment,h),C=!1},d(h){h&&(l(g),l(p),l(T)),y(a,h),y(U,h)}}}function Ni(w){let a,g;return a=new Ci({props:{$$slots:{default:[Bi]},$$scope:{ctx:w}}}),{c(){m(a.$$.fragment)},l(p){d(a.$$.fragment,p)},m(p,b){u(a,p,b),g=!0},p(p,b){const T={};b&2&&(T.$$scope={dirty:b,ctx:p}),a.$set(T)},i(p){g||(M(a.$$.fragment,p),g=!0)},o(p){f(a.$$.fragment,p),g=!1},d(p){y(a,p)}}}function Ri(w){let a,g=`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=o("p"),a.innerHTML=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-1on6rqr"&&(a.innerHTML=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Xi(w){let a,g=`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=o("p"),a.innerHTML=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-k15enw"&&(a.innerHTML=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Ai(w){let a,g=`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=o("p"),a.innerHTML=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-9pdb1s"&&(a.innerHTML=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Gi(w){let a,g=`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=o("p"),a.innerHTML=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-8je27i"&&(a.innerHTML=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Vi(w){let a,g=`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=o("p"),a.innerHTML=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-zgeibt"&&(a.innerHTML=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Hi(w){let a,g=`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=o("p"),a.textContent=g},l(p){a=r(p,"P",{"data-svelte-h":!0}),c(a)!=="svelte-1puyypy"&&(a.textContent=g)},m(p,b){n(p,a,b)},p:x,d(p){p&&l(a)}}}function Ei(w){let a,g,p,b,T,U,C,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.`,J,B,es=`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>.`,Vt,N,Ht,R,ts=`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.`,Et,X,ls=`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).`,Qt,A,ns=`🤗 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.`,Lt,G,ss="Le configurazioni pronte includono le seguenti architetture:",St,V,is="<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>",Ft,H,as="Nelle prossime due sezioni, ti mostreremo come:",qt,E,os="<li>Esporta un modello supportato usando il pacchetto <code>transformers.onnx</code>.</li> <li>Esporta un modello personalizzato per un’architettura non supportata.</li>",Yt,Q,Pt,L,rs=`Per esportare un modello 🤗 Transformers in ONNX, dovrai prima installarne alcune
dipendenze extra:`,Ot,S,Dt,F,ps="Il pacchetto <code>transformers.onnx</code> può essere usato come modulo Python:",Kt,q,el,Y,cs="L’esportazione di un checkpoint utilizzando una configurazione già pronta può essere eseguita come segue:",tl,P,ll,O,ms="che dovrebbe mostrare i seguenti log:",nl,D,sl,K,ds=`Questo esporta un grafico ONNX del checkpoint definito dall’argomento <code>--model</code>.
In questo esempio è <code>distilbert-base-uncased</code>, ma può essere qualsiasi checkpoint
Hugging Face Hub o uno memorizzato localmente.`,il,ee,us=`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:`,al,te,ol,le,Ms=`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:`,rl,ne,pl,se,fs=`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:`,cl,ie,ml,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:`,dl,v,ul,oe,Ml,re,hs=`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:`,fl,pe,gs="<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>",yl,ce,bs=`Per ciascuna configurazione, puoi trovare l’elenco delle funzionalità supportate tramite il
<code>FeaturesManager</code>. Ad esempio, per DistilBERT abbiamo:`,hl,me,gl,de,js=`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,jl,Me,Ts="che visualizzerà i seguenti registri:",Tl,fe,wl,ye,ws=`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-base-uncased</code> precedente. Questo è previsto dal
modello ottimizato visto che ha una testa di e.`,Ul,z,$l,he,Cl,ge,Us=`Se desideri esportare un modello la cui architettura non è nativamente supportata dalla
libreria, ci sono tre passaggi principali da seguire:`,Jl,be,$s="<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>",vl,je,Cs=`In questa sezione, vedremo come DistilBERT è stato implementato per mostrare cosa è
coinvolto in ogni passaggio.`,zl,Te,Zl,we,Js=`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:`,Wl,Ue,vs="<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>",Il,Z,_l,$e,zs=`Poiché DistilBERT è un modello basato su encoder, la sua configurazione eredita da
<code>OnnxConfig</code>:`,kl,Ce,xl,Je,Zs=`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.`,Bl,W,Nl,ve,Ws=`Dopo aver implementato una configurazione ONNX, è possibile istanziarla
fornendo alla configurazione del modello base come segue:`,Rl,ze,Xl,Ze,Is=`L’oggetto risultante ha diverse proprietà utili. Ad esempio è possibile visualizzare il
Set operatore ONNX che verrà utilizzato durante l’esportazione:`,Al,We,Gl,Ie,_s="È inoltre possibile visualizzare gli output associati al modello come segue:",Vl,_e,Hl,ke,ks=`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:`,El,xe,Ql,I,Ll,Be,Sl,Ne,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:`,Fl,Re,ql,Xe,Bs=`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:`,Yl,Ae,Pl,_,Ol,Ge,Dl,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:`,Kl,He,en,Ee,Rs=`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.`,tn,Qe,ln,Le,Xs=`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:`,nn,Se,As="<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>",sn,Fe,Gs=`Scopri come stato contribuito la configurazione per [IBERT]
(<a href="https://github.com/huggingface/transformers/pull/14868/files" rel="nofollow">https://github.com/huggingface/transformers/pull/14868/files</a>) per
avere un’idea di cosa è coinvolto.`,an,qe,on,k,rn,Ye,Vs=`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.`,pn,Pe,Hs=`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.`,cn,Oe,Es="Esportare un modello richiede due cose:",mn,De,Qs="<li>Un passaggio in avanti con input fittizzi.</li> <li>Istanziazione del modello con flag <code>torchscript</code>.</li>",dn,Ke,Ls="Queste necessità implicano diverse cose a cui gli sviluppatori dovrebbero prestare attenzione. Questi dettagli mostrati sotto.",un,et,Mn,tt,Ss=`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.`,fn,lt,Fs=`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.`,yn,nt,qs=`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>.`,hn,st,gn,it,Ys=`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,Ps=`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:`,jn,ot,Os="<code>La dimensione espansa del tensore (3) deve corrispondere alla dimensione esistente (7) nella dimensione non singleton 2</code>",Tn,rt,Ds=`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.`,wn,pt,Ks=`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.`,Un,ct,$n,mt,ei="Di seguito è riportato un esempio, che mostra come salvare, caricare modelli e come utilizzare la traccia per l’inferenza.",Cn,dt,Jn,ut,ti=`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>`,vn,Mt,zn,ft,Zn,yt,li=`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.`,Wn,ht,In,gt,_n,bt,ni="Usare il modello tracciato per l’inferenza è semplice come usare il suo metodo dunder <code>__call__</code>:",kn,jt,xn,Tt,si="###Implementare modelli HuggingFace TorchScript su AWS utilizzando Neuron SDK",Bn,wt,ii=`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:`,Nn,Ut,ai=`<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>`,Rn,$t,Xn,Ct,oi=`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>.`,An,Jt,Gn,vt,ri="L’utilizzo di AWS Neuron per convertire i modelli richiede le seguenti dipendenze e l’ambiente:",Vn,zt,pi=`<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>`,Hn,Zt,En,Wt,ci=`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.`,Qn,It,Ln,_t,mi="E modificare solo la riga di codice di traccia",Sn,kt,di="Da:",Fn,xt,qn,Bt,ui="A:",Yn,Nt,Pn,Rt,Mi="Questa modifica consente a Neuron SDK di tracciare il modello e ottimizzarlo per l’esecuzione nelle istanze Inf1.",On,Xt,fi=`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>.`,Dn,Gt,Kn;return T=new $({props:{title:"Esporta modelli 🤗 Transformers",local:"esporta-modelli--transformers",headingTag:"h1"}}),N=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 j({props:{code:"cGlwJTIwaW5zdGFsbCUyMHRyYW5zZm9ybWVycyU1Qm9ubnglNUQ=",highlighted:"pip install transformers[onnx]",wrap:!1}}),q=new j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0taGVscCUwQSUwQXVzYWdlJTNBJTIwSHVnZ2luZyUyMEZhY2UlMjBUcmFuc2Zvcm1lcnMlMjBPTk5YJTIwZXhwb3J0ZXIlMjAlNUItaCU1RCUyMC1tJTIwTU9ERUwlMjAlNUItLWZlYXR1cmUlMjAlN0JjYXVzYWwtbG0lMkMlMjAuLi4lN0QlNUQlMjAlNUItLW9wc2V0JTIwT1BTRVQlNUQlMjAlNUItLWF0b2wlMjBBVE9MJTVEJTIwb3V0cHV0JTBBJTBBcG9zaXRpb25hbCUyMGFyZ3VtZW50cyUzQSUwQSUyMCUyMG91dHB1dCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMFBhdGglMjBpbmRpY2F0aW5nJTIwd2hlcmUlMjB0byUyMHN0b3JlJTIwZ2VuZXJhdGVkJTIwT05OWCUyMG1vZGVsLiUwQSUwQW9wdGlvbmFsJTIwYXJndW1lbnRzJTNBJTBBJTIwJTIwLWglMkMlMjAtLWhlbHAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBzaG93JTIwdGhpcyUyMGhlbHAlMjBtZXNzYWdlJTIwYW5kJTIwZXhpdCUwQSUyMCUyMC1tJTIwTU9ERUwlMkMlMjAtLW1vZGVsJTIwTU9ERUwlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBNb2RlbCUyMElEJTIwb24lMjBodWdnaW5nZmFjZS5jbyUyMG9yJTIwcGF0aCUyMG9uJTIwZGlzayUyMHRvJTIwbG9hZCUyMG1vZGVsJTIwZnJvbS4lMEElMjAlMjAtLWZlYXR1cmUlMjAlN0JjYXVzYWwtbG0lMkMlMjAuLi4lN0QlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBUaGUlMjB0eXBlJTIwb2YlMjBmZWF0dXJlcyUyMHRvJTIwZXhwb3J0JTIwdGhlJTIwbW9kZWwlMjB3aXRoLiUwQSUyMCUyMC0tb3BzZXQlMjBPUFNFVCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyME9OTlglMjBvcHNldCUyMHZlcnNpb24lMjB0byUyMGV4cG9ydCUyMHRoZSUyMG1vZGVsJTIwd2l0aC4lMEElMjAlMjAtLWF0b2wlMjBBVE9MJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwQWJzb2x1dGUlMjBkaWZmZXJlbmNlJTIwdG9sZXJhbmNlJTIwd2hlbiUyMHZhbGlkYXRpbmclMjB0aGUlMjBtb2RlbC4=",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 j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=distilbert-base-uncased onnx/",wrap:!1}}),D=new j({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 j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEFmcm9tJTIwb25ueHJ1bnRpbWUlMjBpbXBvcnQlMjBJbmZlcmVuY2VTZXNzaW9uJTBBJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTIyZGlzdGlsYmVydC1iYXNlLXVuY2FzZWQlMjIpJTBBc2Vzc2lvbiUyMCUzRCUyMEluZmVyZW5jZVNlc3Npb24oJTIyb25ueCUyRm1vZGVsLm9ubnglMjIpJTBBJTIzJTIwT05OWCUyMFJ1bnRpbWUlMjBleHBlY3RzJTIwTnVtUHklMjBhcnJheXMlMjBhcyUyMGlucHV0JTBBaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMlVzaW5nJTIwRGlzdGlsQkVSVCUyMHdpdGglMjBPTk5YJTIwUnVudGltZSElMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMm5wJTIyKSUwQW91dHB1dHMlMjAlM0QlMjBzZXNzaW9uLnJ1bihvdXRwdXRfbmFtZXMlM0QlNUIlMjJsYXN0X2hpZGRlbl9zdGF0ZSUyMiU1RCUyQyUyMGlucHV0X2ZlZWQlM0RkaWN0KGlucHV0cykp",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-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 j({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 j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RrZXJhcy1pbyUyRnRyYW5zZm9ybWVycy1xYSUyMG9ubnglMkY=",highlighted:"python -m transformers.onnx --model=keras-io/transformers-qa onnx/",wrap:!1}}),v=new _i({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 j({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 j({props:{code:"cHl0aG9uJTIwLW0lMjB0cmFuc2Zvcm1lcnMub25ueCUyMC0tbW9kZWwlM0RkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZC1maW5ldHVuZWQtc3N0LTItZW5nbGlzaCUyMCU1QyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMC0tZmVhdHVyZSUzRHNlcXVlbmNlLWNsYXNzaWZpY2F0aW9uJTIwb25ueCUyRg==",highlighted:`python -m transformers.onnx --model=distilbert-base-uncased-finetuned-sst-2-english \\
                            --feature=sequence-classification onnx/`,wrap:!1}}),fe=new j({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}}),z=new At({props:{$$slots:{default:[Ri]},$$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 At({props:{$$slots:{default:[Xi]},$$scope:{ctx:w}}}),Ce=new j({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}}),W=new At({props:{$$slots:{default:[Ai]},$$scope:{ctx:w}}}),ze=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFjb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFvbm54X2NvbmZpZyUyMCUzRCUyMERpc3RpbEJlcnRPbm54Q29uZmlnKGNvbmZpZyk=",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-base-uncased&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>onnx_config = DistilBertOnnxConfig(config)`,wrap:!1}}),We=new j({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}}),_e=new j({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}}),xe=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Db25maWclMEElMEFjb25maWclMjAlM0QlMjBBdXRvQ29uZmlnLmZyb21fcHJldHJhaW5lZCglMjJkaXN0aWxiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEFvbm54X2NvbmZpZ19mb3Jfc2VxX2NsZiUyMCUzRCUyMERpc3RpbEJlcnRPbm54Q29uZmlnKGNvbmZpZyUyQyUyMHRhc2slM0QlMjJzZXF1ZW5jZS1jbGFzc2lmaWNhdGlvbiUyMiklMEFwcmludChvbm54X2NvbmZpZ19mb3Jfc2VxX2NsZi5vdXRwdXRzKQ==",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-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}}),I=new At({props:{$$slots:{default:[Gi]},$$scope:{ctx:w}}}),Be=new $({props:{title:"Esportazione del modello",local:"esportazione-del-modello",headingTag:"h4"}}),Re=new j({props:{code:"ZnJvbSUyMHBhdGhsaWIlMjBpbXBvcnQlMjBQYXRoJTBBZnJvbSUyMHRyYW5zZm9ybWVycy5vbm54JTIwaW1wb3J0JTIwZXhwb3J0JTBBZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWwlMEElMEFvbm54X3BhdGglMjAlM0QlMjBQYXRoKCUyMm1vZGVsLm9ubnglMjIpJTBBbW9kZWxfY2twdCUyMCUzRCUyMCUyMmRpc3RpbGJlcnQtYmFzZS11bmNhc2VkJTIyJTBBYmFzZV9tb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2twdCklMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9ja3B0KSUwQSUwQW9ubnhfaW5wdXRzJTJDJTIwb25ueF9vdXRwdXRzJTIwJTNEJTIwZXhwb3J0KHRva2VuaXplciUyQyUyMGJhc2VfbW9kZWwlMkMlMjBvbm54X2NvbmZpZyUyQyUyMG9ubnhfY29uZmlnLmRlZmF1bHRfb25ueF9vcHNldCUyQyUyMG9ubnhfcGF0aCk=",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-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}}),Ae=new j({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}}),_=new At({props:{$$slots:{default:[Vi]},$$scope:{ctx:w}}}),Ge=new $({props:{title:"Convalida degli output del modello",local:"convalida-degli-output-del-modello",headingTag:"h4"}}),He=new j({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"}}),k=new At({props:{$$slots:{default:[Hi]},$$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 j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEJlcnRNb2RlbCUyQyUyMEJlcnRUb2tlbml6ZXIlMkMlMjBCZXJ0Q29uZmlnJTBBaW1wb3J0JTIwdG9yY2glMEElMEFlbmMlMjAlM0QlMjBCZXJ0VG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJiZXJ0LWJhc2UtdW5jYXNlZCUyMiklMEElMEElMjMlMjBUb2tlbml6aW5nJTIwaW5wdXQlMjB0ZXh0JTBBdGV4dCUyMCUzRCUyMCUyMiU1QkNMUyU1RCUyMFdobyUyMHdhcyUyMEppbSUyMEhlbnNvbiUyMCUzRiUyMCU1QlNFUCU1RCUyMEppbSUyMEhlbnNvbiUyMHdhcyUyMGElMjBwdXBwZXRlZXIlMjAlNUJTRVAlNUQlMjIlMEF0b2tlbml6ZWRfdGV4dCUyMCUzRCUyMGVuYy50b2tlbml6ZSh0ZXh0KSUwQSUwQSUyMyUyME1hc2tpbmclMjBvbmUlMjBvZiUyMHRoZSUyMGlucHV0JTIwdG9rZW5zJTBBbWFza2VkX2luZGV4JTIwJTNEJTIwOCUwQXRva2VuaXplZF90ZXh0JTVCbWFza2VkX2luZGV4JTVEJTIwJTNEJTIwJTIyJTVCTUFTSyU1RCUyMiUwQWluZGV4ZWRfdG9rZW5zJTIwJTNEJTIwZW5jLmNvbnZlcnRfdG9rZW5zX3RvX2lkcyh0b2tlbml6ZWRfdGV4dCklMEFzZWdtZW50c19pZHMlMjAlM0QlMjAlNUIwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTJDJTIwMSU1RCUwQSUwQSUyMyUyMENyZWF0aW5nJTIwYSUyMGR1bW15JTIwaW5wdXQlMEF0b2tlbnNfdGVuc29yJTIwJTNEJTIwdG9yY2gudGVuc29yKCU1QmluZGV4ZWRfdG9rZW5zJTVEKSUwQXNlZ21lbnRzX3RlbnNvcnMlMjAlM0QlMjB0b3JjaC50ZW5zb3IoJTVCc2VnbWVudHNfaWRzJTVEKSUwQWR1bW15X2lucHV0JTIwJTNEJTIwJTVCdG9rZW5zX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQlMEElMEElMjMlMjBJbml0aWFsaXppbmclMjB0aGUlMjBtb2RlbCUyMHdpdGglMjB0aGUlMjB0b3JjaHNjcmlwdCUyMGZsYWclMEElMjMlMjBGbGFnJTIwc2V0JTIwdG8lMjBUcnVlJTIwZXZlbiUyMHRob3VnaCUyMGl0JTIwaXMlMjBub3QlMjBuZWNlc3NhcnklMjBhcyUyMHRoaXMlMjBtb2RlbCUyMGRvZXMlMjBub3QlMjBoYXZlJTIwYW4lMjBMTSUyMEhlYWQuJTBBY29uZmlnJTIwJTNEJTIwQmVydENvbmZpZyglMEElMjAlMjAlMjAlMjB2b2NhYl9zaXplX29yX2NvbmZpZ19qc29uX2ZpbGUlM0QzMjAwMCUyQyUwQSUyMCUyMCUyMCUyMGhpZGRlbl9zaXplJTNENzY4JTJDJTBBJTIwJTIwJTIwJTIwbnVtX2hpZGRlbl9sYXllcnMlM0QxMiUyQyUwQSUyMCUyMCUyMCUyMG51bV9hdHRlbnRpb25faGVhZHMlM0QxMiUyQyUwQSUyMCUyMCUyMCUyMGludGVybWVkaWF0ZV9zaXplJTNEMzA3MiUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoc2NyaXB0JTNEVHJ1ZSUyQyUwQSklMEElMEElMjMlMjBJbnN0YW50aWF0aW5nJTIwdGhlJTIwbW9kZWwlMEFtb2RlbCUyMCUzRCUyMEJlcnRNb2RlbChjb25maWcpJTBBJTBBJTIzJTIwVGhlJTIwbW9kZWwlMjBuZWVkcyUyMHRvJTIwYmUlMjBpbiUyMGV2YWx1YXRpb24lMjBtb2RlJTBBbW9kZWwuZXZhbCgpJTBBJTBBJTIzJTIwSWYlMjB5b3UlMjBhcmUlMjBpbnN0YW50aWF0aW5nJTIwdGhlJTIwbW9kZWwlMjB3aXRoJTIwKmZyb21fcHJldHJhaW5lZColMjB5b3UlMjBjYW4lMjBhbHNvJTIwZWFzaWx5JTIwc2V0JTIwdGhlJTIwVG9yY2hTY3JpcHQlMjBmbGFnJTBBbW9kZWwlMjAlM0QlMjBCZXJ0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMmJlcnQtYmFzZS11bmNhc2VkJTIyJTJDJTIwdG9yY2hzY3JpcHQlM0RUcnVlKSUwQSUwQSUyMyUyMENyZWF0aW5nJTIwdGhlJTIwdHJhY2UlMEF0cmFjZWRfbW9kZWwlMjAlM0QlMjB0b3JjaC5qaXQudHJhY2UobW9kZWwlMkMlMjAlNUJ0b2tlbnNfdGVuc29yJTJDJTIwc2VnbWVudHNfdGVuc29ycyU1RCklMEF0b3JjaC5qaXQuc2F2ZSh0cmFjZWRfbW9kZWwlMkMlMjAlMjJ0cmFjZWRfYmVydC5wdCUyMik=",highlighted:`<span class="hljs-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;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;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 j({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}}),gt=new $({props:{title:"Utilizzare un modello tracciato per l’inferenza",local:"utilizzare-un-modello-tracciato-per-linferenza",headingTag:"h4"}}),jt=new j({props:{code:"dHJhY2VkX21vZGVsKHRva2Vuc190ZW5zb3IlMkMlMjBzZWdtZW50c190ZW5zb3JzKQ==",highlighted:"traced_model(tokens_tensor, segments_tensors)",wrap:!1}}),$t=new $({props:{title:"Implicazioni",local:"implicazioni",headingTag:"h4"}}),Jt=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"}}),It=new j({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}}),xt=new j({props:{code:"dG9yY2guaml0LnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5zX3RlbnNvciUyQyUyMHNlZ21lbnRzX3RlbnNvcnMlNUQp",highlighted:"torch.jit.trace(model, [tokens_tensor, segments_tensors])",wrap:!1}}),Nt=new j({props:{code:"dG9yY2gubmV1cm9uLnRyYWNlKG1vZGVsJTJDJTIwJTVCdG9rZW5fdGVuc29yJTJDJTIwc2VnbWVudHNfdGVuc29ycyU1RCk=",highlighted:"torch.neuron.trace(model, [token_tensor, segments_tensors])",wrap:!1}}),{c(){a=o("meta"),g=s(),p=o("p"),b=s(),m(T.$$.fragment),U=s(),C=o("p"),C.textContent=h,J=s(),B=o("p"),B.innerHTML=es,Vt=s(),m(N.$$.fragment),Ht=s(),R=o("p"),R.innerHTML=ts,Et=s(),X=o("p"),X.textContent=ls,Qt=s(),A=o("p"),A.innerHTML=ns,Lt=s(),G=o("p"),G.textContent=ss,St=s(),V=o("ul"),V.innerHTML=is,Ft=s(),H=o("p"),H.textContent=as,qt=s(),E=o("ul"),E.innerHTML=os,Yt=s(),m(Q.$$.fragment),Pt=s(),L=o("p"),L.textContent=rs,Ot=s(),m(S.$$.fragment),Dt=s(),F=o("p"),F.innerHTML=ps,Kt=s(),m(q.$$.fragment),el=s(),Y=o("p"),Y.textContent=cs,tl=s(),m(P.$$.fragment),ll=s(),O=o("p"),O.textContent=ms,nl=s(),m(D.$$.fragment),sl=s(),K=o("p"),K.innerHTML=ds,il=s(),ee=o("p"),ee.innerHTML=us,al=s(),m(te.$$.fragment),ol=s(),le=o("p"),le.innerHTML=Ms,rl=s(),m(ne.$$.fragment),pl=s(),se=o("p"),se.innerHTML=fs,cl=s(),m(ie.$$.fragment),ml=s(),ae=o("p"),ae.textContent=ys,dl=s(),m(v.$$.fragment),ul=s(),m(oe.$$.fragment),Ml=s(),re=o("p"),re.innerHTML=hs,fl=s(),pe=o("table"),pe.innerHTML=gs,yl=s(),ce=o("p"),ce.innerHTML=bs,hl=s(),m(me.$$.fragment),gl=s(),de=o("p"),de.innerHTML=js,bl=s(),m(ue.$$.fragment),jl=s(),Me=o("p"),Me.textContent=Ts,Tl=s(),m(fe.$$.fragment),wl=s(),ye=o("p"),ye.innerHTML=ws,Ul=s(),m(z.$$.fragment),$l=s(),m(he.$$.fragment),Cl=s(),ge=o("p"),ge.textContent=Us,Jl=s(),be=o("ol"),be.innerHTML=$s,vl=s(),je=o("p"),je.textContent=Cs,zl=s(),m(Te.$$.fragment),Zl=s(),we=o("p"),we.textContent=Js,Wl=s(),Ue=o("ul"),Ue.innerHTML=vs,Il=s(),m(Z.$$.fragment),_l=s(),$e=o("p"),$e.innerHTML=zs,kl=s(),m(Ce.$$.fragment),xl=s(),Je=o("p"),Je.innerHTML=Zs,Bl=s(),m(W.$$.fragment),Nl=s(),ve=o("p"),ve.textContent=Ws,Rl=s(),m(ze.$$.fragment),Xl=s(),Ze=o("p"),Ze.textContent=Is,Al=s(),m(We.$$.fragment),Gl=s(),Ie=o("p"),Ie.textContent=_s,Vl=s(),m(_e.$$.fragment),Hl=s(),ke=o("p"),ke.innerHTML=ks,El=s(),m(xe.$$.fragment),Ql=s(),m(I.$$.fragment),Ll=s(),m(Be.$$.fragment),Sl=s(),Ne=o("p"),Ne.innerHTML=xs,Fl=s(),m(Re.$$.fragment),ql=s(),Xe=o("p"),Xe.innerHTML=Bs,Yl=s(),m(Ae.$$.fragment),Pl=s(),m(_.$$.fragment),Ol=s(),m(Ge.$$.fragment),Dl=s(),Ve=o("p"),Ve.innerHTML=Ns,Kl=s(),m(He.$$.fragment),en=s(),Ee=o("p"),Ee.innerHTML=Rs,tn=s(),m(Qe.$$.fragment),ln=s(),Le=o("p"),Le.textContent=Xs,nn=s(),Se=o("ul"),Se.innerHTML=As,sn=s(),Fe=o("p"),Fe.innerHTML=Gs,an=s(),m(qe.$$.fragment),on=s(),m(k.$$.fragment),rn=s(),Ye=o("p"),Ye.innerHTML=Vs,pn=s(),Pe=o("p"),Pe.textContent=Hs,cn=s(),Oe=o("p"),Oe.textContent=Es,mn=s(),De=o("ul"),De.innerHTML=Qs,dn=s(),Ke=o("p"),Ke.textContent=Ls,un=s(),m(et.$$.fragment),Mn=s(),tt=o("p"),tt.textContent=Ss,fn=s(),lt=o("p"),lt.innerHTML=Fs,yn=s(),nt=o("p"),nt.innerHTML=qs,hn=s(),m(st.$$.fragment),gn=s(),it=o("p"),it.textContent=Ys,bn=s(),at=o("p"),at.textContent=Ps,jn=s(),ot=o("p"),ot.innerHTML=Os,Tn=s(),rt=o("p"),rt.textContent=Ds,wn=s(),pt=o("p"),pt.textContent=Ks,Un=s(),m(ct.$$.fragment),$n=s(),mt=o("p"),mt.textContent=ei,Cn=s(),m(dt.$$.fragment),Jn=s(),ut=o("p"),ut.innerHTML=ti,vn=s(),m(Mt.$$.fragment),zn=s(),m(ft.$$.fragment),Zn=s(),yt=o("p"),yt.innerHTML=li,Wn=s(),m(ht.$$.fragment),In=s(),m(gt.$$.fragment),_n=s(),bt=o("p"),bt.innerHTML=ni,kn=s(),m(jt.$$.fragment),xn=s(),Tt=o("p"),Tt.textContent=si,Bn=s(),wt=o("p"),wt.innerHTML=ii,Nn=s(),Ut=o("ol"),Ut.innerHTML=ai,Rn=s(),m($t.$$.fragment),Xn=s(),Ct=o("p"),Ct.innerHTML=oi,An=s(),m(Jt.$$.fragment),Gn=s(),vt=o("p"),vt.textContent=ri,Vn=s(),zt=o("ul"),zt.innerHTML=pi,Hn=s(),m(Zt.$$.fragment),En=s(),Wt=o("p"),Wt.innerHTML=ci,Qn=s(),m(It.$$.fragment),Ln=s(),_t=o("p"),_t.textContent=mi,Sn=s(),kt=o("p"),kt.textContent=di,Fn=s(),m(xt.$$.fragment),qn=s(),Bt=o("p"),Bt.textContent=ui,Yn=s(),m(Nt.$$.fragment),Pn=s(),Rt=o("p"),Rt.textContent=Mi,On=s(),Xt=o("p"),Xt.innerHTML=fi,Dn=s(),Gt=o("p"),this.h()},l(e){const t=Wi("svelte-u9bgzb",document.head);a=r(t,"META",{name:!0,content:!0}),t.forEach(l),g=i(e),p=r(e,"P",{}),Ui(p).forEach(l),b=i(e),d(T.$$.fragment,e),U=i(e),C=r(e,"P",{"data-svelte-h":!0}),c(C)!=="svelte-do19d6"&&(C.textContent=h),J=i(e),B=r(e,"P",{"data-svelte-h":!0}),c(B)!=="svelte-1f9txfv"&&(B.innerHTML=es),Vt=i(e),d(N.$$.fragment,e),Ht=i(e),R=r(e,"P",{"data-svelte-h":!0}),c(R)!=="svelte-1gdh4oo"&&(R.innerHTML=ts),Et=i(e),X=r(e,"P",{"data-svelte-h":!0}),c(X)!=="svelte-z64a5j"&&(X.textContent=ls),Qt=i(e),A=r(e,"P",{"data-svelte-h":!0}),c(A)!=="svelte-7rl71e"&&(A.innerHTML=ns),Lt=i(e),G=r(e,"P",{"data-svelte-h":!0}),c(G)!=="svelte-sr712u"&&(G.textContent=ss),St=i(e),V=r(e,"UL",{"data-svelte-h":!0}),c(V)!=="svelte-vozkex"&&(V.innerHTML=is),Ft=i(e),H=r(e,"P",{"data-svelte-h":!0}),c(H)!=="svelte-1sn7n41"&&(H.textContent=as),qt=i(e),E=r(e,"UL",{"data-svelte-h":!0}),c(E)!=="svelte-1g8hsur"&&(E.innerHTML=os),Yt=i(e),d(Q.$$.fragment,e),Pt=i(e),L=r(e,"P",{"data-svelte-h":!0}),c(L)!=="svelte-4psczp"&&(L.textContent=rs),Ot=i(e),d(S.$$.fragment,e),Dt=i(e),F=r(e,"P",{"data-svelte-h":!0}),c(F)!=="svelte-1j72zvu"&&(F.innerHTML=ps),Kt=i(e),d(q.$$.fragment,e),el=i(e),Y=r(e,"P",{"data-svelte-h":!0}),c(Y)!=="svelte-13jbmoq"&&(Y.textContent=cs),tl=i(e),d(P.$$.fragment,e),ll=i(e),O=r(e,"P",{"data-svelte-h":!0}),c(O)!=="svelte-wxqvf3"&&(O.textContent=ms),nl=i(e),d(D.$$.fragment,e),sl=i(e),K=r(e,"P",{"data-svelte-h":!0}),c(K)!=="svelte-1quc6jn"&&(K.innerHTML=ds),il=i(e),ee=r(e,"P",{"data-svelte-h":!0}),c(ee)!=="svelte-rdoavc"&&(ee.innerHTML=us),al=i(e),d(te.$$.fragment,e),ol=i(e),le=r(e,"P",{"data-svelte-h":!0}),c(le)!=="svelte-1t39lef"&&(le.innerHTML=Ms),rl=i(e),d(ne.$$.fragment,e),pl=i(e),se=r(e,"P",{"data-svelte-h":!0}),c(se)!=="svelte-ej8fgq"&&(se.innerHTML=fs),cl=i(e),d(ie.$$.fragment,e),ml=i(e),ae=r(e,"P",{"data-svelte-h":!0}),c(ae)!=="svelte-h5zd9u"&&(ae.textContent=ys),dl=i(e),d(v.$$.fragment,e),ul=i(e),d(oe.$$.fragment,e),Ml=i(e),re=r(e,"P",{"data-svelte-h":!0}),c(re)!=="svelte-ne5myz"&&(re.innerHTML=hs),fl=i(e),pe=r(e,"TABLE",{"data-svelte-h":!0}),c(pe)!=="svelte-1n68aa"&&(pe.innerHTML=gs),yl=i(e),ce=r(e,"P",{"data-svelte-h":!0}),c(ce)!=="svelte-6wtiyv"&&(ce.innerHTML=bs),hl=i(e),d(me.$$.fragment,e),gl=i(e),de=r(e,"P",{"data-svelte-h":!0}),c(de)!=="svelte-3qfl60"&&(de.innerHTML=js),bl=i(e),d(ue.$$.fragment,e),jl=i(e),Me=r(e,"P",{"data-svelte-h":!0}),c(Me)!=="svelte-lgu95w"&&(Me.textContent=Ts),Tl=i(e),d(fe.$$.fragment,e),wl=i(e),ye=r(e,"P",{"data-svelte-h":!0}),c(ye)!=="svelte-1eltngq"&&(ye.innerHTML=ws),Ul=i(e),d(z.$$.fragment,e),$l=i(e),d(he.$$.fragment,e),Cl=i(e),ge=r(e,"P",{"data-svelte-h":!0}),c(ge)!=="svelte-17r0w1i"&&(ge.textContent=Us),Jl=i(e),be=r(e,"OL",{"data-svelte-h":!0}),c(be)!=="svelte-z67jz4"&&(be.innerHTML=$s),vl=i(e),je=r(e,"P",{"data-svelte-h":!0}),c(je)!=="svelte-10yqqq8"&&(je.textContent=Cs),zl=i(e),d(Te.$$.fragment,e),Zl=i(e),we=r(e,"P",{"data-svelte-h":!0}),c(we)!=="svelte-trahak"&&(we.textContent=Js),Wl=i(e),Ue=r(e,"UL",{"data-svelte-h":!0}),c(Ue)!=="svelte-j9of43"&&(Ue.innerHTML=vs),Il=i(e),d(Z.$$.fragment,e),_l=i(e),$e=r(e,"P",{"data-svelte-h":!0}),c($e)!=="svelte-1jb3jgn"&&($e.innerHTML=zs),kl=i(e),d(Ce.$$.fragment,e),xl=i(e),Je=r(e,"P",{"data-svelte-h":!0}),c(Je)!=="svelte-13xj4dt"&&(Je.innerHTML=Zs),Bl=i(e),d(W.$$.fragment,e),Nl=i(e),ve=r(e,"P",{"data-svelte-h":!0}),c(ve)!=="svelte-w0rck2"&&(ve.textContent=Ws),Rl=i(e),d(ze.$$.fragment,e),Xl=i(e),Ze=r(e,"P",{"data-svelte-h":!0}),c(Ze)!=="svelte-6wsqkw"&&(Ze.textContent=Is),Al=i(e),d(We.$$.fragment,e),Gl=i(e),Ie=r(e,"P",{"data-svelte-h":!0}),c(Ie)!=="svelte-1ggtlqz"&&(Ie.textContent=_s),Vl=i(e),d(_e.$$.fragment,e),Hl=i(e),ke=r(e,"P",{"data-svelte-h":!0}),c(ke)!=="svelte-1kn83vw"&&(ke.innerHTML=ks),El=i(e),d(xe.$$.fragment,e),Ql=i(e),d(I.$$.fragment,e),Ll=i(e),d(Be.$$.fragment,e),Sl=i(e),Ne=r(e,"P",{"data-svelte-h":!0}),c(Ne)!=="svelte-1ocrgze"&&(Ne.innerHTML=xs),Fl=i(e),d(Re.$$.fragment,e),ql=i(e),Xe=r(e,"P",{"data-svelte-h":!0}),c(Xe)!=="svelte-kxw9bj"&&(Xe.innerHTML=Bs),Yl=i(e),d(Ae.$$.fragment,e),Pl=i(e),d(_.$$.fragment,e),Ol=i(e),d(Ge.$$.fragment,e),Dl=i(e),Ve=r(e,"P",{"data-svelte-h":!0}),c(Ve)!=="svelte-zllt9o"&&(Ve.innerHTML=Ns),Kl=i(e),d(He.$$.fragment,e),en=i(e),Ee=r(e,"P",{"data-svelte-h":!0}),c(Ee)!=="svelte-1c44gg3"&&(Ee.innerHTML=Rs),tn=i(e),d(Qe.$$.fragment,e),ln=i(e),Le=r(e,"P",{"data-svelte-h":!0}),c(Le)!=="svelte-lrvm1j"&&(Le.textContent=Xs),nn=i(e),Se=r(e,"UL",{"data-svelte-h":!0}),c(Se)!=="svelte-a8pd1a"&&(Se.innerHTML=As),sn=i(e),Fe=r(e,"P",{"data-svelte-h":!0}),c(Fe)!=="svelte-vgj3gr"&&(Fe.innerHTML=Gs),an=i(e),d(qe.$$.fragment,e),on=i(e),d(k.$$.fragment,e),rn=i(e),Ye=r(e,"P",{"data-svelte-h":!0}),c(Ye)!=="svelte-wgebc9"&&(Ye.innerHTML=Vs),pn=i(e),Pe=r(e,"P",{"data-svelte-h":!0}),c(Pe)!=="svelte-9p2ixq"&&(Pe.textContent=Hs),cn=i(e),Oe=r(e,"P",{"data-svelte-h":!0}),c(Oe)!=="svelte-6xn7nf"&&(Oe.textContent=Es),mn=i(e),De=r(e,"UL",{"data-svelte-h":!0}),c(De)!=="svelte-oy2125"&&(De.innerHTML=Qs),dn=i(e),Ke=r(e,"P",{"data-svelte-h":!0}),c(Ke)!=="svelte-m48voh"&&(Ke.textContent=Ls),un=i(e),d(et.$$.fragment,e),Mn=i(e),tt=r(e,"P",{"data-svelte-h":!0}),c(tt)!=="svelte-tz9w6u"&&(tt.textContent=Ss),fn=i(e),lt=r(e,"P",{"data-svelte-h":!0}),c(lt)!=="svelte-1mq7t8t"&&(lt.innerHTML=Fs),yn=i(e),nt=r(e,"P",{"data-svelte-h":!0}),c(nt)!=="svelte-1jmydvh"&&(nt.innerHTML=qs),hn=i(e),d(st.$$.fragment,e),gn=i(e),it=r(e,"P",{"data-svelte-h":!0}),c(it)!=="svelte-c132kv"&&(it.textContent=Ys),bn=i(e),at=r(e,"P",{"data-svelte-h":!0}),c(at)!=="svelte-1bggopo"&&(at.textContent=Ps),jn=i(e),ot=r(e,"P",{"data-svelte-h":!0}),c(ot)!=="svelte-vyea1g"&&(ot.innerHTML=Os),Tn=i(e),rt=r(e,"P",{"data-svelte-h":!0}),c(rt)!=="svelte-1yce0u1"&&(rt.textContent=Ds),wn=i(e),pt=r(e,"P",{"data-svelte-h":!0}),c(pt)!=="svelte-1sr04ao"&&(pt.textContent=Ks),Un=i(e),d(ct.$$.fragment,e),$n=i(e),mt=r(e,"P",{"data-svelte-h":!0}),c(mt)!=="svelte-q23m3c"&&(mt.textContent=ei),Cn=i(e),d(dt.$$.fragment,e),Jn=i(e),ut=r(e,"P",{"data-svelte-h":!0}),c(ut)!=="svelte-k16qri"&&(ut.innerHTML=ti),vn=i(e),d(Mt.$$.fragment,e),zn=i(e),d(ft.$$.fragment,e),Zn=i(e),yt=r(e,"P",{"data-svelte-h":!0}),c(yt)!=="svelte-wh65i"&&(yt.innerHTML=li),Wn=i(e),d(ht.$$.fragment,e),In=i(e),d(gt.$$.fragment,e),_n=i(e),bt=r(e,"P",{"data-svelte-h":!0}),c(bt)!=="svelte-1gnslzu"&&(bt.innerHTML=ni),kn=i(e),d(jt.$$.fragment,e),xn=i(e),Tt=r(e,"P",{"data-svelte-h":!0}),c(Tt)!=="svelte-mniffs"&&(Tt.textContent=si),Bn=i(e),wt=r(e,"P",{"data-svelte-h":!0}),c(wt)!=="svelte-fjq776"&&(wt.innerHTML=ii),Nn=i(e),Ut=r(e,"OL",{"data-svelte-h":!0}),c(Ut)!=="svelte-121gcdu"&&(Ut.innerHTML=ai),Rn=i(e),d($t.$$.fragment,e),Xn=i(e),Ct=r(e,"P",{"data-svelte-h":!0}),c(Ct)!=="svelte-nfv9dr"&&(Ct.innerHTML=oi),An=i(e),d(Jt.$$.fragment,e),Gn=i(e),vt=r(e,"P",{"data-svelte-h":!0}),c(vt)!=="svelte-clfp9m"&&(vt.textContent=ri),Vn=i(e),zt=r(e,"UL",{"data-svelte-h":!0}),c(zt)!=="svelte-1yjzy16"&&(zt.innerHTML=pi),Hn=i(e),d(Zt.$$.fragment,e),En=i(e),Wt=r(e,"P",{"data-svelte-h":!0}),c(Wt)!=="svelte-wberyk"&&(Wt.innerHTML=ci),Qn=i(e),d(It.$$.fragment,e),Ln=i(e),_t=r(e,"P",{"data-svelte-h":!0}),c(_t)!=="svelte-e7n7t3"&&(_t.textContent=mi),Sn=i(e),kt=r(e,"P",{"data-svelte-h":!0}),c(kt)!=="svelte-yedjtf"&&(kt.textContent=di),Fn=i(e),d(xt.$$.fragment,e),qn=i(e),Bt=r(e,"P",{"data-svelte-h":!0}),c(Bt)!=="svelte-a9ap49"&&(Bt.textContent=ui),Yn=i(e),d(Nt.$$.fragment,e),Pn=i(e),Rt=r(e,"P",{"data-svelte-h":!0}),c(Rt)!=="svelte-1pjct15"&&(Rt.textContent=Mi),On=i(e),Xt=r(e,"P",{"data-svelte-h":!0}),c(Xt)!=="svelte-1do2s1n"&&(Xt.innerHTML=fi),Dn=i(e),Gt=r(e,"P",{}),Ui(Gt).forEach(l),this.h()},h(){$i(a,"name","hf:doc:metadata"),$i(a,"content",Qi)},m(e,t){Ii(document.head,a),n(e,g,t),n(e,p,t),n(e,b,t),u(T,e,t),n(e,U,t),n(e,C,t),n(e,J,t),n(e,B,t),n(e,Vt,t),u(N,e,t),n(e,Ht,t),n(e,R,t),n(e,Et,t),n(e,X,t),n(e,Qt,t),n(e,A,t),n(e,Lt,t),n(e,G,t),n(e,St,t),n(e,V,t),n(e,Ft,t),n(e,H,t),n(e,qt,t),n(e,E,t),n(e,Yt,t),u(Q,e,t),n(e,Pt,t),n(e,L,t),n(e,Ot,t),u(S,e,t),n(e,Dt,t),n(e,F,t),n(e,Kt,t),u(q,e,t),n(e,el,t),n(e,Y,t),n(e,tl,t),u(P,e,t),n(e,ll,t),n(e,O,t),n(e,nl,t),u(D,e,t),n(e,sl,t),n(e,K,t),n(e,il,t),n(e,ee,t),n(e,al,t),u(te,e,t),n(e,ol,t),n(e,le,t),n(e,rl,t),u(ne,e,t),n(e,pl,t),n(e,se,t),n(e,cl,t),u(ie,e,t),n(e,ml,t),n(e,ae,t),n(e,dl,t),u(v,e,t),n(e,ul,t),u(oe,e,t),n(e,Ml,t),n(e,re,t),n(e,fl,t),n(e,pe,t),n(e,yl,t),n(e,ce,t),n(e,hl,t),u(me,e,t),n(e,gl,t),n(e,de,t),n(e,bl,t),u(ue,e,t),n(e,jl,t),n(e,Me,t),n(e,Tl,t),u(fe,e,t),n(e,wl,t),n(e,ye,t),n(e,Ul,t),u(z,e,t),n(e,$l,t),u(he,e,t),n(e,Cl,t),n(e,ge,t),n(e,Jl,t),n(e,be,t),n(e,vl,t),n(e,je,t),n(e,zl,t),u(Te,e,t),n(e,Zl,t),n(e,we,t),n(e,Wl,t),n(e,Ue,t),n(e,Il,t),u(Z,e,t),n(e,_l,t),n(e,$e,t),n(e,kl,t),u(Ce,e,t),n(e,xl,t),n(e,Je,t),n(e,Bl,t),u(W,e,t),n(e,Nl,t),n(e,ve,t),n(e,Rl,t),u(ze,e,t),n(e,Xl,t),n(e,Ze,t),n(e,Al,t),u(We,e,t),n(e,Gl,t),n(e,Ie,t),n(e,Vl,t),u(_e,e,t),n(e,Hl,t),n(e,ke,t),n(e,El,t),u(xe,e,t),n(e,Ql,t),u(I,e,t),n(e,Ll,t),u(Be,e,t),n(e,Sl,t),n(e,Ne,t),n(e,Fl,t),u(Re,e,t),n(e,ql,t),n(e,Xe,t),n(e,Yl,t),u(Ae,e,t),n(e,Pl,t),u(_,e,t),n(e,Ol,t),u(Ge,e,t),n(e,Dl,t),n(e,Ve,t),n(e,Kl,t),u(He,e,t),n(e,en,t),n(e,Ee,t),n(e,tn,t),u(Qe,e,t),n(e,ln,t),n(e,Le,t),n(e,nn,t),n(e,Se,t),n(e,sn,t),n(e,Fe,t),n(e,an,t),u(qe,e,t),n(e,on,t),u(k,e,t),n(e,rn,t),n(e,Ye,t),n(e,pn,t),n(e,Pe,t),n(e,cn,t),n(e,Oe,t),n(e,mn,t),n(e,De,t),n(e,dn,t),n(e,Ke,t),n(e,un,t),u(et,e,t),n(e,Mn,t),n(e,tt,t),n(e,fn,t),n(e,lt,t),n(e,yn,t),n(e,nt,t),n(e,hn,t),u(st,e,t),n(e,gn,t),n(e,it,t),n(e,bn,t),n(e,at,t),n(e,jn,t),n(e,ot,t),n(e,Tn,t),n(e,rt,t),n(e,wn,t),n(e,pt,t),n(e,Un,t),u(ct,e,t),n(e,$n,t),n(e,mt,t),n(e,Cn,t),u(dt,e,t),n(e,Jn,t),n(e,ut,t),n(e,vn,t),u(Mt,e,t),n(e,zn,t),u(ft,e,t),n(e,Zn,t),n(e,yt,t),n(e,Wn,t),u(ht,e,t),n(e,In,t),u(gt,e,t),n(e,_n,t),n(e,bt,t),n(e,kn,t),u(jt,e,t),n(e,xn,t),n(e,Tt,t),n(e,Bn,t),n(e,wt,t),n(e,Nn,t),n(e,Ut,t),n(e,Rn,t),u($t,e,t),n(e,Xn,t),n(e,Ct,t),n(e,An,t),u(Jt,e,t),n(e,Gn,t),n(e,vt,t),n(e,Vn,t),n(e,zt,t),n(e,Hn,t),u(Zt,e,t),n(e,En,t),n(e,Wt,t),n(e,Qn,t),u(It,e,t),n(e,Ln,t),n(e,_t,t),n(e,Sn,t),n(e,kt,t),n(e,Fn,t),u(xt,e,t),n(e,qn,t),n(e,Bt,t),n(e,Yn,t),u(Nt,e,t),n(e,Pn,t),n(e,Rt,t),n(e,On,t),n(e,Xt,t),n(e,Dn,t),n(e,Gt,t),Kn=!0},p(e,[t]){const yi={};t&2&&(yi.$$scope={dirty:t,ctx:e}),v.$set(yi);const hi={};t&2&&(hi.$$scope={dirty:t,ctx:e}),z.$set(hi);const gi={};t&2&&(gi.$$scope={dirty:t,ctx:e}),Z.$set(gi);const bi={};t&2&&(bi.$$scope={dirty:t,ctx:e}),W.$set(bi);const ji={};t&2&&(ji.$$scope={dirty:t,ctx:e}),I.$set(ji);const Ti={};t&2&&(Ti.$$scope={dirty:t,ctx:e}),_.$set(Ti);const wi={};t&2&&(wi.$$scope={dirty:t,ctx:e}),k.$set(wi)},i(e){Kn||(M(T.$$.fragment,e),M(N.$$.fragment,e),M(Q.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(P.$$.fragment,e),M(D.$$.fragment,e),M(te.$$.fragment,e),M(ne.$$.fragment,e),M(ie.$$.fragment,e),M(v.$$.fragment,e),M(oe.$$.fragment,e),M(me.$$.fragment,e),M(ue.$$.fragment,e),M(fe.$$.fragment,e),M(z.$$.fragment,e),M(he.$$.fragment,e),M(Te.$$.fragment,e),M(Z.$$.fragment,e),M(Ce.$$.fragment,e),M(W.$$.fragment,e),M(ze.$$.fragment,e),M(We.$$.fragment,e),M(_e.$$.fragment,e),M(xe.$$.fragment,e),M(I.$$.fragment,e),M(Be.$$.fragment,e),M(Re.$$.fragment,e),M(Ae.$$.fragment,e),M(_.$$.fragment,e),M(Ge.$$.fragment,e),M(He.$$.fragment,e),M(Qe.$$.fragment,e),M(qe.$$.fragment,e),M(k.$$.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(gt.$$.fragment,e),M(jt.$$.fragment,e),M($t.$$.fragment,e),M(Jt.$$.fragment,e),M(Zt.$$.fragment,e),M(It.$$.fragment,e),M(xt.$$.fragment,e),M(Nt.$$.fragment,e),Kn=!0)},o(e){f(T.$$.fragment,e),f(N.$$.fragment,e),f(Q.$$.fragment,e),f(S.$$.fragment,e),f(q.$$.fragment,e),f(P.$$.fragment,e),f(D.$$.fragment,e),f(te.$$.fragment,e),f(ne.$$.fragment,e),f(ie.$$.fragment,e),f(v.$$.fragment,e),f(oe.$$.fragment,e),f(me.$$.fragment,e),f(ue.$$.fragment,e),f(fe.$$.fragment,e),f(z.$$.fragment,e),f(he.$$.fragment,e),f(Te.$$.fragment,e),f(Z.$$.fragment,e),f(Ce.$$.fragment,e),f(W.$$.fragment,e),f(ze.$$.fragment,e),f(We.$$.fragment,e),f(_e.$$.fragment,e),f(xe.$$.fragment,e),f(I.$$.fragment,e),f(Be.$$.fragment,e),f(Re.$$.fragment,e),f(Ae.$$.fragment,e),f(_.$$.fragment,e),f(Ge.$$.fragment,e),f(He.$$.fragment,e),f(Qe.$$.fragment,e),f(qe.$$.fragment,e),f(k.$$.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(gt.$$.fragment,e),f(jt.$$.fragment,e),f($t.$$.fragment,e),f(Jt.$$.fragment,e),f(Zt.$$.fragment,e),f(It.$$.fragment,e),f(xt.$$.fragment,e),f(Nt.$$.fragment,e),Kn=!1},d(e){e&&(l(g),l(p),l(b),l(U),l(C),l(J),l(B),l(Vt),l(Ht),l(R),l(Et),l(X),l(Qt),l(A),l(Lt),l(G),l(St),l(V),l(Ft),l(H),l(qt),l(E),l(Yt),l(Pt),l(L),l(Ot),l(Dt),l(F),l(Kt),l(el),l(Y),l(tl),l(ll),l(O),l(nl),l(sl),l(K),l(il),l(ee),l(al),l(ol),l(le),l(rl),l(pl),l(se),l(cl),l(ml),l(ae),l(dl),l(ul),l(Ml),l(re),l(fl),l(pe),l(yl),l(ce),l(hl),l(gl),l(de),l(bl),l(jl),l(Me),l(Tl),l(wl),l(ye),l(Ul),l($l),l(Cl),l(ge),l(Jl),l(be),l(vl),l(je),l(zl),l(Zl),l(we),l(Wl),l(Ue),l(Il),l(_l),l($e),l(kl),l(xl),l(Je),l(Bl),l(Nl),l(ve),l(Rl),l(Xl),l(Ze),l(Al),l(Gl),l(Ie),l(Vl),l(Hl),l(ke),l(El),l(Ql),l(Ll),l(Sl),l(Ne),l(Fl),l(ql),l(Xe),l(Yl),l(Pl),l(Ol),l(Dl),l(Ve),l(Kl),l(en),l(Ee),l(tn),l(ln),l(Le),l(nn),l(Se),l(sn),l(Fe),l(an),l(on),l(rn),l(Ye),l(pn),l(Pe),l(cn),l(Oe),l(mn),l(De),l(dn),l(Ke),l(un),l(Mn),l(tt),l(fn),l(lt),l(yn),l(nt),l(hn),l(gn),l(it),l(bn),l(at),l(jn),l(ot),l(Tn),l(rt),l(wn),l(pt),l(Un),l($n),l(mt),l(Cn),l(Jn),l(ut),l(vn),l(zn),l(Zn),l(yt),l(Wn),l(In),l(_n),l(bt),l(kn),l(xn),l(Tt),l(Bn),l(wt),l(Nn),l(Ut),l(Rn),l(Xn),l(Ct),l(An),l(Gn),l(vt),l(Vn),l(zt),l(Hn),l(En),l(Wt),l(Qn),l(Ln),l(_t),l(Sn),l(kt),l(Fn),l(qn),l(Bt),l(Yn),l(Pn),l(Rt),l(On),l(Xt),l(Dn),l(Gt)),l(a),y(T,e),y(N,e),y(Q,e),y(S,e),y(q,e),y(P,e),y(D,e),y(te,e),y(ne,e),y(ie,e),y(v,e),y(oe,e),y(me,e),y(ue,e),y(fe,e),y(z,e),y(he,e),y(Te,e),y(Z,e),y(Ce,e),y(W,e),y(ze,e),y(We,e),y(_e,e),y(xe,e),y(I,e),y(Be,e),y(Re,e),y(Ae,e),y(_,e),y(Ge,e),y(He,e),y(Qe,e),y(qe,e),y(k,e),y(et,e),y(st,e),y(ct,e),y(dt,e),y(Mt,e),y(ft,e),y(ht,e),y(gt,e),y(jt,e),y($t,e),y(Jt,e),y(Zt,e),y(It,e),y(xt,e),y(Nt,e)}}}const Qi='{"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},{"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 Li(w){return vi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Di extends zi{constructor(a){super(),Zi(this,a,Li,Ei,Ji,{})}}export{Di as component};
