import{s as fs,o as Us,n as $a}from"../chunks/scheduler.893fe8c9.js";import{S as js,i as Is,e as w,s as r,c as u,q as ie,H as Js,h as _s,a as T,d as n,b as m,f as ga,g as M,j as f,r as re,z as bs,k as Da,l as v,m as s,n as d,o as c,D as k,t as o,p as J,E as g}from"../chunks/index.6ee278c6.js";import{T as Ba}from"../chunks/Tip.eab0255c.js";import{C as vs,H as Za,E as ks}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea3ad860.js";import{Y as ys}from"../chunks/Youtube.59d04f41.js";import{C as h}from"../chunks/CodeBlock.8bdd5f33.js";import{C as ws}from"../chunks/CourseFloatingBanner.c25cfa5e.js";import{F as gs}from"../chunks/FrameworkSwitchCourse.77a18d50.js";function Bs(b){let l,i;return l=new ws({props:{chapter:6,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter6/section3b_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter6/section3b_tf.ipynb"}]}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Zs(b){let l,i;return l=new ws({props:{chapter:6,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter6/section3b_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter6/section3b_pt.ipynb"}]}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function $s(b){let l,i;return l=new ys({props:{id:"b3u8RzBCX9Y"}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function xs(b){let l,i;return l=new ys({props:{id:"_wxyB3j3mk4"}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Gs(b){let l,i;return l=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbEZvclF1ZXN0aW9uQW5zd2VyaW5nJTBBJTBBbW9kZWxfY2hlY2twb2ludCUyMCUzRCUyMCUyMmRpc3RpbGJlcnQtYmFzZS1jYXNlZC1kaXN0aWxsZWQtc3F1YWQlMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9jaGVja3BvaW50KSUwQW1vZGVsJTIwJTNEJTIwVEZBdXRvTW9kZWxGb3JRdWVzdGlvbkFuc3dlcmluZy5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2hlY2twb2ludCklMEElMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIocXVlc3Rpb24lMkMlMjBjb250ZXh0JTJDJTIwcmV0dXJuX3RlbnNvcnMlM0QlMjJ0ZiUyMiklMEFvdXRwdXRzJTIwJTNEJTIwbW9kZWwoKippbnB1dHMp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModelForQuestionAnswering

model_checkpoint = <span class="hljs-string">&quot;distilbert-base-cased-distilled-squad&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = TFAutoModelForQuestionAnswering.from_pretrained(model_checkpoint)

inputs = tokenizer(question, context, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>)
outputs = model(**inputs)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Cs(b){let l,i;return l=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JRdWVzdGlvbkFuc3dlcmluZyUwQSUwQW1vZGVsX2NoZWNrcG9pbnQlMjAlM0QlMjAlMjJkaXN0aWxiZXJ0LWJhc2UtY2FzZWQtZGlzdGlsbGVkLXNxdWFkJTIyJTBBdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2hlY2twb2ludCklMEFtb2RlbCUyMCUzRCUyMEF1dG9Nb2RlbEZvclF1ZXN0aW9uQW5zd2VyaW5nLmZyb21fcHJldHJhaW5lZChtb2RlbF9jaGVja3BvaW50KSUwQSUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMGNvbnRleHQlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbCgqKmlucHV0cyk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForQuestionAnswering

model_checkpoint = <span class="hljs-string">&quot;distilbert-base-cased-distilled-squad&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)

inputs = tokenizer(question, context, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
outputs = model(**inputs)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ws(b){let l,i;return l=new h({props:{code:"KDElMkMlMjA2NiklMjAoMSUyQyUyMDY2KQ==",highlighted:'(<span class="hljs-number">1</span>, <span class="hljs-number">66</span>) (<span class="hljs-number">1</span>, <span class="hljs-number">66</span>)',wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Rs(b){let l,i;return l=new h({props:{code:"dG9yY2guU2l6ZSglNUIxJTJDJTIwNjYlNUQpJTIwdG9yY2guU2l6ZSglNUIxJTJDJTIwNjYlNUQp",highlighted:'torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">66</span>]) torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">66</span>])',wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ns(b){let l,i;return l=new h({props:{code:"aW1wb3J0JTIwdGVuc29yZmxvdyUyMGFzJTIwdGYlMEElMEFzZXF1ZW5jZV9pZHMlMjAlM0QlMjBpbnB1dHMuc2VxdWVuY2VfaWRzKCklMEElMjMlMjBNYXNrJTIwZXZlcnl0aGluZyUyMGFwYXJ0JTIwZnJvbSUyMHRoZSUyMHRva2VucyUyMG9mJTIwdGhlJTIwY29udGV4dCUwQW1hc2slMjAlM0QlMjAlNUJpJTIwISUzRCUyMDElMjBmb3IlMjBpJTIwaW4lMjBzZXF1ZW5jZV9pZHMlNUQlMEElMjMlMjBVbm1hc2slMjB0aGUlMjAlNUJDTFMlNUQlMjB0b2tlbiUwQW1hc2slNUIwJTVEJTIwJTNEJTIwRmFsc2UlMEFtYXNrJTIwJTNEJTIwdGYuY29uc3RhbnQobWFzayklNUJOb25lJTVEJTBBJTBBc3RhcnRfbG9naXRzJTIwJTNEJTIwdGYud2hlcmUobWFzayUyQyUyMC0xMDAwMCUyQyUyMHN0YXJ0X2xvZ2l0cyklMEFlbmRfbG9naXRzJTIwJTNEJTIwdGYud2hlcmUobWFzayUyQyUyMC0xMDAwMCUyQyUyMGVuZF9sb2dpdHMp",highlighted:`<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf

sequence_ids = inputs.sequence_ids()
<span class="hljs-comment"># Mask everything apart from the tokens of the context</span>
mask = [i != <span class="hljs-number">1</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> sequence_ids]
<span class="hljs-comment"># Unmask the [CLS] token</span>
mask[<span class="hljs-number">0</span>] = <span class="hljs-literal">False</span>
mask = tf.constant(mask)[<span class="hljs-literal">None</span>]

start_logits = tf.where(mask, -<span class="hljs-number">10000</span>, start_logits)
end_logits = tf.where(mask, -<span class="hljs-number">10000</span>, end_logits)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function zs(b){let l,i;return l=new h({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFzZXF1ZW5jZV9pZHMlMjAlM0QlMjBpbnB1dHMuc2VxdWVuY2VfaWRzKCklMEElMjMlMjBNYXNrJTIwZXZlcnl0aGluZyUyMGFwYXJ0JTIwZnJvbSUyMHRoZSUyMHRva2VucyUyMG9mJTIwdGhlJTIwY29udGV4dCUwQW1hc2slMjAlM0QlMjAlNUJpJTIwISUzRCUyMDElMjBmb3IlMjBpJTIwaW4lMjBzZXF1ZW5jZV9pZHMlNUQlMEElMjMlMjBVbm1hc2slMjB0aGUlMjAlNUJDTFMlNUQlMjB0b2tlbiUwQW1hc2slNUIwJTVEJTIwJTNEJTIwRmFsc2UlMEFtYXNrJTIwJTNEJTIwdG9yY2gudGVuc29yKG1hc2spJTVCTm9uZSU1RCUwQSUwQXN0YXJ0X2xvZ2l0cyU1Qm1hc2slNUQlMjAlM0QlMjAtMTAwMDAlMEFlbmRfbG9naXRzJTVCbWFzayU1RCUyMCUzRCUyMC0xMDAwMA==",highlighted:`<span class="hljs-keyword">import</span> torch

sequence_ids = inputs.sequence_ids()
<span class="hljs-comment"># Mask everything apart from the tokens of the context</span>
mask = [i != <span class="hljs-number">1</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> sequence_ids]
<span class="hljs-comment"># Unmask the [CLS] token</span>
mask[<span class="hljs-number">0</span>] = <span class="hljs-literal">False</span>
mask = torch.tensor(mask)[<span class="hljs-literal">None</span>]

start_logits[mask] = -<span class="hljs-number">10000</span>
end_logits[mask] = -<span class="hljs-number">10000</span>`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Vs(b){let l,i;return l=new h({props:{code:"c3RhcnRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRmLm1hdGguc29mdG1heChzdGFydF9sb2dpdHMlMkMlMjBheGlzJTNELTEpJTVCMCU1RC5udW1weSgpJTBBZW5kX3Byb2JhYmlsaXRpZXMlMjAlM0QlMjB0Zi5tYXRoLnNvZnRtYXgoZW5kX2xvZ2l0cyUyQyUyMGF4aXMlM0QtMSklNUIwJTVELm51bXB5KCk=",highlighted:`start_probabilities = tf.math.softmax(start_logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].numpy()
end_probabilities = tf.math.softmax(end_logits, axis=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>].numpy()`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Xs(b){let l,i;return l=new h({props:{code:"c3RhcnRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwuc29mdG1heChzdGFydF9sb2dpdHMlMkMlMjBkaW0lM0QtMSklNUIwJTVEJTBBZW5kX3Byb2JhYmlsaXRpZXMlMjAlM0QlMjB0b3JjaC5ubi5mdW5jdGlvbmFsLnNvZnRtYXgoZW5kX2xvZ2l0cyUyQyUyMGRpbSUzRC0xKSU1QjAlNUQ=",highlighted:`start_probabilities = torch.nn.functional.softmax(start_logits, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]
end_probabilities = torch.nn.functional.softmax(end_logits, dim=-<span class="hljs-number">1</span>)[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Hs(b){let l,i="Apoi vom masca valorile în care <code>start_index &gt; end_index</code> prin stabilirea lor la <code>0</code> (celelalte probabilități sunt toate numere pozitive). Funcția <code>np.triu()</code> returnează partea triunghiulară superioară a tensorului 2D trecut ca argument, deci va face această mascare pentru noi:",t,p,y;return p=new h({props:{code:"aW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBc2NvcmVzJTIwJTNEJTIwbnAudHJpdShzY29yZXMp",highlighted:`<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

scores = np.triu(scores)`,wrap:!1}}),{c(){l=w("p"),l.innerHTML=i,t=r(),u(p.$$.fragment)},l(U){l=T(U,"P",{"data-svelte-h":!0}),f(l)!=="svelte-139rou0"&&(l.innerHTML=i),t=m(U),M(p.$$.fragment,U)},m(U,j){s(U,l,j),s(U,t,j),d(p,U,j),y=!0},i(U){y||(o(p.$$.fragment,U),y=!0)},o(U){c(p.$$.fragment,U),y=!1},d(U){U&&(n(l),n(t)),J(p,U)}}}function Qs(b){let l,i="Apoi vom masca valorile în care <code>start_index &gt; end_index</code> prin stabilirea lor la <code>0</code> (celelalte probabilități sunt toate numere pozitive). Funcția <code>torch.triu()</code> returnează partea triunghiulară superioară a tensorului 2D trecut ca argument, deci va face această mascare pentru noi:",t,p,y;return p=new h({props:{code:"c2NvcmVzJTIwJTNEJTIwdG9yY2gudHJpdShzY29yZSk=",highlighted:"scores = torch.triu(score)",wrap:!1}}),{c(){l=w("p"),l.innerHTML=i,t=r(),u(p.$$.fragment)},l(U){l=T(U,"P",{"data-svelte-h":!0}),f(l)!=="svelte-1wrvb02"&&(l.innerHTML=i),t=m(U),M(p.$$.fragment,U)},m(U,j){s(U,l,j),s(U,t,j),d(p,U,j),y=!0},i(U){y||(o(p.$$.fragment,U),y=!0)},o(U){c(p.$$.fragment,U),y=!1},d(U){U&&(n(l),n(t)),J(p,U)}}}function Es(b){let l,i="✏️ <strong>Încercați!</strong> Calculați indicii de început și de sfârșit pentru cele mai probabile cinci răspunsuri.";return{c(){l=w("p"),l.innerHTML=i},l(t){l=T(t,"P",{"data-svelte-h":!0}),f(l)!=="svelte-1cmcxlu"&&(l.innerHTML=i)},m(t,p){s(t,l,p)},p:$a,d(t){t&&n(l)}}}function Fs(b){let l,i="✏️ <strong>Încercați!</strong> Utilizați cele mai bune scoruri pe care le-ați calculat anterior pentru a afișa cele mai probabile cinci răspunsuri. Pentru a vă verifica rezultatele, întoarceți-vă la primul pipeline și introduceți <code>top_k=5</code> atunci când îl apelați.";return{c(){l=w("p"),l.innerHTML=i},l(t){l=T(t,"P",{"data-svelte-h":!0}),f(l)!=="svelte-1tm427z"&&(l.innerHTML=i)},m(t,p){s(t,l,p)},p:$a,d(t){t&&n(l)}}}function Ys(b){let l,i,t,p;return l=new h({props:{code:"XyUyMCUzRCUyMGlucHV0cy5wb3AoJTIyb3ZlcmZsb3dfdG9fc2FtcGxlX21hcHBpbmclMjIpJTBBb2Zmc2V0cyUyMCUzRCUyMGlucHV0cy5wb3AoJTIyb2Zmc2V0X21hcHBpbmclMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW5wdXRzLmNvbnZlcnRfdG9fdGVuc29ycyglMjJ0ZiUyMiklMEFwcmludChpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQuc2hhcGUp",highlighted:`_ = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
offsets = inputs.pop(<span class="hljs-string">&quot;offset_mapping&quot;</span>)

inputs = inputs.convert_to_tensors(<span class="hljs-string">&quot;tf&quot;</span>)
<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape)`,wrap:!1}}),t=new h({props:{code:"KDIlMkMlMjAzODQp",highlighted:'(<span class="hljs-number">2</span>, <span class="hljs-number">384</span>)',wrap:!1}}),{c(){u(l.$$.fragment),i=r(),u(t.$$.fragment)},l(y){M(l.$$.fragment,y),i=m(y),M(t.$$.fragment,y)},m(y,U){d(l,y,U),s(y,i,U),d(t,y,U),p=!0},i(y){p||(o(l.$$.fragment,y),o(t.$$.fragment,y),p=!0)},o(y){c(l.$$.fragment,y),c(t.$$.fragment,y),p=!1},d(y){y&&n(i),J(l,y),J(t,y)}}}function Ss(b){let l,i,t,p;return l=new h({props:{code:"XyUyMCUzRCUyMGlucHV0cy5wb3AoJTIyb3ZlcmZsb3dfdG9fc2FtcGxlX21hcHBpbmclMjIpJTBBb2Zmc2V0cyUyMCUzRCUyMGlucHV0cy5wb3AoJTIyb2Zmc2V0X21hcHBpbmclMjIpJTBBJTBBaW5wdXRzJTIwJTNEJTIwaW5wdXRzLmNvbnZlcnRfdG9fdGVuc29ycyglMjJwdCUyMiklMEFwcmludChpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQuc2hhcGUp",highlighted:`_ = inputs.pop(<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>)
offsets = inputs.pop(<span class="hljs-string">&quot;offset_mapping&quot;</span>)

inputs = inputs.convert_to_tensors(<span class="hljs-string">&quot;pt&quot;</span>)
<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>].shape)`,wrap:!1}}),t=new h({props:{code:"dG9yY2guU2l6ZSglNUIyJTJDJTIwMzg0JTVEKQ==",highlighted:'torch.Size([<span class="hljs-number">2</span>, <span class="hljs-number">384</span>])',wrap:!1}}),{c(){u(l.$$.fragment),i=r(),u(t.$$.fragment)},l(y){M(l.$$.fragment,y),i=m(y),M(t.$$.fragment,y)},m(y,U){d(l,y,U),s(y,i,U),d(t,y,U),p=!0},i(y){p||(o(l.$$.fragment,y),o(t.$$.fragment,y),p=!0)},o(y){c(l.$$.fragment,y),c(t.$$.fragment,y),p=!1},d(y){y&&n(i),J(l,y),J(t,y)}}}function As(b){let l,i;return l=new h({props:{code:"KDIlMkMlMjAzODQpJTIwKDIlMkMlMjAzODQp",highlighted:'(<span class="hljs-number">2</span>, <span class="hljs-number">384</span>) (<span class="hljs-number">2</span>, <span class="hljs-number">384</span>)',wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function qs(b){let l,i;return l=new h({props:{code:"dG9yY2guU2l6ZSglNUIyJTJDJTIwMzg0JTVEKSUyMHRvcmNoLlNpemUoJTVCMiUyQyUyMDM4NCU1RCk=",highlighted:'torch.Size([<span class="hljs-number">2</span>, <span class="hljs-number">384</span>]) torch.Size([<span class="hljs-number">2</span>, <span class="hljs-number">384</span>])',wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ls(b){let l,i;return l=new h({props:{code:"c2VxdWVuY2VfaWRzJTIwJTNEJTIwaW5wdXRzLnNlcXVlbmNlX2lkcygpJTBBJTIzJTIwTWFzayUyMGV2ZXJ5dGhpbmclMjBhcGFydCUyMGZyb20lMjB0aGUlMjB0b2tlbnMlMjBvZiUyMHRoZSUyMGNvbnRleHQlMEFtYXNrJTIwJTNEJTIwJTVCaSUyMCElM0QlMjAxJTIwZm9yJTIwaSUyMGluJTIwc2VxdWVuY2VfaWRzJTVEJTBBJTIzJTIwVW5tYXNrJTIwdGhlJTIwJTVCQ0xTJTVEJTIwdG9rZW4lMEFtYXNrJTVCMCU1RCUyMCUzRCUyMEZhbHNlJTBBJTIzJTIwTWFzayUyMGFsbCUyMHRoZSUyMCU1QlBBRCU1RCUyMHRva2VucyUwQW1hc2slMjAlM0QlMjB0Zi5tYXRoLmxvZ2ljYWxfb3IodGYuY29uc3RhbnQobWFzayklNUJOb25lJTVEJTJDJTIwaW5wdXRzJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlNUQlMjAlM0QlM0QlMjAwKSUwQSUwQXN0YXJ0X2xvZ2l0cyUyMCUzRCUyMHRmLndoZXJlKG1hc2slMkMlMjAtMTAwMDAlMkMlMjBzdGFydF9sb2dpdHMpJTBBZW5kX2xvZ2l0cyUyMCUzRCUyMHRmLndoZXJlKG1hc2slMkMlMjAtMTAwMDAlMkMlMjBlbmRfbG9naXRzKQ==",highlighted:`sequence_ids = inputs.sequence_ids()
<span class="hljs-comment"># Mask everything apart from the tokens of the context</span>
mask = [i != <span class="hljs-number">1</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> sequence_ids]
<span class="hljs-comment"># Unmask the [CLS] token</span>
mask[<span class="hljs-number">0</span>] = <span class="hljs-literal">False</span>
<span class="hljs-comment"># Mask all the [PAD] tokens</span>
mask = tf.math.logical_or(tf.constant(mask)[<span class="hljs-literal">None</span>], inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>] == <span class="hljs-number">0</span>)

start_logits = tf.where(mask, -<span class="hljs-number">10000</span>, start_logits)
end_logits = tf.where(mask, -<span class="hljs-number">10000</span>, end_logits)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ds(b){let l,i;return l=new h({props:{code:"c2VxdWVuY2VfaWRzJTIwJTNEJTIwaW5wdXRzLnNlcXVlbmNlX2lkcygpJTBBJTIzJTIwTWFzayUyMGV2ZXJ5dGhpbmclMjBhcGFydCUyMGZyb20lMjB0aGUlMjB0b2tlbnMlMjBvZiUyMHRoZSUyMGNvbnRleHQlMEFtYXNrJTIwJTNEJTIwJTVCaSUyMCElM0QlMjAxJTIwZm9yJTIwaSUyMGluJTIwc2VxdWVuY2VfaWRzJTVEJTBBJTIzJTIwVW5tYXNrJTIwdGhlJTIwJTVCQ0xTJTVEJTIwdG9rZW4lMEFtYXNrJTVCMCU1RCUyMCUzRCUyMEZhbHNlJTBBJTIzJTIwTWFzayUyMGFsbCUyMHRoZSUyMCU1QlBBRCU1RCUyMHRva2VucyUwQW1hc2slMjAlM0QlMjB0b3JjaC5sb2dpY2FsX29yKHRvcmNoLnRlbnNvcihtYXNrKSU1Qk5vbmUlNUQlMkMlMjAoaW5wdXRzJTVCJTIyYXR0ZW50aW9uX21hc2slMjIlNUQlMjAlM0QlM0QlMjAwKSklMEElMEFzdGFydF9sb2dpdHMlNUJtYXNrJTVEJTIwJTNEJTIwLTEwMDAwJTBBZW5kX2xvZ2l0cyU1Qm1hc2slNUQlMjAlM0QlMjAtMTAwMDA=",highlighted:`sequence_ids = inputs.sequence_ids()
<span class="hljs-comment"># Mask everything apart from the tokens of the context</span>
mask = [i != <span class="hljs-number">1</span> <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> sequence_ids]
<span class="hljs-comment"># Unmask the [CLS] token</span>
mask[<span class="hljs-number">0</span>] = <span class="hljs-literal">False</span>
<span class="hljs-comment"># Mask all the [PAD] tokens</span>
mask = torch.logical_or(torch.tensor(mask)[<span class="hljs-literal">None</span>], (inputs[<span class="hljs-string">&quot;attention_mask&quot;</span>] == <span class="hljs-number">0</span>))

start_logits[mask] = -<span class="hljs-number">10000</span>
end_logits[mask] = -<span class="hljs-number">10000</span>`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ps(b){let l,i;return l=new h({props:{code:"c3RhcnRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRmLm1hdGguc29mdG1heChzdGFydF9sb2dpdHMlMkMlMjBheGlzJTNELTEpLm51bXB5KCklMEFlbmRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRmLm1hdGguc29mdG1heChlbmRfbG9naXRzJTJDJTIwYXhpcyUzRC0xKS5udW1weSgp",highlighted:`start_probabilities = tf.math.softmax(start_logits, axis=-<span class="hljs-number">1</span>).numpy()
end_probabilities = tf.math.softmax(end_logits, axis=-<span class="hljs-number">1</span>).numpy()`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Ks(b){let l,i;return l=new h({props:{code:"c3RhcnRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwuc29mdG1heChzdGFydF9sb2dpdHMlMkMlMjBkaW0lM0QtMSklMEFlbmRfcHJvYmFiaWxpdGllcyUyMCUzRCUyMHRvcmNoLm5uLmZ1bmN0aW9uYWwuc29mdG1heChlbmRfbG9naXRzJTJDJTIwZGltJTNELTEp",highlighted:`start_probabilities = torch.nn.functional.softmax(start_logits, dim=-<span class="hljs-number">1</span>)
end_probabilities = torch.nn.functional.softmax(end_logits, dim=-<span class="hljs-number">1</span>)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function Os(b){let l,i;return l=new h({props:{code:"Y2FuZGlkYXRlcyUyMCUzRCUyMCU1QiU1RCUwQWZvciUyMHN0YXJ0X3Byb2JzJTJDJTIwZW5kX3Byb2JzJTIwaW4lMjB6aXAoc3RhcnRfcHJvYmFiaWxpdGllcyUyQyUyMGVuZF9wcm9iYWJpbGl0aWVzKSUzQSUwQSUyMCUyMCUyMCUyMHNjb3JlcyUyMCUzRCUyMHN0YXJ0X3Byb2JzJTVCJTNBJTJDJTIwTm9uZSU1RCUyMColMjBlbmRfcHJvYnMlNUJOb25lJTJDJTIwJTNBJTVEJTBBJTIwJTIwJTIwJTIwaWR4JTIwJTNEJTIwbnAudHJpdShzY29yZXMpLmFyZ21heCgpLml0ZW0oKSUwQSUwQSUyMCUyMCUyMCUyMHN0YXJ0X2lkeCUyMCUzRCUyMGlkeCUyMCUyRiUyRiUyMHNjb3Jlcy5zaGFwZSU1QjElNUQlMEElMjAlMjAlMjAlMjBlbmRfaWR4JTIwJTNEJTIwaWR4JTIwJTI1JTIwc2NvcmVzLnNoYXBlJTVCMSU1RCUwQSUyMCUyMCUyMCUyMHNjb3JlJTIwJTNEJTIwc2NvcmVzJTVCc3RhcnRfaWR4JTJDJTIwZW5kX2lkeCU1RC5pdGVtKCklMEElMjAlMjAlMjAlMjBjYW5kaWRhdGVzLmFwcGVuZCgoc3RhcnRfaWR4JTJDJTIwZW5kX2lkeCUyQyUyMHNjb3JlKSklMEElMEFwcmludChjYW5kaWRhdGVzKQ==",highlighted:`candidates = []
<span class="hljs-keyword">for</span> start_probs, end_probs <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(start_probabilities, end_probabilities):
    scores = start_probs[:, <span class="hljs-literal">None</span>] * end_probs[<span class="hljs-literal">None</span>, :]
    idx = np.triu(scores).argmax().item()

    start_idx = idx // scores.shape[<span class="hljs-number">1</span>]
    end_idx = idx % scores.shape[<span class="hljs-number">1</span>]
    score = scores[start_idx, end_idx].item()
    candidates.append((start_idx, end_idx, score))

<span class="hljs-built_in">print</span>(candidates)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function ei(b){let l,i;return l=new h({props:{code:"Y2FuZGlkYXRlcyUyMCUzRCUyMCU1QiU1RCUwQWZvciUyMHN0YXJ0X3Byb2JzJTJDJTIwZW5kX3Byb2JzJTIwaW4lMjB6aXAoc3RhcnRfcHJvYmFiaWxpdGllcyUyQyUyMGVuZF9wcm9iYWJpbGl0aWVzKSUzQSUwQSUyMCUyMCUyMCUyMHNjb3JlcyUyMCUzRCUyMHN0YXJ0X3Byb2JzJTVCJTNBJTJDJTIwTm9uZSU1RCUyMColMjBlbmRfcHJvYnMlNUJOb25lJTJDJTIwJTNBJTVEJTBBJTIwJTIwJTIwJTIwaWR4JTIwJTNEJTIwdG9yY2gudHJpdShzY29yZXMpLmFyZ21heCgpLml0ZW0oKSUwQSUwQSUyMCUyMCUyMCUyMHN0YXJ0X2lkeCUyMCUzRCUyMGlkeCUyMCUyRiUyRiUyMHNjb3Jlcy5zaGFwZSU1QjElNUQlMEElMjAlMjAlMjAlMjBlbmRfaWR4JTIwJTNEJTIwaWR4JTIwJTI1JTIwc2NvcmVzLnNoYXBlJTVCMSU1RCUwQSUyMCUyMCUyMCUyMHNjb3JlJTIwJTNEJTIwc2NvcmVzJTVCc3RhcnRfaWR4JTJDJTIwZW5kX2lkeCU1RC5pdGVtKCklMEElMjAlMjAlMjAlMjBjYW5kaWRhdGVzLmFwcGVuZCgoc3RhcnRfaWR4JTJDJTIwZW5kX2lkeCUyQyUyMHNjb3JlKSklMEElMEFwcmludChjYW5kaWRhdGVzKQ==",highlighted:`candidates = []
<span class="hljs-keyword">for</span> start_probs, end_probs <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(start_probabilities, end_probabilities):
    scores = start_probs[:, <span class="hljs-literal">None</span>] * end_probs[<span class="hljs-literal">None</span>, :]
    idx = torch.triu(scores).argmax().item()

    start_idx = idx // scores.shape[<span class="hljs-number">1</span>]
    end_idx = idx % scores.shape[<span class="hljs-number">1</span>]
    score = scores[start_idx, end_idx].item()
    candidates.append((start_idx, end_idx, score))

<span class="hljs-built_in">print</span>(candidates)`,wrap:!1}}),{c(){u(l.$$.fragment)},l(t){M(l.$$.fragment,t)},m(t,p){d(l,t,p),i=!0},i(t){i||(o(l.$$.fragment,t),i=!0)},o(t){c(l.$$.fragment,t),i=!1},d(t){J(l,t)}}}function ti(b){let l,i="✏️ <strong>Încercați!</strong> Adaptați codul de mai sus pentru a returna scorurile și spanurile intervalele pentru cele mai probabile cinci răspunsuri (în total, nu pe chunk).";return{c(){l=w("p"),l.innerHTML=i},l(t){l=T(t,"P",{"data-svelte-h":!0}),f(l)!=="svelte-s7zbv9"&&(l.innerHTML=i)},m(t,p){s(t,l,p)},p:$a,d(t){t&&n(l)}}}function li(b){let l,i="✏️ <strong>Încercați!</strong> Utilizați cele mai bune scoruri pe care le-ați calculat înainte pentru a afișa cele mai probabile cinci răspunsuri (pentru întregul context, nu pentru fiecare chunk). Pentru a vă verifica rezultatele, întoarceți-vă la primul pipeline și introduceți <code>top_k=5</code> atunci când îl apelați.";return{c(){l=w("p"),l.innerHTML=i},l(t){l=T(t,"P",{"data-svelte-h":!0}),f(l)!=="svelte-gpytty"&&(l.innerHTML=i)},m(t,p){s(t,l,p)},p:$a,d(t){t&&n(l)}}}function ai(b){let l,i,t,p,y,U,j,el,me,tl,B,Z,Rt,ce,Pa="Acum ne vom aprofunda în pipelineul <code>question-answering</code> și să vedem cum putem valorifica offesturile pentru a primi răspunzuri la întrebări la îndemână din context, asemănător cum am făcut cu entitățile grupate în secțiunea precedentă. Pe urmă vom vedea cum vom face față contextelor foarte lungi care ajung truncate. Puteți trece peste această secțiune dacă nu sunteți interesat în întrebarea care răspunde la sarcina aceasta.",ll,$,x,Nt,oe,al,pe,Ka='Cum am văzut în <a href="/course/chapter1">Capitolul 1</a>, noi putem folosi pipelineul <code>question-answering</code> ca acesta pentru a răspunde la o întrebare:',nl,ue,sl,Me,il,de,Oa="Spre deosebire de alte pipelineuri, care nu put trunca și face split la text care este mai lung decât lungimea maxim acceptată de model(și, prin urmare, pot pierde informații la sfârșitul unui document), accest pipeline poate face față contextelor foarte lungi și va returna răspunsul la întrebare chiar dacă aceasta se află la sfârșit:",rl,Je,ml,be,cl,ye,en="Hai să vedem cum el face toate astea!",ol,we,pl,Te,tn='Ca în cazul oricărui altui pipeline, începem prin tokenizarea datelor de intrare și apoi le trimitem prin model. Checkpointul utilizat în mod implicit pentru pipelineul <code>question-answering</code> este <a href="https://huggingface.co/distilbert-base-cased-distilled-squad" rel="nofollow"><code>distilbert-base-cased-distilled-squad</code></a> (“squad” din nume provine de la datasetul pe care modelul a fost ajustat; vom vorbi mai multe despre datasetul SQuAD în <a href="/course/chapter7/7">Capitolul 7</a>):',ul,G,C,zt,he,ln="Observați că noi tokenizăm întrebrea și contextul ca o perecehe, cu întrebarea prima.",Ml,te,an='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter6/question_tokens.svg" alt="An example of tokenization of question and context"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter6/question_tokens-dark.svg" alt="An example of tokenization of question and context"/>',dl,fe,nn="Modelele create pentru răspunderea la întrebări funcționează puțin diferit de modelele pe care le-am văzut până acum. Folosind imaginea de mai sus ca exemplu, modelul a fost antrenat pentru a prezice indicele tokenului cu care începe răspunsului (aici 21) și indicele simbolului la care se termină răspunsul (aici 24). Acesta este motivul pentru care modelele respective nu returnează un singur tensor de logits, ci două: unul pentru logits-ul corespunzători tokenului cu care începe răspunsului și unul pentru logits-ul corespunzător tokenului de sfârșit al răspunsului. Deoarece în acest caz avem un singur input care conține 66 de token-uri, obținem:",Jl,Ue,bl,W,R,Vt,je,sn="Pentru a converti acești logits în probabilități, vom aplica o funcție softmax - dar înainte de aceasta, trebuie să ne asigurăm că mascăm indicii care nu fac parte din context. Inputul nostru este <code>[CLS] întrebare [SEP] context [SEP]</code>, deci trebuie să mascăm token-urile întrebării, precum și tokenul <code>[SEP]</code>. Cu toate acestea, vom păstra simbolul <code>[CLS]</code>, deoarece unele modele îl folosesc pentru a indica faptul că răspunsul nu se află în context.",yl,Ie,rn="Deoarece vom aplica ulterior un softmax, trebuie doar să înlocuim logiturile pe care dorim să le mascăm cu un număr negativ mare. Aici, folosim <code>-10000</code>:",wl,N,z,Xt,_e,mn="Acum că am mascat în mod corespunzător logiturile corespunzătoare pozițiilor pe care nu dorim să le prezicem, putem aplica softmax:",Tl,V,X,Ht,ve,cn="La acest stadiu, am putea lua argmax al probabilităților de început și de sfârșit - dar am putea ajunge la un indice de început care este mai mare decât indicele de sfârșit, deci trebuie să luăm câteva precauții suplimentare. Vom calcula probabilitățile fiecărui  <code>start_index</code> și <code>end_index</code> posibil în cazul în care <code>start_index &lt;= end_index</code>, apoi vom lua un tuple <code>(start_index, end_index)</code> cu cea mai mare probabilitate.",hl,I,xa,Qt,on="start_index",Ga,Et,pn="end_index",Ca,Ft,un="start_index",Wa,Yt,Mn="end_index",Ra,fl,Ts='<span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mrow><mi mathvariant="normal">s</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">s</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">]</mo><mo>×</mo><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\\mathrm{start\\_probabilities}[\\mathrm{start\\_index}] \\times \\mathrm{end\\_probabilities}[\\mathrm{end\\_index}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em;"></span><span class="mord"><span class="mord mathrm">start_probabilities</span></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">start_index</span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em;"></span><span class="mord"><span class="mord mathrm">end_probabilities</span></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">end_index</span></span><span class="mclose">]</span></span></span></span></span>',Ul,O,Na,jl,hs='<span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi mathvariant="normal">s</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">s</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">]</mo><mo>×</mo><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">p</mi><mi mathvariant="normal">r</mi><mi mathvariant="normal">o</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">a</mi><mi mathvariant="normal">b</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">l</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">t</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">s</mi></mrow><mo stretchy="false">[</mo><mrow><mi mathvariant="normal">e</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">_</mi><mi mathvariant="normal">i</mi><mi mathvariant="normal">n</mi><mi mathvariant="normal">d</mi><mi mathvariant="normal">e</mi><mi mathvariant="normal">x</mi></mrow><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">\\mathrm{start\\_probabilities}[\\mathrm{start\\_index}] \\times \\mathrm{end\\_probabilities}[\\mathrm{end\\_index}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em;"></span><span class="mord"><span class="mord mathrm">start_probabilities</span></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">start_index</span></span><span class="mclose">]</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:1.06em;vertical-align:-0.31em;"></span><span class="mord"><span class="mord mathrm">end_probabilities</span></span><span class="mopen">[</span><span class="mord"><span class="mord mathrm">end_index</span></span><span class="mclose">]</span></span></span></span>',Il,St,dn="start_index <= end_index",za,_l,ke,Jn="Mai întâi hai să calculăm toate produsele posibile:",vl,ge,kl,H,Q,At,Be,bn="Acum trebuie doar să obținem indicele maximului. Deoarece PyTorch va returna indicele în tensorul aplatizat, trebuie să folosim operațiile floor division <code>//</code> și modulusul <code>%</code> pentru a obține <code>start_index</code> și <code>end_index</code>:",gl,Ze,Bl,$e,yn="Nu am terminat încă, dar cel puțin avem deja scorul corect pentru răspuns (puteți verifica acest lucru comparându-l cu primul rezultat din secțiunea anterioară):",Zl,xe,$l,le,xl,Ge,wn="Avem <code>start_index</code> și <code>end_index</code> ale răspunsului în termeni de tokens, deci acum trebuie doar să convertim în character indices în context. Acesta este momentul în care offseturile vor fi foarte utile. Putem să le luăm și să le folosim așa cum am făcut în sarcina de clasificare a tokenurilor:",Gl,Ce,Cl,We,Tn="Acum trebuie doar să formatăm totul pentru a obține rezultatul nostru:",Wl,Re,Rl,Ne,Nl,ze,hn="Grozav! Este la fel ca în primul nostru exemplu!",zl,ae,Vl,Ve,Xl,Xe,fn="Dacă încercăm să tokenizăm întrebarea și contextul lung pe care le-am folosit ca un exemplu anterior, vom obține un număr de tokenuri mai mare decât lungimea maximă utilizată în pipelineul <code>question-answering</code> (care este 384):",Hl,He,Ql,Qe,El,Ee,Un="Prin urmare, va trebui să trunchiem inputurile la lungimea maximă. Există mai multe modalități prin care putem face acest lucru, dar nu dorim să trunchiem întrebarea, ci doar contextul. Deoarece contextul este a doua propoziție, vom utiliza strategia de trunchiere <code>&quot;only_second&quot;</code>. Problema care apare atunci este că răspunsul la întrebare poate să nu fie în contextul trunchiat. Aici, de exemplu, am ales o întrebare la care răspunsul se află spre sfârșitul contextului, iar atunci când îl trunchiem, răspunsul nu este prezent:",Fl,Fe,Yl,Ye,Sl,Se,jn="Aceasta înseamnă că modelul va avea dificultăți în a alege răspunsul corect. Pentru a rezolva acest lucru, pipelineul <code>question-answering</code> ne permite să împărțim contextul în bucăți mai mici, specificând lungimea maximă. Pentru a ne asigura că nu împărțim contextul exact în locul nepotrivit pentru a face posibilă găsirea răspunsului, aceasta include și o anumită suprapunere între bucăți.",Al,Ae,In="Putem cere tokenizerului (rapid sau lent) să facă acest lucru pentru noi adăugând <code>return_overflowing_tokens=True</code>, și putem specifica suprapunerea dorită cu argumentul <code>stride</code>. Iată un exemplu, folosind o propoziție mai mică:",ql,qe,Ll,Le,Dl,De,_n="După cum putem vedea, propoziția a fost împărțită în bucăți astfel încât fiecare intrare din <code>inputs[&quot;input_ids&quot;]</code> să aibă cel mult 6 token-uri (aici ar trebui să adăugăm padding pentru ca ultima intrare să aibă aceeași dimensiune ca celelalte) și există o suprapunere de 2 tokenuri între fiecare intrare.",Pl,Pe,vn="Să aruncăm o privire mai atentă la rezultatul tokenizării:",Kl,Ke,Ol,Oe,ea,et,kn="Așa cum era de așteptat, obținem ID-uri de intrare și un attention mask. Ultima cheie, <code>overflow_to_sample_mapping</code>, este o hartă care ne spune cărei propoziții îi corespunde fiecare dintre rezultate - aici avem 7 rezultate care provin toate din (singura) propoziție pe care am transmis-o tokenizerului:",ta,tt,la,lt,aa,at,gn="Acest lucru este mai util atunci când tokenizăm mai multe propoziții împreună. De exemplu, aceasta:",na,nt,sa,st,Bn="gets us:",ia,it,ra,rt,Zn="ceea ce înseamnă că prima propoziție este împărțită în 7 fragmente ca înainte, iar următoarele 4 fragmente provin din a doua propoziție.",ma,mt,$n="Acum să ne întoarcem la contextul nostru lung. În mod implicit, pipelineul <code>question-answering</code> utilizează o lungime maximă de 384, așa cum am menționat mai devreme, și un stride de 128, care corespund modului în care modelul a fost fine-tuned (puteți ajusta acești parametri prin trecerea argumentelor <code>max_seq_len</code> și <code>stride</code> atunci când apelați pipelineul). Astfel, vom utiliza acești parametri la tokenizare. Vom adăuga, de asemenea, padding (pentru a avea sampleuri de aceeași lungime, astfel încât să putem construi tensori), precum și pentru a solicita offsets:",ca,ct,oa,ot,xn="Aceste “inputuri” vor conține ID-urile de input și attention maskurile așteptate de model, precum și offseturile și “overflow_to_sample_mapping” despre care tocmai am vorbit. Deoarece cei doi nu sunt parametri utilizați de model, îi vom scoate din <code>inputs</code> (și nu vom stoca harta, deoarece nu este utilă aici) înainte de a-l converti într-un tensor:",pa,E,F,qt,pt,Gn="Contextul nostru lung a fost împărțit în două, ceea ce înseamnă că, după ce trece prin modelul nostru, vom avea două seturi de logits de început și de sfârșit:",ua,ut,Ma,Y,S,Lt,Mt,Cn="Ca și înainte, mai întâi mascăm tokenii care nu fac parte din context înainte de a lua softmax. De asemenea, mascăm toți padding tokens(marcate de attention mask):",da,A,q,Dt,dt,Wn="Then we can use the softmax to convert our logits to probabilities:",Ja,L,D,Pt,Jt,Rn="Următorul pas este similar cu ceea ce am făcut pentru contextul mic, dar îl repetăm pentru fiecare dintre cele două chunkuri. Atribuim un scor tuturor intervalelor posibile de răspuns, apoi luăm intervalul cu cel mai bun scor:",ba,P,K,Kt,bt,ya,yt,Nn="Cei doi candidați corespund celor mai bune răspunsuri pe care modelul le-a putut găsi în fiecare parte. Modelul este mult mai încrezător că răspunsul corect se află în a doua parte (ceea ce este un semn bun!). Acum trebuie doar să facem map celor două intervale de tokenuri cu intervalele de caractere din context (trebuie să o punem în corespondență doar pe a doua pentru a avea răspunsul nostru, dar este interesant să vedem ce a ales modelul în prima parte).",wa,ne,Ta,wt,zn="<code>offsets</code>-urile pe care le-am luat mai devreme este de fapt o listă de offsets, cu o listă pentru fiecare chunk de text:",ha,Tt,fa,ht,Ua,ft,Vn="Dacă ignorăm primul rezultat, obținem același rezultat ca și pipelineul noastru pentru acest context lung - yay!",ja,se,Ia,Ut,Xn="Aici se încheie scufundarea noastră în capacitățile tokenizerului. Vom pune toate acestea din nou în practică în capitolul următor, când vă vom arăta cum să ajustați un model pentru o serie de sarcini NLP comune.",_a,jt,va,Ot,ka;y=new gs({props:{fw:b[0]}}),j=new vs({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),me=new Za({props:{title:"Tokenizerii rapizi în pipeline-ul de QA",local:"fast-tokenizers-in-the-qa-pipeline",headingTag:"h1"}});const Hn=[Zs,Bs],It=[];function Qn(e,a){return e[0]==="pt"?0:1}B=Qn(b),Z=It[B]=Hn[B](b);const En=[xs,$s],_t=[];function Fn(e,a){return e[0]==="pt"?0:1}$=Fn(b),x=_t[$]=En[$](b),oe=new Za({props:{title:"Folosind question-answering pipeline",local:"using-the-question-answering-pipeline",headingTag:"h2"}}),ue=new h({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMHBpcGVsaW5lJTBBJTBBcXVlc3Rpb25fYW5zd2VyZXIlMjAlM0QlMjBwaXBlbGluZSglMjJxdWVzdGlvbi1hbnN3ZXJpbmclMjIpJTBBY29udGV4dCUyMCUzRCUyMCUyMiUyMiUyMiUwQSVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycyUyMGlzJTIwYmFja2VkJTIwYnklMjB0aGUlMjB0aHJlZSUyMG1vc3QlMjBwb3B1bGFyJTIwZGVlcCUyMGxlYXJuaW5nJTIwbGlicmFyaWVzJTIwJUUyJTgwJTk0JTIwSmF4JTJDJTIwUHlUb3JjaCUyQyUyMGFuZCUyMFRlbnNvckZsb3clMjAlRTIlODAlOTQlMjB3aXRoJTIwYSUyMHNlYW1sZXNzJTIwaW50ZWdyYXRpb24lMEFiZXR3ZWVuJTIwdGhlbS4lMjBJdCdzJTIwc3RyYWlnaHRmb3J3YXJkJTIwdG8lMjB0cmFpbiUyMHlvdXIlMjBtb2RlbHMlMjB3aXRoJTIwb25lJTIwYmVmb3JlJTIwbG9hZGluZyUyMHRoZW0lMjBmb3IlMjBpbmZlcmVuY2UlMjB3aXRoJTIwdGhlJTIwb3RoZXIuJTBBJTIyJTIyJTIyJTBBcXVlc3Rpb24lMjAlM0QlMjAlMjJXaGljaCUyMGRlZXAlMjBsZWFybmluZyUyMGxpYnJhcmllcyUyMGJhY2slMjAlRjAlOUYlQTQlOTclMjBUcmFuc2Zvcm1lcnMlM0YlMjIlMEFxdWVzdGlvbl9hbnN3ZXJlcihxdWVzdGlvbiUzRHF1ZXN0aW9uJTJDJTIwY29udGV4dCUzRGNvbnRleHQp",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline

question_answerer = pipeline(<span class="hljs-string">&quot;question-answering&quot;</span>)
context = <span class="hljs-string">&quot;&quot;&quot;
🤗 Transformers is backed by the three most popular deep learning libraries — Jax, PyTorch, and TensorFlow — with a seamless integration
between them. It&#x27;s straightforward to train your models with one before loading them for inference with the other.
&quot;&quot;&quot;</span>
question = <span class="hljs-string">&quot;Which deep learning libraries back 🤗 Transformers?&quot;</span>
question_answerer(question=question, context=context)`,wrap:!1}}),Me=new h({props:{code:"JTdCJ3Njb3JlJyUzQSUyMDAuOTc3NzMlMkMlMEElMjAnc3RhcnQnJTNBJTIwNzglMkMlMEElMjAnZW5kJyUzQSUyMDEwNSUyQyUwQSUyMCdhbnN3ZXInJTNBJTIwJ0pheCUyQyUyMFB5VG9yY2glMjBhbmQlMjBUZW5zb3JGbG93JyU3RA==",highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97773</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">78</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">105</span>,
 <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>}`,wrap:!1}}),Je=new h({props:{code:"bG9uZ19jb250ZXh0JTIwJTNEJTIwJTIyJTIyJTIyJTBBJUYwJTlGJUE0JTk3JTIwVHJhbnNmb3JtZXJzJTNBJTIwU3RhdGUlMjBvZiUyMHRoZSUyMEFydCUyME5MUCUwQSUwQSVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycyUyMHByb3ZpZGVzJTIwdGhvdXNhbmRzJTIwb2YlMjBwcmV0cmFpbmVkJTIwbW9kZWxzJTIwdG8lMjBwZXJmb3JtJTIwdGFza3MlMjBvbiUyMHRleHRzJTIwc3VjaCUyMGFzJTIwY2xhc3NpZmljYXRpb24lMkMlMjBpbmZvcm1hdGlvbiUyMGV4dHJhY3Rpb24lMkMlMEFxdWVzdGlvbiUyMGFuc3dlcmluZyUyQyUyMHN1bW1hcml6YXRpb24lMkMlMjB0cmFuc2xhdGlvbiUyQyUyMHRleHQlMjBnZW5lcmF0aW9uJTIwYW5kJTIwbW9yZSUyMGluJTIwb3ZlciUyMDEwMCUyMGxhbmd1YWdlcy4lMEFJdHMlMjBhaW0lMjBpcyUyMHRvJTIwbWFrZSUy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JhaW4lMjB5b3VyJTIwbW9kZWxzJTIwd2l0aCUyMG9uZSUyMGJlZm9yZSUyMGxvYWRpbmclMjB0aGVtJTIwZm9yJTIwaW5mZXJlbmNlJTIwd2l0aCUyMHRoZSUyMG90aGVyLiUwQSUyMiUyMiUyMiUwQXF1ZXN0aW9uX2Fuc3dlcmVyKHF1ZXN0aW9uJTNEcXVlc3Rpb24lMkMlMjBjb250ZXh0JTNEbG9uZ19jb250ZXh0KQ==",highlighted:`long_context = <span class="hljs-string">&quot;&quot;&quot;
🤗 Transformers: State of the Art NLP

🤗 Transformers provides thousands of pretrained models to perform tasks on texts such as classification, information extraction,
question answering, summarization, translation, text generation and more in over 100 languages.
Its aim is to make cutting-edge NLP easier to use for everyone.

🤗 Transformers provides APIs to quickly download and use those pretrained models on a given text, fine-tune them on your own datasets and
then share them with the community on our model hub. At the same time, each python module defining an architecture is fully standalone and
can be modified to enable quick research experiments.

Why should I use transformers?

1. Easy-to-use state-of-the-art models:
  - High performance on NLU and NLG tasks.
  - Low barrier to entry for educators and practitioners.
  - Few user-facing abstractions with just three classes to learn.
  - A unified API for using all our pretrained models.
  - Lower compute costs, smaller carbon footprint:

2. Researchers can share trained models instead of always retraining.
  - Practitioners can reduce compute time and production costs.
  - Dozens of architectures with over 10,000 pretrained models, some in more than 100 languages.

3. Choose the right framework for every part of a model&#x27;s lifetime:
  - Train state-of-the-art models in 3 lines of code.
  - Move a single model between TF2.0/PyTorch frameworks at will.
  - Seamlessly pick the right framework for training, evaluation and production.

4. Easily customize a model or an example to your needs:
  - We provide examples for each architecture to reproduce the results published by its original authors.
  - Model internals are exposed as consistently as possible.
  - Model files can be used independently of the library for quick experiments.

🤗 Transformers is backed by the three most popular deep learning libraries — Jax, PyTorch and TensorFlow — with a seamless integration
between them. It&#x27;s straightforward to train your models with one before loading them for inference with the other.
&quot;&quot;&quot;</span>
question_answerer(question=question, context=long_context)`,wrap:!1}}),be=new h({props:{code:"JTdCJ3Njb3JlJyUzQSUyMDAuOTcxNDklMkMlMEElMjAnc3RhcnQnJTNBJTIwMTg5MiUyQyUwQSUyMCdlbmQnJTNBJTIwMTkxOSUyQyUwQSUyMCdhbnN3ZXInJTNBJTIwJ0pheCUyQyUyMFB5VG9yY2glMjBhbmQlMjBUZW5zb3JGbG93JyU3RA==",highlighted:`{<span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97149</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">1892</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">1919</span>,
 <span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>}`,wrap:!1}}),we=new Za({props:{title:"Folosind un model pentru răspunderea la întrebări",local:"using-a-model-for-question-answering",headingTag:"h2"}});const Yn=[Cs,Gs],vt=[];function Sn(e,a){return e[0]==="pt"?0:1}G=Sn(b),C=vt[G]=Yn[G](b),Ue=new h({props:{code:"c3RhcnRfbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5zdGFydF9sb2dpdHMlMEFlbmRfbG9naXRzJTIwJTNEJTIwb3V0cHV0cy5lbmRfbG9naXRzJTBBcHJpbnQoc3RhcnRfbG9naXRzLnNoYXBlJTJDJTIwZW5kX2xvZ2l0cy5zaGFwZSk=",highlighted:`start_logits = outputs.start_logits
end_logits = outputs.end_logits
<span class="hljs-built_in">print</span>(start_logits.shape, end_logits.shape)`,wrap:!1}});const An=[Rs,Ws],kt=[];function qn(e,a){return e[0]==="pt"?0:1}W=qn(b),R=kt[W]=An[W](b);const Ln=[zs,Ns],gt=[];function Dn(e,a){return e[0]==="pt"?0:1}N=Dn(b),z=gt[N]=Ln[N](b);const Pn=[Xs,Vs],Bt=[];function Kn(e,a){return e[0]==="pt"?0:1}V=Kn(b),X=Bt[V]=Pn[V](b),ge=new h({props:{code:"c2NvcmVzJTIwJTNEJTIwc3RhcnRfcHJvYmFiaWxpdGllcyU1QiUzQSUyQyUyME5vbmUlNUQlMjAqJTIwZW5kX3Byb2JhYmlsaXRpZXMlNUJOb25lJTJDJTIwJTNBJTVE",highlighted:'scores = start_probabilities[:, <span class="hljs-literal">None</span>] * end_probabilities[<span class="hljs-literal">None</span>, :]',wrap:!1}});const On=[Qs,Hs],Zt=[];function es(e,a){return e[0]==="pt"?0:1}H=es(b),Q=Zt[H]=On[H](b),Ze=new h({props:{code:"bWF4X2luZGV4JTIwJTNEJTIwc2NvcmVzLmFyZ21heCgpLml0ZW0oKSUwQXN0YXJ0X2luZGV4JTIwJTNEJTIwbWF4X2luZGV4JTIwJTJGJTJGJTIwc2NvcmVzLnNoYXBlJTVCMSU1RCUwQWVuZF9pbmRleCUyMCUzRCUyMG1heF9pbmRleCUyMCUyNSUyMHNjb3Jlcy5zaGFwZSU1QjElNUQlMEFwcmludChzY29yZXMlNUJzdGFydF9pbmRleCUyQyUyMGVuZF9pbmRleCU1RCk=",highlighted:`max_index = scores.argmax().item()
start_index = max_index // scores.shape[<span class="hljs-number">1</span>]
end_index = max_index % scores.shape[<span class="hljs-number">1</span>]
<span class="hljs-built_in">print</span>(scores[start_index, end_index])`,wrap:!1}}),xe=new h({props:{code:"MC45Nzc3Mw==",highlighted:'<span class="hljs-number">0.97773</span>',wrap:!1}}),le=new Ba({props:{$$slots:{default:[Es]},$$scope:{ctx:b}}}),Ce=new h({props:{code:"aW5wdXRzX3dpdGhfb2Zmc2V0cyUyMCUzRCUyMHRva2VuaXplcihxdWVzdGlvbiUyQyUyMGNvbnRleHQlMkMlMjByZXR1cm5fb2Zmc2V0c19tYXBwaW5nJTNEVHJ1ZSklMEFvZmZzZXRzJTIwJTNEJTIwaW5wdXRzX3dpdGhfb2Zmc2V0cyU1QiUyMm9mZnNldF9tYXBwaW5nJTIyJTVEJTBBJTBBc3RhcnRfY2hhciUyQyUyMF8lMjAlM0QlMjBvZmZzZXRzJTVCc3RhcnRfaW5kZXglNUQlMEFfJTJDJTIwZW5kX2NoYXIlMjAlM0QlMjBvZmZzZXRzJTVCZW5kX2luZGV4JTVEJTBBYW5zd2VyJTIwJTNEJTIwY29udGV4dCU1QnN0YXJ0X2NoYXIlM0FlbmRfY2hhciU1RA==",highlighted:`inputs_with_offsets = tokenizer(question, context, return_offsets_mapping=<span class="hljs-literal">True</span>)
offsets = inputs_with_offsets[<span class="hljs-string">&quot;offset_mapping&quot;</span>]

start_char, _ = offsets[start_index]
_, end_char = offsets[end_index]
answer = context[start_char:end_char]`,wrap:!1}}),Re=new h({props:{code:"cmVzdWx0JTIwJTNEJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIyYW5zd2VyJTIyJTNBJTIwYW5zd2VyJTJDJTBBJTIwJTIwJTIwJTIwJTIyc3RhcnQlMjIlM0ElMjBzdGFydF9jaGFyJTJDJTBBJTIwJTIwJTIwJTIwJTIyZW5kJTIyJTNBJTIwZW5kX2NoYXIlMkMlMEElMjAlMjAlMjAlMjAlMjJzY29yZSUyMiUzQSUyMHNjb3JlcyU1QnN0YXJ0X2luZGV4JTJDJTIwZW5kX2luZGV4JTVEJTJDJTBBJTdEJTBBcHJpbnQocmVzdWx0KQ==",highlighted:`result = {
    <span class="hljs-string">&quot;answer&quot;</span>: answer,
    <span class="hljs-string">&quot;start&quot;</span>: start_char,
    <span class="hljs-string">&quot;end&quot;</span>: end_char,
    <span class="hljs-string">&quot;score&quot;</span>: scores[start_index, end_index],
}
<span class="hljs-built_in">print</span>(result)`,wrap:!1}}),Ne=new h({props:{code:"JTdCJ2Fuc3dlciclM0ElMjAnSmF4JTJDJTIwUHlUb3JjaCUyMGFuZCUyMFRlbnNvckZsb3cnJTJDJTBBJTIwJ3N0YXJ0JyUzQSUyMDc4JTJDJTBBJTIwJ2VuZCclM0ElMjAxMDUlMkMlMEElMjAnc2NvcmUnJTNBJTIwMC45Nzc3MyU3RA==",highlighted:`{<span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>,
 <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">78</span>,
 <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">105</span>,
 <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97773</span>}`,wrap:!1}}),ae=new Ba({props:{$$slots:{default:[Fs]},$$scope:{ctx:b}}}),Ve=new Za({props:{title:"Gestionarea contextelor lungi",local:"handling-long-contexts",headingTag:"h2"}}),He=new h({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHF1ZXN0aW9uJTJDJTIwbG9uZ19jb250ZXh0KSUwQXByaW50KGxlbihpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQpKQ==",highlighted:`inputs = tokenizer(question, long_context)
<span class="hljs-built_in">print</span>(<span class="hljs-built_in">len</span>(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]))`,wrap:!1}}),Qe=new h({props:{code:"NDYx",highlighted:'<span class="hljs-number">461</span>',wrap:!1}}),Fe=new h({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHF1ZXN0aW9uJTJDJTIwbG9uZ19jb250ZXh0JTJDJTIwbWF4X2xlbmd0aCUzRDM4NCUyQyUyMHRydW5jYXRpb24lM0QlMjJvbmx5X3NlY29uZCUyMiklMEFwcmludCh0b2tlbml6ZXIuZGVjb2RlKGlucHV0cyU1QiUyMmlucHV0X2lkcyUyMiU1RCkp",highlighted:`inputs = tokenizer(question, long_context, max_length=<span class="hljs-number">384</span>, truncation=<span class="hljs-string">&quot;only_second&quot;</span>)
<span class="hljs-built_in">print</span>(tokenizer.decode(inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]))`,wrap:!1}}),Ye=new h({props:{code:"JTIyJTIyJTIyJTBBJTVCQ0xTJTVEJTIwV2hpY2glMjBkZWVwJTIwbGVhcm5pbmclMjBsaWJyYXJpZXMlMjBiYWNrJTIwJTVCVU5LJTVEJTIwVHJhbnNmb3JtZXJzJTNGJTIwJTVCU0VQ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Iy",highlighted:`<span class="hljs-string">&quot;&quot;&quot;
[CLS] Which deep learning libraries back [UNK] Transformers? [SEP] [UNK] Transformers : State of the Art NLP

[UNK] Transformers provides thousands of pretrained models to perform tasks on texts such as classification, information extraction,
question answering, summarization, translation, text generation and more in over 100 languages.
Its aim is to make cutting-edge NLP easier to use for everyone.

[UNK] Transformers provides APIs to quickly download and use those pretrained models on a given text, fine-tune them on your own datasets and
then share them with the community on our model hub. At the same time, each python module defining an architecture is fully standalone and
can be modified to enable quick research experiments.

Why should I use transformers?

1. Easy-to-use state-of-the-art models:
  - High performance on NLU and NLG tasks.
  - Low barrier to entry for educators and practitioners.
  - Few user-facing abstractions with just three classes to learn.
  - A unified API for using all our pretrained models.
  - Lower compute costs, smaller carbon footprint:

2. Researchers can share trained models instead of always retraining.
  - Practitioners can reduce compute time and production costs.
  - Dozens of architectures with over 10,000 pretrained models, some in more than 100 languages.

3. Choose the right framework for every part of a model&#x27;s lifetime:
  - Train state-of-the-art models in 3 lines of code.
  - Move a single model between TF2.0/PyTorch frameworks at will.
  - Seamlessly pick the right framework for training, evaluation and production.

4. Easily customize a model or an example to your needs:
  - We provide examples for each architecture to reproduce the results published by its original authors.
  - Model internal [SEP]
&quot;&quot;&quot;</span>`,wrap:!1}}),qe=new h({props:{code:"c2VudGVuY2UlMjAlM0QlMjAlMjJUaGlzJTIwc2VudGVuY2UlMjBpcyUyMG5vdCUyMHRvbyUyMGxvbmclMjBidXQlMjB3ZSUyMGFyZSUyMGdvaW5nJTIwdG8lMjBzcGxpdCUyMGl0JTIwYW55d2F5LiUyMiUwQWlucHV0cyUyMCUzRCUyMHRva2VuaXplciglMEElMjAlMjAlMjAlMjBzZW50ZW5jZSUyQyUyMHRydW5jYXRpb24lM0RUcnVlJTJDJTIwcmV0dXJuX292ZXJmbG93aW5nX3Rva2VucyUzRFRydWUlMkMlMjBtYXhfbGVuZ3RoJTNENiUyQyUyMHN0cmlkZSUzRDIlMEEpJTBBJTBBZm9yJTIwaWRzJTIwaW4lMjBpbnB1dHMlNUIlMjJpbnB1dF9pZHMlMjIlNUQlM0ElMEElMjAlMjAlMjAlMjBwcmludCh0b2tlbml6ZXIuZGVjb2RlKGlkcykp",highlighted:`sentence = <span class="hljs-string">&quot;This sentence is not too long but we are going to split it anyway.&quot;</span>
inputs = tokenizer(
    sentence, truncation=<span class="hljs-literal">True</span>, return_overflowing_tokens=<span class="hljs-literal">True</span>, max_length=<span class="hljs-number">6</span>, stride=<span class="hljs-number">2</span>
)

<span class="hljs-keyword">for</span> ids <span class="hljs-keyword">in</span> inputs[<span class="hljs-string">&quot;input_ids&quot;</span>]:
    <span class="hljs-built_in">print</span>(tokenizer.decode(ids))`,wrap:!1}}),Le=new h({props:{code:"JyU1QkNMUyU1RCUyMFRoaXMlMjBzZW50ZW5jZSUyMGlzJTIwbm90JTIwJTVCU0VQJTVEJyUwQSclNUJDTFMlNUQlMjBpcyUyMG5vdCUyMHRvbyUyMGxvbmclMjAlNUJTRVAlNUQnJTBBJyU1QkNMUyU1RCUyMHRvbyUyMGxvbmclMjBidXQlMjB3ZSUyMCU1QlNFUCU1RCclMEEnJTVCQ0xTJTVEJTIwYnV0JTIwd2UlMjBhcmUlMjBnb2luZyUyMCU1QlNFUCU1RCclMEEnJTVCQ0xTJTVEJTIwYXJlJTIwZ29pbmclMjB0byUyMHNwbGl0JTIwJTVCU0VQJTVEJyUwQSclNUJDTFMlNUQlMjB0byUyMHNwbGl0JTIwaXQlMjBhbnl3YXklMjAlNUJTRVAlNUQnJTBBJyU1QkNMUyU1RCUyMGl0JTIwYW55d2F5LiUyMCU1QlNFUCU1RCc=",highlighted:`<span class="hljs-string">&#x27;[CLS] This sentence is not [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] is not too long [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] too long but we [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] but we are going [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] are going to split [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] to split it anyway [SEP]&#x27;</span>
<span class="hljs-string">&#x27;[CLS] it anyway. [SEP]&#x27;</span>`,wrap:!1}}),Ke=new h({props:{code:"cHJpbnQoaW5wdXRzLmtleXMoKSk=",highlighted:'<span class="hljs-built_in">print</span>(inputs.keys())',wrap:!1}}),Oe=new h({props:{code:"ZGljdF9rZXlzKCU1QidpbnB1dF9pZHMnJTJDJTIwJ2F0dGVudGlvbl9tYXNrJyUyQyUyMCdvdmVyZmxvd190b19zYW1wbGVfbWFwcGluZyclNUQp",highlighted:'dict_keys([<span class="hljs-string">&#x27;input_ids&#x27;</span>, <span class="hljs-string">&#x27;attention_mask&#x27;</span>, <span class="hljs-string">&#x27;overflow_to_sample_mapping&#x27;</span>])',wrap:!1}}),tt=new h({props:{code:"cHJpbnQoaW5wdXRzJTVCJTIyb3ZlcmZsb3dfdG9fc2FtcGxlX21hcHBpbmclMjIlNUQp",highlighted:'<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>])',wrap:!1}}),lt=new h({props:{code:"JTVCMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCU1RA==",highlighted:'[<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>]',wrap:!1}}),nt=new h({props:{code:"c2VudGVuY2VzJTIwJTNEJTIwJTVCJTBBJTIwJTIwJTIwJTIwJTIyVGhpcyUyMHNlbnRlbmNlJTIwaXMlMjBub3QlMjB0b28lMjBsb25nJTIwYnV0JTIwd2UlMjBhcmUlMjBnb2luZyUyMHRvJTIwc3BsaXQlMjBpdCUyMGFueXdheS4lMjIlMkMlMEElMjAlMjAlMjAlMjAlMjJUaGlzJTIwc2VudGVuY2UlMjBpcyUyMHNob3J0ZXIlMjBidXQlMjB3aWxsJTIwc3RpbGwlMjBnZXQlMjBzcGxpdC4lMjIlMkMlMEElNUQlMEFpbnB1dHMlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwc2VudGVuY2VzJTJDJTIwdHJ1bmNhdGlvbiUzRFRydWUlMkMlMjByZXR1cm5fb3ZlcmZsb3dpbmdfdG9rZW5zJTNEVHJ1ZSUyQyUyMG1heF9sZW5ndGglM0Q2JTJDJTIwc3RyaWRlJTNEMiUwQSklMEElMEFwcmludChpbnB1dHMlNUIlMjJvdmVyZmxvd190b19zYW1wbGVfbWFwcGluZyUyMiU1RCk=",highlighted:`sentences = [
    <span class="hljs-string">&quot;This sentence is not too long but we are going to split it anyway.&quot;</span>,
    <span class="hljs-string">&quot;This sentence is shorter but will still get split.&quot;</span>,
]
inputs = tokenizer(
    sentences, truncation=<span class="hljs-literal">True</span>, return_overflowing_tokens=<span class="hljs-literal">True</span>, max_length=<span class="hljs-number">6</span>, stride=<span class="hljs-number">2</span>
)

<span class="hljs-built_in">print</span>(inputs[<span class="hljs-string">&quot;overflow_to_sample_mapping&quot;</span>])`,wrap:!1}}),it=new h({props:{code:"JTVCMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDAlMkMlMjAwJTJDJTIwMCUyQyUyMDElMkMlMjAxJTJDJTIwMSUyQyUyMDElNUQ=",highlighted:'[<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>]',wrap:!1}}),ct=new h({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUwQSUyMCUyMCUyMCUyMHF1ZXN0aW9uJTJDJTBBJTIwJTIwJTIwJTIwbG9uZ19jb250ZXh0JTJDJTBBJTIwJTIwJTIwJTIwc3RyaWRlJTNEMTI4JTJDJTBBJTIwJTIwJTIwJTIwbWF4X2xlbmd0aCUzRDM4NCUyQyUwQSUyMCUyMCUyMCUyMHBhZGRpbmclM0QlMjJsb25nZXN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwdHJ1bmNhdGlvbiUzRCUyMm9ubHlfc2Vjb25kJTIyJTJDJTBBJTIwJTIwJTIwJTIwcmV0dXJuX292ZXJmbG93aW5nX3Rva2VucyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fb2Zmc2V0c19tYXBwaW5nJTNEVHJ1ZSUyQyUwQSk=",highlighted:`inputs = tokenizer(
    question,
    long_context,
    stride=<span class="hljs-number">128</span>,
    max_length=<span class="hljs-number">384</span>,
    padding=<span class="hljs-string">&quot;longest&quot;</span>,
    truncation=<span class="hljs-string">&quot;only_second&quot;</span>,
    return_overflowing_tokens=<span class="hljs-literal">True</span>,
    return_offsets_mapping=<span class="hljs-literal">True</span>,
)`,wrap:!1}});const ts=[Ss,Ys],$t=[];function ls(e,a){return e[0]==="pt"?0:1}E=ls(b),F=$t[E]=ts[E](b),ut=new h({props:{code:"b3V0cHV0cyUyMCUzRCUyMG1vZGVsKCoqaW5wdXRzKSUwQSUwQXN0YXJ0X2xvZ2l0cyUyMCUzRCUyMG91dHB1dHMuc3RhcnRfbG9naXRzJTBBZW5kX2xvZ2l0cyUyMCUzRCUyMG91dHB1dHMuZW5kX2xvZ2l0cyUwQXByaW50KHN0YXJ0X2xvZ2l0cy5zaGFwZSUyQyUyMGVuZF9sb2dpdHMuc2hhcGUp",highlighted:`outputs = model(**inputs)

start_logits = outputs.start_logits
end_logits = outputs.end_logits
<span class="hljs-built_in">print</span>(start_logits.shape, end_logits.shape)`,wrap:!1}});const as=[qs,As],xt=[];function ns(e,a){return e[0]==="pt"?0:1}Y=ns(b),S=xt[Y]=as[Y](b);const ss=[Ds,Ls],Gt=[];function is(e,a){return e[0]==="pt"?0:1}A=is(b),q=Gt[A]=ss[A](b);const rs=[Ks,Ps],Ct=[];function ms(e,a){return e[0]==="pt"?0:1}L=ms(b),D=Ct[L]=rs[L](b);const cs=[ei,Os],Wt=[];function os(e,a){return e[0]==="pt"?0:1}return P=os(b),K=Wt[P]=cs[P](b),bt=new h({props:{code:"JTVCKDAlMkMlMjAxOCUyQyUyMDAuMzM4NjcpJTJDJTIwKDE3MyUyQyUyMDE4NCUyQyUyMDAuOTcxNDkpJTVE",highlighted:'[(<span class="hljs-number">0</span>, <span class="hljs-number">18</span>, <span class="hljs-number">0.33867</span>), (<span class="hljs-number">173</span>, <span class="hljs-number">184</span>, <span class="hljs-number">0.97149</span>)]',wrap:!1}}),ne=new Ba({props:{$$slots:{default:[ti]},$$scope:{ctx:b}}}),Tt=new h({props:{code:"Zm9yJTIwY2FuZGlkYXRlJTJDJTIwb2Zmc2V0JTIwaW4lMjB6aXAoY2FuZGlkYXRlcyUyQyUyMG9mZnNldHMpJTNBJTBBJTIwJTIwJTIwJTIwc3RhcnRfdG9rZW4lMkMlMjBlbmRfdG9rZW4lMkMlMjBzY29yZSUyMCUzRCUyMGNhbmRpZGF0ZSUwQSUyMCUyMCUyMCUyMHN0YXJ0X2NoYXIlMkMlMjBfJTIwJTNEJTIwb2Zmc2V0JTVCc3RhcnRfdG9rZW4lNUQlMEElMjAlMjAlMjAlMjBfJTJDJTIwZW5kX2NoYXIlMjAlM0QlMjBvZmZzZXQlNUJlbmRfdG9rZW4lNUQlMEElMjAlMjAlMjAlMjBhbnN3ZXIlMjAlM0QlMjBsb25nX2NvbnRleHQlNUJzdGFydF9jaGFyJTNBZW5kX2NoYXIlNUQlMEElMjAlMjAlMjAlMjByZXN1bHQlMjAlM0QlMjAlN0IlMjJhbnN3ZXIlMjIlM0ElMjBhbnN3ZXIlMkMlMjAlMjJzdGFydCUyMiUzQSUyMHN0YXJ0X2NoYXIlMkMlMjAlMjJlbmQlMjIlM0ElMjBlbmRfY2hhciUyQyUyMCUyMnNjb3JlJTIyJTNBJTIwc2NvcmUlN0QlMEElMjAlMjAlMjAlMjBwcmludChyZXN1bHQp",highlighted:`<span class="hljs-keyword">for</span> candidate, offset <span class="hljs-keyword">in</span> <span class="hljs-built_in">zip</span>(candidates, offsets):
    start_token, end_token, score = candidate
    start_char, _ = offset[start_token]
    _, end_char = offset[end_token]
    answer = long_context[start_char:end_char]
    result = {<span class="hljs-string">&quot;answer&quot;</span>: answer, <span class="hljs-string">&quot;start&quot;</span>: start_char, <span class="hljs-string">&quot;end&quot;</span>: end_char, <span class="hljs-string">&quot;score&quot;</span>: score}
    <span class="hljs-built_in">print</span>(result)`,wrap:!1}}),ht=new h({props:{code:"JTdCJ2Fuc3dlciclM0ElMjAnJTVDbiVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycyUzQSUyMFN0YXRlJTIwb2YlMjB0aGUlMjBBcnQlMjBOTFAnJTJDJTIwJ3N0YXJ0JyUzQSUyMDAlMkMlMjAnZW5kJyUzQSUyMDM3JTJDJTIwJ3Njb3JlJyUzQSUyMDAuMzM4NjclN0QlMEElN0InYW5zd2VyJyUzQSUyMCdKYXglMkMlMjBQeVRvcmNoJTIwYW5kJTIwVGVuc29yRmxvdyclMkMlMjAnc3RhcnQnJTNBJTIwMTg5MiUyQyUyMCdlbmQnJTNBJTIwMTkxOSUyQyUyMCdzY29yZSclM0ElMjAwLjk3MTQ5JTdE",highlighted:`{<span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;\\n🤗 Transformers: State of the Art NLP&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">0</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">37</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.33867</span>}
{<span class="hljs-string">&#x27;answer&#x27;</span>: <span class="hljs-string">&#x27;Jax, PyTorch and TensorFlow&#x27;</span>, <span class="hljs-string">&#x27;start&#x27;</span>: <span class="hljs-number">1892</span>, <span class="hljs-string">&#x27;end&#x27;</span>: <span class="hljs-number">1919</span>, <span class="hljs-string">&#x27;score&#x27;</span>: <span class="hljs-number">0.97149</span>}`,wrap:!1}}),se=new Ba({props:{$$slots:{default:[li]},$$scope:{ctx:b}}}),jt=new ks({props:{source:"https://github.com/huggingface/course/blob/main/chapters/ro/chapter6/3b.mdx"}}),{c(){l=w("meta"),i=r(),t=w("p"),p=r(),u(y.$$.fragment),U=r(),u(j.$$.fragment),el=r(),u(me.$$.fragment),tl=r(),Z.c(),Rt=r(),ce=w("p"),ce.innerHTML=Pa,ll=r(),x.c(),Nt=r(),u(oe.$$.fragment),al=r(),pe=w("p"),pe.innerHTML=Ka,nl=r(),u(ue.$$.fragment),sl=r(),u(Me.$$.fragment),il=r(),de=w("p"),de.textContent=Oa,rl=r(),u(Je.$$.fragment),ml=r(),u(be.$$.fragment),cl=r(),ye=w("p"),ye.textContent=en,ol=r(),u(we.$$.fragment),pl=r(),Te=w("p"),Te.innerHTML=tn,ul=r(),C.c(),zt=r(),he=w("p"),he.textContent=ln,Ml=r(),te=w("div"),te.innerHTML=an,dl=r(),fe=w("p"),fe.textContent=nn,Jl=r(),u(Ue.$$.fragment),bl=r(),R.c(),Vt=r(),je=w("p"),je.innerHTML=sn,yl=r(),Ie=w("p"),Ie.innerHTML=rn,wl=r(),z.c(),Xt=r(),_e=w("p"),_e.textContent=mn,Tl=r(),X.c(),Ht=r(),ve=w("p"),ve.innerHTML=cn,hl=r(),I=w("p"),xa=ie("Presupunând că evenimentele “The answer starts at "),Qt=w("code"),Qt.textContent=on,Ga=ie("” și “The answer ends at "),Et=w("code"),Et.textContent=pn,Ca=ie("” sunt independente, probabilitatea ca răspunsul să înceapă la "),Ft=w("code"),Ft.textContent=un,Wa=ie(" și să se termine la "),Yt=w("code"),Yt.textContent=Mn,Ra=ie(` este:
`),fl=new Js(!1),Ul=r(),O=w("p"),Na=ie("Deci, pentru a calcula toate scorurile, trebuie doar să calculăm toate produsele"),jl=new Js(!1),Il=ie(" unde "),St=w("code"),St.textContent=dn,za=ie("."),_l=r(),ke=w("p"),ke.textContent=Jn,vl=r(),u(ge.$$.fragment),kl=r(),Q.c(),At=r(),Be=w("p"),Be.innerHTML=bn,gl=r(),u(Ze.$$.fragment),Bl=r(),$e=w("p"),$e.textContent=yn,Zl=r(),u(xe.$$.fragment),$l=r(),u(le.$$.fragment),xl=r(),Ge=w("p"),Ge.innerHTML=wn,Gl=r(),u(Ce.$$.fragment),Cl=r(),We=w("p"),We.textContent=Tn,Wl=r(),u(Re.$$.fragment),Rl=r(),u(Ne.$$.fragment),Nl=r(),ze=w("p"),ze.textContent=hn,zl=r(),u(ae.$$.fragment),Vl=r(),u(Ve.$$.fragment),Xl=r(),Xe=w("p"),Xe.innerHTML=fn,Hl=r(),u(He.$$.fragment),Ql=r(),u(Qe.$$.fragment),El=r(),Ee=w("p"),Ee.innerHTML=Un,Fl=r(),u(Fe.$$.fragment),Yl=r(),u(Ye.$$.fragment),Sl=r(),Se=w("p"),Se.innerHTML=jn,Al=r(),Ae=w("p"),Ae.innerHTML=In,ql=r(),u(qe.$$.fragment),Ll=r(),u(Le.$$.fragment),Dl=r(),De=w("p"),De.innerHTML=_n,Pl=r(),Pe=w("p"),Pe.textContent=vn,Kl=r(),u(Ke.$$.fragment),Ol=r(),u(Oe.$$.fragment),ea=r(),et=w("p"),et.innerHTML=kn,ta=r(),u(tt.$$.fragment),la=r(),u(lt.$$.fragment),aa=r(),at=w("p"),at.textContent=gn,na=r(),u(nt.$$.fragment),sa=r(),st=w("p"),st.textContent=Bn,ia=r(),u(it.$$.fragment),ra=r(),rt=w("p"),rt.textContent=Zn,ma=r(),mt=w("p"),mt.innerHTML=$n,ca=r(),u(ct.$$.fragment),oa=r(),ot=w("p"),ot.innerHTML=xn,pa=r(),F.c(),qt=r(),pt=w("p"),pt.textContent=Gn,ua=r(),u(ut.$$.fragment),Ma=r(),S.c(),Lt=r(),Mt=w("p"),Mt.textContent=Cn,da=r(),q.c(),Dt=r(),dt=w("p"),dt.textContent=Wn,Ja=r(),D.c(),Pt=r(),Jt=w("p"),Jt.textContent=Rn,ba=r(),K.c(),Kt=r(),u(bt.$$.fragment),ya=r(),yt=w("p"),yt.textContent=Nn,wa=r(),u(ne.$$.fragment),Ta=r(),wt=w("p"),wt.innerHTML=zn,ha=r(),u(Tt.$$.fragment),fa=r(),u(ht.$$.fragment),Ua=r(),ft=w("p"),ft.textContent=Vn,ja=r(),u(se.$$.fragment),Ia=r(),Ut=w("p"),Ut.textContent=Xn,_a=r(),u(jt.$$.fragment),va=r(),Ot=w("p"),this.h()},l(e){const a=_s("svelte-u9bgzb",document.head);l=T(a,"META",{name:!0,content:!0}),a.forEach(n),i=m(e),t=T(e,"P",{}),ga(t).forEach(n),p=m(e),M(y.$$.fragment,e),U=m(e),M(j.$$.fragment,e),el=m(e),M(me.$$.fragment,e),tl=m(e),Z.l(e),Rt=m(e),ce=T(e,"P",{"data-svelte-h":!0}),f(ce)!=="svelte-gs77xf"&&(ce.innerHTML=Pa),ll=m(e),x.l(e),Nt=m(e),M(oe.$$.fragment,e),al=m(e),pe=T(e,"P",{"data-svelte-h":!0}),f(pe)!=="svelte-1drz3d6"&&(pe.innerHTML=Ka),nl=m(e),M(ue.$$.fragment,e),sl=m(e),M(Me.$$.fragment,e),il=m(e),de=T(e,"P",{"data-svelte-h":!0}),f(de)!=="svelte-1jof88z"&&(de.textContent=Oa),rl=m(e),M(Je.$$.fragment,e),ml=m(e),M(be.$$.fragment,e),cl=m(e),ye=T(e,"P",{"data-svelte-h":!0}),f(ye)!=="svelte-41pc3s"&&(ye.textContent=en),ol=m(e),M(we.$$.fragment,e),pl=m(e),Te=T(e,"P",{"data-svelte-h":!0}),f(Te)!=="svelte-hx0mps"&&(Te.innerHTML=tn),ul=m(e),C.l(e),zt=m(e),he=T(e,"P",{"data-svelte-h":!0}),f(he)!=="svelte-1o0rxfe"&&(he.textContent=ln),Ml=m(e),te=T(e,"DIV",{class:!0,"data-svelte-h":!0}),f(te)!=="svelte-47wedv"&&(te.innerHTML=an),dl=m(e),fe=T(e,"P",{"data-svelte-h":!0}),f(fe)!=="svelte-1k6k3aj"&&(fe.textContent=nn),Jl=m(e),M(Ue.$$.fragment,e),bl=m(e),R.l(e),Vt=m(e),je=T(e,"P",{"data-svelte-h":!0}),f(je)!=="svelte-1eehlns"&&(je.innerHTML=sn),yl=m(e),Ie=T(e,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-doo8ql"&&(Ie.innerHTML=rn),wl=m(e),z.l(e),Xt=m(e),_e=T(e,"P",{"data-svelte-h":!0}),f(_e)!=="svelte-1p1eafu"&&(_e.textContent=mn),Tl=m(e),X.l(e),Ht=m(e),ve=T(e,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-pz25ke"&&(ve.innerHTML=cn),hl=m(e),I=T(e,"P",{});var _=ga(I);xa=re(_,"Presupunând că evenimentele “The answer starts at "),Qt=T(_,"CODE",{"data-svelte-h":!0}),f(Qt)!=="svelte-8eqb3b"&&(Qt.textContent=on),Ga=re(_,"” și “The answer ends at "),Et=T(_,"CODE",{"data-svelte-h":!0}),f(Et)!=="svelte-9cistc"&&(Et.textContent=pn),Ca=re(_,"” sunt independente, probabilitatea ca răspunsul să înceapă la "),Ft=T(_,"CODE",{"data-svelte-h":!0}),f(Ft)!=="svelte-8eqb3b"&&(Ft.textContent=un),Wa=re(_," și să se termine la "),Yt=T(_,"CODE",{"data-svelte-h":!0}),f(Yt)!=="svelte-9cistc"&&(Yt.textContent=Mn),Ra=re(_,` este:
`),fl=bs(_,!1),_.forEach(n),Ul=m(e),O=T(e,"P",{});var ee=ga(O);Na=re(ee,"Deci, pentru a calcula toate scorurile, trebuie doar să calculăm toate produsele"),jl=bs(ee,!1),Il=re(ee," unde "),St=T(ee,"CODE",{"data-svelte-h":!0}),f(St)!=="svelte-1kp3szf"&&(St.textContent=dn),za=re(ee,"."),ee.forEach(n),_l=m(e),ke=T(e,"P",{"data-svelte-h":!0}),f(ke)!=="svelte-i54l9f"&&(ke.textContent=Jn),vl=m(e),M(ge.$$.fragment,e),kl=m(e),Q.l(e),At=m(e),Be=T(e,"P",{"data-svelte-h":!0}),f(Be)!=="svelte-1lao0yt"&&(Be.innerHTML=bn),gl=m(e),M(Ze.$$.fragment,e),Bl=m(e),$e=T(e,"P",{"data-svelte-h":!0}),f($e)!=="svelte-128j8ii"&&($e.textContent=yn),Zl=m(e),M(xe.$$.fragment,e),$l=m(e),M(le.$$.fragment,e),xl=m(e),Ge=T(e,"P",{"data-svelte-h":!0}),f(Ge)!=="svelte-2ksf6i"&&(Ge.innerHTML=wn),Gl=m(e),M(Ce.$$.fragment,e),Cl=m(e),We=T(e,"P",{"data-svelte-h":!0}),f(We)!=="svelte-1jq8cgv"&&(We.textContent=Tn),Wl=m(e),M(Re.$$.fragment,e),Rl=m(e),M(Ne.$$.fragment,e),Nl=m(e),ze=T(e,"P",{"data-svelte-h":!0}),f(ze)!=="svelte-sb5jce"&&(ze.textContent=hn),zl=m(e),M(ae.$$.fragment,e),Vl=m(e),M(Ve.$$.fragment,e),Xl=m(e),Xe=T(e,"P",{"data-svelte-h":!0}),f(Xe)!=="svelte-1b2qe2s"&&(Xe.innerHTML=fn),Hl=m(e),M(He.$$.fragment,e),Ql=m(e),M(Qe.$$.fragment,e),El=m(e),Ee=T(e,"P",{"data-svelte-h":!0}),f(Ee)!=="svelte-1a66x7q"&&(Ee.innerHTML=Un),Fl=m(e),M(Fe.$$.fragment,e),Yl=m(e),M(Ye.$$.fragment,e),Sl=m(e),Se=T(e,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-wbvi95"&&(Se.innerHTML=jn),Al=m(e),Ae=T(e,"P",{"data-svelte-h":!0}),f(Ae)!=="svelte-15swwgh"&&(Ae.innerHTML=In),ql=m(e),M(qe.$$.fragment,e),Ll=m(e),M(Le.$$.fragment,e),Dl=m(e),De=T(e,"P",{"data-svelte-h":!0}),f(De)!=="svelte-10ynzq4"&&(De.innerHTML=_n),Pl=m(e),Pe=T(e,"P",{"data-svelte-h":!0}),f(Pe)!=="svelte-14khn33"&&(Pe.textContent=vn),Kl=m(e),M(Ke.$$.fragment,e),Ol=m(e),M(Oe.$$.fragment,e),ea=m(e),et=T(e,"P",{"data-svelte-h":!0}),f(et)!=="svelte-mjj8y4"&&(et.innerHTML=kn),ta=m(e),M(tt.$$.fragment,e),la=m(e),M(lt.$$.fragment,e),aa=m(e),at=T(e,"P",{"data-svelte-h":!0}),f(at)!=="svelte-1l99crl"&&(at.textContent=gn),na=m(e),M(nt.$$.fragment,e),sa=m(e),st=T(e,"P",{"data-svelte-h":!0}),f(st)!=="svelte-b6k3qh"&&(st.textContent=Bn),ia=m(e),M(it.$$.fragment,e),ra=m(e),rt=T(e,"P",{"data-svelte-h":!0}),f(rt)!=="svelte-1l5swnq"&&(rt.textContent=Zn),ma=m(e),mt=T(e,"P",{"data-svelte-h":!0}),f(mt)!=="svelte-xddee7"&&(mt.innerHTML=$n),ca=m(e),M(ct.$$.fragment,e),oa=m(e),ot=T(e,"P",{"data-svelte-h":!0}),f(ot)!=="svelte-ehoc4e"&&(ot.innerHTML=xn),pa=m(e),F.l(e),qt=m(e),pt=T(e,"P",{"data-svelte-h":!0}),f(pt)!=="svelte-zlhaau"&&(pt.textContent=Gn),ua=m(e),M(ut.$$.fragment,e),Ma=m(e),S.l(e),Lt=m(e),Mt=T(e,"P",{"data-svelte-h":!0}),f(Mt)!=="svelte-w1s80s"&&(Mt.textContent=Cn),da=m(e),q.l(e),Dt=m(e),dt=T(e,"P",{"data-svelte-h":!0}),f(dt)!=="svelte-xc3z5h"&&(dt.textContent=Wn),Ja=m(e),D.l(e),Pt=m(e),Jt=T(e,"P",{"data-svelte-h":!0}),f(Jt)!=="svelte-6l5dky"&&(Jt.textContent=Rn),ba=m(e),K.l(e),Kt=m(e),M(bt.$$.fragment,e),ya=m(e),yt=T(e,"P",{"data-svelte-h":!0}),f(yt)!=="svelte-wybiq2"&&(yt.textContent=Nn),wa=m(e),M(ne.$$.fragment,e),Ta=m(e),wt=T(e,"P",{"data-svelte-h":!0}),f(wt)!=="svelte-1e1qzy4"&&(wt.innerHTML=zn),ha=m(e),M(Tt.$$.fragment,e),fa=m(e),M(ht.$$.fragment,e),Ua=m(e),ft=T(e,"P",{"data-svelte-h":!0}),f(ft)!=="svelte-1d49c5t"&&(ft.textContent=Vn),ja=m(e),M(se.$$.fragment,e),Ia=m(e),Ut=T(e,"P",{"data-svelte-h":!0}),f(Ut)!=="svelte-1r5vmkg"&&(Ut.textContent=Xn),_a=m(e),M(jt.$$.fragment,e),va=m(e),Ot=T(e,"P",{}),ga(Ot).forEach(n),this.h()},h(){Da(l,"name","hf:doc:metadata"),Da(l,"content",ni),Da(te,"class","flex justify-center"),fl.a=null,jl.a=Il},m(e,a){v(document.head,l),s(e,i,a),s(e,t,a),s(e,p,a),d(y,e,a),s(e,U,a),d(j,e,a),s(e,el,a),d(me,e,a),s(e,tl,a),It[B].m(e,a),s(e,Rt,a),s(e,ce,a),s(e,ll,a),_t[$].m(e,a),s(e,Nt,a),d(oe,e,a),s(e,al,a),s(e,pe,a),s(e,nl,a),d(ue,e,a),s(e,sl,a),d(Me,e,a),s(e,il,a),s(e,de,a),s(e,rl,a),d(Je,e,a),s(e,ml,a),d(be,e,a),s(e,cl,a),s(e,ye,a),s(e,ol,a),d(we,e,a),s(e,pl,a),s(e,Te,a),s(e,ul,a),vt[G].m(e,a),s(e,zt,a),s(e,he,a),s(e,Ml,a),s(e,te,a),s(e,dl,a),s(e,fe,a),s(e,Jl,a),d(Ue,e,a),s(e,bl,a),kt[W].m(e,a),s(e,Vt,a),s(e,je,a),s(e,yl,a),s(e,Ie,a),s(e,wl,a),gt[N].m(e,a),s(e,Xt,a),s(e,_e,a),s(e,Tl,a),Bt[V].m(e,a),s(e,Ht,a),s(e,ve,a),s(e,hl,a),s(e,I,a),v(I,xa),v(I,Qt),v(I,Ga),v(I,Et),v(I,Ca),v(I,Ft),v(I,Wa),v(I,Yt),v(I,Ra),fl.m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(e,Kt,a),d(bt,e,a),s(e,ya,a),s(e,yt,a),s(e,wa,a),d(ne,e,a),s(e,Ta,a),s(e,wt,a),s(e,ha,a),d(Tt,e,a),s(e,fa,a),d(ht,e,a),s(e,Ua,a),s(e,ft,a),s(e,ja,a),d(se,e,a),s(e,Ia,a),s(e,Ut,a),s(e,_a,a),d(jt,e,a),s(e,va,a),s(e,Ot,a),ka=!0},p(e,[a]){const _={};a&1&&(_.fw=e[0]),y.$set(_);let ee=B;B=Qn(e),B!==ee&&(g(),c(It[ee],1,1,()=>{It[ee]=null}),k(),Z=It[B],Z||(Z=It[B]=Hn[B](e),Z.c()),o(Z,1),Z.m(Rt.parentNode,Rt));let Va=$;$=Fn(e),$!==Va&&(g(),c(_t[Va],1,1,()=>{_t[Va]=null}),k(),x=_t[$],x||(x=_t[$]=En[$](e),x.c()),o(x,1),x.m(Nt.parentNode,Nt));let Xa=G;G=Sn(e),G!==Xa&&(g(),c(vt[Xa],1,1,()=>{vt[Xa]=null}),k(),C=vt[G],C||(C=vt[G]=Yn[G](e),C.c()),o(C,1),C.m(zt.parentNode,zt));let Ha=W;W=qn(e),W!==Ha&&(g(),c(kt[Ha],1,1,()=>{kt[Ha]=null}),k(),R=kt[W],R||(R=kt[W]=An[W](e),R.c()),o(R,1),R.m(Vt.parentNode,Vt));let Qa=N;N=Dn(e),N!==Qa&&(g(),c(gt[Qa],1,1,()=>{gt[Qa]=null}),k(),z=gt[N],z||(z=gt[N]=Ln[N](e),z.c()),o(z,1),z.m(Xt.parentNode,Xt));let Ea=V;V=Kn(e),V!==Ea&&(g(),c(Bt[Ea],1,1,()=>{Bt[Ea]=null}),k(),X=Bt[V],X||(X=Bt[V]=Pn[V](e),X.c()),o(X,1),X.m(Ht.parentNode,Ht));let Fa=H;H=es(e),H!==Fa&&(g(),c(Zt[Fa],1,1,()=>{Zt[Fa]=null}),k(),Q=Zt[H],Q||(Q=Zt[H]=On[H](e),Q.c()),o(Q,1),Q.m(At.parentNode,At));const ps={};a&2&&(ps.$$scope={dirty:a,ctx:e}),le.$set(ps);const us={};a&2&&(us.$$scope={dirty:a,ctx:e}),ae.$set(us);let Ya=E;E=ls(e),E!==Ya&&(g(),c($t[Ya],1,1,()=>{$t[Ya]=null}),k(),F=$t[E],F||(F=$t[E]=ts[E](e),F.c()),o(F,1),F.m(qt.parentNode,qt));let Sa=Y;Y=ns(e),Y!==Sa&&(g(),c(xt[Sa],1,1,()=>{xt[Sa]=null}),k(),S=xt[Y],S||(S=xt[Y]=as[Y](e),S.c()),o(S,1),S.m(Lt.parentNode,Lt));let Aa=A;A=is(e),A!==Aa&&(g(),c(Gt[Aa],1,1,()=>{Gt[Aa]=null}),k(),q=Gt[A],q||(q=Gt[A]=ss[A](e),q.c()),o(q,1),q.m(Dt.parentNode,Dt));let qa=L;L=ms(e),L!==qa&&(g(),c(Ct[qa],1,1,()=>{Ct[qa]=null}),k(),D=Ct[L],D||(D=Ct[L]=rs[L](e),D.c()),o(D,1),D.m(Pt.parentNode,Pt));let La=P;P=os(e),P!==La&&(g(),c(Wt[La],1,1,()=>{Wt[La]=null}),k(),K=Wt[P],K||(K=Wt[P]=cs[P](e),K.c()),o(K,1),K.m(Kt.parentNode,Kt));const Ms={};a&2&&(Ms.$$scope={dirty:a,ctx:e}),ne.$set(Ms);const ds={};a&2&&(ds.$$scope={dirty:a,ctx:e}),se.$set(ds)},i(e){ka||(o(y.$$.fragment,e),o(j.$$.fragment,e),o(me.$$.fragment,e),o(Z),o(x),o(oe.$$.fragment,e),o(ue.$$.fragment,e),o(Me.$$.fragment,e),o(Je.$$.fragment,e),o(be.$$.fragment,e),o(we.$$.fragment,e),o(C),o(Ue.$$.fragment,e),o(R),o(z),o(X),o(ge.$$.fragment,e),o(Q),o(Ze.$$.fragment,e),o(xe.$$.fragment,e),o(le.$$.fragment,e),o(Ce.$$.fragment,e),o(Re.$$.fragment,e),o(Ne.$$.fragment,e),o(ae.$$.fragment,e),o(Ve.$$.fragment,e),o(He.$$.fragment,e),o(Qe.$$.fragment,e),o(Fe.$$.fragment,e),o(Ye.$$.fragment,e),o(qe.$$.fragment,e),o(Le.$$.fragment,e),o(Ke.$$.fragment,e),o(Oe.$$.fragment,e),o(tt.$$.fragment,e),o(lt.$$.fragment,e),o(nt.$$.fragment,e),o(it.$$.fragment,e),o(ct.$$.fragment,e),o(F),o(ut.$$.fragment,e),o(S),o(q),o(D),o(K),o(bt.$$.fragment,e),o(ne.$$.fragment,e),o(Tt.$$.fragment,e),o(ht.$$.fragment,e),o(se.$$.fragment,e),o(jt.$$.fragment,e),ka=!0)},o(e){c(y.$$.fragment,e),c(j.$$.fragment,e),c(me.$$.fragment,e),c(Z),c(x),c(oe.$$.fragment,e),c(ue.$$.fragment,e),c(Me.$$.fragment,e),c(Je.$$.fragment,e),c(be.$$.fragment,e),c(we.$$.fragment,e),c(C),c(Ue.$$.fragment,e),c(R),c(z),c(X),c(ge.$$.fragment,e),c(Q),c(Ze.$$.fragment,e),c(xe.$$.fragment,e),c(le.$$.fragment,e),c(Ce.$$.fragment,e),c(Re.$$.fragment,e),c(Ne.$$.fragment,e),c(ae.$$.fragment,e),c(Ve.$$.fragment,e),c(He.$$.fragment,e),c(Qe.$$.fragment,e),c(Fe.$$.fragment,e),c(Ye.$$.fragment,e),c(qe.$$.fragment,e),c(Le.$$.fragment,e),c(Ke.$$.fragment,e),c(Oe.$$.fragment,e),c(tt.$$.fragment,e),c(lt.$$.fragment,e),c(nt.$$.fragment,e),c(it.$$.fragment,e),c(ct.$$.fragment,e),c(F),c(ut.$$.fragment,e),c(S),c(q),c(D),c(K),c(bt.$$.fragment,e),c(ne.$$.fragment,e),c(Tt.$$.fragment,e),c(ht.$$.fragment,e),c(se.$$.fragment,e),c(jt.$$.fragment,e),ka=!1},d(e){e&&(n(i),n(t),n(p),n(U),n(el),n(tl),n(Rt),n(ce),n(ll),n(Nt),n(al),n(pe),n(nl),n(sl),n(il),n(de),n(rl),n(ml),n(cl),n(ye),n(ol),n(pl),n(Te),n(ul),n(zt),n(he),n(Ml),n(te),n(dl),n(fe),n(Jl),n(bl),n(Vt),n(je),n(yl),n(Ie),n(wl),n(Xt),n(_e),n(Tl),n(Ht),n(ve),n(hl),n(I),n(Ul),n(O),n(_l),n(ke),n(vl),n(kl),n(At),n(Be),n(gl),n(Bl),n($e),n(Zl),n($l),n(xl),n(Ge),n(Gl),n(Cl),n(We),n(Wl),n(Rl),n(Nl),n(ze),n(zl),n(Vl),n(Xl),n(Xe),n(Hl),n(Ql),n(El),n(Ee),n(Fl),n(Yl),n(Sl),n(Se),n(Al),n(Ae),n(ql),n(Ll),n(Dl),n(De),n(Pl),n(Pe),n(Kl),n(Ol),n(ea),n(et),n(ta),n(la),n(aa),n(at),n(na),n(sa),n(st),n(ia),n(ra),n(rt),n(ma),n(mt),n(ca),n(oa),n(ot),n(pa),n(qt),n(pt),n(ua),n(Ma),n(Lt),n(Mt),n(da),n(Dt),n(dt),n(Ja),n(Pt),n(Jt),n(ba),n(Kt),n(ya),n(yt),n(wa),n(Ta),n(wt),n(ha),n(fa),n(Ua),n(ft),n(ja),n(Ia),n(Ut),n(_a),n(va),n(Ot)),n(l),J(y,e),J(j,e),J(me,e),It[B].d(e),_t[$].d(e),J(oe,e),J(ue,e),J(Me,e),J(Je,e),J(be,e),J(we,e),vt[G].d(e),J(Ue,e),kt[W].d(e),gt[N].d(e),Bt[V].d(e),J(ge,e),Zt[H].d(e),J(Ze,e),J(xe,e),J(le,e),J(Ce,e),J(Re,e),J(Ne,e),J(ae,e),J(Ve,e),J(He,e),J(Qe,e),J(Fe,e),J(Ye,e),J(qe,e),J(Le,e),J(Ke,e),J(Oe,e),J(tt,e),J(lt,e),J(nt,e),J(it,e),J(ct,e),$t[E].d(e),J(ut,e),xt[Y].d(e),Gt[A].d(e),Ct[L].d(e),Wt[P].d(e),J(bt,e),J(ne,e),J(Tt,e),J(ht,e),J(se,e),J(jt,e)}}}const ni='{"title":"Tokenizerii rapizi în pipeline-ul de QA","local":"fast-tokenizers-in-the-qa-pipeline","sections":[{"title":"Folosind question-answering pipeline","local":"using-the-question-answering-pipeline","sections":[],"depth":2},{"title":"Folosind un model pentru răspunderea la întrebări","local":"using-a-model-for-question-answering","sections":[],"depth":2},{"title":"Gestionarea contextelor lungi","local":"handling-long-contexts","sections":[],"depth":2}],"depth":1}';function si(b,l,i){let t="pt";return Us(()=>{const p=new URLSearchParams(window.location.search);i(0,t=p.get("fw")||"pt")}),[t]}class di extends js{constructor(l){super(),Is(this,l,si,ai,fs,{})}}export{di as component};
