import{s as tt,n as lt,o as nt}from"../chunks/scheduler.12fdeddc.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 h,w as g}from"../chunks/index.88dae322.js";import{C as $}from"../chunks/CodeBlock.8e54a086.js";import{H as q,E as mt}from"../chunks/getInferenceSnippets.00466244.js";function pt(Xe){let M,K,D,ee,d,te,x,Re='<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,je="It comes with a variety of examples:",ne,c,Ee='<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,Se=`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,We="Thanks to MLX Hugging Face Hub integration, you can load MLX models with a few lines of code.",oe,T,me,U,Ae=`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,Be='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,_,Pe="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,J,Ze="With <code>pip</code>:",he,G,ge,H,Ne="With <code>conda</code>:",Me,I,$e,k,de,F,Ye="MLX-LM has useful utilities to generate text. The following line directly downloads and loads the model and starts generating text.",xe,X,we,R,Ve="For a full list of generation options, run",ce,j,be,E,Qe="You can also load a model and start generating text through Python like below:",ye,S,Le,W,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,A,Ue,B,Ce,P,qe="You can convert, and optionally quantize, LLMs from the Hugging Face Hub as follows:",ve,Z,_e,N,De="If you want to directly push the model after the conversion, you can do it like below.",Je,Y,Ge,V,He,Q,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-lm/tree/main/mlx_lm/examples" 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,ke,O,Fe;return d=new q({props:{title:"Using MLX at Hugging Face",local:"using-mlx-at-hugging-face",headingTag:"h1"}}),b=new q({props:{title:"Exploring MLX on the Hub",local:"exploring-mlx-on-the-hub",headingTag:"h2"}}),T=new q({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}}),k=new q({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),X=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}}),j=new $({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uZ2VuZXJhdGUlMjAtLWhlbHA=",highlighted:'python -m mlx_lm.generate --<span class="hljs-built_in">help</span>',wrap:!1}}),S=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}}),A=new $({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}}),B=new q({props:{title:"Converting and Sharing Models",local:"converting-and-sharing-models",headingTag:"h2"}}),Z=new $({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uY29udmVydCUyMC0taGYtcGF0aCUyMG1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMC1xJTIw",highlighted:"python -m mlx_lm.convert --hf-path mistralai/Mistral-7B-v0.1 -q ",wrap:!1}}),Y=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}}),V=new q({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(),D=s("p"),ee=i(),p(d.$$.fragment),te=i(),x=s("p"),x.innerHTML=Re,le=i(),w=s("p"),w.textContent=je,ne=i(),c=s("ul"),c.innerHTML=Ee,ie=i(),p(b.$$.fragment),ae=i(),y=s("p"),y.innerHTML=Se,se=i(),L=s("p"),L.textContent=We,oe=i(),p(T.$$.fragment),me=i(),U=s("p"),U.innerHTML=Ae,pe=i(),p(C.$$.fragment),re=i(),v=s("p"),v.innerHTML=Be,fe=i(),_=s("p"),_.innerHTML=Pe,ue=i(),J=s("p"),J.innerHTML=Ze,he=i(),p(G.$$.fragment),ge=i(),H=s("p"),H.innerHTML=Ne,Me=i(),p(I.$$.fragment),$e=i(),p(k.$$.fragment),de=i(),F=s("p"),F.textContent=Ye,xe=i(),p(X.$$.fragment),we=i(),R=s("p"),R.textContent=Ve,ce=i(),p(j.$$.fragment),be=i(),E=s("p"),E.textContent=Qe,ye=i(),p(S.$$.fragment),Le=i(),W=s("p"),W.textContent=ze,Te=i(),p(A.$$.fragment),Ue=i(),p(B.$$.fragment),Ce=i(),P=s("p"),P.textContent=qe,ve=i(),p(Z.$$.fragment),_e=i(),N=s("p"),N.textContent=De,Je=i(),p(Y.$$.fragment),Ge=i(),p(V.$$.fragment),He=i(),Q=s("ul"),Q.innerHTML=Oe,Ie=i(),p(z.$$.fragment),ke=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),D=o(e,"P",{}),Ke(D).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=Re),le=a(e),w=o(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-dorrup"&&(w.textContent=je),ne=a(e),c=o(e,"UL",{"data-svelte-h":!0}),m(c)!=="svelte-1uksf4x"&&(c.innerHTML=Ee),ie=a(e),r(b.$$.fragment,e),ae=a(e),y=o(e,"P",{"data-svelte-h":!0}),m(y)!=="svelte-nhocwz"&&(y.innerHTML=Se),se=a(e),L=o(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-msvbqi"&&(L.textContent=We),oe=a(e),r(T.$$.fragment,e),me=a(e),U=o(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-1n6pkaa"&&(U.innerHTML=Ae),pe=a(e),r(C.$$.fragment,e),re=a(e),v=o(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-17r1xsl"&&(v.innerHTML=Be),fe=a(e),_=o(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-1ca35sc"&&(_.innerHTML=Pe),ue=a(e),J=o(e,"P",{"data-svelte-h":!0}),m(J)!=="svelte-1cc82oq"&&(J.innerHTML=Ze),he=a(e),r(G.$$.fragment,e),ge=a(e),H=o(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-fre6c0"&&(H.innerHTML=Ne),Me=a(e),r(I.$$.fragment,e),$e=a(e),r(k.$$.fragment,e),de=a(e),F=o(e,"P",{"data-svelte-h":!0}),m(F)!=="svelte-ke1alk"&&(F.textContent=Ye),xe=a(e),r(X.$$.fragment,e),we=a(e),R=o(e,"P",{"data-svelte-h":!0}),m(R)!=="svelte-4f447r"&&(R.textContent=Ve),ce=a(e),r(j.$$.fragment,e),be=a(e),E=o(e,"P",{"data-svelte-h":!0}),m(E)!=="svelte-2rm0yr"&&(E.textContent=Qe),ye=a(e),r(S.$$.fragment,e),Le=a(e),W=o(e,"P",{"data-svelte-h":!0}),m(W)!=="svelte-q5ysas"&&(W.textContent=ze),Te=a(e),r(A.$$.fragment,e),Ue=a(e),r(B.$$.fragment,e),Ce=a(e),P=o(e,"P",{"data-svelte-h":!0}),m(P)!=="svelte-sjxg6x"&&(P.textContent=qe),ve=a(e),r(Z.$$.fragment,e),_e=a(e),N=o(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-1efi7xb"&&(N.textContent=De),Je=a(e),r(Y.$$.fragment,e),Ge=a(e),r(V.$$.fragment,e),He=a(e),Q=o(e,"UL",{"data-svelte-h":!0}),m(Q)!=="svelte-1ub2q8d"&&(Q.innerHTML=Oe),Ie=a(e),r(z.$$.fragment,e),ke=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,D,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,_,t),n(e,ue,t),n(e,J,t),n(e,he,t),f(G,e,t),n(e,ge,t),n(e,H,t),n(e,Me,t),f(I,e,t),n(e,$e,t),f(k,e,t),n(e,de,t),n(e,F,t),n(e,xe,t),f(X,e,t),n(e,we,t),n(e,R,t),n(e,ce,t),f(j,e,t),n(e,be,t),n(e,E,t),n(e,ye,t),f(S,e,t),n(e,Le,t),n(e,W,t),n(e,Te,t),f(A,e,t),n(e,Ue,t),f(B,e,t),n(e,Ce,t),n(e,P,t),n(e,ve,t),f(Z,e,t),n(e,_e,t),n(e,N,t),n(e,Je,t),f(Y,e,t),n(e,Ge,t),f(V,e,t),n(e,He,t),n(e,Q,t),n(e,Ie,t),f(z,e,t),n(e,ke,t),n(e,O,t),Fe=!0},p:lt,i(e){Fe||(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(k.$$.fragment,e),u(X.$$.fragment,e),u(j.$$.fragment,e),u(S.$$.fragment,e),u(A.$$.fragment,e),u(B.$$.fragment,e),u(Z.$$.fragment,e),u(Y.$$.fragment,e),u(V.$$.fragment,e),u(z.$$.fragment,e),Fe=!0)},o(e){h(d.$$.fragment,e),h(b.$$.fragment,e),h(T.$$.fragment,e),h(C.$$.fragment,e),h(G.$$.fragment,e),h(I.$$.fragment,e),h(k.$$.fragment,e),h(X.$$.fragment,e),h(j.$$.fragment,e),h(S.$$.fragment,e),h(A.$$.fragment,e),h(B.$$.fragment,e),h(Z.$$.fragment,e),h(Y.$$.fragment,e),h(V.$$.fragment,e),h(z.$$.fragment,e),Fe=!1},d(e){e&&(l(K),l(D),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(_),l(ue),l(J),l(he),l(ge),l(H),l(Me),l($e),l(de),l(F),l(xe),l(we),l(R),l(ce),l(be),l(E),l(ye),l(Le),l(W),l(Te),l(Ue),l(Ce),l(P),l(ve),l(_e),l(N),l(Je),l(Ge),l(He),l(Q),l(Ie),l(ke),l(O)),l(M),g(d,e),g(b,e),g(T,e),g(C,e),g(G,e),g(I,e),g(k,e),g(X,e),g(j,e),g(S,e),g(A,e),g(B,e),g(Z,e),g(Y,e),g(V,e),g(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(Xe){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};
