import{s as nt,n as it,o as at}from"../chunks/scheduler.9cda857a.js";import{S as st,i as ot,e as s,s as i,c as m,h as mt,a as o,d as l,b as a,f as tt,g as p,j as r,k as lt,l as pt,m as n,n as f,t as u,o as g,p as h}from"../chunks/index.f47f3121.js";import{C as rt}from"../chunks/CopyLLMTxtMenu.676ed699.js";import{C as M}from"../chunks/CodeBlock.24d62f98.js";import{H as D,E as ft}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.64d112fc.js";function ut(je){let $,ee,O,te,d,le,x,ne,w,Se='<a href="https://github.com/ml-explore/mlx" rel="nofollow">MLX</a> is a model training and serving framework for Apple silicon made by Apple Machine Learning Research.',ie,c,We="It comes with a variety of examples:",ae,y,Ee='<li><a href="https://github.com/ml-explore/mlx-lm/tree/main" rel="nofollow">Generate text with MLX-LM</a> and <a href="https://github.com/ml-explore/mlx-examples/tree/main/llms/gguf_llm" rel="nofollow">generating text with MLX-LM for models in GGUF format</a>.</li> <li>Large-scale text generation with <a href="https://github.com/ml-explore/mlx-examples/tree/main/llms/llama" rel="nofollow">LLaMA</a>.</li> <li>Fine-tuning with <a href="https://github.com/ml-explore/mlx-examples/tree/main/lora" rel="nofollow">LoRA</a>.</li> <li>Generating images with <a href="https://github.com/ml-explore/mlx-examples/tree/main/stable_diffusion" rel="nofollow">Stable Diffusion</a>.</li> <li>Speech recognition with <a href="https://github.com/ml-explore/mlx-examples/tree/main/whisper" rel="nofollow">OpenAI’s Whisper</a>.</li>',se,b,oe,L,Be=`You can find MLX models by filtering at the left of the <a href="https://huggingface.co/models?library=mlx&amp;sort=trending" rel="nofollow">models page</a>.
There’s also an open <a href="https://huggingface.co/mlx-community" rel="nofollow">MLX community</a> of contributors converting and publishing weights for MLX format.`,me,T,Ae="Thanks to MLX Hugging Face Hub integration, you can load MLX models with a few lines of code.",pe,C,re,U,Pe=`MLX comes as a standalone package, and there’s a subpackage called MLX-LM with Hugging Face integration for Large Language Models.
To install MLX-LM, you can use the following one-line install through <code>pip</code>:`,fe,v,ue,J,Ze='You can get more information about it <a href="https://github.com/ml-explore/mlx-lm/tree/main" rel="nofollow">here</a>.',ge,_,Ne="If you install <code>mlx-lm</code>, you don’t need to install <code>mlx</code>. If you don’t want to use <code>mlx-lm</code> but only MLX, you can install MLX itself as follows.",he,G,Ye="With <code>pip</code>:",$e,H,Me,I,Ve="With <code>conda</code>:",de,k,xe,F,we,X,ze="MLX-LM has useful utilities to generate text. The following line directly downloads and loads the model and starts generating text.",ce,R,ye,j,Qe="For a full list of generation options, run",be,S,Le,W,qe="You can also load a model and start generating text through Python like below:",Te,E,Ce,B,De="MLX-LM supports popular LLM architectures including LLaMA, Phi-2, Mistral, and Qwen. Models other than supported ones can easily be downloaded as follows:",Ue,A,ve,P,Je,Z,Oe="You can convert, and optionally quantize, LLMs from the Hugging Face Hub as follows:",_e,N,Ge,Y,Ke="If you want to directly push the model after the conversion, you can do it like below.",He,V,Ie,z,ke,Q,et='<li><a href="https://github.com/ml-explore/mlx" rel="nofollow">MLX Repository</a></li> <li><a href="https://ml-explore.github.io/mlx/" rel="nofollow">MLX Docs</a></li> <li><a href="https://github.com/ml-explore/mlx-lm/tree/main" rel="nofollow">MLX-LM</a></li> <li><a href="https://github.com/ml-explore/mlx-examples/tree/main" rel="nofollow">MLX Examples</a></li> <li><a href="https://huggingface.co/models?library=mlx&amp;sort=trending" rel="nofollow">All MLX models on the Hub</a></li>',Fe,q,Xe,K,Re;return d=new rt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),x=new D({props:{title:"Using MLX at Hugging Face",local:"using-mlx-at-hugging-face",headingTag:"h1"}}),b=new D({props:{title:"Exploring MLX on the Hub",local:"exploring-mlx-on-the-hub",headingTag:"h2"}}),C=new D({props:{title:"Installation",local:"installation",headingTag:"h2"}}),v=new M({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seC1sbQ==",highlighted:"pip install mlx-lm",wrap:!1}}),H=new M({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seA==",highlighted:"pip install mlx",wrap:!1}}),k=new M({props:{code:"Y29uZGElMjBpbnN0YWxsJTIwLWMlMjBjb25kYS1mb3JnZSUyMG1seA==",highlighted:"conda install -c conda-forge mlx",wrap:!1}}),F=new D({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),R=new M({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uZ2VuZXJhdGUlMjAtLW1vZGVsJTIwbWlzdHJhbGFpJTJGTWlzdHJhbC03Qi1JbnN0cnVjdC12MC4yJTIwLS1wcm9tcHQlMjAlMjJoZWxsbyUyMg==",highlighted:'python -m mlx_lm.generate --model mistralai/Mistral-7B-Instruct-v0.2 --prompt <span class="hljs-string">&quot;hello&quot;</span>',wrap:!1}}),S=new M({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uZ2VuZXJhdGUlMjAtLWhlbHA=",highlighted:'python -m mlx_lm.generate --<span class="hljs-built_in">help</span>',wrap:!1}}),E=new M({props:{code:"ZnJvbSUyMG1seF9sbSUyMGltcG9ydCUyMGxvYWQlMkMlMjBnZW5lcmF0ZSUwQSUwQW1vZGVsJTJDJTIwdG9rZW5pemVyJTIwJTNEJTIwbG9hZCglMjJtaXN0cmFsYWklMkZNaXN0cmFsLTdCLUluc3RydWN0LXYwLjIlMjIpJTBBJTBBcmVzcG9uc2UlMjAlM0QlMjBnZW5lcmF0ZShtb2RlbCUyQyUyMHRva2VuaXplciUyQyUyMHByb21wdCUzRCUyMmhlbGxvJTIyJTJDJTIwdmVyYm9zZSUzRFRydWUp",highlighted:`<span class="hljs-keyword">from</span> mlx_lm <span class="hljs-keyword">import</span> load, generate

