import{s as tt,n as lt,o as nt}from"../chunks/scheduler.d6170356.js";import{S as it,i as at,g as s,s as i,r as p,A as st,h as o,f as l,c as a,j as Ke,u as r,x as m,k as et,y as ot,a as n,v as f,d as u,t as g,w as h}from"../chunks/index.fcd4cc08.js";import{C as $}from"../chunks/CodeBlock.db16bf50.js";import{H as D,E as mt}from"../chunks/getInferenceSnippets.0f6acb26.js";function pt(Re){let M,K,q,ee,d,te,x,Fe='<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.',le,w,We="It comes with a variety of examples:",ne,c,Xe='<li><a href="https://github.com/ml-explore/mlx-examples/tree/main/llms/mlx_lm" 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>',ie,b,ae,y,Ee=`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.`,se,L,Se="Thanks to MLX Hugging Face Hub integration, you can load MLX models with a few lines of code.",oe,T,me,U,Be=`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>:`,pe,C,re,v,Ae='You can get more information about it <a href="https://github.com/ml-explore/mlx-examples/blob/main/llms/README.md#generate-text-with-llms-and-mlx" rel="nofollow">here</a>.',fe,J,Ze="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.",ue,_,Pe="With <code>pip</code>:",ge,G,he,H,Ye="With <code>conda</code>:",Me,I,$e,j,de,k,Ve="MLX-LM has useful utilities to generate text. The following line directly downloads and loads the model and starts generating text.",xe,R,we,F,Qe="For a full list of generation options, run",ce,W,be,X,Ne="You can also load a model and start generating text through Python like below:",ye,E,Le,S,ze="MLX-LM supports popular LLM architectures including LLaMA, Phi-2, Mistral, and Qwen. Models other than supported ones can easily be downloaded as follows:",Te,B,Ue,A,Ce,Z,De="You can convert, and optionally quantize, LLMs from the Hugging Face Hub as follows:",ve,P,Je,Y,qe="If you want to directly push the model after the conversion, you can do it like below.",_e,V,Ge,Q,He,N,Oe='<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-examples/tree/main" rel="nofollow">MLX Examples</a></li> <li><a href="https://github.com/ml-explore/mlx-examples/tree/main/llms/mlx_lm" rel="nofollow">MLX-LM</a></li> <li><a href="https://huggingface.co/models?library=mlx&amp;sort=trending" rel="nofollow">All MLX models on Hub</a></li>',Ie,z,je,O,ke;return d=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"}}),T=new D({props:{title:"Installation",local:"installation",headingTag:"h2"}}),C=new $({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seC1sbQ==",highlighted:"pip install mlx-lm",wrap:!1}}),G=new $({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seA==",highlighted:"pip install mlx",wrap:!1}}),I=new $({props:{code:"Y29uZGElMjBpbnN0YWxsJTIwLWMlMjBjb25kYS1mb3JnZSUyMG1seA==",highlighted:"conda install -c conda-forge mlx",wrap:!1}}),j=new D({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),R=new $({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}}),W=new $({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uZ2VuZXJhdGUlMjAtLWhlbHA=",highlighted:'python -m mlx_lm.generate --<span class="hljs-built_in">help</span>',wrap:!1}}),E=new $({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}}),B=new $({props:{code:"cGlwJTIwaW5zdGFsbCUyMGh1Z2dpbmdmYWNlX2h1YiUyMGhmX3RyYW5zZmVyJTBBJTBBZXhwb3J0JTIwSEZfSFVCX0VOQUJMRV9IRl9UUkFOU0ZFUiUzRDElMEFodWdnaW5nZmFjZS1jbGklMjBkb3dubG9hZCUyMC0tbG9jYWwtZGlyJTIwJTNDTE9DQUwlMjBGT0xERVIlMjBQQVRIJTNFJTIwJTNDVVNFUl9JRCUzRSUyRiUzQ01PREVMX05BTUUlM0U=",highlighted:`pip install huggingface_hub hf_transfer

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