import{s as Ht,n as kt,o as Ut}from"../chunks/scheduler.12fdeddc.js";import{S as Wt,i as jt,g as s,s as a,r,A as It,h as o,f as i,c as n,j as xt,u as p,x as m,k as Ct,y as Ft,a as l,v as h,d,t as g,w as c}from"../chunks/index.88dae322.js";import{C as P}from"../chunks/CodeBlock.8e54a086.js";import{H as S,E as Lt}from"../chunks/getInferenceSnippets.00466244.js";function St(bt){let u,N,V,Y,f,z,b,Tt='<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.',Q,T,$t="BERTopic supports all kinds of topic modeling techniques:",X,$,wt='<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>',q,w,A,M,Mt='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>.',K,_,_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>.',D,B,O,E,Bt=`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:`,tt,R,et,y,it,v,Et="All BERTopic models can easily be loaded from the Hub:",lt,J,at,G,Rt="Once loaded, you can use BERTopic’s features to predict the topics for new instances:",nt,x,st,C,yt="Which gives us the following topic:",ot,H,rt,k,pt,U,vt="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:",mt,W,ht,j,Jt="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.",dt,I,gt,F,Gt='<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,L,ut,Z,ft;return f=new S({props:{title:"Using BERTopic at Hugging Face",local:"using-bertopic-at-hugging-face",headingTag:"h1"}}),w=new S({props:{title:"Exploring BERTopic on the Hub",local:"exploring-bertopic-on-the-hub",headingTag:"h2"}}),B=new S({props:{title:"Installation",local:"installation",headingTag:"h2"}}),R=new P({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJlcnRvcGlj",highlighted:"pip install bertopic",wrap:!1}}),y=new S({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),J=new P({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}}),x=new P({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 P({props:{code:"NjRfcmF0aW5nX3JhdGVkX2NpbmVtYXRvZ3JhcGh5X2ZpbG0=",highlighted:"64_rating_rated_cinematography_film",wrap:!1}}),k=new S({props:{title:"Sharing Models",local:"sharing-models",headingTag:"h2"}}),W=new P({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 S({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),L=new Lt({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/bertopic.md"}}),{c(){u=s("meta"),N=a(),V=s("p"),Y=a(),r(f.$$.fragment),z=a(),b=s("p"),b.innerHTML=Tt,Q=a(),T=s("p"),T.textContent=$t,X=a(),$=s("table"),$.innerHTML=wt,q=a(),r(w.$$.fragment),A=a(),M=s("p"),M.innerHTML=Mt,K=a(),_=s("p"),_.innerHTML=_t,D=a(),r(B.$$.fragment),O=a(),E=s("p"),E.innerHTML=Bt,tt=a(),r(R.$$.fragment),et=a(),r(y.$$.fragment),it=a(),v=s("p"),v.textContent=Et,lt=a(),r(J.$$.fragment),at=a(),G=s("p"),G.textContent=Rt,nt=a(),r(x.$$.fragment),st=a(),C=s("p"),C.textContent=yt,ot=a(),r(H.$$.fragment),rt=a(),r(k.$$.fragment),pt=a(),U=s("p"),U.innerHTML=vt,mt=a(),r(W.$$.fragment),ht=a(),j=s("p"),j.textContent=Jt,dt=a(),r(I.$$.fragment),gt=a(),F=s("ul"),F.innerHTML=Gt,ct=a(),r(L.$$.fragment),ut=a(),Z=s("p"),this.h()},l(t){const e=It("svelte-u9bgzb",document.head);u=o(e,"META",{name:!0,content:!0}),e.forEach(i),N=n(t),V=o(t,"P",{}),xt(V).forEach(i),Y=n(t),p(f.$$.fragment,t),z=n(t),b=o(t,"P",{"data-svelte-h":!0}),m(b)!=="svelte-1vac4fj"&&(b.innerHTML=Tt),Q=n(t),T=o(t,"P",{"data-svelte-h":!0}),m(T)!=="svelte-2lpmi"&&(T.textContent=$t),X=n(t),$=o(t,"TABLE",{"data-svelte-h":!0}),m($)!=="svelte-f8lag4"&&($.innerHTML=wt),q=n(t),p(w.$$.fragment,t),A=n(t),M=o(t,"P",{"data-svelte-h":!0}),m(M)!=="svelte-h54dmr"&&(M.innerHTML=Mt),K=n(t),_=o(t,"P",{"data-svelte-h":!0}),m(_)!=="svelte-19z0354"&&(_.innerHTML=_t),D=n(t),p(B.$$.fragment,t),O=n(t),E=o(t,"P",{"data-svelte-h":!0}),m(E)!=="svelte-11uhnkk"&&(E.innerHTML=Bt),tt=n(t),p(R.$$.fragment,t),et=n(t),p(y.$$.fragment,t),it=n(t),v=o(t,"P",{"data-svelte-h":!0}),m(v)!=="svelte-1hiuiu0"&&(v.textContent=Et),lt=n(t),p(J.$$.fragment,t),at=n(t),G=o(t,"P",{"data-svelte-h":!0}),m(G)!=="svelte-1jlzyo7"&&(G.textContent=Rt),nt=n(t),p(x.$$.fragment,t),st=n(t),C=o(t,"P",{"data-svelte-h":!0}),m(C)!=="svelte-11mda4g"&&(C.textContent=yt),ot=n(t),p(H.$$.fragment,t),rt=n(t),p(k.$$.fragment,t),pt=n(t),U=o(t,"P",{"data-svelte-h":!0}),m(U)!=="svelte-1l3xl6p"&&(U.innerHTML=vt),mt=n(t),p(W.$$.fragment,t),ht=n(t),j=o(t,"P",{"data-svelte-h":!0}),m(j)!=="svelte-4orzxy"&&(j.textContent=Jt),dt=n(t),p(I.$$.fragment,t),gt=n(t),F=o(t,"UL",{"data-svelte-h":!0}),m(F)!=="svelte-arbtte"&&(F.innerHTML=Gt),ct=n(t),p(L.$$.fragment,t),ut=n(t),Z=o(t,"P",{}),xt(Z).forEach(i),this.h()},h(){Ct(u,"name","hf:doc:metadata"),Ct(u,"content",Vt)},m(t,e){Ft(document.head,u),l(t,N,e),l(t,V,e),l(t,Y,e),h(f,t,e),l(t,z,e),l(t,b,e),l(t,Q,e),l(t,T,e),l(t,X,e),l(t,$,e),l(t,q,e),h(w,t,e),l(t,A,e),l(t,M,e),l(t,K,e),l(t,_,e),l(t,D,e),h(B,t,e),l(t,O,e),l(t,E,e),l(t,tt,e),h(R,t,e),l(t,et,e),h(y,t,e),l(t,it,e),l(t,v,e),l(t,lt,e),h(J,t,e),l(t,at,e),l(t,G,e),l(t,nt,e),h(x,t,e),l(t,st,e),l(t,C,e),l(t,ot,e),h(H,t,e),l(t,rt,e),h(k,t,e),l(t,pt,e),l(t,U,e),l(t,mt,e),h(W,t,e),l(t,ht,e),l(t,j,e),l(t,dt,e),h(I,t,e),l(t,gt,e),l(t,F,e),l(t,ct,e),h(L,t,e),l(t,ut,e),l(t,Z,e),ft=!0},p:kt,i(t){ft||(d(f.$$.fragment,t),d(w.$$.fragment,t),d(B.$$.fragment,t),d(R.$$.fragment,t),d(y.$$.fragment,t),d(J.$$.fragment,t),d(x.$$.fragment,t),d(H.$$.fragment,t),d(k.$$.fragment,t),d(W.$$.fragment,t),d(I.$$.fragment,t),d(L.$$.fragment,t),ft=!0)},o(t){g(f.$$.fragment,t),g(w.$$.fragment,t),g(B.$$.fragment,t),g(R.$$.fragment,t),g(y.$$.fragment,t),g(J.$$.fragment,t),g(x.$$.fragment,t),g(H.$$.fragment,t),g(k.$$.fragment,t),g(W.$$.fragment,t),g(I.$$.fragment,t),g(L.$$.fragment,t),ft=!1},d(t){t&&(i(N),i(V),i(Y),i(z),i(b),i(Q),i(T),i(X),i($),i(q),i(A),i(M),i(K),i(_),i(D),i(O),i(E),i(tt),i(et),i(it),i(v),i(lt),i(at),i(G),i(nt),i(st),i(C),i(ot),i(rt),i(pt),i(U),i(mt),i(ht),i(j),i(dt),i(gt),i(F),i(ct),i(ut),i(Z)),i(u),c(f,t),c(w,t),c(B,t),c(R,t),c(y,t),c(J,t),c(x,t),c(H,t),c(k,t),c(W,t),c(I,t),c(L,t)}}}const Vt='{"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 Zt(bt){return Ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qt extends Wt{constructor(u){super(),jt(this,u,Zt,St,Ht,{})}}export{Qt as component};