model, tokenizer = load(<span class="hljs-string">&quot;mistralai/Mistral-7B-Instruct-v0.2&quot;</span>)

response = generate(model, tokenizer, prompt=<span class="hljs-string">&quot;hello&quot;</span>, verbose=<span class="hljs-literal">True</span>)`,wrap:!1}}),A=new M({props:{code:"cGlwJTIwaW5zdGFsbCUyMGh1Z2dpbmdmYWNlX2h1YiUyMGhmX3RyYW5zZmVyJTBBJTBBZXhwb3J0JTIwSEZfSFVCX0VOQUJMRV9IRl9UUkFOU0ZFUiUzRDElMEFoZiUyMGRvd25sb2FkJTIwLS1sb2NhbC1kaXIlMjAlM0NMT0NBTCUyMEZPTERFUiUyMFBBVEglM0UlMjAlM0NVU0VSX0lEJTNFJTJGJTNDTU9ERUxfTkFNRSUzRQ==",highlighted:`pip install huggingface_hub hf_transfer

export HF_HUB_ENABLE_HF_TRANSFER=<span class="hljs-number">1</span>
hf download --local-<span class="hljs-built_in">dir</span> &lt;LOCAL FOLDER PATH&gt; &lt;USER_ID&gt;/&lt;MODEL_NAME&gt;`,wrap:!1}}),P=new D({props:{title:"Converting and Sharing Models",local:"converting-and-sharing-models",headingTag:"h2"}}),N=new M({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uY29udmVydCUyMC0taGYtcGF0aCUyMG1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMC1xJTIw",highlighted:"python -m mlx_lm.convert --hf-path mistralai/Mistral-7B-v0.1 -q ",wrap:!1}}),V=new M({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uY29udmVydCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0taGYtcGF0aCUyMG1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMCU1QyUwQSUyMCUyMCUyMCUyMC1xJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS11cGxvYWQtcmVwbyUyMCUzQ1VTRVJfSUQlM0UlMkYlM0NNT0RFTF9OQU1FJTNF",highlighted:`python -m mlx_lm.convert \\
    --hf-path mistralai/Mistral-7B-v0.1 \\
    -q \\
    --upload-repo &lt;USER_ID&gt;/&lt;MODEL_NAME&gt;`,wrap:!1}}),z=new D({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),q=new ft({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/mlx.md"}}),{c(){$=s("meta"),ee=i(),O=s("p"),te=i(),m(d.$$.fragment),le=i(),m(x.$$.fragment),ne=i(),w=s("p"),w.innerHTML=Se,ie=i(),c=s("p"),c.textContent=We,ae=i(),y=s("ul"),y.innerHTML=Ee,se=i(),m(b.$$.fragment),oe=i(),L=s("p"),L.innerHTML=Be,me=i(),T=s("p"),T.textContent=Ae,pe=i(),m(C.$$.fragment),re=i(),U=s("p"),U.innerHTML=Pe,fe=i(),m(v.$$.fragment),ue=i(),J=s("p"),J.innerHTML=Ze,ge=i(),_=s("p"),_.innerHTML=Ne,he=i(),G=s("p"),G.innerHTML=Ye,$e=i(),m(H.$$.fragment),Me=i(),I=s("p"),I.innerHTML=Ve,de=i(),m(k.$$.fragment),xe=i(),m(F.$$.fragment),we=i(),X=s("p"),X.textContent=ze,ce=i(),m(R.$$.fragment),ye=i(),j=s("p"),j.textContent=Qe,be=i(),m(S.$$.fragment),Le=i(),W=s("p"),W.textContent=qe,Te=i(),m(E.$$.fragment),Ce=i(),B=s("p"),B.textContent=De,Ue=i(),m(A.$$.fragment),ve=i(),m(P.$$.fragment),Je=i(),Z=s("p"),Z.textContent=Oe,_e=i(),m(N.$$.fragment),Ge=i(),Y=s("p"),Y.textContent=Ke,He=i(),m(V.$$.fragment),Ie=i(),m(z.$$.fragment),ke=i(),Q=s("ul"),Q.innerHTML=et,Fe=i(),m(q.$$.fragment),Xe=i(),K=s("p"),this.h()},l(e){const t=mt("svelte-u9bgzb",document.head);$=o(t,"META",{name:!0,content:!0}),t.forEach(l),ee=a(e),O=o(e,"P",{}),tt(O).forEach(l),te=a(e),p(d.$$.fragment,e),le=a(e),p(x.$$.fragment,e),ne=a(e),w=o(e,"P",{"data-svelte-h":!0}),r(w)!=="svelte-1efkr56"&&(w.innerHTML=Se),ie=a(e),c=o(e,"P",{"data-svelte-h":!0}),r(c)!=="svelte-dorrup"&&(c.textContent=We),ae=a(e),y=o(e,"UL",{"data-svelte-h":!0}),r(y)!=="svelte-19xzay0"&&(y.innerHTML=Ee),se=a(e),p(b.$$.fragment,e),oe=a(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-nhocwz"&&(L.innerHTML=Be),me=a(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-msvbqi"&&(T.textContent=Ae),pe=a(e),p(C.$$.fragment,e),re=a(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1n6pkaa"&&(U.innerHTML=Pe),fe=a(e),p(v.$$.fragment,e),ue=a(e),J=o(e,"P",{"data-svelte-h":!0}),r(J)!=="svelte-3kh97r"&&(J.innerHTML=Ze),ge=a(e),_=o(e,"P",{"data-svelte-h":!0}),r(_)!=="svelte-1ca35sc"&&(_.innerHTML=Ne),he=a(e),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1cc82oq"&&(G.innerHTML=Ye),$e=a(e),p(H.$$.fragment,e),Me=a(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-fre6c0"&&(I.innerHTML=Ve),de=a(e),p(k.$$.fragment,e),xe=a(e),p(F.$$.fragment,e),we=a(e),X=o(e,"P",{"data-svelte-h":!0}),r(X)!=="svelte-ke1alk"&&(X.textContent=ze),ce=a(e),p(R.$$.fragment,e),ye=a(e),j=o(e,"P",{"data-svelte-h":!0}),r(j)!=="svelte-4f447r"&&(j.textContent=Qe),be=a(e),p(S.$$.fragment,e),Le=a(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-2rm0yr"&&(W.textContent=qe),Te=a(e),p(E.$$.fragment,e),Ce=a(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-q5ysas"&&(B.textContent=De),Ue=a(e),p(A.$$.fragment,e),ve=a(e),p(P.$$.fragment,e),Je=a(e),Z=o(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-sjxg6x"&&(Z.textContent=Oe),_e=a(e),p(N.$$.fragment,e),Ge=a(e),Y=o(e,"P",{"data-svelte-h":!0}),r(Y)!=="svelte-1efi7xb"&&(Y.textContent=Ke),He=a(e),p(V.$$.fragment,e),Ie=a(e),p(z.$$.fragment,e),ke=a(e),Q=o(e,"UL",{"data-svelte-h":!0}),r(Q)!=="svelte-9inmuc"&&(Q.innerHTML=et),Fe=a(e),p(q.$$.fragment,e),Xe=a(e),K=o(e,"P",{}),tt(K).forEach(l),this.h()},h(){lt($,"name","hf:doc:metadata"),lt($,"content",gt)},m(e,t){pt(document.head,$),n(e,ee,t),n(e,O,t),n(e,te,t),f(d,e,t),n(e,le,t),f(x,e,t),n(e,ne,t),n(e,w,t),n(e,ie,t),n(e,c,t),n(e,ae,t),n(e,y,t),n(e,se,t),f(b,e,t),n(e,oe,t),n(e,L,t),n(e,me,t),n(e,T,t),n(e,pe,t),f(C,e,t),n(e,re,t),n(e,U,t),n(e,fe,t),f(v,e,t),n(e,ue,t),n(e,J,t),n(e,ge,t),n(e,_,t),n(e,he,t),n(e,G,t),n(e,$e,t),f(H,e,t),n(e,Me,t),n(e,I,t),n(e,de,t),f(k,e,t),n(e,xe,t),f(F,e,t),n(e,we,t),n(e,X,t),n(e,ce,t),f(R,e,t),n(e,ye,t),n(e,j,t),n(e,be,t),f(S,e,t),n(e,Le,t),n(e,W,t),n(e,Te,t),f(E,e,t),n(e,Ce,t),n(e,B,t),n(e,Ue,t),f(A,e,t),n(e,ve,t),f(P,e,t),n(e,Je,t),n(e,Z,t),n(e,_e,t),f(N,e,t),n(e,Ge,t),n(e,Y,t),n(e,He,t),f(V,e,t),n(e,Ie,t),f(z,e,t),n(e,ke,t),n(e,Q,t),n(e,Fe,t),f(q,e,t),n(e,Xe,t),n(e,K,t),Re=!0},p:it,i(e){Re||(u(d.$$.fragment,e),u(x.$$.fragment,e),u(b.$$.fragment,e),u(C.$$.fragment,e),u(v.$$.fragment,e),u(H.$$.fragment,e),u(k.$$.fragment,e),u(F.$$.fragment,e),u(R.$$.fragment,e),u(S.$$.fragment,e),u(E.$$.fragment,e),u(A.$$.fragment,e),u(P.$$.fragment,e),u(N.$$.fragment,e),u(V.$$.fragment,e),u(z.$$.fragment,e),u(q.$$.fragment,e),Re=!0)},o(e){g(d.$$.fragment,e),g(x.$$.fragment,e),g(b.$$.fragment,e),g(C.$$.fragment,e),g(v.$$.fragment,e),g(H.$$.fragment,e),g(k.$$.fragment,e),g(F.$$.fragment,e),g(R.$$.fragment,e),g(S.$$.fragment,e),g(E.$$.fragment,e),g(A.$$.fragment,e),g(P.$$.fragment,e),g(N.$$.fragment,e),g(V.$$.fragment,e),g(z.$$.fragment,e),g(q.$$.fragment,e),Re=!1},d(e){e&&(l(ee),l(O),l(te),l(le),l(ne),l(w),l(ie),l(c),l(ae),l(y),l(se),l(oe),l(L),l(me),l(T),l(pe),l(re),l(U),l(fe),l(ue),l(J),l(ge),l(_),l(he),l(G),l($e),l(Me),l(I),l(de),l(xe),l(we),l(X),l(ce),l(ye),l(j),l(be),l(Le),l(W),l(Te),l(Ce),l(B),l(Ue),l(ve),l(Je),l(Z),l(_e),l(Ge),l(Y),l(He),l(Ie),l(ke),l(Q),l(Fe),l(Xe),l(K)),l($),h(d,e),h(x,e),h(b,e),h(C,e),h(v,e),h(H,e),h(k,e),h(F,e),h(R,e),h(S,e),h(E,e),h(A,e),h(P,e),h(N,e),h(V,e),h(z,e),h(q,e)}}}const gt='{"title":"Using MLX at Hugging Face","local":"using-mlx-at-hugging-face","sections":[{"title":"Exploring MLX on the Hub","local":"exploring-mlx-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":"Converting and Sharing Models","local":"converting-and-sharing-models","sections":[],"depth":2},{"title":"Additional Resources","local":"additional-resources","sections":[],"depth":2}],"depth":1}';function ht(je){return at(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ct extends st{constructor($){super(),ot(this,$,ht,ut,nt,{})}}export{ct as component};
