import{s as Gt,n as Ct,o as Ht}from"../chunks/scheduler.d6170356.js";import{S as kt,i as Ut,g as s,s as a,r as p,A as Wt,h as o,f as i,c as n,j as Jt,u as m,x as r,k as xt,y as jt,a as l,v as h,d,t as c,w as g}from"../chunks/index.fcd4cc08.js";import{C as Z}from"../chunks/CodeBlock.7b16bdef.js";import{H as L}from"../chunks/Heading.8660bd0e.js";function It(ut){let u,P,S,N,f,Y,T,ft='<a href="https://github.com/MaartenGr/BERTopic" rel="nofollow">BERTopic</a> is a topic modeling framework that leverages 🤗 transformers and c-TF-IDF to create dense clusters allowing for easily interpretable topics whilst keeping important words in the topic descriptions.',z,b,Tt="BERTopic supports all kinds of topic modeling techniques:",Q,w,bt='<tbody><tr><td><a href="https://maartengr.github.io/BERTopic/getting_started/guided/guided.html">Guided</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/supervised/supervised.html">Supervised</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/semisupervised/semisupervised.html">Semi-supervised</a></td></tr> <tr><td><a href="https://maartengr.github.io/BERTopic/getting_started/manual/manual.html">Manual</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/distribution/distribution.html">Multi-topic distributions</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/hierarchicaltopics/hierarchicaltopics.html">Hierarchical</a></td></tr> <tr><td><a href="https://maartengr.github.io/BERTopic/getting_started/topicsperclass/topicsperclass.html">Class-based</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/topicsovertime/topicsovertime.html">Dynamic</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/online/online.html">Online/Incremental</a></td></tr> <tr><td><a href="https://maartengr.github.io/BERTopic/getting_started/multimodal/multimodal.html">Multimodal</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/multiaspect/multiaspect.html">Multi-aspect</a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/representation/llm.html">Text Generation/LLM</a></td></tr> <tr><td><a href="https://maartengr.github.io/BERTopic/getting_started/zeroshot/zeroshot.html">Zero-shot <b>(new!)</b></a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/merge/merge.html">Merge Models <b>(new!)</b></a></td> <td><a href="https://maartengr.github.io/BERTopic/getting_started/seed_words/seed_words.html">Seed Words <b>(new!)</b></a></td></tr></tbody>',X,$,q,M,wt='You can find BERTopic models by filtering at the left of the <a href="https://huggingface.co/models?library=bertopic&amp;sort=trending" rel="nofollow">models page</a>.',A,_,$t='BERTopic models hosted on the Hub have a model card with useful information about the models. Thanks to BERTopic Hugging Face Hub integration, you can load BERTopic models with a few lines of code. You can also deploy these models using <a href="https://huggingface.co/inference-endpoints" rel="nofollow">Inference Endpoints</a>.',K,B,D,E,Mt=`To get started, you can follow the <a href="https://github.com/MaartenGr/BERTopic#installation" rel="nofollow">BERTopic installation guide</a>.
You can also use the following one-line install through pip:`,O,R,tt,y,et,v,_t="All BERTopic models can easily be loaded from the Hub:",it,J,lt,x,Bt="Once loaded, you can use BERTopic’s features to predict the topics for new instances:",at,G,nt,C,Et="Which gives us the following topic:",st,H,ot,k,rt,U,Rt="When you have created a BERTopic model, you can easily share it with others through the Hugging Face Hub. To do so, we can make use of the <code>push_to_hf_hub</code> function that allows us to directly push the model to the Hugging Face Hub:",pt,W,mt,j,yt="Note that the saved model does not include the dimensionality reduction and clustering algorithms. Those are removed since they are only necessary to train the model and find relevant topics. Inference is done through a straightforward cosine similarity between the topic and document embeddings. This not only speeds up the model but allows us to have a tiny BERTopic model that we can work with.",ht,I,dt,F,vt='<li><a href="https://github.com/MaartenGr/BERTopic" rel="nofollow">BERTopic repository</a></li> <li><a href="https://maartengr.github.io/BERTopic/" rel="nofollow">BERTopic docs</a></li> <li><a href="https://huggingface.co/models?library=bertopic&amp;sort=trending" rel="nofollow">BERTopic models in the Hub</a></li>',ct,V,gt;return f=new L({props:{title:"Using BERTopic at Hugging Face",local:"using-bertopic-at-hugging-face",headingTag:"h1"}}),$=new L({props:{title:"Exploring BERTopic on the Hub",local:"exploring-bertopic-on-the-hub",headingTag:"h2"}}),B=new L({props:{title:"Installation",local:"installation",headingTag:"h2"}}),R=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJlcnRvcGlj",highlighted:"pip install bertopic",wrap:!1}}),y=new L({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),J=new Z({props:{code:"ZnJvbSUyMGJlcnRvcGljJTIwaW1wb3J0JTIwQkVSVG9waWMlMEF0b3BpY19tb2RlbCUyMCUzRCUyMEJFUlRvcGljLmxvYWQoJTIyTWFhcnRlbkdyJTJGQkVSVG9waWNfV2lraXBlZGlhJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> bertopic <span class="hljs-keyword">import</span> BERTopic
topic_model = BERTopic.load(<span class="hljs-string">&quot;MaartenGr/BERTopic_Wikipedia&quot;</span>)`,wrap:!1}}),G=new Z({props:{code:"dG9waWMlMkMlMjBwcm9iJTIwJTNEJTIwdG9waWNfbW9kZWwudHJhbnNmb3JtKCUyMlRoaXMlMjBpcyUyMGFuJTIwaW5jcmVkaWJsZSUyMG1vdmllISUyMiklMEF0b3BpY19tb2RlbC50b3BpY19sYWJlbHNfJTVCdG9waWMlNUQ=",highlighted:`topic, prob = topic_model.transform(<span class="hljs-string">&quot;This is an incredible movie!&quot;</span>)
topic_model.topic_labels_[topic]`,wrap:!1}}),H=new Z({props:{code:"NjRfcmF0aW5nX3JhdGVkX2NpbmVtYXRvZ3JhcGh5X2ZpbG0=",highlighted:"64_rating_rated_cinematography_film",wrap:!1}}),k=new L({props:{title:"Sharing Models",local:"sharing-models",headingTag:"h2"}}),W=new Z({props:{code:"ZnJvbSUyMGJlcnRvcGljJTIwaW1wb3J0JTIwQkVSVG9waWMlMEElMEElMjMlMjBUcmFpbiUyMG1vZGVsJTBBdG9waWNfbW9kZWwlMjAlM0QlMjBCRVJUb3BpYygpLmZpdChteV9kb2NzKSUwQSUwQSUyMyUyMFB1c2glMjB0byUyMEh1Z2dpbmdGYWNlJTIwSHViJTBBdG9waWNfbW9kZWwucHVzaF90b19oZl9odWIoJTBBJTIwJTIwJTIwJTIwcmVwb19pZCUzRCUyMk1hYXJ0ZW5HciUyRkJFUlRvcGljX0FyWGl2JTIyJTJDJTBBJTIwJTIwJTIwJTIwc2F2ZV9jdGZpZGYlM0RUcnVlJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> bertopic <span class="hljs-keyword">import</span> BERTopic

<span class="hljs-comment"># Train model</span>
topic_model = BERTopic().fit(my_docs)

<span class="hljs-comment"># Push to HuggingFace Hub</span>
topic_model.push_to_hf_hub(
    repo_id=<span class="hljs-string">&quot;MaartenGr/BERTopic_ArXiv&quot;</span>,
    save_ctfidf=<span class="hljs-literal">True</span>
)`,wrap:!1}}),I=new L({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),{c(){u=s("meta"),P=a(),S=s("p"),N=a(),p(f.$$.fragment),Y=a(),T=s("p"),T.innerHTML=ft,z=a(),b=s("p"),b.textContent=Tt,Q=a(),w=s("table"),w.innerHTML=bt,X=a(),p($.$$.fragment),q=a(),M=s("p"),M.innerHTML=wt,A=a(),_=s("p"),_.innerHTML=$t,K=a(),p(B.$$.fragment),D=a(),E=s("p"),E.innerHTML=Mt,O=a(),p(R.$$.fragment),tt=a(),p(y.$$.fragment),et=a(),v=s("p"),v.textContent=_t,it=a(),p(J.$$.fragment),lt=a(),x=s("p"),x.textContent=Bt,at=a(),p(G.$$.fragment),nt=a(),C=s("p"),C.textContent=Et,st=a(),p(H.$$.fragment),ot=a(),p(k.$$.fragment),rt=a(),U=s("p"),U.innerHTML=Rt,pt=a(),p(W.$$.fragment),mt=a(),j=s("p"),j.textContent=yt,ht=a(),p(I.$$.fragment),dt=a(),F=s("ul"),F.innerHTML=vt,ct=a(),V=s("p"),this.h()},l(t){const e=Wt("svelte-u9bgzb",document.head);u=o(e,"META",{name:!0,content:!0}),e.forEach(i),P=n(t),S=o(t,"P",{}),Jt(S).forEach(i),N=n(t),m(f.$$.fragment,t),Y=n(t),T=o(t,"P",{"data-svelte-h":!0}),r(T)!=="svelte-1vac4fj"&&(T.innerHTML=ft),z=n(t),b=o(t,"P",{"data-svelte-h":!0}),r(b)!=="svelte-2lpmi"&&(b.textContent=Tt),Q=n(t),w=o(t,"TABLE",{"data-svelte-h":!0}),r(w)!=="svelte-f8lag4"&&(w.innerHTML=bt),X=n(t),m($.$$.fragment,t),q=n(t),M=o(t,"P",{"data-svelte-h":!0}),r(M)!=="svelte-h54dmr"&&(M.innerHTML=wt),A=n(t),_=o(t,"P",{"data-svelte-h":!0}),r(_)!=="svelte-19z0354"&&(_.innerHTML=$t),K=n(t),m(B.$$.fragment,t),D=n(t),E=o(t,"P",{"data-svelte-h":!0}),r(E)!=="svelte-11uhnkk"&&(E.innerHTML=Mt),O=n(t),m(R.$$.fragment,t),tt=n(t),m(y.$$.fragment,t),et=n(t),v=o(t,"P",{"data-svelte-h":!0}),r(v)!=="svelte-1hiuiu0"&&(v.textContent=_t),it=n(t),m(J.$$.fragment,t),lt=n(t),x=o(t,"P",{"data-svelte-h":!0}),r(x)!=="svelte-1jlzyo7"&&(x.textContent=Bt),at=n(t),m(G.$$.fragment,t),nt=n(t),C=o(t,"P",{"data-svelte-h":!0}),r(C)!=="svelte-11mda4g"&&(C.textContent=Et),st=n(t),m(H.$$.fragment,t),ot=n(t),m(k.$$.fragment,t),rt=n(t),U=o(t,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1l3xl6p"&&(U.innerHTML=Rt),pt=n(t),m(W.$$.fragment,t),mt=n(t),j=o(t,"P",{"data-svelte-h":!0}),r(j)!=="svelte-4orzxy"&&(j.textContent=yt),ht=n(t),m(I.$$.fragment,t),dt=n(t),F=o(t,"UL",{"data-svelte-h":!0}),r(F)!=="svelte-arbtte"&&(F.innerHTML=vt),ct=n(t),V=o(t,"P",{}),Jt(V).forEach(i),this.h()},h(){xt(u,"name","hf:doc:metadata"),xt(u,"content",Ft)},m(t,e){jt(document.head,u),l(t,P,e),l(t,S,e),l(t,N,e),h(f,t,e),l(t,Y,e),l(t,T,e),l(t,z,e),l(t,b,e),l(t,Q,e),l(t,w,e),l(t,X,e),h($,t,e),l(t,q,e),l(t,M,e),l(t,A,e),l(t,_,e),l(t,K,e),h(B,t,e),l(t,D,e),l(t,E,e),l(t,O,e),h(R,t,e),l(t,tt,e),h(y,t,e),l(t,et,e),l(t,v,e),l(t,it,e),h(J,t,e),l(t,lt,e),l(t,x,e),l(t,at,e),h(G,t,e),l(t,nt,e),l(t,C,e),l(t,st,e),h(H,t,e),l(t,ot,e),h(k,t,e),l(t,rt,e),l(t,U,e),l(t,pt,e),h(W,t,e),l(t,mt,e),l(t,j,e),l(t,ht,e),h(I,t,e),l(t,dt,e),l(t,F,e),l(t,ct,e),l(t,V,e),gt=!0},p:Ct,i(t){gt||(d(f.$$.fragment,t),d($.$$.fragment,t),d(B.$$.fragment,t),d(R.$$.fragment,t),d(y.$$.fragment,t),d(J.$$.fragment,t),d(G.$$.fragment,t),d(H.$$.fragment,t),d(k.$$.fragment,t),d(W.$$.fragment,t),d(I.$$.fragment,t),gt=!0)},o(t){c(f.$$.fragment,t),c($.$$.fragment,t),c(B.$$.fragment,t),c(R.$$.fragment,t),c(y.$$.fragment,t),c(J.$$.fragment,t),c(G.$$.fragment,t),c(H.$$.fragment,t),c(k.$$.fragment,t),c(W.$$.fragment,t),c(I.$$.fragment,t),gt=!1},d(t){t&&(i(P),i(S),i(N),i(Y),i(T),i(z),i(b),i(Q),i(w),i(X),i(q),i(M),i(A),i(_),i(K),i(D),i(E),i(O),i(tt),i(et),i(v),i(it),i(lt),i(x),i(at),i(nt),i(C),i(st),i(ot),i(rt),i(U),i(pt),i(mt),i(j),i(ht),i(dt),i(F),i(ct),i(V)),i(u),g(f,t),g($,t),g(B,t),g(R,t),g(y,t),g(J,t),g(G,t),g(H,t),g(k,t),g(W,t),g(I,t)}}}const Ft='{"title":"Using BERTopic at Hugging Face","local":"using-bertopic-at-hugging-face","sections":[{"title":"Exploring BERTopic on the Hub","local":"exploring-bertopic-on-the-hub","sections":[],"depth":2},{"title":"Installation","local":"installation","sections":[],"depth":2},{"title":"Using Existing Models","local":"using-existing-models","sections":[],"depth":2},{"title":"Sharing Models","local":"sharing-models","sections":[],"depth":2},{"title":"Additional Resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function Lt(ut){return Ht(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nt extends kt{constructor(u){super(),Ut(this,u,Lt,It,Gt,{})}}export{Nt as component};
