import{s as He,n as je,o as Ze}from"../chunks/scheduler.12fdeddc.js";import{S as Je,i as Le,g as i,s as a,r as c,A as Ge,h as r,f as n,c as l,j as ke,u as d,x as o,k as R,y as Ne,a as s,v as p,d as f,t as u,w as g}from"../chunks/index.88dae322.js";import{C as fe}from"../chunks/CodeBlock.8e54a086.js";import{H as z,E as Ve}from"../chunks/getInferenceSnippets.00466244.js";function Se(ue){let m,E,W,Y,M,X,w,ge="<code>sentence-transformers</code> is a library that provides easy methods to compute embeddings (dense vector representations) for sentences, paragraphs and images. Texts are embedded in a vector space such that similar text is close, which enables applications such as semantic search, clustering, and retrieval.",B,U,P,$,he='You can find over 500 hundred <code>sentence-transformer</code> models by filtering at the left of the <a href="https://huggingface.co/models?library=sentence-transformers&amp;sort=downloads" rel="nofollow">models page</a>. Most of these models support different tasks, such as doing <a href="https://huggingface.co/models?library=sentence-transformers&amp;pipeline_tag=feature-extraction&amp;sort=downloads" rel="nofollow"><code>feature-extraction</code></a> to generate the embedding, and <a href="https://huggingface.co/models?library=sentence-transformers&amp;pipeline_tag=sentence-similarity&amp;sort=downloads" rel="nofollow"><code>sentence-similarity</code></a> as a way to determine how similar is a given sentence to other. You can also find an overview of the official pre-trained models in <a href="https://www.sbert.net/docs/pretrained_models.html" rel="nofollow">the official docs</a>.',Q,v,ye="All models on the Hub come up with features:",F,C,be="<li>An automatically generated model card with a description, example code snippets, architecture overview, and more.</li> <li>Metadata tags that help for discoverability and contain information such as license.</li> <li>An interactive widget you can use to play out with the model directly in the browser.</li> <li>An Inference API that allows to make inference requests.</li>",q,h,Me='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_widget.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_widget-dark.png"/>',A,_,K,x,we="The pre-trained models on the Hub can be loaded with a single line of code",D,T,O,k,Ue="Here is an example that encodes sentences and then computes the distance between them for doing semantic search.",ee,H,te,j,$e="If you want to see how to load a specific model, you can click <code>Use in sentence-transformers</code> and you will be given a working snippet that you can load it!",ne,y,ve='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_snippet1.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_snippet1-dark.png"/>',se,b,Ce='<img class="block dark:hidden" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_snippet2.png"/> <img class="hidden dark:block" src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/libraries-sentence_transformers_snippet2-dark.png"/>',ae,Z,le,J,_e="You can share your Sentence Transformers by using the <code>save_to_hub</code> method from a trained model.",ie,L,re,G,xe='This command creates a repository with an automatically generated model card, an inference widget, example code snippets, and more! <a href="https://huggingface.co/osanseviero/my_new_model" rel="nofollow">Here</a> is an example.',oe,N,me,V,Te='<li>Sentence Transformers <a href="https://github.com/UKPLab/sentence-transformers" rel="nofollow">library</a>.</li> <li>Sentence Transformers <a href="https://www.sbert.net/" rel="nofollow">docs</a>.</li> <li>Integration with Hub <a href="https://huggingface.co/blog/sentence-transformers-in-the-hub" rel="nofollow">announcement</a>.</li>',ce,S,de,I,pe;return M=new z({props:{title:"Using Sentence Transformers at Hugging Face",local:"using-sentence-transformers-at-hugging-face",headingTag:"h1"}}),U=new z({props:{title:"Exploring sentence-transformers in the Hub",local:"exploring-sentence-transformers-in-the-hub",headingTag:"h2"}}),_=new z({props:{title:"Using existing models",local:"using-existing-models",headingTag:"h2"}}),T=new fe({props:{code:"ZnJvbSUyMHNlbnRlbmNlX3RyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlbnRlbmNlVHJhbnNmb3JtZXIlMEFtb2RlbCUyMCUzRCUyMFNlbnRlbmNlVHJhbnNmb3JtZXIoJ21vZGVsX25hbWUnKQ==",highlighted:`<span class="hljs-keyword">from</span> sentence_transformers <span class="hljs-keyword">import</span> SentenceTransformer
model = SentenceTransformer(<span class="hljs-string">&#x27;model_name&#x27;</span>)`,wrap:!1}}),H=new fe({props:{code:"ZnJvbSUyMHNlbnRlbmNlX3RyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlbnRlbmNlVHJhbnNmb3JtZXIlMkMlMjB1dGlsJTBBbW9kZWwlMjAlM0QlMjBTZW50ZW5jZVRyYW5zZm9ybWVyKCdtdWx0aS1xYS1NaW5pTE0tTDYtY29zLXYxJyklMEElMEFxdWVyeV9lbWJlZGRpbmclMjAlM0QlMjBtb2RlbC5lbmNvZGUoJ0hvdyUyMGJpZyUyMGlzJTIwTG9uZG9uJyklMEFwYXNzYWdlX2VtYmVkZGluZyUyMCUzRCUyMG1vZGVsLmVuY29kZSglNUInTG9uZG9uJTIwaGFzJTIwOSUyQzc4NyUyQzQyNiUyMGluaGFiaXRhbnRzJTIwYXQlMjB0aGUlMjAyMDExJTIwY2Vuc3VzJyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCdMb25kb24lMjBpcyUyMGtub3duJTIwZm9yJTIwaXRzJTIwZmluYWNpYWwlMjBkaXN0cmljdCclNUQpJTBBJTBBcHJpbnQoJTIyU2ltaWxhcml0eSUzQSUyMiUyQyUyMHV0aWwuZG90X3Njb3JlKHF1ZXJ5X2VtYmVkZGluZyUyQyUyMHBhc3NhZ2VfZW1iZWRkaW5nKSk=",highlighted:`<span class="hljs-keyword">from</span> sentence_transformers <span class="hljs-keyword">import</span> SentenceTransformer, util
model = SentenceTransformer(<span class="hljs-string">&#x27;multi-qa-MiniLM-L6-cos-v1&#x27;</span>)

query_embedding = model.encode(<span class="hljs-string">&#x27;How big is London&#x27;</span>)
passage_embedding = model.encode([<span class="hljs-string">&#x27;London has 9,787,426 inhabitants at the 2011 census&#x27;</span>,
                                  <span class="hljs-string">&#x27;London is known for its finacial district&#x27;</span>])

<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Similarity:&quot;</span>, util.dot_score(query_embedding, passage_embedding))`,wrap:!1}}),Z=new z({props:{title:"Sharing your models",local:"sharing-your-models",headingTag:"h2"}}),L=new fe({props:{code:"ZnJvbSUyMHNlbnRlbmNlX3RyYW5zZm9ybWVycyUyMGltcG9ydCUyMFNlbnRlbmNlVHJhbnNmb3JtZXIlMEElMEElMjMlMjBMb2FkJTIwb3IlMjB0cmFpbiUyMGElMjBtb2RlbCUwQW1vZGVsLnNhdmVfdG9faHViKCUyMm15X25ld19tb2RlbCUyMik=",highlighted:`<span class="hljs-keyword">from</span> sentence_transformers <span class="hljs-keyword">import</span> SentenceTransformer

<span class="hljs-comment"># Load or train a model</span>
model.save_to_hub(<span class="hljs-string">&quot;my_new_model&quot;</span>)`,wrap:!1}}),N=new z({props:{title:"Additional resources",local:"additional-resources",headingTag:"h2"}}),S=new Ve({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/sentence-transformers.md"}}),{c(){m=i("meta"),E=a(),W=i("p"),Y=a(),c(M.$$.fragment),X=a(),w=i("p"),w.innerHTML=ge,B=a(),c(U.$$.fragment),P=a(),$=i("p"),$.innerHTML=he,Q=a(),v=i("p"),v.textContent=ye,F=a(),C=i("ol"),C.innerHTML=be,q=a(),h=i("div"),h.innerHTML=Me,A=a(),c(_.$$.fragment),K=a(),x=i("p"),x.textContent=we,D=a(),c(T.$$.fragment),O=a(),k=i("p"),k.textContent=Ue,ee=a(),c(H.$$.fragment),te=a(),j=i("p"),j.innerHTML=$e,ne=a(),y=i("div"),y.innerHTML=ve,se=a(),b=i("div"),b.innerHTML=Ce,ae=a(),c(Z.$$.fragment),le=a(),J=i("p"),J.innerHTML=_e,ie=a(),c(L.$$.fragment),re=a(),G=i("p"),G.innerHTML=xe,oe=a(),c(N.$$.fragment),me=a(),V=i("ul"),V.innerHTML=Te,ce=a(),c(S.$$.fragment),de=a(),I=i("p"),this.h()},l(e){const t=Ge("svelte-u9bgzb",document.head);m=r(t,"META",{name:!0,content:!0}),t.forEach(n),E=l(e),W=r(e,"P",{}),ke(W).forEach(n),Y=l(e),d(M.$$.fragment,e),X=l(e),w=r(e,"P",{"data-svelte-h":!0}),o(w)!=="svelte-1wv75gz"&&(w.innerHTML=ge),B=l(e),d(U.$$.fragment,e),P=l(e),$=r(e,"P",{"data-svelte-h":!0}),o($)!=="svelte-1kwq3q9"&&($.innerHTML=he),Q=l(e),v=r(e,"P",{"data-svelte-h":!0}),o(v)!=="svelte-1fjy6ak"&&(v.textContent=ye),F=l(e),C=r(e,"OL",{"data-svelte-h":!0}),o(C)!=="svelte-ps2y1k"&&(C.innerHTML=be),q=l(e),h=r(e,"DIV",{class:!0,"data-svelte-h":!0}),o(h)!=="svelte-6f1q4b"&&(h.innerHTML=Me),A=l(e),d(_.$$.fragment,e),K=l(e),x=r(e,"P",{"data-svelte-h":!0}),o(x)!=="svelte-17convi"&&(x.textContent=we),D=l(e),d(T.$$.fragment,e),O=l(e),k=r(e,"P",{"data-svelte-h":!0}),o(k)!=="svelte-1coip9"&&(k.textContent=Ue),ee=l(e),d(H.$$.fragment,e),te=l(e),j=r(e,"P",{"data-svelte-h":!0}),o(j)!=="svelte-j79ve8"&&(j.innerHTML=$e),ne=l(e),y=r(e,"DIV",{class:!0,"data-svelte-h":!0}),o(y)!=="svelte-1dfa4gr"&&(y.innerHTML=ve),se=l(e),b=r(e,"DIV",{class:!0,"data-svelte-h":!0}),o(b)!=="svelte-1pl1odp"&&(b.innerHTML=Ce),ae=l(e),d(Z.$$.fragment,e),le=l(e),J=r(e,"P",{"data-svelte-h":!0}),o(J)!=="svelte-17y3b3y"&&(J.innerHTML=_e),ie=l(e),d(L.$$.fragment,e),re=l(e),G=r(e,"P",{"data-svelte-h":!0}),o(G)!=="svelte-1jzzki7"&&(G.innerHTML=xe),oe=l(e),d(N.$$.fragment,e),me=l(e),V=r(e,"UL",{"data-svelte-h":!0}),o(V)!=="svelte-1gh4ozl"&&(V.innerHTML=Te),ce=l(e),d(S.$$.fragment,e),de=l(e),I=r(e,"P",{}),ke(I).forEach(n),this.h()},h(){R(m,"name","hf:doc:metadata"),R(m,"content",We),R(h,"class","flex justify-center"),R(y,"class","flex justify-center"),R(b,"class","flex justify-center")},m(e,t){Ne(document.head,m),s(e,E,t),s(e,W,t),s(e,Y,t),p(M,e,t),s(e,X,t),s(e,w,t),s(e,B,t),p(U,e,t),s(e,P,t),s(e,$,t),s(e,Q,t),s(e,v,t),s(e,F,t),s(e,C,t),s(e,q,t),s(e,h,t),s(e,A,t),p(_,e,t),s(e,K,t),s(e,x,t),s(e,D,t),p(T,e,t),s(e,O,t),s(e,k,t),s(e,ee,t),p(H,e,t),s(e,te,t),s(e,j,t),s(e,ne,t),s(e,y,t),s(e,se,t),s(e,b,t),s(e,ae,t),p(Z,e,t),s(e,le,t),s(e,J,t),s(e,ie,t),p(L,e,t),s(e,re,t),s(e,G,t),s(e,oe,t),p(N,e,t),s(e,me,t),s(e,V,t),s(e,ce,t),p(S,e,t),s(e,de,t),s(e,I,t),pe=!0},p:je,i(e){pe||(f(M.$$.fragment,e),f(U.$$.fragment,e),f(_.$$.fragment,e),f(T.$$.fragment,e),f(H.$$.fragment,e),f(Z.$$.fragment,e),f(L.$$.fragment,e),f(N.$$.fragment,e),f(S.$$.fragment,e),pe=!0)},o(e){u(M.$$.fragment,e),u(U.$$.fragment,e),u(_.$$.fragment,e),u(T.$$.fragment,e),u(H.$$.fragment,e),u(Z.$$.fragment,e),u(L.$$.fragment,e),u(N.$$.fragment,e),u(S.$$.fragment,e),pe=!1},d(e){e&&(n(E),n(W),n(Y),n(X),n(w),n(B),n(P),n($),n(Q),n(v),n(F),n(C),n(q),n(h),n(A),n(K),n(x),n(D),n(O),n(k),n(ee),n(te),n(j),n(ne),n(y),n(se),n(b),n(ae),n(le),n(J),n(ie),n(re),n(G),n(oe),n(me),n(V),n(ce),n(de),n(I)),n(m),g(M,e),g(U,e),g(_,e),g(T,e),g(H,e),g(Z,e),g(L,e),g(N,e),g(S,e)}}}const We='{"title":"Using Sentence Transformers at Hugging Face","local":"using-sentence-transformers-at-hugging-face","sections":[{"title":"Exploring sentence-transformers in the Hub","local":"exploring-sentence-transformers-in-the-hub","sections":[],"depth":2},{"title":"Using existing models","local":"using-existing-models","sections":[],"depth":2},{"title":"Sharing your models","local":"sharing-your-models","sections":[],"depth":2},{"title":"Additional resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function Ie(ue){return Ze(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xe extends Je{constructor(m){super(),Le(this,m,Ie,Se,He,{})}}export{Xe as component};
