import{s as Ke,n as et,o as tt}from"../chunks/scheduler.d6170356.js";import{S as lt,i as nt,g as s,s as i,r as p,A as it,h as o,f as l,c as a,j as qe,u as r,x as m,k as Oe,y as at,a as n,v as f,d as u,t as h,w as g}from"../chunks/index.fcd4cc08.js";import{C as d}from"../chunks/CodeBlock.7b16bdef.js";import{H as z}from"../chunks/Heading.8660bd0e.js";function st(je){let M,O,D,K,x,ee,$,ke='<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.',te,w,Re="It comes with a variety of examples:",le,c,Fe='<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>',ne,y,ie,b,We=`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.`,ae,L,Xe="Thanks to MLX Hugging Face Hub integration, you can load MLX models with a few lines of code.",se,T,oe,U,Se=`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>:`,me,C,pe,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>.',re,J,Ee="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.",fe,_,Ae="With <code>pip</code>:",ue,G,he,H,Ze="With <code>conda</code>:",ge,I,Me,j,de,k,Pe="MLX-LM has useful utilities to generate text. The following line directly downloads and loads the model and starts generating text.",xe,R,$e,F,Ye="For a full list of generation options, run",we,W,ce,X,Ve="You can also load a model and start generating text through Python like below:",ye,S,be,B,Qe="MLX-LM supports popular LLM architectures including LLaMA, Phi-2, Mistral, and Qwen. Models other than supported ones can easily be downloaded as follows:",Le,E,Te,A,Ue,Z,Ne="You can convert, and optionally quantize, LLMs from the Hugging Face Hub as follows:",Ce,P,ve,Y,ze="If you want to directly push the model after the conversion, you can do it like below.",Je,V,_e,Q,Ge,N,De='<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>',He,q,Ie;return x=new z({props:{title:"Using MLX at Hugging Face",local:"using-mlx-at-hugging-face",headingTag:"h1"}}),y=new z({props:{title:"Exploring MLX on the Hub",local:"exploring-mlx-on-the-hub",headingTag:"h2"}}),T=new z({props:{title:"Installation",local:"installation",headingTag:"h2"}}),C=new d({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seC1sbQ==",highlighted:"pip install mlx-lm",wrap:!1}}),G=new d({props:{code:"cGlwJTIwaW5zdGFsbCUyMG1seA==",highlighted:"pip install mlx",wrap:!1}}),I=new d({props:{code:"Y29uZGElMjBpbnN0YWxsJTIwLWMlMjBjb25kYS1mb3JnZSUyMG1seA==",highlighted:"conda install -c conda-forge mlx",wrap:!1}}),j=new z({props:{title:"Using Existing Models",local:"using-existing-models",headingTag:"h2"}}),R=new d({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 d({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uZ2VuZXJhdGUlMjAtLWhlbHA=",highlighted:'python -m mlx_lm.generate --<span class="hljs-built_in">help</span>',wrap:!1}}),S=new d({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}}),E=new d({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 z({props:{title:"Converting and Sharing Models",local:"converting-and-sharing-models",headingTag:"h2"}}),P=new d({props:{code:"cHl0aG9uJTIwLW0lMjBtbHhfbG0uY29udmVydCUyMC0taGYtcGF0aCUyMG1pc3RyYWxhaSUyRk1pc3RyYWwtN0ItdjAuMSUyMC1xJTIw",highlighted:"python -m mlx_lm.convert --hf-path mistralai/Mistral-7B-v0.1 -q ",wrap:!1}}),V=new d({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 z({props:{title:"Additional Resources",local:"additional-resources",headingTag:"h2"}}),{c(){M=s("meta"),O=i(),D=s("p"),K=i(),p(x.$$.fragment),ee=i(),$=s("p"),$.innerHTML=ke,te=i(),w=s("p"),w.textContent=Re,le=i(),c=s("ul"),c.innerHTML=Fe,ne=i(),p(y.$$.fragment),ie=i(),b=s("p"),b.innerHTML=We,ae=i(),L=s("p"),L.textContent=Xe,se=i(),p(T.$$.fragment),oe=i(),U=s("p"),U.innerHTML=Se,me=i(),p(C.$$.fragment),pe=i(),v=s("p"),v.innerHTML=Be,re=i(),J=s("p"),J.innerHTML=Ee,fe=i(),_=s("p"),_.innerHTML=Ae,ue=i(),p(G.$$.fragment),he=i(),H=s("p"),H.innerHTML=Ze,ge=i(),p(I.$$.fragment),Me=i(),p(j.$$.fragment),de=i(),k=s("p"),k.textContent=Pe,xe=i(),p(R.$$.fragment),$e=i(),F=s("p"),F.textContent=Ye,we=i(),p(W.$$.fragment),ce=i(),X=s("p"),X.textContent=Ve,ye=i(),p(S.$$.fragment),be=i(),B=s("p"),B.textContent=Qe,Le=i(),p(E.$$.fragment),Te=i(),p(A.$$.fragment),Ue=i(),Z=s("p"),Z.textContent=Ne,Ce=i(),p(P.$$.fragment),ve=i(),Y=s("p"),Y.textContent=ze,Je=i(),p(V.$$.fragment),_e=i(),p(Q.$$.fragment),Ge=i(),N=s("ul"),N.innerHTML=De,He=i(),q=s("p"),this.h()},l(e){const t=it("svelte-u9bgzb",document.head);M=o(t,"META",{name:!0,content:!0}),t.forEach(l),O=a(e),D=o(e,"P",{}),qe(D).forEach(l),K=a(e),r(x.$$.fragment,e),ee=a(e),$=o(e,"P",{"data-svelte-h":!0}),m($)!=="svelte-1efkr56"&&($.innerHTML=ke),te=a(e),w=o(e,"P",{"data-svelte-h":!0}),m(w)!=="svelte-dorrup"&&(w.textContent=Re),le=a(e),c=o(e,"UL",{"data-svelte-h":!0}),m(c)!=="svelte-1uksf4x"&&(c.innerHTML=Fe),ne=a(e),r(y.$$.fragment,e),ie=a(e),b=o(e,"P",{"data-svelte-h":!0}),m(b)!=="svelte-nhocwz"&&(b.innerHTML=We),ae=a(e),L=o(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-msvbqi"&&(L.textContent=Xe),se=a(e),r(T.$$.fragment,e),oe=a(e),U=o(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-1n6pkaa"&&(U.innerHTML=Se),me=a(e),r(C.$$.fragment,e),pe=a(e),v=o(e,"P",{"data-svelte-h":!0}),m(v)!=="svelte-17r1xsl"&&(v.innerHTML=Be),re=a(e),J=o(e,"P",{"data-svelte-h":!0}),m(J)!=="svelte-1ca35sc"&&(J.innerHTML=Ee),fe=a(e),_=o(e,"P",{"data-svelte-h":!0}),m(_)!=="svelte-1cc82oq"&&(_.innerHTML=Ae),ue=a(e),r(G.$$.fragment,e),he=a(e),H=o(e,"P",{"data-svelte-h":!0}),m(H)!=="svelte-fre6c0"&&(H.innerHTML=Ze),ge=a(e),r(I.$$.fragment,e),Me=a(e),r(j.$$.fragment,e),de=a(e),k=o(e,"P",{"data-svelte-h":!0}),m(k)!=="svelte-ke1alk"&&(k.textContent=Pe),xe=a(e),r(R.$$.fragment,e),$e=a(e),F=o(e,"P",{"data-svelte-h":!0}),m(F)!=="svelte-4f447r"&&(F.textContent=Ye),we=a(e),r(W.$$.fragment,e),ce=a(e),X=o(e,"P",{"data-svelte-h":!0}),m(X)!=="svelte-2rm0yr"&&(X.textContent=Ve),ye=a(e),r(S.$$.fragment,e),be=a(e),B=o(e,"P",{"data-svelte-h":!0}),m(B)!=="svelte-q5ysas"&&(B.textContent=Qe),Le=a(e),r(E.$$.fragment,e),Te=a(e),r(A.$$.fragment,e),Ue=a(e),Z=o(e,"P",{"data-svelte-h":!0}),m(Z)!=="svelte-sjxg6x"&&(Z.textContent=Ne),Ce=a(e),r(P.$$.fragment,e),ve=a(e),Y=o(e,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-1efi7xb"&&(Y.textContent=ze),Je=a(e),r(V.$$.fragment,e),_e=a(e),r(Q.$$.fragment,e),Ge=a(e),N=o(e,"UL",{"data-svelte-h":!0}),m(N)!=="svelte-1u1ws3e"&&(N.innerHTML=De),He=a(e),q=o(e,"P",{}),qe(q).forEach(l),this.h()},h(){Oe(M,"name","hf:doc:metadata"),Oe(M,"content",ot)},m(e,t){at(document.head,M),n(e,O,t),n(e,D,t),n(e,K,t),f(x,e,t),n(e,ee,t),n(e,$,t),n(e,te,t),n(e,w,t),n(e,le,t),n(e,c,t),n(e,ne,t),f(y,e,t),n(e,ie,t),n(e,b,t),n(e,ae,t),n(e,L,t),n(e,se,t),f(T,e,t),n(e,oe,t),n(e,U,t),n(e,me,t),f(C,e,t),n(e,pe,t),n(e,v,t),n(e,re,t),n(e,J,t),n(e,fe,t),n(e,_,t),n(e,ue,t),f(G,e,t),n(e,he,t),n(e,H,t),n(e,ge,t),f(I,e,t),n(e,Me,t),f(j,e,t),n(e,de,t),n(e,k,t),n(e,xe,t),f(R,e,t),n(e,$e,t),n(e,F,t),n(e,we,t),f(W,e,t),n(e,ce,t),n(e,X,t),n(e,ye,t),f(S,e,t),n(e,be,t),n(e,B,t),n(e,Le,t),f(E,e,t),n(e,Te,t),f(A,e,t),n(e,Ue,t),n(e,Z,t),n(e,Ce,t),f(P,e,t),n(e,ve,t),n(e,Y,t),n(e,Je,t),f(V,e,t),n(e,_e,t),f(Q,e,t),n(e,Ge,t),n(e,N,t),n(e,He,t),n(e,q,t),Ie=!0},p:et,i(e){Ie||(u(x.$$.fragment,e),u(y.$$.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(S.$$.fragment,e),u(E.$$.fragment,e),u(A.$$.fragment,e),u(P.$$.fragment,e),u(V.$$.fragment,e),u(Q.$$.fragment,e),Ie=!0)},o(e){h(x.$$.fragment,e),h(y.$$.fragment,e),h(T.$$.fragment,e),h(C.$$.fragment,e),h(G.$$.fragment,e),h(I.$$.fragment,e),h(j.$$.fragment,e),h(R.$$.fragment,e),h(W.$$.fragment,e),h(S.$$.fragment,e),h(E.$$.fragment,e),h(A.$$.fragment,e),h(P.$$.fragment,e),h(V.$$.fragment,e),h(Q.$$.fragment,e),Ie=!1},d(e){e&&(l(O),l(D),l(K),l(ee),l($),l(te),l(w),l(le),l(c),l(ne),l(ie),l(b),l(ae),l(L),l(se),l(oe),l(U),l(me),l(pe),l(v),l(re),l(J),l(fe),l(_),l(ue),l(he),l(H),l(ge),l(Me),l(de),l(k),l(xe),l($e),l(F),l(we),l(ce),l(X),l(ye),l(be),l(B),l(Le),l(Te),l(Ue),l(Z),l(Ce),l(ve),l(Y),l(Je),l(_e),l(Ge),l(N),l(He),l(q)),l(M),g(x,e),g(y,e),g(T,e),g(C,e),g(G,e),g(I,e),g(j,e),g(R,e),g(W,e),g(S,e),g(E,e),g(A,e),g(P,e),g(V,e),g(Q,e)}}}const ot='{"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 mt(je){return tt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ht extends lt{constructor(M){super(),nt(this,M,mt,st,Ke,{})}}export{ht as component};
