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