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.003612b0.js";import{C as rt}from"../chunks/CopyLLMTxtMenu.44d08a39.js";import{C as M}from"../chunks/CodeBlock.a90632f1.js";import{H as D,E as ft}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.e5cfda8c.js";function ut(We){let $,ee,O,te,x,le,d,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,Be="It comes with a variety of examples:",ae,b,Fe='<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,y,oe,L,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.`,me,T,Pe="Thanks to MLX Hugging Face Hub integration, you can load MLX models with a few lines of code.",pe,C,re,U,Ve=`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,G,Ae="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,H,Qe="With <code>pip</code>:",$e,_,Me,I,Ye="With <code>conda</code>:",xe,j,de,k,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,be,W,Ne="For a full list of generation options, run",ye,S,Le,B,qe="You can also load a model and start generating text through Python like below:",Te,F,Ce,E,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,P,ve,V,Je,Z,Oe="You can convert, and optionally quantize, LLMs from the Hugging Face Hub as follows:",Ge,A,He,Q,Ke="If you want to directly push the model after the conversion, you can do it like below.",_e,Y,Ie,z,je,N,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>',ke,q,Xe,K,Re;return x=new rt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),d=new D({props:{title:"Using MLX at Hugging Face",local:"using-mlx-at-hugging-face",headingTag:"h1"}}),y=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}}),_=new M({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seA==",highlighted:"pip install mlx",wrap:!1}}),j=new M({props:{code:"Y29uZGElMjBpbnN0YWxsJTIwLWMlMjBjb25kYS1mb3JnZSUyMG1seA==",highlighted:"conda install -c conda-forge mlx",wrap:!1}}),k=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}}),F=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}}),P=new M({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwaHVnZ2luZ2ZhY2VfaHViJTBBJTBBZXhwb3J0JTIwSEZfWEVUX0hJR0hfUEVSRk9STUFOQ0UlM0QxJTBBaGYlMjBkb3dubG9hZCUyMC0tbG9jYWwtZGlyJTIwJTNDTE9DQUwlMjBGT0xERVIlMjBQQVRIJTNFJTIwJTNDVVNFUl9JRCUzRSUyRiUzQ01PREVMX05BTUUlM0U=",highlighted:`pip install -U huggingface_hub

export HF_XET_HIGH_PERFORMANCE=<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}}),V=new D({props:{title:"Converting and Sharing Models",local:"converting-and-sharing-models",headingTag:"h2"}}),A=new M({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uY29udmVydCUyMC0taGYtcGF0aCUyMG1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMC1xJTIw",highlighted:"python -m mlx_lm.convert --hf-path mistralai/Mistral-7B-v0.1 -q ",wrap:!1}}),Y=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(x.$$.fragment),le=i(),m(d.$$.fragment),ne=i(),w=s("p"),w.innerHTML=Se,ie=i(),c=s("p"),c.textContent=Be,ae=i(),b=s("ul"),b.innerHTML=Fe,se=i(),m(y.$$.fragment),oe=i(),L=s("p"),L.innerHTML=Ee,me=i(),T=s("p"),T.textContent=Pe,pe=i(),m(C.$$.fragment),re=i(),U=s("p"),U.innerHTML=Ve,fe=i(),m(v.$$.fragment),ue=i(),J=s("p"),J.innerHTML=Ze,ge=i(),G=s("p"),G.innerHTML=Ae,he=i(),H=s("p"),H.innerHTML=Qe,$e=i(),m(_.$$.fragment),Me=i(),I=s("p"),I.innerHTML=Ye,xe=i(),m(j.$$.fragment),de=i(),m(k.$$.fragment),we=i(),X=s("p"),X.textContent=ze,ce=i(),m(R.$$.fragment),be=i(),W=s("p"),W.textContent=Ne,ye=i(),m(S.$$.fragment),Le=i(),B=s("p"),B.textContent=qe,Te=i(),m(F.$$.fragment),Ce=i(),E=s("p"),E.textContent=De,Ue=i(),m(P.$$.fragment),ve=i(),m(V.$$.fragment),Je=i(),Z=s("p"),Z.textContent=Oe,Ge=i(),m(A.$$.fragment),He=i(),Q=s("p"),Q.textContent=Ke,_e=i(),m(Y.$$.fragment),Ie=i(),m(z.$$.fragment),je=i(),N=s("ul"),N.innerHTML=et,ke=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(x.$$.fragment,e),le=a(e),p(d.$$.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=Be),ae=a(e),b=o(e,"UL",{"data-svelte-h":!0}),r(b)!=="svelte-19xzay0"&&(b.innerHTML=Fe),se=a(e),p(y.$$.fragment,e),oe=a(e),L=o(e,"P",{"data-svelte-h":!0}),r(L)!=="svelte-nhocwz"&&(L.innerHTML=Ee),me=a(e),T=o(e,"P",{"data-svelte-h":!0}),r(T)!=="svelte-msvbqi"&&(T.textContent=Pe),pe=a(e),p(C.$$.fragment,e),re=a(e),U=o(e,"P",{"data-svelte-h":!0}),r(U)!=="svelte-1n6pkaa"&&(U.innerHTML=Ve),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),G=o(e,"P",{"data-svelte-h":!0}),r(G)!=="svelte-1ca35sc"&&(G.innerHTML=Ae),he=a(e),H=o(e,"P",{"data-svelte-h":!0}),r(H)!=="svelte-1cc82oq"&&(H.innerHTML=Qe),$e=a(e),p(_.$$.fragment,e),Me=a(e),I=o(e,"P",{"data-svelte-h":!0}),r(I)!=="svelte-fre6c0"&&(I.innerHTML=Ye),xe=a(e),p(j.$$.fragment,e),de=a(e),p(k.$$.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),be=a(e),W=o(e,"P",{"data-svelte-h":!0}),r(W)!=="svelte-4f447r"&&(W.textContent=Ne),ye=a(e),p(S.$$.fragment,e),Le=a(e),B=o(e,"P",{"data-svelte-h":!0}),r(B)!=="svelte-2rm0yr"&&(B.textContent=qe),Te=a(e),p(F.$$.fragment,e),Ce=a(e),E=o(e,"P",{"data-svelte-h":!0}),r(E)!=="svelte-q5ysas"&&(E.textContent=De),Ue=a(e),p(P.$$.fragment,e),ve=a(e),p(V.$$.fragment,e),Je=a(e),Z=o(e,"P",{"data-svelte-h":!0}),r(Z)!=="svelte-sjxg6x"&&(Z.textContent=Oe),Ge=a(e),p(A.$$.fragment,e),He=a(e),Q=o(e,"P",{"data-svelte-h":!0}),r(Q)!=="svelte-1efi7xb"&&(Q.textContent=Ke),_e=a(e),p(Y.$$.fragment,e),Ie=a(e),p(z.$$.fragment,e),je=a(e),N=o(e,"UL",{"data-svelte-h":!0}),r(N)!=="svelte-9inmuc"&&(N.innerHTML=et),ke=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(x,e,t),n(e,le,t),f(d,e,t),n(e,ne,t),n(e,w,t),n(e,ie,t),n(e,c,t),n(e,ae,t),n(e,b,t),n(e,se,t),f(y,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,G,t),n(e,he,t),n(e,H,t),n(e,$e,t),f(_,e,t),n(e,Me,t),n(e,I,t),n(e,xe,t),f(j,e,t),n(e,de,t),f(k,e,t),n(e,we,t),n(e,X,t),n(e,ce,t),f(R,e,t),n(e,be,t),n(e,W,t),n(e,ye,t),f(S,e,t),n(e,Le,t),n(e,B,t),n(e,Te,t),f(F,e,t),n(e,Ce,t),n(e,E,t),n(e,Ue,t),f(P,e,t),n(e,ve,t),f(V,e,t),n(e,Je,t),n(e,Z,t),n(e,Ge,t),f(A,e,t),n(e,He,t),n(e,Q,t),n(e,_e,t),f(Y,e,t),n(e,Ie,t),f(z,e,t),n(e,je,t),n(e,N,t),n(e,ke,t),f(q,e,t),n(e,Xe,t),n(e,K,t),Re=!0},p:it,i(e){Re||(u(x.$$.fragment,e),u(d.$$.fragment,e),u(y.$$.fragment,e),u(C.$$.fragment,e),u(v.$$.fragment,e),u(_.$$.fragment,e),u(j.$$.fragment,e),u(k.$$.fragment,e),u(R.$$.fragment,e),u(S.$$.fragment,e),u(F.$$.fragment,e),u(P.$$.fragment,e),u(V.$$.fragment,e),u(A.$$.fragment,e),u(Y.$$.fragment,e),u(z.$$.fragment,e),u(q.$$.fragment,e),Re=!0)},o(e){g(x.$$.fragment,e),g(d.$$.fragment,e),g(y.$$.fragment,e),g(C.$$.fragment,e),g(v.$$.fragment,e),g(_.$$.fragment,e),g(j.$$.fragment,e),g(k.$$.fragment,e),g(R.$$.fragment,e),g(S.$$.fragment,e),g(F.$$.fragment,e),g(P.$$.fragment,e),g(V.$$.fragment,e),g(A.$$.fragment,e),g(Y.$$.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(b),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(G),l(he),l(H),l($e),l(Me),l(I),l(xe),l(de),l(we),l(X),l(ce),l(be),l(W),l(ye),l(Le),l(B),l(Te),l(Ce),l(E),l(Ue),l(ve),l(Je),l(Z),l(Ge),l(He),l(Q),l(_e),l(Ie),l(je),l(N),l(ke),l(Xe),l(K)),l($),h(x,e),h(d,e),h(y,e),h(C,e),h(v,e),h(_,e),h(j,e),h(k,e),h(R,e),h(S,e),h(F,e),h(P,e),h(V,e),h(A,e),h(Y,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(We){return at(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ct extends st{constructor($){super(),ot(this,$,ht,ut,nt,{})}}export{ct as component};
