import{s as Ts,o as hs,n as Ba}from"../chunks/scheduler.37c15a92.js";import{S as fs,i as Us,g as w,s as r,r as u,m as ie,H as Ms,A as js,h as T,f as n,c as m,j as va,u as M,x as f,n as re,E as ds,k as qa,y as v,a as s,v as d,t as c,b as k,d as o,w as J,p as g}from"../chunks/index.2bf4358c.js";import{T as ka}from"../chunks/Tip.363c041f.js";import{Y as Js}from"../chunks/Youtube.1e50a667.js";import{C as h}from"../chunks/CodeBlock.4e987730.js";import{C as bs}from"../chunks/CourseFloatingBanner.6add7356.js";import{F as Is}from"../chunks/FrameworkSwitchCourse.8d4d4ab6.js";import{H as ga,E as _s}from"../chunks/getInferenceSnippets.1837c472.js";function vs(b){let l,i;return l=new bs({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 ks(b){let l,i;return l=new bs({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 gs(b){let l,i;return l=new Js({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 Bs(b){let l,i;return l=new Js({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 Zs(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 $s(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 xs(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 Gs(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 Cs(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 Ws(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 Rs(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 Ns(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 zs(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 Vs(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 Xs(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:Ba,d(t){t&&n(l)}}}function Hs(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:Ba,d(t){t&&n(l)}}}function Qs(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 Es(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 Fs(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 Ys(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 Ss(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 As(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 qs(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 Ls(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 Ds(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 Ps(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 Ks(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:Ba,d(t){t&&n(l)}}}function Os(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:Ba,d(t){t&&n(l)}}}function ei(b){let l,i,t,p,y,U,j,Ot,B,Z,Wt,me,La="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.",el,$,x,Rt,ce,tl,oe,Da='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:',ll,pe,al,ue,nl,Me,Pa="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:",sl,de,il,Je,rl,be,Ka="Hai să vedem cum el face toate astea!",ml,ye,cl,we,Oa='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>):',ol,G,C,Nt,Te,en="Observați că noi tokenizăm întrebrea și contextul ca o perecehe, cu întrebarea prima.",pl,te,tn='<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"/>',ul,he,ln="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:",Ml,fe,dl,W,R,zt,Ue,an="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.",Jl,je,nn="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>:",bl,N,z,Vt,Ie,sn="Acum că am mascat în mod corespunzător logiturile corespunzătoare pozițiilor pe care nu dorim să le prezicem, putem aplica softmax:",yl,V,X,Xt,_e,rn="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.",wl,I,Za,Ht,mn="start_index",$a,Qt,cn="end_index",xa,Et,on="start_index",Ga,Ft,pn="end_index",Ca,Tl,ys='<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>',hl,O,Wa,fl,ws='<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>',Ul,Yt,un="start_index <= end_index",Ra,jl,ve,Mn="Mai întâi hai să calculăm toate produsele posibile:",Il,ke,_l,H,Q,St,ge,dn="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>:",vl,Be,kl,Ze,Jn="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ă):",gl,$e,Bl,le,Zl,xe,bn="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:",$l,Ge,xl,Ce,yn="Acum trebuie doar să formatăm totul pentru a obține rezultatul nostru:",Gl,We,Cl,Re,Wl,Ne,wn="Grozav! Este la fel ca în primul nostru exemplu!",Rl,ae,Nl,ze,zl,Ve,Tn="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):",Vl,Xe,Xl,He,Hl,Qe,hn="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:",Ql,Ee,El,Fe,Fl,Ye,fn="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.",Yl,Se,Un="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ă:",Sl,Ae,Al,qe,ql,Le,jn="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.",Ll,De,In="Să aruncăm o privire mai atentă la rezultatul tokenizării:",Dl,Pe,Pl,Ke,Kl,Oe,_n="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:",Ol,et,ea,tt,ta,lt,vn="Acest lucru este mai util atunci când tokenizăm mai multe propoziții împreună. De exemplu, aceasta:",la,at,aa,nt,kn="gets us:",na,st,sa,it,gn="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.",ia,rt,Bn="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:",ra,mt,ma,ct,Zn="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:",ca,E,F,At,ot,$n="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:",oa,pt,pa,Y,S,qt,ut,xn="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):",ua,A,q,Lt,Mt,Gn="Then we can use the softmax to convert our logits to probabilities:",Ma,L,D,Dt,dt,Cn="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:",da,P,K,Pt,Jt,Ja,bt,Wn="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).",ba,ne,ya,yt,Rn="<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:",wa,wt,Ta,Tt,ha,ht,Nn="Dacă ignorăm primul rezultat, obținem același rezultat ca și pipelineul noastru pentru acest context lung - yay!",fa,se,Ua,ft,zn="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.",ja,Ut,Ia,Kt,_a;y=new Is({props:{fw:b[0]}}),j=new ga({props:{title:"Tokenizerii rapizi în pipeline-ul de QA",local:"fast-tokenizers-in-the-qa-pipeline",headingTag:"h1"}});const Vn=[ks,vs],jt=[];function Xn(e,a){return e[0]==="pt"?0:1}B=Xn(b),Z=jt[B]=Vn[B](b);const Hn=[Bs,gs],It=[];function Qn(e,a){return e[0]==="pt"?0:1}$=Qn(b),x=It[$]=Hn[$](b),ce=new ga({props:{title:"Folosind question-answering pipeline",local:"using-the-question-answering-pipeline",headingTag:"h2"}}),pe=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}}),ue=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}}),de=new h({props:{code:"bG9uZ19jb250ZXh0JTIwJTNEJTIwJTIyJTIyJTIyJTBBJUYwJTlGJUE0JTk3JTIwVHJhbnNmb3JtZXJzJTNBJTIwU3RhdGUlMjBvZiUyMHRoZSUyMEFydCUyME5MUCUwQSUwQSVGMCU5RiVBNCU5NyUyMFRyYW5zZm9ybWVycyUyMHByb3ZpZGVzJTIwdGhvdXNhbmRzJTIwb2YlMjBwcmV0cmFpbmVkJTIwbW9kZWxzJTIwdG8lMjBwZXJmb3JtJTIwdGFza3MlMjBvbiUyMHRleHRzJTIwc3VjaCUyMGFzJTIwY2xhc3NpZmljYXRpb24lMkMlMjBpbmZvcm1hdGlvbiUyMGV4dHJhY3Rpb24lMkMlMEFxdWVzdGlvbiUyMGFuc3dlcmluZyUyQyUyMHN1bW1hcml6YXRpb24lMkMlMjB0cmFuc2xhdGlvbiUyQyUyMHRleHQlMjBnZW5lcmF0aW9uJTIwYW5kJTIwbW9yZSUyMGluJTIwb3ZlciUyMDEwMCUyMGxhbmd1YWdlcy4lMEFJdHMlMjBhaW0lMjBpcyUyMHRvJTIwbWFrZSUyMGN1dHRpbmctZWRnZSUyME5MUCUyMGVhc2llciUyMHRvJTIwdXNlJTIwZm9yJTIwZXZlcnlvbmUuJTBB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tJTIwZm9yJTIwaW5mZXJlbmNlJTIwd2l0aCUyMHRoZSUyMG90aGVyLiUwQSUyMiUyMiUyMiUwQXF1ZXN0aW9uX2Fuc3dlcmVyKHF1ZXN0aW9uJTNEcXVlc3Rpb24lMkMlMjBjb250ZXh0JTNEbG9uZ19jb250ZXh0KQ==",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}}),Je=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}}),ye=new ga({props:{title:"Folosind un model pentru răspunderea la întrebări",local:"using-a-model-for-question-answering",headingTag:"h2"}});const En=[$s,Zs],_t=[];function Fn(e,a){return e[0]==="pt"?0:1}G=Fn(b),C=_t[G]=En[G](b),fe=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 Yn=[Gs,xs],vt=[];function Sn(e,a){return e[0]==="pt"?0:1}W=Sn(b),R=vt[W]=Yn[W](b);const An=[Ws,Cs],kt=[];function qn(e,a){return e[0]==="pt"?0:1}N=qn(b),z=kt[N]=An[N](b);const Ln=[Ns,Rs],gt=[];function Dn(e,a){return e[0]==="pt"?0:1}V=Dn(b),X=gt[V]=Ln[V](b),ke=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 Pn=[Vs,zs],Bt=[];function Kn(e,a){return e[0]==="pt"?0:1}H=Kn(b),Q=Bt[H]=Pn[H](b),Be=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}}),$e=new h({props:{code:"MC45Nzc3Mw==",highlighted:'<span class="hljs-number">0.97773</span>',wrap:!1}}),le=new ka({props:{$$slots:{default:[Xs]},$$scope:{ctx:b}}}),Ge=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}}),We=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}}),Re=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 ka({props:{$$slots:{default:[Hs]},$$scope:{ctx:b}}}),ze=new ga({props:{title:"Gestionarea contextelor lungi",local:"handling-long-contexts",headingTag:"h2"}}),Xe=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}}),He=new h({props:{code:"NDYx",highlighted:'<span class="hljs-number">461</span>',wrap:!1}}),Ee=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}}),Fe=new h({props:{code:"JTIyJTIyJTIyJTBBJTVCQ0xTJTVEJTIwV2hpY2glMjBkZWVwJTIwbGVhcm5pbmclMjBsaWJyYXJpZXMlMjBiYWNrJTIwJTVCVU5LJTVEJTIwVHJhbnNmb3JtZXJzJTNGJTIwJTVCU0VQJTVEJTIwJTVCVU5LJTVEJTIwVHJhbnNmb3JtZXJzJTIwJTNBJTIwU3RhdGUlMjBvZiUyMHRoZSUyMEFyd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AwJTIwcHJldHJhaW5lZCUyMG1vZGVscyUyQyUyMHNvbWUlMjBpbiUyMG1vcmUlMjB0aGFuJTIwMTAwJTIwbGFuZ3VhZ2VzLiUwQSUwQTMuJTIwQ2hvb3NlJTIwdGhlJTIwcmlnaHQlMjBmcmFtZXdvcmslMjBmb3IlMjBldmVyeSUyMHBhcnQlMjBvZiUyMGElMjBtb2RlbCdzJTIwbGlmZXRpbWUlM0ElMEElMjAlMjAtJTIwVHJhaW4lMjBzdGF0ZS1vZi10aGUtYXJ0JTIwbW9kZWxzJTIwaW4lMjAzJTIwbGluZXMlMjBvZiUyMGNvZGUuJTBBJTIwJTIwLSUyME1vdmUlMjBhJTIwc2luZ2xlJTIwbW9kZWwlMjBiZXR3ZWVuJTIwVEYyLjAlMkZQeVRvcmNoJTIwZnJhbWV3b3JrcyUyMGF0JTIwd2lsbC4lMEElMjAlMjAtJTIwU2VhbWxlc3NseSUyMHBpY2slMjB0aGUlMjByaWdodCUyMGZyYW1ld29yayUyMGZvciUyMHRyYWluaW5nJTJDJTIwZXZhbHVhdGlvbiUyMGFuZCUyMHByb2R1Y3Rpb24uJTBBJTBBNC4lMjBFYXNpbHklMjBjdXN0b21pemUlMjBhJTIwbW9kZWwlMjBvciUyMGFuJTIwZXhhbXBsZSUyMHRvJTIweW91ciUyMG5lZWRzJTNBJTBBJTIwJTIwLSUyMFdlJTIwcHJvdmlkZSUyMGV4YW1wbGVzJTIwZm9yJTIwZWFjaCUyMGFyY2hpdGVjdHVyZSUyMHRvJTIwcmVwcm9kdWNlJTIwdGhlJTIwcmVzdWx0cyUyMHB1Ymxpc2hlZCUyMGJ5JTIwaXRzJTIwb3JpZ2luYWwlMjBhdXRob3JzLiUwQSUyMCUyMC0lMjBNb2RlbCUyMGludGVybmFsJTIwJTVCU0VQJTVEJTBBJTIyJTIyJTIy",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}}),Ae=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}}),qe=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}}),Pe=new h({props:{code:"cHJpbnQoaW5wdXRzLmtleXMoKSk=",highlighted:'<span class="hljs-built_in">print</span>(inputs.keys())',wrap:!1}}),Ke=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}}),et=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}}),tt=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}}),at=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}}),st=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}}),mt=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 On=[Es,Qs],Zt=[];function es(e,a){return e[0]==="pt"?0:1}E=es(b),F=Zt[E]=On[E](b),pt=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 ts=[Ys,Fs],$t=[];function ls(e,a){return e[0]==="pt"?0:1}Y=ls(b),S=$t[Y]=ts[Y](b);const as=[As,Ss],xt=[];function ns(e,a){return e[0]==="pt"?0:1}A=ns(b),q=xt[A]=as[A](b);const ss=[Ls,qs],Gt=[];function is(e,a){return e[0]==="pt"?0:1}L=is(b),D=Gt[L]=ss[L](b);const rs=[Ps,Ds],Ct=[];function ms(e,a){return e[0]==="pt"?0:1}return P=ms(b),K=Ct[P]=rs[P](b),Jt=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 ka({props:{$$slots:{default:[Ks]},$$scope:{ctx:b}}}),wt=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}}),Tt=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 ka({props:{$$slots:{default:[Os]},$$scope:{ctx:b}}}),Ut=new _s({props:{source:"https://github.com/huggingface/course/blob/main/chapters/rum/chapter6/3b.mdx"}}),{c(){l=w("meta"),i=r(),t=w("p"),p=r(),u(y.$$.fragment),U=r(),u(j.$$.fragment),Ot=r(),Z.c(),Wt=r(),me=w("p"),me.innerHTML=La,el=r(),x.c(),Rt=r(),u(ce.$$.fragment),tl=r(),oe=w("p"),oe.innerHTML=Da,ll=r(),u(pe.$$.fragment),al=r(),u(ue.$$.fragment),nl=r(),Me=w("p"),Me.textContent=Pa,sl=r(),u(de.$$.fragment),il=r(),u(Je.$$.fragment),rl=r(),be=w("p"),be.textContent=Ka,ml=r(),u(ye.$$.fragment),cl=r(),we=w("p"),we.innerHTML=Oa,ol=r(),C.c(),Nt=r(),Te=w("p"),Te.textContent=en,pl=r(),te=w("div"),te.innerHTML=tn,ul=r(),he=w("p"),he.textContent=ln,Ml=r(),u(fe.$$.fragment),dl=r(),R.c(),zt=r(),Ue=w("p"),Ue.innerHTML=an,Jl=r(),je=w("p"),je.innerHTML=nn,bl=r(),z.c(),Vt=r(),Ie=w("p"),Ie.textContent=sn,yl=r(),X.c(),Xt=r(),_e=w("p"),_e.innerHTML=rn,wl=r(),I=w("p"),Za=ie("Presupunând că evenimentele “The answer starts at "),Ht=w("code"),Ht.textContent=mn,$a=ie("” și “The answer ends at "),Qt=w("code"),Qt.textContent=cn,xa=ie("” sunt independente, probabilitatea ca răspunsul să înceapă la "),Et=w("code"),Et.textContent=on,Ga=ie(" și să se termine la "),Ft=w("code"),Ft.textContent=pn,Ca=ie(` este:
`),Tl=new Ms(!1),hl=r(),O=w("p"),Wa=ie("Deci, pentru a calcula toate scorurile, trebuie doar să calculăm toate produsele"),fl=new Ms(!1),Ul=ie(" unde "),Yt=w("code"),Yt.textContent=un,Ra=ie("."),jl=r(),ve=w("p"),ve.textContent=Mn,Il=r(),u(ke.$$.fragment),_l=r(),Q.c(),St=r(),ge=w("p"),ge.innerHTML=dn,vl=r(),u(Be.$$.fragment),kl=r(),Ze=w("p"),Ze.textContent=Jn,gl=r(),u($e.$$.fragment),Bl=r(),u(le.$$.fragment),Zl=r(),xe=w("p"),xe.innerHTML=bn,$l=r(),u(Ge.$$.fragment),xl=r(),Ce=w("p"),Ce.textContent=yn,Gl=r(),u(We.$$.fragment),Cl=r(),u(Re.$$.fragment),Wl=r(),Ne=w("p"),Ne.textContent=wn,Rl=r(),u(ae.$$.fragment),Nl=r(),u(ze.$$.fragment),zl=r(),Ve=w("p"),Ve.innerHTML=Tn,Vl=r(),u(Xe.$$.fragment),Xl=r(),u(He.$$.fragment),Hl=r(),Qe=w("p"),Qe.innerHTML=hn,Ql=r(),u(Ee.$$.fragment),El=r(),u(Fe.$$.fragment),Fl=r(),Ye=w("p"),Ye.innerHTML=fn,Yl=r(),Se=w("p"),Se.innerHTML=Un,Sl=r(),u(Ae.$$.fragment),Al=r(),u(qe.$$.fragment),ql=r(),Le=w("p"),Le.innerHTML=jn,Ll=r(),De=w("p"),De.textContent=In,Dl=r(),u(Pe.$$.fragment),Pl=r(),u(Ke.$$.fragment),Kl=r(),Oe=w("p"),Oe.innerHTML=_n,Ol=r(),u(et.$$.fragment),ea=r(),u(tt.$$.fragment),ta=r(),lt=w("p"),lt.textContent=vn,la=r(),u(at.$$.fragment),aa=r(),nt=w("p"),nt.textContent=kn,na=r(),u(st.$$.fragment),sa=r(),it=w("p"),it.textContent=gn,ia=r(),rt=w("p"),rt.innerHTML=Bn,ra=r(),u(mt.$$.fragment),ma=r(),ct=w("p"),ct.innerHTML=Zn,ca=r(),F.c(),At=r(),ot=w("p"),ot.textContent=$n,oa=r(),u(pt.$$.fragment),pa=r(),S.c(),qt=r(),ut=w("p"),ut.textContent=xn,ua=r(),q.c(),Lt=r(),Mt=w("p"),Mt.textContent=Gn,Ma=r(),D.c(),Dt=r(),dt=w("p"),dt.textContent=Cn,da=r(),K.c(),Pt=r(),u(Jt.$$.fragment),Ja=r(),bt=w("p"),bt.textContent=Wn,ba=r(),u(ne.$$.fragment),ya=r(),yt=w("p"),yt.innerHTML=Rn,wa=r(),u(wt.$$.fragment),Ta=r(),u(Tt.$$.fragment),ha=r(),ht=w("p"),ht.textContent=Nn,fa=r(),u(se.$$.fragment),Ua=r(),ft=w("p"),ft.textContent=zn,ja=r(),u(Ut.$$.fragment),Ia=r(),Kt=w("p"),this.h()},l(e){const a=js("svelte-u9bgzb",document.head);l=T(a,"META",{name:!0,content:!0}),a.forEach(n),i=m(e),t=T(e,"P",{}),va(t).forEach(n),p=m(e),M(y.$$.fragment,e),U=m(e),M(j.$$.fragment,e),Ot=m(e),Z.l(e),Wt=m(e),me=T(e,"P",{"data-svelte-h":!0}),f(me)!=="svelte-gs77xf"&&(me.innerHTML=La),el=m(e),x.l(e),Rt=m(e),M(ce.$$.fragment,e),tl=m(e),oe=T(e,"P",{"data-svelte-h":!0}),f(oe)!=="svelte-1drz3d6"&&(oe.innerHTML=Da),ll=m(e),M(pe.$$.fragment,e),al=m(e),M(ue.$$.fragment,e),nl=m(e),Me=T(e,"P",{"data-svelte-h":!0}),f(Me)!=="svelte-1jof88z"&&(Me.textContent=Pa),sl=m(e),M(de.$$.fragment,e),il=m(e),M(Je.$$.fragment,e),rl=m(e),be=T(e,"P",{"data-svelte-h":!0}),f(be)!=="svelte-41pc3s"&&(be.textContent=Ka),ml=m(e),M(ye.$$.fragment,e),cl=m(e),we=T(e,"P",{"data-svelte-h":!0}),f(we)!=="svelte-hx0mps"&&(we.innerHTML=Oa),ol=m(e),C.l(e),Nt=m(e),Te=T(e,"P",{"data-svelte-h":!0}),f(Te)!=="svelte-1o0rxfe"&&(Te.textContent=en),pl=m(e),te=T(e,"DIV",{class:!0,"data-svelte-h":!0}),f(te)!=="svelte-47wedv"&&(te.innerHTML=tn),ul=m(e),he=T(e,"P",{"data-svelte-h":!0}),f(he)!=="svelte-1k6k3aj"&&(he.textContent=ln),Ml=m(e),M(fe.$$.fragment,e),dl=m(e),R.l(e),zt=m(e),Ue=T(e,"P",{"data-svelte-h":!0}),f(Ue)!=="svelte-1eehlns"&&(Ue.innerHTML=an),Jl=m(e),je=T(e,"P",{"data-svelte-h":!0}),f(je)!=="svelte-doo8ql"&&(je.innerHTML=nn),bl=m(e),z.l(e),Vt=m(e),Ie=T(e,"P",{"data-svelte-h":!0}),f(Ie)!=="svelte-1p1eafu"&&(Ie.textContent=sn),yl=m(e),X.l(e),Xt=m(e),_e=T(e,"P",{"data-svelte-h":!0}),f(_e)!=="svelte-pz25ke"&&(_e.innerHTML=rn),wl=m(e),I=T(e,"P",{});var _=va(I);Za=re(_,"Presupunând că evenimentele “The answer starts at "),Ht=T(_,"CODE",{"data-svelte-h":!0}),f(Ht)!=="svelte-8eqb3b"&&(Ht.textContent=mn),$a=re(_,"” și “The answer ends at "),Qt=T(_,"CODE",{"data-svelte-h":!0}),f(Qt)!=="svelte-9cistc"&&(Qt.textContent=cn),xa=re(_,"” sunt independente, probabilitatea ca răspunsul să înceapă la "),Et=T(_,"CODE",{"data-svelte-h":!0}),f(Et)!=="svelte-8eqb3b"&&(Et.textContent=on),Ga=re(_," și să se termine la "),Ft=T(_,"CODE",{"data-svelte-h":!0}),f(Ft)!=="svelte-9cistc"&&(Ft.textContent=pn),Ca=re(_,` este:
`),Tl=ds(_,!1),_.forEach(n),hl=m(e),O=T(e,"P",{});var ee=va(O);Wa=re(ee,"Deci, pentru a calcula toate scorurile, trebuie doar să calculăm toate produsele"),fl=ds(ee,!1),Ul=re(ee," unde "),Yt=T(ee,"CODE",{"data-svelte-h":!0}),f(Yt)!=="svelte-1kp3szf"&&(Yt.textContent=un),Ra=re(ee,"."),ee.forEach(n),jl=m(e),ve=T(e,"P",{"data-svelte-h":!0}),f(ve)!=="svelte-i54l9f"&&(ve.textContent=Mn),Il=m(e),M(ke.$$.fragment,e),_l=m(e),Q.l(e),St=m(e),ge=T(e,"P",{"data-svelte-h":!0}),f(ge)!=="svelte-1lao0yt"&&(ge.innerHTML=dn),vl=m(e),M(Be.$$.fragment,e),kl=m(e),Ze=T(e,"P",{"data-svelte-h":!0}),f(Ze)!=="svelte-128j8ii"&&(Ze.textContent=Jn),gl=m(e),M($e.$$.fragment,e),Bl=m(e),M(le.$$.fragment,e),Zl=m(e),xe=T(e,"P",{"data-svelte-h":!0}),f(xe)!=="svelte-2ksf6i"&&(xe.innerHTML=bn),$l=m(e),M(Ge.$$.fragment,e),xl=m(e),Ce=T(e,"P",{"data-svelte-h":!0}),f(Ce)!=="svelte-1jq8cgv"&&(Ce.textContent=yn),Gl=m(e),M(We.$$.fragment,e),Cl=m(e),M(Re.$$.fragment,e),Wl=m(e),Ne=T(e,"P",{"data-svelte-h":!0}),f(Ne)!=="svelte-sb5jce"&&(Ne.textContent=wn),Rl=m(e),M(ae.$$.fragment,e),Nl=m(e),M(ze.$$.fragment,e),zl=m(e),Ve=T(e,"P",{"data-svelte-h":!0}),f(Ve)!=="svelte-1b2qe2s"&&(Ve.innerHTML=Tn),Vl=m(e),M(Xe.$$.fragment,e),Xl=m(e),M(He.$$.fragment,e),Hl=m(e),Qe=T(e,"P",{"data-svelte-h":!0}),f(Qe)!=="svelte-1a66x7q"&&(Qe.innerHTML=hn),Ql=m(e),M(Ee.$$.fragment,e),El=m(e),M(Fe.$$.fragment,e),Fl=m(e),Ye=T(e,"P",{"data-svelte-h":!0}),f(Ye)!=="svelte-wbvi95"&&(Ye.innerHTML=fn),Yl=m(e),Se=T(e,"P",{"data-svelte-h":!0}),f(Se)!=="svelte-15swwgh"&&(Se.innerHTML=Un),Sl=m(e),M(Ae.$$.fragment,e),Al=m(e),M(qe.$$.fragment,e),ql=m(e),Le=T(e,"P",{"data-svelte-h":!0}),f(Le)!=="svelte-10ynzq4"&&(Le.innerHTML=jn),Ll=m(e),De=T(e,"P",{"data-svelte-h":!0}),f(De)!=="svelte-14khn33"&&(De.textContent=In),Dl=m(e),M(Pe.$$.fragment,e),Pl=m(e),M(Ke.$$.fragment,e),Kl=m(e),Oe=T(e,"P",{"data-svelte-h":!0}),f(Oe)!=="svelte-mjj8y4"&&(Oe.innerHTML=_n),Ol=m(e),M(et.$$.fragment,e),ea=m(e),M(tt.$$.fragment,e),ta=m(e),lt=T(e,"P",{"data-svelte-h":!0}),f(lt)!=="svelte-1l99crl"&&(lt.textContent=vn),la=m(e),M(at.$$.fragment,e),aa=m(e),nt=T(e,"P",{"data-svelte-h":!0}),f(nt)!=="svelte-b6k3qh"&&(nt.textContent=kn),na=m(e),M(st.$$.fragment,e),sa=m(e),it=T(e,"P",{"data-svelte-h":!0}),f(it)!=="svelte-1l5swnq"&&(it.textContent=gn),ia=m(e),rt=T(e,"P",{"data-svelte-h":!0}),f(rt)!=="svelte-xddee7"&&(rt.innerHTML=Bn),ra=m(e),M(mt.$$.fragment,e),ma=m(e),ct=T(e,"P",{"data-svelte-h":!0}),f(ct)!=="svelte-ehoc4e"&&(ct.innerHTML=Zn),ca=m(e),F.l(e),At=m(e),ot=T(e,"P",{"data-svelte-h":!0}),f(ot)!=="svelte-zlhaau"&&(ot.textContent=$n),oa=m(e),M(pt.$$.fragment,e),pa=m(e),S.l(e),qt=m(e),ut=T(e,"P",{"data-svelte-h":!0}),f(ut)!=="svelte-w1s80s"&&(ut.textContent=xn),ua=m(e),q.l(e),Lt=m(e),Mt=T(e,"P",{"data-svelte-h":!0}),f(Mt)!=="svelte-xc3z5h"&&(Mt.textContent=Gn),Ma=m(e),D.l(e),Dt=m(e),dt=T(e,"P",{"data-svelte-h":!0}),f(dt)!=="svelte-6l5dky"&&(dt.textContent=Cn),da=m(e),K.l(e),Pt=m(e),M(Jt.$$.fragment,e),Ja=m(e),bt=T(e,"P",{"data-svelte-h":!0}),f(bt)!=="svelte-wybiq2"&&(bt.textContent=Wn),ba=m(e),M(ne.$$.fragment,e),ya=m(e),yt=T(e,"P",{"data-svelte-h":!0}),f(yt)!=="svelte-1e1qzy4"&&(yt.innerHTML=Rn),wa=m(e),M(wt.$$.fragment,e),Ta=m(e),M(Tt.$$.fragment,e),ha=m(e),ht=T(e,"P",{"data-svelte-h":!0}),f(ht)!=="svelte-1d49c5t"&&(ht.textContent=Nn),fa=m(e),M(se.$$.fragment,e),Ua=m(e),ft=T(e,"P",{"data-svelte-h":!0}),f(ft)!=="svelte-1r5vmkg"&&(ft.textContent=zn),ja=m(e),M(Ut.$$.fragment,e),Ia=m(e),Kt=T(e,"P",{}),va(Kt).forEach(n),this.h()},h(){qa(l,"name","hf:doc:metadata"),qa(l,"content",ti),qa(te,"class","flex justify-center"),Tl.a=null,fl.a=Ul},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,Ot,a),jt[B].m(e,a),s(e,Wt,a),s(e,me,a),s(e,el,a),It[$].m(e,a),s(e,Rt,a),d(ce,e,a),s(e,tl,a),s(e,oe,a),s(e,ll,a),d(pe,e,a),s(e,al,a),d(ue,e,a),s(e,nl,a),s(e,Me,a),s(e,sl,a),d(de,e,a),s(e,il,a),d(Je,e,a),s(e,rl,a),s(e,be,a),s(e,ml,a),d(ye,e,a),s(e,cl,a),s(e,we,a),s(e,ol,a),_t[G].m(e,a),s(e,Nt,a),s(e,Te,a),s(e,pl,a),s(e,te,a),s(e,ul,a),s(e,he,a),s(e,Ml,a),d(fe,e,a),s(e,dl,a),vt[W].m(e,a),s(e,zt,a),s(e,Ue,a),s(e,Jl,a),s(e,je,a),s(e,bl,a),kt[N].m(e,a),s(e,Vt,a),s(e,Ie,a),s(e,yl,a),gt[V].m(e,a),s(e,Xt,a),s(e,_e,a),s(e,wl,a),s(e,I,a),v(I,Za),v(I,Ht),v(I,$a),v(I,Qt),v(I,xa),v(I,Et),v(I,Ga),v(I,Ft),v(I,Ca),Tl.m(ys,I),s(e,hl,a),s(e,O,a),v(O,Wa),fl.m(ws,O),v(O,Ul),v(O,Yt),v(O,Ra),s(e,jl,a),s(e,ve,a),s(e,Il,a),d(ke,e,a),s(e,_l,a),Bt[H].m(e,a),s(e,St,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),s(e,fa,a),d(se,e,a),s(e,Ua,a),s(e,ft,a),s(e,ja,a),d(Ut,e,a),s(e,Ia,a),s(e,Kt,a),_a=!0},p(e,[a]){const _={};a&1&&(_.fw=e[0]),y.$set(_);let ee=B;B=Xn(e),B!==ee&&(g(),c(jt[ee],1,1,()=>{jt[ee]=null}),k(),Z=jt[B],Z||(Z=jt[B]=Vn[B](e),Z.c()),o(Z,1),Z.m(Wt.parentNode,Wt));let Na=$;$=Qn(e),$!==Na&&(g(),c(It[Na],1,1,()=>{It[Na]=null}),k(),x=It[$],x||(x=It[$]=Hn[$](e),x.c()),o(x,1),x.m(Rt.parentNode,Rt));let za=G;G=Fn(e),G!==za&&(g(),c(_t[za],1,1,()=>{_t[za]=null}),k(),C=_t[G],C||(C=_t[G]=En[G](e),C.c()),o(C,1),C.m(Nt.parentNode,Nt));let Va=W;W=Sn(e),W!==Va&&(g(),c(vt[Va],1,1,()=>{vt[Va]=null}),k(),R=vt[W],R||(R=vt[W]=Yn[W](e),R.c()),o(R,1),R.m(zt.parentNode,zt));let Xa=N;N=qn(e),N!==Xa&&(g(),c(kt[Xa],1,1,()=>{kt[Xa]=null}),k(),z=kt[N],z||(z=kt[N]=An[N](e),z.c()),o(z,1),z.m(Vt.parentNode,Vt));let Ha=V;V=Dn(e),V!==Ha&&(g(),c(gt[Ha],1,1,()=>{gt[Ha]=null}),k(),X=gt[V],X||(X=gt[V]=Ln[V](e),X.c()),o(X,1),X.m(Xt.parentNode,Xt));let Qa=H;H=Kn(e),H!==Qa&&(g(),c(Bt[Qa],1,1,()=>{Bt[Qa]=null}),k(),Q=Bt[H],Q||(Q=Bt[H]=Pn[H](e),Q.c()),o(Q,1),Q.m(St.parentNode,St));const cs={};a&2&&(cs.$$scope={dirty:a,ctx:e}),le.$set(cs);const os={};a&2&&(os.$$scope={dirty:a,ctx:e}),ae.$set(os);let Ea=E;E=es(e),E!==Ea&&(g(),c(Zt[Ea],1,1,()=>{Zt[Ea]=null}),k(),F=Zt[E],F||(F=Zt[E]=On[E](e),F.c()),o(F,1),F.m(At.parentNode,At));let Fa=Y;Y=ls(e),Y!==Fa&&(g(),c($t[Fa],1,1,()=>{$t[Fa]=null}),k(),S=$t[Y],S||(S=$t[Y]=ts[Y](e),S.c()),o(S,1),S.m(qt.parentNode,qt));let Ya=A;A=ns(e),A!==Ya&&(g(),c(xt[Ya],1,1,()=>{xt[Ya]=null}),k(),q=xt[A],q||(q=xt[A]=as[A](e),q.c()),o(q,1),q.m(Lt.parentNode,Lt));let Sa=L;L=is(e),L!==Sa&&(g(),c(Gt[Sa],1,1,()=>{Gt[Sa]=null}),k(),D=Gt[L],D||(D=Gt[L]=ss[L](e),D.c()),o(D,1),D.m(Dt.parentNode,Dt));let Aa=P;P=ms(e),P!==Aa&&(g(),c(Ct[Aa],1,1,()=>{Ct[Aa]=null}),k(),K=Ct[P],K||(K=Ct[P]=rs[P](e),K.c()),o(K,1),K.m(Pt.parentNode,Pt));const ps={};a&2&&(ps.$$scope={dirty:a,ctx:e}),ne.$set(ps);const us={};a&2&&(us.$$scope={dirty:a,ctx:e}),se.$set(us)},i(e){_a||(o(y.$$.fragment,e),o(j.$$.fragment,e),o(Z),o(x),o(ce.$$.fragment,e),o(pe.$$.fragment,e),o(ue.$$.fragment,e),o(de.$$.fragment,e),o(Je.$$.fragment,e),o(ye.$$.fragment,e),o(C),o(fe.$$.fragment,e),o(R),o(z),o(X),o(ke.$$.fragment,e),o(Q),o(Be.$$.fragment,e),o($e.$$.fragment,e),o(le.$$.fragment,e),o(Ge.$$.fragment,e),o(We.$$.fragment,e),o(Re.$$.fragment,e),o(ae.$$.fragment,e),o(ze.$$.fragment,e),o(Xe.$$.fragment,e),o(He.$$.fragment,e),o(Ee.$$.fragment,e),o(Fe.$$.fragment,e),o(Ae.$$.fragment,e),o(qe.$$.fragment,e),o(Pe.$$.fragment,e),o(Ke.$$.fragment,e),o(et.$$.fragment,e),o(tt.$$.fragment,e),o(at.$$.fragment,e),o(st.$$.fragment,e),o(mt.$$.fragment,e),o(F),o(pt.$$.fragment,e),o(S),o(q),o(D),o(K),o(Jt.$$.fragment,e),o(ne.$$.fragment,e),o(wt.$$.fragment,e),o(Tt.$$.fragment,e),o(se.$$.fragment,e),o(Ut.$$.fragment,e),_a=!0)},o(e){c(y.$$.fragment,e),c(j.$$.fragment,e),c(Z),c(x),c(ce.$$.fragment,e),c(pe.$$.fragment,e),c(ue.$$.fragment,e),c(de.$$.fragment,e),c(Je.$$.fragment,e),c(ye.$$.fragment,e),c(C),c(fe.$$.fragment,e),c(R),c(z),c(X),c(ke.$$.fragment,e),c(Q),c(Be.$$.fragment,e),c($e.$$.fragment,e),c(le.$$.fragment,e),c(Ge.$$.fragment,e),c(We.$$.fragment,e),c(Re.$$.fragment,e),c(ae.$$.fragment,e),c(ze.$$.fragment,e),c(Xe.$$.fragment,e),c(He.$$.fragment,e),c(Ee.$$.fragment,e),c(Fe.$$.fragment,e),c(Ae.$$.fragment,e),c(qe.$$.fragment,e),c(Pe.$$.fragment,e),c(Ke.$$.fragment,e),c(et.$$.fragment,e),c(tt.$$.fragment,e),c(at.$$.fragment,e),c(st.$$.fragment,e),c(mt.$$.fragment,e),c(F),c(pt.$$.fragment,e),c(S),c(q),c(D),c(K),c(Jt.$$.fragment,e),c(ne.$$.fragment,e),c(wt.$$.fragment,e),c(Tt.$$.fragment,e),c(se.$$.fragment,e),c(Ut.$$.fragment,e),_a=!1},d(e){e&&(n(i),n(t),n(p),n(U),n(Ot),n(Wt),n(me),n(el),n(Rt),n(tl),n(oe),n(ll),n(al),n(nl),n(Me),n(sl),n(il),n(rl),n(be),n(ml),n(cl),n(we),n(ol),n(Nt),n(Te),n(pl),n(te),n(ul),n(he),n(Ml),n(dl),n(zt),n(Ue),n(Jl),n(je),n(bl),n(Vt),n(Ie),n(yl),n(Xt),n(_e),n(wl),n(I),n(hl),n(O),n(jl),n(ve),n(Il),n(_l),n(St),n(ge),n(vl),n(kl),n(Ze),n(gl),n(Bl),n(Zl),n(xe),n($l),n(xl),n(Ce),n(Gl),n(Cl),n(Wl),n(Ne),n(Rl),n(Nl),n(zl),n(Ve),n(Vl),n(Xl),n(Hl),n(Qe),n(Ql),n(El),n(Fl),n(Ye),n(Yl),n(Se),n(Sl),n(Al),n(ql),n(Le),n(Ll),n(De),n(Dl),n(Pl),n(Kl),n(Oe),n(Ol),n(ea),n(ta),n(lt),n(la),n(aa),n(nt),n(na),n(sa),n(it),n(ia),n(rt),n(ra),n(ma),n(ct),n(ca),n(At),n(ot),n(oa),n(pa),n(qt),n(ut),n(ua),n(Lt),n(Mt),n(Ma),n(Dt),n(dt),n(da),n(Pt),n(Ja),n(bt),n(ba),n(ya),n(yt),n(wa),n(Ta),n(ha),n(ht),n(fa),n(Ua),n(ft),n(ja),n(Ia),n(Kt)),n(l),J(y,e),J(j,e),jt[B].d(e),It[$].d(e),J(ce,e),J(pe,e),J(ue,e),J(de,e),J(Je,e),J(ye,e),_t[G].d(e),J(fe,e),vt[W].d(e),kt[N].d(e),gt[V].d(e),J(ke,e),Bt[H].d(e),J(Be,e),J($e,e),J(le,e),J(Ge,e),J(We,e),J(Re,e),J(ae,e),J(ze,e),J(Xe,e),J(He,e),J(Ee,e),J(Fe,e),J(Ae,e),J(qe,e),J(Pe,e),J(Ke,e),J(et,e),J(tt,e),J(at,e),J(st,e),J(mt,e),Zt[E].d(e),J(pt,e),$t[Y].d(e),xt[A].d(e),Gt[L].d(e),Ct[P].d(e),J(Jt,e),J(ne,e),J(wt,e),J(Tt,e),J(se,e),J(Ut,e)}}}const ti='{"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 li(b,l,i){let t="pt";return hs(()=>{const p=new URLSearchParams(window.location.search);i(0,t=p.get("fw")||"pt")}),[t]}class pi extends fs{constructor(l){super(),Us(this,l,li,ei,Ts,{})}}export{pi as component};
