import{s as Pl,o as Kl,n as Dl}from"../chunks/scheduler.893fe8c9.js";import{S as Ol,i as es,e as f,s as r,c as m,h as ts,a as T,d as l,b as c,f as Hl,g as U,j as w,k as Le,F as cl,l as ls,m as s,n as y,o as M,D as ll,t as p,p as J,E as sl}from"../chunks/index.6ee278c6.js";import{T as ql}from"../chunks/Tip.eab0255c.js";import{C as ss,H as Pe,E as as}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea3ad860.js";import{Y as ns}from"../chunks/Youtube.59d04f41.js";import{C as j}from"../chunks/CodeBlock.8bdd5f33.js";import{C as Ll}from"../chunks/CourseFloatingBanner.c25cfa5e.js";import{F as is}from"../chunks/FrameworkSwitchCourse.77a18d50.js";function rs(Z){let a,o;return a=new Ll({props:{chapter:5,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/chapter5/section6_tf.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter5/section6_tf.ipynb"}]}}),{c(){m(a.$$.fragment)},l(n){U(a.$$.fragment,n)},m(n,h){y(a,n,h),o=!0},i(n){o||(p(a.$$.fragment,n),o=!0)},o(n){M(a.$$.fragment,n),o=!1},d(n){J(a,n)}}}function cs(Z){let a,o;return a=new Ll({props:{chapter:5,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/chapter5/section6_pt.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter5/section6_pt.ipynb"}]}}),{c(){m(a.$$.fragment)},l(n){U(a.$$.fragment,n)},m(n,h){y(a,n,h),o=!0},i(n){o||(p(a.$$.fragment,n),o=!0)},o(n){M(a.$$.fragment,n),o=!1},d(n){J(a,n)}}}function us(Z){let a,o='✏️ <strong>Încercați!</strong> Vezi dacă poți utiliza <code>Dataset.map()</code> pentru a exploda coloana <code>comments</code> din <code>issues_dataset</code> <em>fără</em> a recurge la utilizarea Pandas. Acest lucru este puțin dificil; s-ar putea să găsiți utilă secțiunea <a href="https://huggingface.co/docs/datasets/about_map_batch#batch-mapping" rel="nofollow">“Mapping batch”</a> din documentația 🤗 Datasets pentru această sarcină.';return{c(){a=f("p"),a.innerHTML=o},l(n){a=T(n,"P",{"data-svelte-h":!0}),w(a)!=="svelte-1nrl4qf"&&(a.innerHTML=o)},m(n,h){s(n,a,h)},p:Dl,d(n){n&&l(a)}}}function Ms(Z){let a,o,n,h="Notăm că am setat <code>from_pt=True</code> ca argument al metodei <code>from_pretrained()</code>. Acest lucru se datorează faptului că checkpoint-ul <code>multi-qa-mpnet-base-dot-v1</code> are doar PyTorch weights, astfel încât setarea <code>from_pt=True</code> le va converti automat în format TensorFlow pentru noi. După cum puteți vedea, este foarte simplu să treci de la un framework la altul în 🤗 Transformers!",u;return a=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBURkF1dG9Nb2RlbCUwQSUwQW1vZGVsX2NrcHQlMjAlM0QlMjAlMjJzZW50ZW5jZS10cmFuc2Zvcm1lcnMlMkZtdWx0aS1xYS1tcG5ldC1iYXNlLWRvdC12MSUyMiUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2NrcHQpJTBBbW9kZWwlMjAlM0QlMjBURkF1dG9Nb2RlbC5mcm9tX3ByZXRyYWluZWQobW9kZWxfY2twdCUyQyUyMGZyb21fcHQlM0RUcnVlKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, TFAutoModel

model_ckpt = <span class="hljs-string">&quot;sentence-transformers/multi-qa-mpnet-base-dot-v1&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
model = TFAutoModel.from_pretrained(model_ckpt, from_pt=<span class="hljs-literal">True</span>)`,wrap:!1}}),{c(){m(a.$$.fragment),o=r(),n=f("p"),n.innerHTML=h},l(d){U(a.$$.fragment,d),o=c(d),n=T(d,"P",{"data-svelte-h":!0}),w(n)!=="svelte-1wd48pf"&&(n.innerHTML=h)},m(d,Q){y(a,d,Q),s(d,o,Q),s(d,n,Q),u=!0},i(d){u||(p(a.$$.fragment,d),u=!0)},o(d){M(a.$$.fragment,d),u=!1},d(d){d&&(l(o),l(n)),J(a,d)}}}function ps(Z){let a,o,n,h="Pentru a accelera procesul de embedding, este util să punem modelul și inputurile pe un GPU, deci hai să facem asta acum:",u,d,Q;return a=new j({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWwlMEElMEFtb2RlbF9ja3B0JTIwJTNEJTIwJTIyc2VudGVuY2UtdHJhbnNmb3JtZXJzJTJGbXVsdGktcWEtbXBuZXQtYmFzZS1kb3QtdjElMjIlMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZChtb2RlbF9ja3B0KSUwQW1vZGVsJTIwJTNEJTIwQXV0b01vZGVsLmZyb21fcHJldHJhaW5lZChtb2RlbF9ja3B0KQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModel

model_ckpt = <span class="hljs-string">&quot;sentence-transformers/multi-qa-mpnet-base-dot-v1&quot;</span>
tokenizer = AutoTokenizer.from_pretrained(model_ckpt)
model = AutoModel.from_pretrained(model_ckpt)`,wrap:!1}}),d=new j({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFkZXZpY2UlMjAlM0QlMjB0b3JjaC5kZXZpY2UoJTIyY3VkYSUyMiklMEFtb2RlbC50byhkZXZpY2Up",highlighted:`<span class="hljs-keyword">import</span> torch

device = torch.device(<span class="hljs-string">&quot;cuda&quot;</span>)
model.to(device)`,wrap:!1}}),{c(){m(a.$$.fragment),o=r(),n=f("p"),n.textContent=h,u=r(),m(d.$$.fragment)},l(b){U(a.$$.fragment,b),o=c(b),n=T(b,"P",{"data-svelte-h":!0}),w(n)!=="svelte-1y5lz39"&&(n.textContent=h),u=c(b),U(d.$$.fragment,b)},m(b,G){y(a,b,G),s(b,o,G),s(b,n,G),s(b,u,G),y(d,b,G),Q=!0},i(b){Q||(p(a.$$.fragment,b),p(d.$$.fragment,b),Q=!0)},o(b){M(a.$$.fragment,b),M(d.$$.fragment,b),Q=!1},d(b){b&&(l(o),l(n),l(u)),J(a,b),J(d,b)}}}function os(Z){let a,o,n,h="Putem testa funcția oferindui prima intrare de text în corpusul nostru și analizând output shapeul:",u,d,Q,b,G,k,$="Minunat, am transformat prima intrare din corpusul nostru într-un vector de 768 de dimensiuni! Putem utiliza <code>Dataset.map()</code> pentru a aplica funcția noastră <code>get_embeddings()</code> la fiecare rând din corpusul nostru, astfel încât să creăm o nouă coloană <code>embeddings</code> în acest mod:",I,C,R;return a=new j({props:{code:"ZGVmJTIwZ2V0X2VtYmVkZGluZ3ModGV4dF9saXN0KSUzQSUwQSUyMCUyMCUyMCUyMGVuY29kZWRfaW5wdXQlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGV4dF9saXN0JTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIydGYlMjIlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwZW5jb2RlZF9pbnB1dCUyMCUzRCUyMCU3QmslM0ElMjB2JTIwZm9yJTIwayUyQyUyMHYlMjBpbiUyMGVuY29kZWRfaW5wdXQuaXRlbXMoKSU3RCUwQSUyMCUyMCUyMCUyMG1vZGVsX291dHB1dCUyMCUzRCUyMG1vZGVsKCoqZW5jb2RlZF9pbnB1dCklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBjbHNfcG9vbGluZyhtb2RlbF9vdXRwdXQp",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_embeddings</span>(<span class="hljs-params">text_list</span>):
    encoded_input = tokenizer(
        text_list, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;tf&quot;</span>
    )
    encoded_input = {k: v <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> encoded_input.items()}
    model_output = model(**encoded_input)
    <span class="hljs-keyword">return</span> cls_pooling(model_output)`,wrap:!1}}),d=new j({props:{code:"ZW1iZWRkaW5nJTIwJTNEJTIwZ2V0X2VtYmVkZGluZ3MoY29tbWVudHNfZGF0YXNldCU1QiUyMnRleHQlMjIlNUQlNUIwJTVEKSUwQWVtYmVkZGluZy5zaGFwZQ==",highlighted:`embedding = get_embeddings(comments_dataset[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
embedding.shape`,wrap:!1}}),b=new j({props:{code:"VGVuc29yU2hhcGUoJTVCMSUyQyUyMDc2OCU1RCk=",highlighted:'TensorShape([<span class="hljs-number">1</span>, <span class="hljs-number">768</span>])',wrap:!1}}),C=new j({props:{code:"ZW1iZWRkaW5nc19kYXRhc2V0JTIwJTNEJTIwY29tbWVudHNfZGF0YXNldC5tYXAoJTBBJTIwJTIwJTIwJTIwbGFtYmRhJTIweCUzQSUyMCU3QiUyMmVtYmVkZGluZ3MlMjIlM0ElMjBnZXRfZW1iZWRkaW5ncyh4JTVCJTIydGV4dCUyMiU1RCkubnVtcHkoKSU1QjAlNUQlN0QlMEEp",highlighted:`embeddings_dataset = comments_dataset.<span class="hljs-built_in">map</span>(
    <span class="hljs-keyword">lambda</span> x: {<span class="hljs-string">&quot;embeddings&quot;</span>: get_embeddings(x[<span class="hljs-string">&quot;text&quot;</span>]).numpy()[<span class="hljs-number">0</span>]}
)`,wrap:!1}}),{c(){m(a.$$.fragment),o=r(),n=f("p"),n.textContent=h,u=r(),m(d.$$.fragment),Q=r(),m(b.$$.fragment),G=r(),k=f("p"),k.innerHTML=$,I=r(),m(C.$$.fragment)},l(i){U(a.$$.fragment,i),o=c(i),n=T(i,"P",{"data-svelte-h":!0}),w(n)!=="svelte-nqgrhi"&&(n.textContent=h),u=c(i),U(d.$$.fragment,i),Q=c(i),U(b.$$.fragment,i),G=c(i),k=T(i,"P",{"data-svelte-h":!0}),w(k)!=="svelte-p4v437"&&(k.innerHTML=$),I=c(i),U(C.$$.fragment,i)},m(i,g){y(a,i,g),s(i,o,g),s(i,n,g),s(i,u,g),y(d,i,g),s(i,Q,g),y(b,i,g),s(i,G,g),s(i,k,g),s(i,I,g),y(C,i,g),R=!0},i(i){R||(p(a.$$.fragment,i),p(d.$$.fragment,i),p(b.$$.fragment,i),p(C.$$.fragment,i),R=!0)},o(i){M(a.$$.fragment,i),M(d.$$.fragment,i),M(b.$$.fragment,i),M(C.$$.fragment,i),R=!1},d(i){i&&(l(o),l(n),l(u),l(Q),l(G),l(k),l(I)),J(a,i),J(d,i),J(b,i),J(C,i)}}}function ds(Z){let a,o,n,h="Putem testa funcția oferindui prima intrare de text în corpusul nostru și analizând output shapeul:",u,d,Q,b,G,k,$="Minunat, am transformat prima intrare din corpusul nostru într-un vector de 768 de dimensiuni! Putem utiliza <code>Dataset.map()</code> pentru a aplica funcția noastră <code>get_embeddings()</code> la fiecare rând din corpusul nostru, astfel încât să creăm o nouă coloană <code>embeddings</code> în acest mod:",I,C,R;return a=new j({props:{code:"ZGVmJTIwZ2V0X2VtYmVkZGluZ3ModGV4dF9saXN0KSUzQSUwQSUyMCUyMCUyMCUyMGVuY29kZWRfaW5wdXQlMjAlM0QlMjB0b2tlbml6ZXIoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGV4dF9saXN0JTJDJTIwcGFkZGluZyUzRFRydWUlMkMlMjB0cnVuY2F0aW9uJTNEVHJ1ZSUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIlMEElMjAlMjAlMjAlMjApJTBBJTIwJTIwJTIwJTIwZW5jb2RlZF9pbnB1dCUyMCUzRCUyMCU3QmslM0ElMjB2LnRvKGRldmljZSklMjBmb3IlMjBrJTJDJTIwdiUyMGluJTIwZW5jb2RlZF9pbnB1dC5pdGVtcygpJTdEJTBBJTIwJTIwJTIwJTIwbW9kZWxfb3V0cHV0JTIwJTNEJTIwbW9kZWwoKiplbmNvZGVkX2lucHV0KSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMGNsc19wb29saW5nKG1vZGVsX291dHB1dCk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">get_embeddings</span>(<span class="hljs-params">text_list</span>):
    encoded_input = tokenizer(
        text_list, padding=<span class="hljs-literal">True</span>, truncation=<span class="hljs-literal">True</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>
    )
    encoded_input = {k: v.to(device) <span class="hljs-keyword">for</span> k, v <span class="hljs-keyword">in</span> encoded_input.items()}
    model_output = model(**encoded_input)
    <span class="hljs-keyword">return</span> cls_pooling(model_output)`,wrap:!1}}),d=new j({props:{code:"ZW1iZWRkaW5nJTIwJTNEJTIwZ2V0X2VtYmVkZGluZ3MoY29tbWVudHNfZGF0YXNldCU1QiUyMnRleHQlMjIlNUQlNUIwJTVEKSUwQWVtYmVkZGluZy5zaGFwZQ==",highlighted:`embedding = get_embeddings(comments_dataset[<span class="hljs-string">&quot;text&quot;</span>][<span class="hljs-number">0</span>])
embedding.shape`,wrap:!1}}),b=new j({props:{code:"dG9yY2guU2l6ZSglNUIxJTJDJTIwNzY4JTVEKQ==",highlighted:'torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">768</span>])',wrap:!1}}),C=new j({props:{code:"ZW1iZWRkaW5nc19kYXRhc2V0JTIwJTNEJTIwY29tbWVudHNfZGF0YXNldC5tYXAoJTBBJTIwJTIwJTIwJTIwbGFtYmRhJTIweCUzQSUyMCU3QiUyMmVtYmVkZGluZ3MlMjIlM0ElMjBnZXRfZW1iZWRkaW5ncyh4JTVCJTIydGV4dCUyMiU1RCkuZGV0YWNoKCkuY3B1KCkubnVtcHkoKSU1QjAlNUQlN0QlMEEp",highlighted:`embeddings_dataset = comments_dataset.<span class="hljs-built_in">map</span>(
    <span class="hljs-keyword">lambda</span> x: {<span class="hljs-string">&quot;embeddings&quot;</span>: get_embeddings(x[<span class="hljs-string">&quot;text&quot;</span>]).detach().cpu().numpy()[<span class="hljs-number">0</span>]}
)`,wrap:!1}}),{c(){m(a.$$.fragment),o=r(),n=f("p"),n.textContent=h,u=r(),m(d.$$.fragment),Q=r(),m(b.$$.fragment),G=r(),k=f("p"),k.innerHTML=$,I=r(),m(C.$$.fragment)},l(i){U(a.$$.fragment,i),o=c(i),n=T(i,"P",{"data-svelte-h":!0}),w(n)!=="svelte-nqgrhi"&&(n.textContent=h),u=c(i),U(d.$$.fragment,i),Q=c(i),U(b.$$.fragment,i),G=c(i),k=T(i,"P",{"data-svelte-h":!0}),w(k)!=="svelte-p4v437"&&(k.innerHTML=$),I=c(i),U(C.$$.fragment,i)},m(i,g){y(a,i,g),s(i,o,g),s(i,n,g),s(i,u,g),y(d,i,g),s(i,Q,g),y(b,i,g),s(i,G,g),s(i,k,g),s(i,I,g),y(C,i,g),R=!0},i(i){R||(p(a.$$.fragment,i),p(d.$$.fragment,i),p(b.$$.fragment,i),p(C.$$.fragment,i),R=!0)},o(i){M(a.$$.fragment,i),M(d.$$.fragment,i),M(b.$$.fragment,i),M(C.$$.fragment,i),R=!1},d(i){i&&(l(o),l(n),l(u),l(Q),l(G),l(k),l(I)),J(a,i),J(d,i),J(b,i),J(C,i)}}}function ms(Z){let a,o,n,h;return a=new j({props:{code:"cXVlc3Rpb24lMjAlM0QlMjAlMjJIb3clMjBjYW4lMjBJJTIwbG9hZCUyMGElMjBkYXRhc2V0JTIwb2ZmbGluZSUzRiUyMiUwQXF1ZXN0aW9uX2VtYmVkZGluZyUyMCUzRCUyMGdldF9lbWJlZGRpbmdzKCU1QnF1ZXN0aW9uJTVEKS5udW1weSgpJTBBcXVlc3Rpb25fZW1iZWRkaW5nLnNoYXBl",highlighted:`question = <span class="hljs-string">&quot;How can I load a dataset offline?&quot;</span>
question_embedding = get_embeddings([question]).numpy()
question_embedding.shape`,wrap:!1}}),n=new j({props:{code:"KDElMkMlMjA3Njgp",highlighted:'(<span class="hljs-number">1</span>, <span class="hljs-number">768</span>)',wrap:!1}}),{c(){m(a.$$.fragment),o=r(),m(n.$$.fragment)},l(u){U(a.$$.fragment,u),o=c(u),U(n.$$.fragment,u)},m(u,d){y(a,u,d),s(u,o,d),y(n,u,d),h=!0},i(u){h||(p(a.$$.fragment,u),p(n.$$.fragment,u),h=!0)},o(u){M(a.$$.fragment,u),M(n.$$.fragment,u),h=!1},d(u){u&&l(o),J(a,u),J(n,u)}}}function Us(Z){let a,o,n,h;return a=new j({props:{code:"cXVlc3Rpb24lMjAlM0QlMjAlMjJIb3clMjBjYW4lMjBJJTIwbG9hZCUyMGElMjBkYXRhc2V0JTIwb2ZmbGluZSUzRiUyMiUwQXF1ZXN0aW9uX2VtYmVkZGluZyUyMCUzRCUyMGdldF9lbWJlZGRpbmdzKCU1QnF1ZXN0aW9uJTVEKS5jcHUoKS5kZXRhY2goKS5udW1weSgpJTBBcXVlc3Rpb25fZW1iZWRkaW5nLnNoYXBl",highlighted:`question = <span class="hljs-string">&quot;How can I load a dataset offline?&quot;</span>
question_embedding = get_embeddings([question]).cpu().detach().numpy()
question_embedding.shape`,wrap:!1}}),n=new j({props:{code:"dG9yY2guU2l6ZSglNUIxJTJDJTIwNzY4JTVEKQ==",highlighted:'torch.Size([<span class="hljs-number">1</span>, <span class="hljs-number">768</span>])',wrap:!1}}),{c(){m(a.$$.fragment),o=r(),m(n.$$.fragment)},l(u){U(a.$$.fragment,u),o=c(u),U(n.$$.fragment,u)},m(u,d){y(a,u,d),s(u,o,d),y(n,u,d),h=!0},i(u){h||(p(a.$$.fragment,u),p(n.$$.fragment,u),h=!0)},o(u){M(a.$$.fragment,u),M(n.$$.fragment,u),h=!1},d(u){u&&l(o),J(a,u),J(n,u)}}}function ys(Z){let a,o="✏️ <strong>Încearcă!</strong> Creează propriul tău query și vezi dacp poți găsi un răspuns și să extragi documentele. S-ar putea să trebuiești să crești parametrul <code>k</code> în <code>Dataset.get_nearest_examples()</code> pentru a mări căutarea.";return{c(){a=f("p"),a.innerHTML=o},l(n){a=T(n,"P",{"data-svelte-h":!0}),w(a)!=="svelte-1as03g8"&&(a.innerHTML=o)},m(n,h){s(n,a,h)},p:Dl,d(n){n&&l(a)}}}function Js(Z){let a,o,n,h,u,d,Q,b,G,k,$,I,C,R,i='În <a href="/course/chapter5/5">secțiunea 5</a>, am creat un dataset cu issues și comentarii din repositoriul 🤗 Datasets. În această secțiune, vom utiliza aceste informații pentru a construi un motor de căutare care ne poate ajuta să găsim răspunsurile la  cele mai importante cele mai importante întrebări despre bibliotecă!',g,S,Ke,F,Oe,E,ul='După cum am văzut în <a href="/course/chapter1">Capitolul 1</a>, Transformer-based language models reprezintă fiecare token într-un fragment de text ca un <em>embedding vector</em>. S-a dovedit că se poate face “pool” embeddingurilor individuale pentru a crea o reprezentare vectorială pentru fraze întregi, paragrafe sau (în anumite cazuri) documente. Aceste embeddings pot fi apoi utilizate pentru a găsi documente similare în corpus prin calcularea dot-product similarity (sau a unei alte metrice de similaritate) între fiecare embedding și returnarea documentelor cu cea mai mare suprapunere.',et,A,Ml="În această secțiune, vom utiliza embeddings pentru a dezvolta un motor de căutare semantică. Aceste motoare de căutare oferă mai multe avantaje față de abordările convenționale bazate pe căutarea de cuvinte cheie într-un query cu documente.",tt,V,pl='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter5/semantic-search.svg" alt="Căutare semantică."/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface-course/documentation-images/resolve/main/en/chapter5/semantic-search-dark.svg" alt="Căutare semantică."/>',lt,H,st,q,ol="Prima lucru pe care trebuie să îl facem este să descărcăm datasetul nostru cu GitHub issues, așa că folosim funcția <code>load_dataset()</code> ca de obicei:",at,D,nt,L,it,P,dl="Aici am specificat splitul default <code>train</code> în <code>load_dataset()</code>, astfel încât returnează un <code>Dataset</code> în loc de <code>DatasetDict</code>. Primul lucru care treubuie făcut este să filtrăm pull requesturile, deoarece acestea rareori tind să fie utilizate pentru a răspunde la întrebările utilizatorilor și vor introduce noise în motorul nostru de căutare. Așa cum ar trebuie deja să știți, putem utiliza funcția <code>Dataset.filter()</code> pentru a exclude aceste rânduri din datasetul nostru. În timp ce suntem aici, putem să filtrăm și rândurile fără comentari, deoarece acestea nu oferă niciun răspuns la întrebările utilizatorilor:",rt,K,ct,O,ut,ee,ml="Putem vedea că există multe coloane în datasetul nostru, majoritatea dintre care nu sunt necesare pentru a construi motorul nostru de căutare. Din perspectiva căutării, cele mai informative coloane sunt <code>title</code>, <code>body</code> și <code>comments</code>, în timp ce <code>html_url</code> ne oferă un link înapoi la problema sursă. Hai să utilizăm funcția <code>Dataset.remove_columns()</code> pentru a elimina restul:",Mt,te,pt,le,ot,se,Ul='Pentru a crea embeddedurile noastre, vom completa fiecare comentariu cu titlul și body-ul problemei, deoarece aceste câmpuri adesea includ informații contextuale utile. Deoarece coloana noastră <code>comments</code> este în prezent o listă de comentarii pentru fiecare issue, trebuie să “explodăm” coloana, astfel încât fiecare rând să fie format dintr-un tuple <code>(html_url, title, body, comment)</code>. În Pandas, putem face acest lucru cu funcția <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.explode.html" rel="nofollow"><code>DataFrame.explode()</code></a>, care creează un rând nou pentru fiecare element dintr-o coloană asemănătoare cu o listă, în timp ce copiază toate celelalte valori ale coloanelor. Pentru a vedea acest lucru în acțiune, să trecem la formatul pandas <code>DataFrame</code> mai întâi:',dt,ae,mt,ne,yl="Dacă inspectăm primul rând din acest <code>DataFrame</code>, putem vedea că există patru comentarii asociate acestei probleme:",Ut,ie,yt,re,Jt,ce,Jl="Când facem explode <code>df</code>, ne așteptăm să obținem un rând pentru fiecare dintre aceste comentarii. Haideți să verificăm dacă ăsta e cazul:",bt,ue,ft,_,bl='<thead><tr style="text-align: right;"><th></th> <th>html_url</th> <th>title</th> <th>comments</th> <th>body</th></tr></thead> <tbody><tr><th>0</th> <td>https://github.com/huggingface/datasets/issues/2787</td> <td>ConnectionError: Couldn&#39;t reach https://raw.githubusercontent.com</td> <td>the bug code locate in ：\\r\\n    if data_args.task_name is not None...</td> <td>Hello,\\r\\nI am trying to run run_glue.py and it gives me this error...</td></tr> <tr><th>1</th> <td>https://github.com/huggingface/datasets/issues/2787</td> <td>ConnectionError: Couldn&#39;t reach https://raw.githubusercontent.com</td> <td>Hi @jinec,\\r\\n\\r\\nFrom time to time we get this kind of `ConnectionError` coming from the github.com website: https://raw.githubusercontent.com...</td> <td>Hello,\\r\\nI am trying to run run_glue.py and it gives me this error...</td></tr> <tr><th>2</th> <td>https://github.com/huggingface/datasets/issues/2787</td> <td>ConnectionError: Couldn&#39;t reach https://raw.githubusercontent.com</td> <td>cannot connect，even by Web browser，please check that  there is some  problems。</td> <td>Hello,\\r\\nI am trying to run run_glue.py and it gives me this error...</td></tr> <tr><th>3</th> <td>https://github.com/huggingface/datasets/issues/2787</td> <td>ConnectionError: Couldn&#39;t reach https://raw.githubusercontent.com</td> <td>I can access https://raw.githubusercontent.com/huggingface/datasets/1.7.0/datasets/glue/glue.py without problem...</td> <td>Hello,\\r\\nI am trying to run run_glue.py and it gives me this error...</td></tr></tbody>',Tt,Me,fl="Great, putem vedea că rândurile au fost reproduse, cu coloanele <code>comments</code> incluzând și comentariile individuale. Acum că am terminat cu Pandas, noi putem să schimăm rapid înapoi la un <code>Dataset</code> înărcând <code>DataFrame</code> în memorie:",jt,pe,ht,oe,wt,de,Tl="Okay, acest lucru ne-a oferit câteva mii de comentarii cu care să lucrăm!",gt,W,Qt,me,jl="Acum că avem un singur comentariu pe rând, să creăm o nouă coloană <code>comments_length</code> care conține numărul de cuvinte din fiecare comentariu:",Zt,Ue,Gt,ye,hl="Putem utiliza această nouă coloană pentru a filtra comentariile scurte, care de obicei includ lucruri precum “cc @lewtun” sau “Mulțumesc!” care nu sunt relevante pentru motorul nostru de căutare. Nu există un număr precis care trebuie selectat pentru filtru, dar aproximativ 15 cuvinte pare a fi un bun punct de plecare:",Ct,Je,It,be,kt,fe,wl="După ce am curățat puțin setul nostru de date, putem să concatenăm titlul, descrirea și comentariile problemei împreună într-o nouă coloană <code>text</code>. Ca de obicei, vom scrie o funcție simplă pe care o putem transmite în <code>Dataset.map()</code>:",$t,Te,Rt,je,gl="Suntem în final pregătiți să creăm niște embeddings! Haideți să vedem cum facem acest lucru.",_t,he,Nt,we,Ql='Am văzut în <a href="/course/chapter2">Capitolul 2</a> că putem obține token embeddings prin utilizarea clasei <code>AutoModel</code>. Tot ce trebuie să facem este să alegem un checkpoint potrivit pentru a încărca modelul. Din fericire, există o bibliotecă numită <code>sentence-transformers</code> care se ocupă de crearea embeddingurilor. Așa cum se descrie în <a href="https://www.sbert.net/examples/applications/semantic-search/README.html#symmetric-vs-asymmetric-semantic-search" rel="nofollow">documentația</a> bibliotecii, cazul nostru este un exemplu de <em>căutare semantică asimetrică</em> deoarece avem o întrebare scurtă al cărei răspuns ne-ar plăcea să îl găsim într-un document mai lung, precum un comentariu la un issue. [Tabelul] (<a href="https://www.sbert.net/docs/pretrained_models.html#model-overview" rel="nofollow">https://www.sbert.net/docs/pretrained_models.html#model-overview</a>) util de prezentare a modelului din documentație indică faptul că checkpointul <code>multi-qa-mpnet-base-dot-v1</code> are cea mai bună performanță pentru căutarea semantică, așa că îl vom folosi acesta pentru aplicația noastră. De asemenea, vom încărca tokenizer-ul folosind același checkpoint:',xt,N,x,Ae,ge,Zl="După cum am menționat anterior, dorim să reprezentăm fiecare intrare din corpusul nostru de GitHub issues sub forma unui vector, astfel încât avem nevoie să “agregăm” sau să facem media la tokem embeddings într-un anumit mod. O abordare populară este de a efectua <em>CLS pooling</em> pe outputurile modelului nostru, unde pur și simplu colectăm ultimul stadiu ascuns pentru tokenul special <code>[CLS]</code>. Următoarea funcție face acest lucru pentru noi:",Bt,Qe,zt,Ze,Gl="În continuare, vom crea o funcție ajutătoare care va tokeniza o listă de documente, va plasa tensorii pe GPU, îi va alimenta în model și, în final, va aplica CLS pooling la outputuri:",vt,B,z,He,Ge,Cl="Observăm că am transformat embeddingurile în matrice NumPy — acest lucru este necesar deoarece biblioteca 🤗 Datasets cere acest format atunci când încercăm să indexăm cu FAISS, ceea ce vom face în continuare.",Xt,Ce,Vt,Ie,Il='Acum că avem un dataset de embeddings, avem nevoie de o modalitate de a căuta printre ele. Pentru a face acest lucru, vom utiliza o structură de date specială din 🤗 Datasets, numită <em>FAISS index</em>. <a href="https://faiss.ai/" rel="nofollow">FAISS</a> (prescurtat de la Facebook AI Similarity Search) este o bibliotecă care oferă algoritmi eficienți pentru căutarea rapidă și clusteringul al embedding vectors.',Wt,ke,kl="Ideea de bază din spatele FAISS este crearea unei structuri de date speciale numite <em>index</em>, care permite găsirea embeddingurilor similare cu un input embedding. Crearea unui index FAISS în 🤗 Datasets este simplu — utilizăm funcția <code>Dataset.add_faiss_index()</code> și specificăm care coloană a datasetului nostru dorim să indexăm:",Yt,$e,St,Re,$l="Acum putem efectua queries pe acest index realizând o căutare a celor mai apropiați vecini cu funcția <code>Dataset.get_nearest_examples()</code>. Haideți să testăm acest lucru prin încorporarea unei întrebări astfel:",Ft,v,X,qe,_e,Rl="La fel ca și în cazul documentelor, acum avem un vector de 768 de dimensiuni care reprezintă query-ul, pe care îl putem compara cu întregul corpus pentru a găsi embeddingurile cele mai similare:",Et,Ne,At,xe,_l="Funcția <code>Dataset.get_nearest_examples()</code> returnează un tuple cu scorurile care clasifică suprapunerea dintre query și document, și un set corespunzător de sampleuri (în acest caz, cele 5 match-uri). Haideți să colectăm acestea într-un <code>pandas.DataFrame</code> pentru a le putea sorta cu ușurință:",Ht,Be,qt,ze,Nl="Acum putem itera peste primele rânduri pentru a veadea cât de bine un query se potrivește cu comentariile disponibile:",Dt,ve,Lt,Xe,Pt,Ve,xl="Nu-i rău! A doua încercare se pare că se potrivește cu query-ul!",Kt,Y,Ot,We,el,De,tl;u=new is({props:{fw:Z[0]}}),Q=new ss({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),G=new Pe({props:{title:"Căutare semantică cu FAISS",local:"semantic-search-with-faiss",headingTag:"h1"}});const Bl=[cs,rs],Ye=[];function zl(e,t){return e[0]==="pt"?0:1}$=zl(Z),I=Ye[$]=Bl[$](Z),S=new ns({props:{id:"OATCgQtNX2o"}}),F=new Pe({props:{title:"Utilizarea embeddings pentru căutare semantică",local:"using-embeddings-for-semantic-search",headingTag:"h2"}}),H=new Pe({props:{title:"Încărcarea și pregătirea datasetului",local:"loading-and-preparing-the-dataset",headingTag:"h2"}}),D=new j({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwbG9hZF9kYXRhc2V0JTBBJTBBaXNzdWVzX2RhdGFzZXQlMjAlM0QlMjBsb2FkX2RhdGFzZXQoJTIybGV3dHVuJTJGZ2l0aHViLWlzc3VlcyUyMiUyQyUyMHNwbGl0JTNEJTIydHJhaW4lMjIpJTBBaXNzdWVzX2RhdGFzZXQ=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> load_dataset

issues_dataset = load_dataset(<span class="hljs-string">&quot;lewtun/github-issues&quot;</span>, split=<span class="hljs-string">&quot;train&quot;</span>)
issues_dataset`,wrap:!1}}),L=new j({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1Qid1cmwnJTJDJTIwJ3JlcG9zaXRvcnlfdXJsJyUyQyUyMCdsYWJlbHNfdXJsJyUyQyUyMCdjb21tZW50c191cmwnJTJDJTIwJ2V2ZW50c191cmwnJTJDJTIwJ2h0bWxfdXJsJyUyQyUyMCdpZCclMkMlMjAnbm9kZV9pZCclMkMlMjAnbnVtYmVyJyUyQyUyMCd0aXRsZSclMkMlMjAndXNlciclMkMlMjAnbGFiZWxzJyUyQyUyMCdzdGF0ZSclMkMlMjAnbG9ja2VkJyUyQyUyMCdhc3NpZ25lZSclMkMlMjAnYXNzaWduZWVzJyUyQyUyMCdtaWxlc3RvbmUnJTJDJTIwJ2NvbW1lbnRzJyUyQyUyMCdjcmVhdGVkX2F0JyUyQyUyMCd1cGRhdGVkX2F0JyUyQyUyMCdjbG9zZWRfYXQnJTJDJTIwJ2F1dGhvcl9hc3NvY2lhdGlvbiclMkMlMjAnYWN0aXZlX2xvY2tfcmVhc29uJyUyQyUyMCdwdWxsX3JlcXVlc3QnJTJDJTIwJ2JvZHknJTJDJTIwJ3BlcmZvcm1lZF92aWFfZ2l0aHViX2FwcCclMkMlMjAnaXNfcHVsbF9yZXF1ZXN0JyU1RCUyQyUwQSUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMjg1NSUwQSU3RCk=",highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;url&#x27;</span>, <span class="hljs-string">&#x27;repository_url&#x27;</span>, <span class="hljs-string">&#x27;labels_url&#x27;</span>, <span class="hljs-string">&#x27;comments_url&#x27;</span>, <span class="hljs-string">&#x27;events_url&#x27;</span>, <span class="hljs-string">&#x27;html_url&#x27;</span>, <span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;node_id&#x27;</span>, <span class="hljs-string">&#x27;number&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;user&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;state&#x27;</span>, <span class="hljs-string">&#x27;locked&#x27;</span>, <span class="hljs-string">&#x27;assignee&#x27;</span>, <span class="hljs-string">&#x27;assignees&#x27;</span>, <span class="hljs-string">&#x27;milestone&#x27;</span>, <span class="hljs-string">&#x27;comments&#x27;</span>, <span class="hljs-string">&#x27;created_at&#x27;</span>, <span class="hljs-string">&#x27;updated_at&#x27;</span>, <span class="hljs-string">&#x27;closed_at&#x27;</span>, <span class="hljs-string">&#x27;author_association&#x27;</span>, <span class="hljs-string">&#x27;active_lock_reason&#x27;</span>, <span class="hljs-string">&#x27;pull_request&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>, <span class="hljs-string">&#x27;performed_via_github_app&#x27;</span>, <span class="hljs-string">&#x27;is_pull_request&#x27;</span>],
    num_rows: <span class="hljs-number">2855</span>
})`,wrap:!1}}),K=new j({props:{code:"aXNzdWVzX2RhdGFzZXQlMjAlM0QlMjBpc3N1ZXNfZGF0YXNldC5maWx0ZXIoJTBBJTIwJTIwJTIwJTIwbGFtYmRhJTIweCUzQSUyMCh4JTVCJTIyaXNfcHVsbF9yZXF1ZXN0JTIyJTVEJTIwJTNEJTNEJTIwRmFsc2UlMjBhbmQlMjBsZW4oeCU1QiUyMmNvbW1lbnRzJTIyJTVEKSUyMCUzRSUyMDApJTBBKSUwQWlzc3Vlc19kYXRhc2V0",highlighted:`issues_dataset = issues_dataset.<span class="hljs-built_in">filter</span>(
    <span class="hljs-keyword">lambda</span> x: (x[<span class="hljs-string">&quot;is_pull_request&quot;</span>] == <span class="hljs-literal">False</span> <span class="hljs-keyword">and</span> <span class="hljs-built_in">len</span>(x[<span class="hljs-string">&quot;comments&quot;</span>]) &gt; <span class="hljs-number">0</span>)
)
issues_dataset`,wrap:!1}}),O=new j({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBjYXJhY3RlcmlzdGljaSUzQSUyMCU1Qid1cmwnJTJDJTIwJ3JlcG9zaXRvcnlfdXJsJyUyQyUyMCdsYWJlbHNfdXJsJyUyQyUyMCdjb21tZW50c191cmwnJTJDJTIwJ2V2ZW50c191cmwnJTJDJTIwJ2h0bWxfdXJsJyUyQyUyMCdpZCclMkMlMjAnbm9kZV9pZCclMkMlMjAnbnVtYmVyJyUyQyUyMCd0aXRsZSclMkMlMjAndXNlciclMkMlMjAnbGFiZWxzJyUyQyUyMCdzdGF0ZSclMkMlMjAnbG9ja2VkJyUyQyUyMCdhc3NpZ25lZSclMkMlMjAnYXNzaWduZWVzJyUyQyUyMCdtaWxlc3RvbmUnJTJDJTIwJ2NvbW1lbnRzJyUyQyUyMCdjcmVhdGVkX2F0JyUyQyUyMCd1cGRhdGVkX2F0JyUyQyUyMCdjbG9zZWRfYXQnJTJDJTIwJ2F1dGhvcl9hc3NvY2lhdGlvbiclMkMlMjAnYWN0aXZlX2xvY2tfcmVhc29uJyUyQyUyMCdwdWxsX3JlcXVlc3QnJTJDJTIwJ2JvZHknJTJDJTIwJ3BlcmZvcm1lZF92aWFfZ2l0aHViX2FwcCclMkMlMjAnaXNfcHVsbF9yZXF1ZXN0JyU1RCUyQyUwQSUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNzcxJTBBJTdEKQ==",highlighted:`Dataset({
    caracteristici: [<span class="hljs-string">&#x27;url&#x27;</span>, <span class="hljs-string">&#x27;repository_url&#x27;</span>, <span class="hljs-string">&#x27;labels_url&#x27;</span>, <span class="hljs-string">&#x27;comments_url&#x27;</span>, <span class="hljs-string">&#x27;events_url&#x27;</span>, <span class="hljs-string">&#x27;html_url&#x27;</span>, <span class="hljs-string">&#x27;id&#x27;</span>, <span class="hljs-string">&#x27;node_id&#x27;</span>, <span class="hljs-string">&#x27;number&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;user&#x27;</span>, <span class="hljs-string">&#x27;labels&#x27;</span>, <span class="hljs-string">&#x27;state&#x27;</span>, <span class="hljs-string">&#x27;locked&#x27;</span>, <span class="hljs-string">&#x27;assignee&#x27;</span>, <span class="hljs-string">&#x27;assignees&#x27;</span>, <span class="hljs-string">&#x27;milestone&#x27;</span>, <span class="hljs-string">&#x27;comments&#x27;</span>, <span class="hljs-string">&#x27;created_at&#x27;</span>, <span class="hljs-string">&#x27;updated_at&#x27;</span>, <span class="hljs-string">&#x27;closed_at&#x27;</span>, <span class="hljs-string">&#x27;author_association&#x27;</span>, <span class="hljs-string">&#x27;active_lock_reason&#x27;</span>, <span class="hljs-string">&#x27;pull_request&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>, <span class="hljs-string">&#x27;performed_via_github_app&#x27;</span>, <span class="hljs-string">&#x27;is_pull_request&#x27;</span>],
    num_rows: <span class="hljs-number">771</span>
})`,wrap:!1}}),te=new j({props:{code:"Y29sdW1ucyUyMCUzRCUyMGlzc3Vlc19kYXRhc2V0LmNvbHVtbl9uYW1lcyUwQWNvbHVtbnNfdG9fa2VlcCUyMCUzRCUyMCU1QiUyMnRpdGxlJTIyJTJDJTIwJTIyYm9keSUyMiUyQyUyMCUyMmh0bWxfdXJsJTIyJTJDJTIwJTIyY29tbWVudHMlMjIlNUQlMEFjb2x1bW5zX3RvX3JlbW92ZSUyMCUzRCUyMHNldChjb2x1bW5zX3RvX2tlZXApLnN5bW1ldHJpY19kaWZmZXJlbmNlKGNvbHVtbnMpJTBBaXNzdWVzX2RhdGFzZXQlMjAlM0QlMjBpc3N1ZXNfZGF0YXNldC5yZW1vdmVfY29sdW1ucyhjb2x1bW5zX3RvX3JlbW92ZSklMEFpc3N1ZXNfZGF0YXNldA==",highlighted:`columns = issues_dataset.column_names
columns_to_keep = [<span class="hljs-string">&quot;title&quot;</span>, <span class="hljs-string">&quot;body&quot;</span>, <span class="hljs-string">&quot;html_url&quot;</span>, <span class="hljs-string">&quot;comments&quot;</span>]
columns_to_remove = <span class="hljs-built_in">set</span>(columns_to_keep).symmetric_difference(columns)
issues_dataset = issues_dataset.remove_columns(columns_to_remove)
issues_dataset`,wrap:!1}}),le=new j({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidodG1sX3VybCclMkMlMjAndGl0bGUnJTJDJTIwJ2NvbW1lbnRzJyUyQyUyMCdib2R5JyU1RCUyQyUwQSUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwNzcxJTBBJTdEKQ==",highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;html_url&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;comments&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>],
    num_rows: <span class="hljs-number">771</span>
})`,wrap:!1}}),ae=new j({props:{code:"aXNzdWVzX2RhdGFzZXQuc2V0X2Zvcm1hdCglMjJwYW5kYXMlMjIpJTBBZGYlMjAlM0QlMjBpc3N1ZXNfZGF0YXNldCU1QiUzQSU1RA==",highlighted:`issues_dataset.set_format(<span class="hljs-string">&quot;pandas&quot;</span>)
df = issues_dataset[:]`,wrap:!1}}),ie=new j({props:{code:"ZGYlNUIlMjJjb21tZW50cyUyMiU1RCU1QjAlNUQudG9saXN0KCk=",highlighted:'df[<span class="hljs-string">&quot;comments&quot;</span>][<span class="hljs-number">0</span>].tolist()',wrap:!1}}),re=new j({props:{code:"JTVCJ3RoZSUyMGJ1ZyUyMGNvZGUlMjBsb2NhdGUlMjBpbiUyMCVFRiVCQyU5QSU1Q3IlNUNuJTIwJTIwJTIwJTIwaWYlMjBkYXRhX2FyZ3MudGFza19uYW1lJTIwaXMlMjBub3QlMjBOb25lJTNBJTVDciU1Q24lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBEb3dubG9hZGluZyUyMGFuZCUyMGxvYWRpbmclMjBhJTIwZGF0YXNldCUyMGZyb20lMjB0aGUlMjBodWIuJTVDciU1Q24lMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkYXRhc2V0cyUyMCUzRCUyMGxvYWRfZGF0YXNldCglMjJnbHVlJTIyJTJDJTIwZGF0YV9hcmdzLnRhc2tfbmFtZSUyQyUyMGNhY2hlX2RpciUzRG1vZGVsX2FyZ3MuY2FjaGVfZGlyKSclMkMlMEElMjAnSGklMjAlNDBqaW5lYyUyQyU1Q3IlNUNuJTVDciU1Q25Gcm9tJTIwdGltZSUyMHRvJTIwdGltZSUyMHdlJTIwZ2V0JTIwdGhpcyUyMGtpbmQlMjBvZiUyMCU2MENvbm5lY3Rpb25FcnJvciU2MCUyMGNvbWluZyUyMGZyb20lMjB0aGUlMjBnaXRodWIuY29tJTIwd2Vic2l0ZSUzQSUyMGh0dHBzJTNBJTJGJTJGcmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSU1Q3IlNUNuJTVDciU1Q25Ob3JtYWxseSUyQyUyMGl0JTIwc2hvdWxkJTIwd29yayUyMGlmJTIweW91JTIwd2FpdCUyMGElMjBsaXR0bGUlMjBhbmQlMjB0aGVuJTIwcmV0cnkuJTVDciU1Q24lNUNyJTVDbkNvdWxkJTIweW91JTIwcGxlYXNlJTIwY29uZmlybSUyMGlmJTIwdGhlJTIwcHJvYmxlbSUyMHBlcnNpc3RzJTNGJyUyQyUwQSUyMCdjYW5ub3QlMjBjb25uZWN0JUVGJUJDJThDZXZlbiUyMGJ5JTIwV2ViJTIwYnJvd3NlciVFRiVCQyU4Q3BsZWFzZSUyMGNoZWNrJTIwdGhhdCUyMCUyMHRoZXJlJTIwaXMlMjBzb21lJTIwJTIwcHJvYmxlbXMlRTMlODAlODInJTJDJTBBJTIwJ0klMjBjYW4lMjBhY2Nlc3MlMjBodHRwcyUzQSUyRiUyRnJhdy5naXRodWJ1c2VyY29udGVudC5jb20lMkZodWdnaW5nZmFjZSUyRmRhdGFzZXRzJTJGMS43LjAlMkZkYXRhc2V0cyUyRmdsdWUlMkZnbHVlLnB5JTIwd2l0aG91dCUyMHByb2JsZW0uLi4nJTVE",highlighted:`[<span class="hljs-string">&#x27;the bug code locate in ：\\r\\n    if data_args.task_name is not None:\\r\\n        # Downloading and loading a dataset from the hub.\\r\\n        datasets = load_dataset(&quot;glue&quot;, data_args.task_name, cache_dir=model_args.cache_dir)&#x27;</span>,
 <span class="hljs-string">&#x27;Hi @jinec,\\r\\n\\r\\nFrom time to time we get this kind of \`ConnectionError\` coming from the github.com website: https://raw.githubusercontent.com\\r\\n\\r\\nNormally, it should work if you wait a little and then retry.\\r\\n\\r\\nCould you please confirm if the problem persists?&#x27;</span>,
 <span class="hljs-string">&#x27;cannot connect，even by Web browser，please check that  there is some  problems。&#x27;</span>,
 <span class="hljs-string">&#x27;I can access https://raw.githubusercontent.com/huggingface/datasets/1.7.0/datasets/glue/glue.py without problem...&#x27;</span>]`,wrap:!1}}),ue=new j({props:{code:"Y29tbWVudHNfZGYlMjAlM0QlMjBkZi5leHBsb2RlKCUyMmNvbW1lbnRzJTIyJTJDJTIwaWdub3JlX2luZGV4JTNEVHJ1ZSklMEFjb21tZW50c19kZi5oZWFkKDQp",highlighted:`comments_df = df.explode(<span class="hljs-string">&quot;comments&quot;</span>, ignore_index=<span class="hljs-literal">True</span>)
comments_df.head(<span class="hljs-number">4</span>)`,wrap:!1}}),pe=new j({props:{code:"ZnJvbSUyMGRhdGFzZXRzJTIwaW1wb3J0JTIwRGF0YXNldCUwQSUwQWNvbW1lbnRzX2RhdGFzZXQlMjAlM0QlMjBEYXRhc2V0LmZyb21fcGFuZGFzKGNvbW1lbnRzX2RmKSUwQWNvbW1lbnRzX2RhdGFzZXQ=",highlighted:`<span class="hljs-keyword">from</span> datasets <span class="hljs-keyword">import</span> Dataset

comments_dataset = Dataset.from_pandas(comments_df)
comments_dataset`,wrap:!1}}),oe=new j({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidodG1sX3VybCclMkMlMjAndGl0bGUnJTJDJTIwJ2NvbW1lbnRzJyUyQyUyMCdib2R5JyU1RCUyQyUwQSUyMCUyMCUyMCUyMG51bV9yb3dzJTNBJTIwMjg0MiUwQSU3RCk=",highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;html_url&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;comments&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>],
    num_rows: <span class="hljs-number">2842</span>
})`,wrap:!1}}),W=new ql({props:{$$slots:{default:[us]},$$scope:{ctx:Z}}}),Ue=new j({props:{code:"Y29tbWVudHNfZGF0YXNldCUyMCUzRCUyMGNvbW1lbnRzX2RhdGFzZXQubWFwKCUwQSUyMCUyMCUyMCUyMGxhbWJkYSUyMHglM0ElMjAlN0IlMjJjb21tZW50X2xlbmd0aCUyMiUzQSUyMGxlbih4JTVCJTIyY29tbWVudHMlMjIlNUQuc3BsaXQoKSklN0QlMEEp",highlighted:`comments_dataset = comments_dataset.<span class="hljs-built_in">map</span>(
    <span class="hljs-keyword">lambda</span> x: {<span class="hljs-string">&quot;comment_length&quot;</span>: <span class="hljs-built_in">len</span>(x[<span class="hljs-string">&quot;comments&quot;</span>].split())}
)`,wrap:!1}}),Je=new j({props:{code:"Y29tbWVudHNfZGF0YXNldCUyMCUzRCUyMGNvbW1lbnRzX2RhdGFzZXQuZmlsdGVyKGxhbWJkYSUyMHglM0ElMjB4JTVCJTIyY29tbWVudF9sZW5ndGglMjIlNUQlMjAlM0UlMjAxNSklMEFjb21tZW50c19kYXRhc2V0",highlighted:`comments_dataset = comments_dataset.<span class="hljs-built_in">filter</span>(<span class="hljs-keyword">lambda</span> x: x[<span class="hljs-string">&quot;comment_length&quot;</span>] &gt; <span class="hljs-number">15</span>)
comments_dataset`,wrap:!1}}),be=new j({props:{code:"RGF0YXNldCglN0IlMEElMjAlMjAlMjAlMjBmZWF0dXJlcyUzQSUyMCU1QidodG1sX3VybCclMkMlMjAndGl0bGUnJTJDJTIwJ2NvbW1lbnRzJyUyQyUyMCdib2R5JyUyQyUyMCdjb21tZW50X2xlbmd0aCclNUQlMkMlMEElMjAlMjAlMjAlMjBudW1fcm93cyUzQSUyMDIwOTglMEElN0Qp",highlighted:`Dataset({
    features: [<span class="hljs-string">&#x27;html_url&#x27;</span>, <span class="hljs-string">&#x27;title&#x27;</span>, <span class="hljs-string">&#x27;comments&#x27;</span>, <span class="hljs-string">&#x27;body&#x27;</span>, <span class="hljs-string">&#x27;comment_length&#x27;</span>],
    num_rows: <span class="hljs-number">2098</span>
})`,wrap:!1}}),Te=new j({props:{code:"ZGVmJTIwY29uY2F0ZW5hdGVfdGV4dChleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjByZXR1cm4lMjAlN0IlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJ0ZXh0JTIyJTNBJTIwZXhhbXBsZXMlNUIlMjJ0aXRsZSUyMiU1RCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyQiUyMCUyMiUyMCU1Q24lMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkIlMjBleGFtcGxlcyU1QiUyMmJvZHklMjIlNUQlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMkIlMjAlMjIlMjAlNUNuJTIwJTIyJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTJCJTIwZXhhbXBsZXMlNUIlMjJjb21tZW50cyUyMiU1RCUwQSUyMCUyMCUyMCUyMCU3RCUwQSUwQSUwQWNvbW1lbnRzX2RhdGFzZXQlMjAlM0QlMjBjb21tZW50c19kYXRhc2V0Lm1hcChjb25jYXRlbmF0ZV90ZXh0KQ==",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">concatenate_text</span>(<span class="hljs-params">examples</span>):
    <span class="hljs-keyword">return</span> {
        <span class="hljs-string">&quot;text&quot;</span>: examples[<span class="hljs-string">&quot;title&quot;</span>]
        + <span class="hljs-string">&quot; \\n &quot;</span>
        + examples[<span class="hljs-string">&quot;body&quot;</span>]
        + <span class="hljs-string">&quot; \\n &quot;</span>
        + examples[<span class="hljs-string">&quot;comments&quot;</span>]
    }


comments_dataset = comments_dataset.<span class="hljs-built_in">map</span>(concatenate_text)`,wrap:!1}}),he=new Pe({props:{title:"Crearea embeddings-urilor de text",local:"creating-text-embeddings",headingTag:"h2"}});const vl=[ps,Ms],Se=[];function Xl(e,t){return e[0]==="pt"?0:1}N=Xl(Z),x=Se[N]=vl[N](Z),Qe=new j({props:{code:"ZGVmJTIwY2xzX3Bvb2xpbmcobW9kZWxfb3V0cHV0KSUzQSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMG1vZGVsX291dHB1dC5sYXN0X2hpZGRlbl9zdGF0ZSU1QiUzQSUyQyUyMDAlNUQ=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">cls_pooling</span>(<span class="hljs-params">model_output</span>):
    <span class="hljs-keyword">return</span> model_output.last_hidden_state[:, <span class="hljs-number">0</span>]`,wrap:!1}});const Vl=[ds,os],Fe=[];function Wl(e,t){return e[0]==="pt"?0:1}B=Wl(Z),z=Fe[B]=Vl[B](Z),Ce=new Pe({props:{title:"Utilizarea FAISS pentru căutare de similaritate eficientă",local:"using-faiss-for-efficient-similarity-search",headingTag:"h2"}}),$e=new j({props:{code:"ZW1iZWRkaW5nc19kYXRhc2V0LmFkZF9mYWlzc19pbmRleChjb2x1bW4lM0QlMjJlbWJlZGRpbmdzJTIyKQ==",highlighted:'embeddings_dataset.add_faiss_index(column=<span class="hljs-string">&quot;embeddings&quot;</span>)',wrap:!1}});const Yl=[Us,ms],Ee=[];function Sl(e,t){return e[0]==="pt"?0:1}return v=Sl(Z),X=Ee[v]=Yl[v](Z),Ne=new j({props:{code:"c2NvcmVzJTJDJTIwc2FtcGxlcyUyMCUzRCUyMGVtYmVkZGluZ3NfZGF0YXNldC5nZXRfbmVhcmVzdF9leGFtcGxlcyglMEElMjAlMjAlMjAlMjAlMjJlbWJlZGRpbmdzJTIyJTJDJTIwcXVlc3Rpb25fZW1iZWRkaW5nJTJDJTIwayUzRDUlMEEp",highlighted:`scores, samples = embeddings_dataset.get_nearest_examples(
    <span class="hljs-string">&quot;embeddings&quot;</span>, question_embedding, k=<span class="hljs-number">5</span>
)`,wrap:!1}}),Be=new j({props:{code:"aW1wb3J0JTIwcGFuZGFzJTIwYXMlMjBwZCUwQSUwQXNhbXBsZXNfZGYlMjAlM0QlMjBwZC5EYXRhRnJhbWUuZnJvbV9kaWN0KHNhbXBsZXMpJTBBc2FtcGxlc19kZiU1QiUyMnNjb3JlcyUyMiU1RCUyMCUzRCUyMHNjb3JlcyUwQXNhbXBsZXNfZGYuc29ydF92YWx1ZXMoJTIyc2NvcmVzJTIyJTJDJTIwYXNjZW5kaW5nJTNERmFsc2UlMkMlMjBpbnBsYWNlJTNEVHJ1ZSk=",highlighted:`<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

samples_df = pd.DataFrame.from_dict(samples)
samples_df[<span class="hljs-string">&quot;scores&quot;</span>] = scores
samples_df.sort_values(<span class="hljs-string">&quot;scores&quot;</span>, ascending=<span class="hljs-literal">False</span>, inplace=<span class="hljs-literal">True</span>)`,wrap:!1}}),ve=new j({props:{code:"Zm9yJTIwXyUyQyUyMHJvdyUyMGluJTIwc2FtcGxlc19kZi5pdGVycm93cygpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMkNPTU1FTlQlM0ElMjAlN0Jyb3cuY29tbWVudHMlN0QlMjIpJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMlNDT1JFJTNBJTIwJTdCcm93LnNjb3JlcyU3RCUyMiklMEElMjAlMjAlMjAlMjBwcmludChmJTIyVElUTEUlM0ElMjAlN0Jyb3cudGl0bGUlN0QlMjIpJTBBJTIwJTIwJTIwJTIwcHJpbnQoZiUyMlVSTCUzQSUyMCU3QnJvdy5odG1sX3VybCU3RCUyMiklMEElMjAlMjAlMjAlMjBwcmludCglMjIlM0QlMjIlMjAqJTIwNTApJTBBJTIwJTIwJTIwJTIwcHJpbnQoKQ==",highlighted:`<span class="hljs-keyword">for</span> _, row <span class="hljs-keyword">in</span> samples_df.iterrows():
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;COMMENT: <span class="hljs-subst">{row.comments}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;SCORE: <span class="hljs-subst">{row.scores}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;TITLE: <span class="hljs-subst">{row.title}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">f&quot;URL: <span class="hljs-subst">{row.html_url}</span>&quot;</span>)
    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;=&quot;</span> * <span class="hljs-number">50</span>)
    <span class="hljs-built_in">print</span>()`,wrap:!1}}),Xe=new j({props:{code:" ",highlighted:`<span class="hljs-string">&quot;&quot;&quot;
COMMENT: Requiring online connection is a deal breaker in some cases unfortunately so it&#x27;d be great if offline mode is added similar to how \`transformers\` loads models offline fine.

@mandubian&#x27;s second bullet point suggests that there&#x27;s a workaround allowing you to use your offline (custom?) dataset with \`datasets\`. Could you please elaborate on how that should look like?
SCORE: 25.505046844482422
TITLE: Discussion using datasets in offline mode
URL: https://github.com/huggingface/datasets/issues/824
==================================================

COMMENT: The local dataset builders (csv, text , json and pandas) are now part of the \`datasets\` package since #1726 :)
You can now use them offline
\\\`\\\`\\\`python
datasets = load_dataset(&quot;text&quot;, data_files=data_files)
\\\`\\\`\\\`

We&#x27;ll do a new release soon
SCORE: 24.555509567260742
TITLE: Discussion using datasets in offline mode
URL: https://github.com/huggingface/datasets/issues/824
==================================================

COMMENT: I opened a PR that allows to reload modules that have already been loaded once even if there&#x27;s no internet.

Let me know if you know other ways that can make the offline mode experience better. I&#x27;d be happy to add them :)

I already note the &quot;freeze&quot; modules option, to prevent local modules updates. It would be a cool feature.

----------

&gt; @mandubian&#x27;s second bullet point suggests that there&#x27;s a workaround allowing you to use your offline (custom?) dataset with \`datasets\`. Could you please elaborate on how that should look like?

Indeed \`load_dataset\` allows to load remote dataset script (squad, glue, etc.) but also you own local ones.
For example if you have a dataset script at \`./my_dataset/my_dataset.py\` then you can do
\\\`\\\`\\\`python
load_dataset(&quot;./my_dataset&quot;)
\\\`\\\`\\\`
and the dataset script will generate your dataset once and for all.

----------

About I&#x27;m looking into having \`csv\`, \`json\`, \`text\`, \`pandas\` dataset builders already included in the \`datasets\` package, so that they are available offline by default, as opposed to the other datasets that require the script to be downloaded.
cf #1724
SCORE: 24.14896583557129
TITLE: Discussion using datasets in offline mode
URL: https://github.com/huggingface/datasets/issues/824
==================================================

COMMENT: &gt; here is my way to load a dataset offline, but it **requires** an online machine
&gt;
&gt; 1. (online machine)
&gt;
&gt; \`\`\`
&gt;
&gt; import datasets
&gt;
&gt; data = datasets.load_dataset(...)
&gt;
&gt; data.save_to_disk(/YOUR/DATASET/DIR)
&gt;
&gt; \`\`\`
&gt;
&gt; 2. copy the dir from online to the offline machine
&gt;
&gt; 3. (offline machine)
&gt;
&gt; \`\`\`
&gt;
&gt; import datasets
&gt;
&gt; data = datasets.load_from_disk(/SAVED/DATA/DIR)
&gt;
&gt; \`\`\`
&gt;
&gt;
&gt;
&gt; HTH.


SCORE: 22.893993377685547
TITLE: Discussion using datasets in offline mode
URL: https://github.com/huggingface/datasets/issues/824
==================================================

COMMENT: here is my way to load a dataset offline, but it **requires** an online machine
1. (online machine)
\\\`\\\`\\\`
import datasets
data = datasets.load_dataset(...)
data.save_to_disk(/YOUR/DATASET/DIR)
\\\`\\\`\\\`
2. copy the dir from online to the offline machine
3. (offline machine)
\\\`\\\`\\\`
import datasets
data = datasets.load_from_disk(/SAVED/DATA/DIR)
\\\`\\\`\\\`

HTH.
SCORE: 22.406635284423828
TITLE: Discussion using datasets in offline mode
URL: https://github.com/huggingface/datasets/issues/824
==================================================
&quot;&quot;&quot;</span>`,wrap:!1}}),Y=new ql({props:{$$slots:{default:[ys]},$$scope:{ctx:Z}}}),We=new as({props:{source:"https://github.com/huggingface/course/blob/main/chapters/ro/chapter5/6.mdx"}}),{c(){a=f("meta"),o=r(),n=f("p"),h=r(),m(u.$$.fragment),d=r(),m(Q.$$.fragment),b=r(),m(G.$$.fragment),k=r(),I.c(),C=r(),R=f("p"),R.innerHTML=i,g=r(),m(S.$$.fragment),Ke=r(),m(F.$$.fragment),Oe=r(),E=f("p"),E.innerHTML=ul,et=r(),A=f("p"),A.textContent=Ml,tt=r(),V=f("div"),V.innerHTML=pl,lt=r(),m(H.$$.fragment),st=r(),q=f("p"),q.innerHTML=ol,at=r(),m(D.$$.fragment),nt=r(),m(L.$$.fragment),it=r(),P=f("p"),P.innerHTML=dl,rt=r(),m(K.$$.fragment),ct=r(),m(O.$$.fragment),ut=r(),ee=f("p"),ee.innerHTML=ml,Mt=r(),m(te.$$.fragment),pt=r(),m(le.$$.fragment),ot=r(),se=f("p"),se.innerHTML=Ul,dt=r(),m(ae.$$.fragment),mt=r(),ne=f("p"),ne.innerHTML=yl,Ut=r(),m(ie.$$.fragment),yt=r(),m(re.$$.fragment),Jt=r(),ce=f("p"),ce.innerHTML=Jl,bt=r(),m(ue.$$.fragment),ft=r(),_=f("table"),_.innerHTML=bl,Tt=r(),Me=f("p"),Me.innerHTML=fl,jt=r(),m(pe.$$.fragment),ht=r(),m(oe.$$.fragment),wt=r(),de=f("p"),de.textContent=Tl,gt=r(),m(W.$$.fragment),Qt=r(),me=f("p"),me.innerHTML=jl,Zt=r(),m(Ue.$$.fragment),Gt=r(),ye=f("p"),ye.textContent=hl,Ct=r(),m(Je.$$.fragment),It=r(),m(be.$$.fragment),kt=r(),fe=f("p"),fe.innerHTML=wl,$t=r(),m(Te.$$.fragment),Rt=r(),je=f("p"),je.textContent=gl,_t=r(),m(he.$$.fragment),Nt=r(),we=f("p"),we.innerHTML=Ql,xt=r(),x.c(),Ae=r(),ge=f("p"),ge.innerHTML=Zl,Bt=r(),m(Qe.$$.fragment),zt=r(),Ze=f("p"),Ze.textContent=Gl,vt=r(),z.c(),He=r(),Ge=f("p"),Ge.textContent=Cl,Xt=r(),m(Ce.$$.fragment),Vt=r(),Ie=f("p"),Ie.innerHTML=Il,Wt=r(),ke=f("p"),ke.innerHTML=kl,Yt=r(),m($e.$$.fragment),St=r(),Re=f("p"),Re.innerHTML=$l,Ft=r(),X.c(),qe=r(),_e=f("p"),_e.textContent=Rl,Et=r(),m(Ne.$$.fragment),At=r(),xe=f("p"),xe.innerHTML=_l,Ht=r(),m(Be.$$.fragment),qt=r(),ze=f("p"),ze.textContent=Nl,Dt=r(),m(ve.$$.fragment),Lt=r(),m(Xe.$$.fragment),Pt=r(),Ve=f("p"),Ve.textContent=xl,Kt=r(),m(Y.$$.fragment),Ot=r(),m(We.$$.fragment),el=r(),De=f("p"),this.h()},l(e){const t=ts("svelte-u9bgzb",document.head);a=T(t,"META",{name:!0,content:!0}),t.forEach(l),o=c(e),n=T(e,"P",{}),Hl(n).forEach(l),h=c(e),U(u.$$.fragment,e),d=c(e),U(Q.$$.fragment,e),b=c(e),U(G.$$.fragment,e),k=c(e),I.l(e),C=c(e),R=T(e,"P",{"data-svelte-h":!0}),w(R)!=="svelte-ky680v"&&(R.innerHTML=i),g=c(e),U(S.$$.fragment,e),Ke=c(e),U(F.$$.fragment,e),Oe=c(e),E=T(e,"P",{"data-svelte-h":!0}),w(E)!=="svelte-126wabi"&&(E.innerHTML=ul),et=c(e),A=T(e,"P",{"data-svelte-h":!0}),w(A)!=="svelte-5jfpph"&&(A.textContent=Ml),tt=c(e),V=T(e,"DIV",{class:!0,"data-svelte-h":!0}),w(V)!=="svelte-ombmkb"&&(V.innerHTML=pl),lt=c(e),U(H.$$.fragment,e),st=c(e),q=T(e,"P",{"data-svelte-h":!0}),w(q)!=="svelte-dpm7gd"&&(q.innerHTML=ol),at=c(e),U(D.$$.fragment,e),nt=c(e),U(L.$$.fragment,e),it=c(e),P=T(e,"P",{"data-svelte-h":!0}),w(P)!=="svelte-1j9ksj"&&(P.innerHTML=dl),rt=c(e),U(K.$$.fragment,e),ct=c(e),U(O.$$.fragment,e),ut=c(e),ee=T(e,"P",{"data-svelte-h":!0}),w(ee)!=="svelte-lg3h7h"&&(ee.innerHTML=ml),Mt=c(e),U(te.$$.fragment,e),pt=c(e),U(le.$$.fragment,e),ot=c(e),se=T(e,"P",{"data-svelte-h":!0}),w(se)!=="svelte-1f2m6qj"&&(se.innerHTML=Ul),dt=c(e),U(ae.$$.fragment,e),mt=c(e),ne=T(e,"P",{"data-svelte-h":!0}),w(ne)!=="svelte-156gjqh"&&(ne.innerHTML=yl),Ut=c(e),U(ie.$$.fragment,e),yt=c(e),U(re.$$.fragment,e),Jt=c(e),ce=T(e,"P",{"data-svelte-h":!0}),w(ce)!=="svelte-1dcvwa7"&&(ce.innerHTML=Jl),bt=c(e),U(ue.$$.fragment,e),ft=c(e),_=T(e,"TABLE",{border:!0,class:!0,style:!0,"data-svelte-h":!0}),w(_)!=="svelte-1g5whzd"&&(_.innerHTML=bl),Tt=c(e),Me=T(e,"P",{"data-svelte-h":!0}),w(Me)!=="svelte-kh0qqf"&&(Me.innerHTML=fl),jt=c(e),U(pe.$$.fragment,e),ht=c(e),U(oe.$$.fragment,e),wt=c(e),de=T(e,"P",{"data-svelte-h":!0}),w(de)!=="svelte-v5a6j7"&&(de.textContent=Tl),gt=c(e),U(W.$$.fragment,e),Qt=c(e),me=T(e,"P",{"data-svelte-h":!0}),w(me)!=="svelte-pvv6jb"&&(me.innerHTML=jl),Zt=c(e),U(Ue.$$.fragment,e),Gt=c(e),ye=T(e,"P",{"data-svelte-h":!0}),w(ye)!=="svelte-bfmb2z"&&(ye.textContent=hl),Ct=c(e),U(Je.$$.fragment,e),It=c(e),U(be.$$.fragment,e),kt=c(e),fe=T(e,"P",{"data-svelte-h":!0}),w(fe)!=="svelte-197key7"&&(fe.innerHTML=wl),$t=c(e),U(Te.$$.fragment,e),Rt=c(e),je=T(e,"P",{"data-svelte-h":!0}),w(je)!=="svelte-iwzotw"&&(je.textContent=gl),_t=c(e),U(he.$$.fragment,e),Nt=c(e),we=T(e,"P",{"data-svelte-h":!0}),w(we)!=="svelte-1goq14a"&&(we.innerHTML=Ql),xt=c(e),x.l(e),Ae=c(e),ge=T(e,"P",{"data-svelte-h":!0}),w(ge)!=="svelte-z1os81"&&(ge.innerHTML=Zl),Bt=c(e),U(Qe.$$.fragment,e),zt=c(e),Ze=T(e,"P",{"data-svelte-h":!0}),w(Ze)!=="svelte-1ksn3i2"&&(Ze.textContent=Gl),vt=c(e),z.l(e),He=c(e),Ge=T(e,"P",{"data-svelte-h":!0}),w(Ge)!=="svelte-ozuz78"&&(Ge.textContent=Cl),Xt=c(e),U(Ce.$$.fragment,e),Vt=c(e),Ie=T(e,"P",{"data-svelte-h":!0}),w(Ie)!=="svelte-kgage5"&&(Ie.innerHTML=Il),Wt=c(e),ke=T(e,"P",{"data-svelte-h":!0}),w(ke)!=="svelte-n2rsrh"&&(ke.innerHTML=kl),Yt=c(e),U($e.$$.fragment,e),St=c(e),Re=T(e,"P",{"data-svelte-h":!0}),w(Re)!=="svelte-ply641"&&(Re.innerHTML=$l),Ft=c(e),X.l(e),qe=c(e),_e=T(e,"P",{"data-svelte-h":!0}),w(_e)!=="svelte-19g227w"&&(_e.textContent=Rl),Et=c(e),U(Ne.$$.fragment,e),At=c(e),xe=T(e,"P",{"data-svelte-h":!0}),w(xe)!=="svelte-jyw2su"&&(xe.innerHTML=_l),Ht=c(e),U(Be.$$.fragment,e),qt=c(e),ze=T(e,"P",{"data-svelte-h":!0}),w(ze)!=="svelte-15mcgtc"&&(ze.textContent=Nl),Dt=c(e),U(ve.$$.fragment,e),Lt=c(e),U(Xe.$$.fragment,e),Pt=c(e),Ve=T(e,"P",{"data-svelte-h":!0}),w(Ve)!=="svelte-19uhxe9"&&(Ve.textContent=xl),Kt=c(e),U(Y.$$.fragment,e),Ot=c(e),U(We.$$.fragment,e),el=c(e),De=T(e,"P",{}),Hl(De).forEach(l),this.h()},h(){Le(a,"name","hf:doc:metadata"),Le(a,"content",bs),Le(V,"class","flex justify-center"),Le(_,"border","1"),Le(_,"class","dataframe"),cl(_,"table-layout","fixed"),cl(_,"word-wrap","break-word"),cl(_,"width","100%")},m(e,t){ls(document.head,a),s(e,o,t),s(e,n,t),s(e,h,t),y(u,e,t),s(e,d,t),y(Q,e,t),s(e,b,t),y(G,e,t),s(e,k,t),Ye[$].m(e,t),s(e,C,t),s(e,R,t),s(e,g,t),y(S,e,t),s(e,Ke,t),y(F,e,t),s(e,Oe,t),s(e,E,t),s(e,et,t),s(e,A,t),s(e,tt,t),s(e,V,t),s(e,lt,t),y(H,e,t),s(e,st,t),s(e,q,t),s(e,at,t),y(D,e,t),s(e,nt,t),y(L,e,t),s(e,it,t),s(e,P,t),s(e,rt,t),y(K,e,t),s(e,ct,t),y(O,e,t),s(e,ut,t),s(e,ee,t),s(e,Mt,t),y(te,e,t),s(e,pt,t),y(le,e,t),s(e,ot,t),s(e,se,t),s(e,dt,t),y(ae,e,t),s(e,mt,t),s(e,ne,t),s(e,Ut,t),y(ie,e,t),s(e,yt,t),y(re,e,t),s(e,Jt,t),s(e,ce,t),s(e,bt,t),y(ue,e,t),s(e,ft,t),s(e,_,t),s(e,Tt,t),s(e,Me,t),s(e,jt,t),y(pe,e,t),s(e,ht,t),y(oe,e,t),s(e,wt,t),s(e,de,t),s(e,gt,t),y(W,e,t),s(e,Qt,t),s(e,me,t),s(e,Zt,t),y(Ue,e,t),s(e,Gt,t),s(e,ye,t),s(e,Ct,t),y(Je,e,t),s(e,It,t),y(be,e,t),s(e,kt,t),s(e,fe,t),s(e,$t,t),y(Te,e,t),s(e,Rt,t),s(e,je,t),s(e,_t,t),y(he,e,t),s(e,Nt,t),s(e,we,t),s(e,xt,t),Se[N].m(e,t),s(e,Ae,t),s(e,ge,t),s(e,Bt,t),y(Qe,e,t),s(e,zt,t),s(e,Ze,t),s(e,vt,t),Fe[B].m(e,t),s(e,He,t),s(e,Ge,t),s(e,Xt,t),y(Ce,e,t),s(e,Vt,t),s(e,Ie,t),s(e,Wt,t),s(e,ke,t),s(e,Yt,t),y($e,e,t),s(e,St,t),s(e,Re,t),s(e,Ft,t),Ee[v].m(e,t),s(e,qe,t),s(e,_e,t),s(e,Et,t),y(Ne,e,t),s(e,At,t),s(e,xe,t),s(e,Ht,t),y(Be,e,t),s(e,qt,t),s(e,ze,t),s(e,Dt,t),y(ve,e,t),s(e,Lt,t),y(Xe,e,t),s(e,Pt,t),s(e,Ve,t),s(e,Kt,t),y(Y,e,t),s(e,Ot,t),y(We,e,t),s(e,el,t),s(e,De,t),tl=!0},p(e,[t]){const Fl={};t&1&&(Fl.fw=e[0]),u.$set(Fl);let al=$;$=zl(e),$!==al&&(sl(),M(Ye[al],1,1,()=>{Ye[al]=null}),ll(),I=Ye[$],I||(I=Ye[$]=Bl[$](e),I.c()),p(I,1),I.m(C.parentNode,C));const El={};t&2&&(El.$$scope={dirty:t,ctx:e}),W.$set(El);let nl=N;N=Xl(e),N!==nl&&(sl(),M(Se[nl],1,1,()=>{Se[nl]=null}),ll(),x=Se[N],x||(x=Se[N]=vl[N](e),x.c()),p(x,1),x.m(Ae.parentNode,Ae));let il=B;B=Wl(e),B!==il&&(sl(),M(Fe[il],1,1,()=>{Fe[il]=null}),ll(),z=Fe[B],z||(z=Fe[B]=Vl[B](e),z.c()),p(z,1),z.m(He.parentNode,He));let rl=v;v=Sl(e),v!==rl&&(sl(),M(Ee[rl],1,1,()=>{Ee[rl]=null}),ll(),X=Ee[v],X||(X=Ee[v]=Yl[v](e),X.c()),p(X,1),X.m(qe.parentNode,qe));const Al={};t&2&&(Al.$$scope={dirty:t,ctx:e}),Y.$set(Al)},i(e){tl||(p(u.$$.fragment,e),p(Q.$$.fragment,e),p(G.$$.fragment,e),p(I),p(S.$$.fragment,e),p(F.$$.fragment,e),p(H.$$.fragment,e),p(D.$$.fragment,e),p(L.$$.fragment,e),p(K.$$.fragment,e),p(O.$$.fragment,e),p(te.$$.fragment,e),p(le.$$.fragment,e),p(ae.$$.fragment,e),p(ie.$$.fragment,e),p(re.$$.fragment,e),p(ue.$$.fragment,e),p(pe.$$.fragment,e),p(oe.$$.fragment,e),p(W.$$.fragment,e),p(Ue.$$.fragment,e),p(Je.$$.fragment,e),p(be.$$.fragment,e),p(Te.$$.fragment,e),p(he.$$.fragment,e),p(x),p(Qe.$$.fragment,e),p(z),p(Ce.$$.fragment,e),p($e.$$.fragment,e),p(X),p(Ne.$$.fragment,e),p(Be.$$.fragment,e),p(ve.$$.fragment,e),p(Xe.$$.fragment,e),p(Y.$$.fragment,e),p(We.$$.fragment,e),tl=!0)},o(e){M(u.$$.fragment,e),M(Q.$$.fragment,e),M(G.$$.fragment,e),M(I),M(S.$$.fragment,e),M(F.$$.fragment,e),M(H.$$.fragment,e),M(D.$$.fragment,e),M(L.$$.fragment,e),M(K.$$.fragment,e),M(O.$$.fragment,e),M(te.$$.fragment,e),M(le.$$.fragment,e),M(ae.$$.fragment,e),M(ie.$$.fragment,e),M(re.$$.fragment,e),M(ue.$$.fragment,e),M(pe.$$.fragment,e),M(oe.$$.fragment,e),M(W.$$.fragment,e),M(Ue.$$.fragment,e),M(Je.$$.fragment,e),M(be.$$.fragment,e),M(Te.$$.fragment,e),M(he.$$.fragment,e),M(x),M(Qe.$$.fragment,e),M(z),M(Ce.$$.fragment,e),M($e.$$.fragment,e),M(X),M(Ne.$$.fragment,e),M(Be.$$.fragment,e),M(ve.$$.fragment,e),M(Xe.$$.fragment,e),M(Y.$$.fragment,e),M(We.$$.fragment,e),tl=!1},d(e){e&&(l(o),l(n),l(h),l(d),l(b),l(k),l(C),l(R),l(g),l(Ke),l(Oe),l(E),l(et),l(A),l(tt),l(V),l(lt),l(st),l(q),l(at),l(nt),l(it),l(P),l(rt),l(ct),l(ut),l(ee),l(Mt),l(pt),l(ot),l(se),l(dt),l(mt),l(ne),l(Ut),l(yt),l(Jt),l(ce),l(bt),l(ft),l(_),l(Tt),l(Me),l(jt),l(ht),l(wt),l(de),l(gt),l(Qt),l(me),l(Zt),l(Gt),l(ye),l(Ct),l(It),l(kt),l(fe),l($t),l(Rt),l(je),l(_t),l(Nt),l(we),l(xt),l(Ae),l(ge),l(Bt),l(zt),l(Ze),l(vt),l(He),l(Ge),l(Xt),l(Vt),l(Ie),l(Wt),l(ke),l(Yt),l(St),l(Re),l(Ft),l(qe),l(_e),l(Et),l(At),l(xe),l(Ht),l(qt),l(ze),l(Dt),l(Lt),l(Pt),l(Ve),l(Kt),l(Ot),l(el),l(De)),l(a),J(u,e),J(Q,e),J(G,e),Ye[$].d(e),J(S,e),J(F,e),J(H,e),J(D,e),J(L,e),J(K,e),J(O,e),J(te,e),J(le,e),J(ae,e),J(ie,e),J(re,e),J(ue,e),J(pe,e),J(oe,e),J(W,e),J(Ue,e),J(Je,e),J(be,e),J(Te,e),J(he,e),Se[N].d(e),J(Qe,e),Fe[B].d(e),J(Ce,e),J($e,e),Ee[v].d(e),J(Ne,e),J(Be,e),J(ve,e),J(Xe,e),J(Y,e),J(We,e)}}}const bs='{"title":"Căutare semantică cu FAISS","local":"semantic-search-with-faiss","sections":[{"title":"Utilizarea embeddings pentru căutare semantică","local":"using-embeddings-for-semantic-search","sections":[],"depth":2},{"title":"Încărcarea și pregătirea datasetului","local":"loading-and-preparing-the-dataset","sections":[],"depth":2},{"title":"Crearea embeddings-urilor de text","local":"creating-text-embeddings","sections":[],"depth":2},{"title":"Utilizarea FAISS pentru căutare de similaritate eficientă","local":"using-faiss-for-efficient-similarity-search","sections":[],"depth":2}],"depth":1}';function fs(Z,a,o){let n="pt";return Kl(()=>{const h=new URLSearchParams(window.location.search);o(0,n=h.get("fw")||"pt")}),[n]}class Cs extends Ol{constructor(a){super(),es(this,a,fs,Js,Pl,{})}}export{Cs as component};
