import{s as He,n as Je,o as Ue}from"../chunks/scheduler.25b97de1.js";import{S as ze,i as Se,g as a,s as o,r as f,A as qe,h as r,f as l,c as n,j as Ge,u,x as s,k as Qe,y as Ie,a as i,v as m,d,t as h,w as c}from"../chunks/index.d9030fc9.js";import{C as Ze}from"../chunks/CodeBlock.e6cd0d95.js";import{H as B,E as Xe}from"../chunks/EditOnGithub.91d95064.js";function Be(he){let p,E,I,P,g,F,b,ce=`The GGUF file format is used to store models for inference with <a href="https://github.com/ggerganov/ggml" rel="nofollow">GGML</a> and other
libraries that depend on it, like the very popular <a href="https://github.com/ggerganov/llama.cpp" rel="nofollow">llama.cpp</a> or
<a href="https://github.com/ggerganov/whisper.cpp" rel="nofollow">whisper.cpp</a>.`,V,T,ge=`It is a file format <a href="https://huggingface.co/docs/hub/en/gguf" rel="nofollow">supported by the Hugging Face Hub</a> with features
allowing for quick inspection of tensors and metadata within the file.`,j,w,be=`This file format is designed as a “single-file-format” where a single file usually contains both the configuration
attributes, the tokenizer vocabulary and other attributes, as well as all tensors to be loaded in the model. These
files come in different formats according to the quantization type of the file. We briefly go over some of them
<a href="https://huggingface.co/docs/hub/en/gguf#quantization-types" rel="nofollow">here</a>.`,Y,y,R,v,Te=`We have added the ability to load <code>gguf</code> files within <code>transformers</code> in order to offer further training/fine-tuning
capabilities to gguf models, before converting back those models to <code>gguf</code> to use within the <code>ggml</code> ecosystem. When
loading a model, we first dequantize it to fp32, before loading the weights to be used in PyTorch.`,N,_,we=`<p>[!NOTE]
The support is still very exploratory and we welcome contributions in order to solidify it across quantization types
and model architectures.</p>`,K,$,ye="For now, here are the supported model architectures and quantization types:",A,M,O,x,ve=`The initial supported quantization types are decided according to the popular quantized files that have been shared
on the Hub.`,D,C,_e="<li>F32</li> <li>F16</li> <li>BF16</li> <li>Q4_0</li> <li>Q4_1</li> <li>Q5_0</li> <li>Q5_1</li> <li>Q8_0</li> <li>Q2_K</li> <li>Q3_K</li> <li>Q4_K</li> <li>Q5_K</li> <li>Q6_K</li> <li>IQ1_S</li> <li>IQ1_M</li> <li>IQ2_XXS</li> <li>IQ2_XS</li> <li>IQ2_S</li> <li>IQ3_XXS</li> <li>IQ3_S</li> <li>IQ4_XS</li> <li>IQ4_NL</li>",ee,L,$e=`<p>[!NOTE]
To support gguf dequantization, <code>gguf&gt;=0.10.0</code> installation is required.</p>`,te,k,le,W,Me="For now the supported model architectures are the architectures that have been very popular on the Hub, namely:",ie,G,xe="<li>LLaMa</li> <li>Mistral</li> <li>Qwen2</li> <li>Qwen2Moe</li> <li>Phi3</li> <li>Bloom</li> <li>Falcon</li> <li>StableLM</li> <li>GPT2</li> <li>Starcoder2</li> <li>T5</li> <li>Mamba</li>",oe,Q,ne,Z,Ce=`In order to load <code>gguf</code> files in <code>transformers</code>, you should specify the <code>gguf_file</code> argument to the <code>from_pretrained</code>
methods of both tokenizers and models. Here is how one would load a tokenizer and a model, which can be loaded
from the exact same file:`,ae,H,re,J,Le=`Now you have access to the full, unquantized version of the model in the PyTorch ecosystem, where you can combine it
with a plethora of other tools.`,se,U,ke=`In order to convert back to a <code>gguf</code> file, we recommend using the
<a href="https://github.com/ggerganov/llama.cpp/blob/master/convert_hf_to_gguf.py" rel="nofollow"><code>convert-hf-to-gguf.py</code> file</a> from llama.cpp.`,pe,z,We="Here’s how you would complete the script above to save the model and export it back to <code>gguf</code>:",fe,S,ue,q,me,X,de;return g=new B({props:{title:"GGUF and interaction with Transformers",local:"gguf-and-interaction-with-transformers",headingTag:"h1"}}),y=new B({props:{title:"Support within Transformers",local:"support-within-transformers",headingTag:"h2"}}),M=new B({props:{title:"Supported quantization types",local:"supported-quantization-types",headingTag:"h3"}}),k=new B({props:{title:"Supported model architectures",local:"supported-model-architectures",headingTag:"h3"}}),Q=new B({props:{title:"Example usage",local:"example-usage",headingTag:"h2"}}),H=new Ze({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMkMlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTSUwQSUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyVGhlQmxva2UlMkZUaW55TGxhbWEtMS4xQi1DaGF0LXYxLjAtR0dVRiUyMiUwQWZpbGVuYW1lJTIwJTNEJTIwJTIydGlueWxsYW1hLTEuMWItY2hhdC12MS4wLlE2X0suZ2d1ZiUyMiUwQSUwQXRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwZ2d1Zl9maWxlJTNEZmlsZW5hbWUpJTBBbW9kZWwlMjAlM0QlMjBBdXRvTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjBnZ3VmX2ZpbGUlM0RmaWxlbmFtZSk=",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer, AutoModelForCausalLM

model_id = <span class="hljs-string">&quot;TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF&quot;</span>
filename = <span class="hljs-string">&quot;tinyllama-1.1b-chat-v1.0.Q6_K.gguf&quot;</span>

tokenizer = AutoTokenizer.from_pretrained(model_id, gguf_file=filename)
model = AutoModelForCausalLM.from_pretrained(model_id, gguf_file=filename)`,wrap:!1}}),S=new Ze({props:{code:"dG9rZW5pemVyLnNhdmVfcHJldHJhaW5lZCgnZGlyZWN0b3J5JyklMEFtb2RlbC5zYXZlX3ByZXRyYWluZWQoJ2RpcmVjdG9yeScpJTBBJTBBIXB5dGhvbiUyMCUyNCU3QnBhdGhfdG9fbGxhbWFfY3BwJTdEJTJGY29udmVydC1oZi10by1nZ3VmLnB5JTIwJTI0JTdCZGlyZWN0b3J5JTdE",highlighted:`tokenizer.save_pretrained(<span class="hljs-string">&#x27;directory&#x27;</span>)
model.save_pretrained(<span class="hljs-string">&#x27;directory&#x27;</span>)

!python \${path_to_llama_cpp}/convert-hf-to-gguf.py \${directory}`,wrap:!1}}),q=new Xe({props:{source:"https://github.com/huggingface/transformers/blob/main/docs/source/en/gguf.md"}}),{c(){p=a("meta"),E=o(),I=a("p"),P=o(),f(g.$$.fragment),F=o(),b=a("p"),b.innerHTML=ce,V=o(),T=a("p"),T.innerHTML=ge,j=o(),w=a("p"),w.innerHTML=be,Y=o(),f(y.$$.fragment),R=o(),v=a("p"),v.innerHTML=Te,N=o(),_=a("blockquote"),_.innerHTML=we,K=o(),$=a("p"),$.textContent=ye,A=o(),f(M.$$.fragment),O=o(),x=a("p"),x.textContent=ve,D=o(),C=a("ul"),C.innerHTML=_e,ee=o(),L=a("blockquote"),L.innerHTML=$e,te=o(),f(k.$$.fragment),le=o(),W=a("p"),W.textContent=Me,ie=o(),G=a("ul"),G.innerHTML=xe,oe=o(),f(Q.$$.fragment),ne=o(),Z=a("p"),Z.innerHTML=Ce,ae=o(),f(H.$$.fragment),re=o(),J=a("p"),J.textContent=Le,se=o(),U=a("p"),U.innerHTML=ke,pe=o(),z=a("p"),z.innerHTML=We,fe=o(),f(S.$$.fragment),ue=o(),f(q.$$.fragment),me=o(),X=a("p"),this.h()},l(e){const t=qe("svelte-u9bgzb",document.head);p=r(t,"META",{name:!0,content:!0}),t.forEach(l),E=n(e),I=r(e,"P",{}),Ge(I).forEach(l),P=n(e),u(g.$$.fragment,e),F=n(e),b=r(e,"P",{"data-svelte-h":!0}),s(b)!=="svelte-117klwz"&&(b.innerHTML=ce),V=n(e),T=r(e,"P",{"data-svelte-h":!0}),s(T)!=="svelte-14alsnt"&&(T.innerHTML=ge),j=n(e),w=r(e,"P",{"data-svelte-h":!0}),s(w)!=="svelte-1lcntb8"&&(w.innerHTML=be),Y=n(e),u(y.$$.fragment,e),R=n(e),v=r(e,"P",{"data-svelte-h":!0}),s(v)!=="svelte-1fcaojo"&&(v.innerHTML=Te),N=n(e),_=r(e,"BLOCKQUOTE",{"data-svelte-h":!0}),s(_)!=="svelte-13g437o"&&(_.innerHTML=we),K=n(e),$=r(e,"P",{"data-svelte-h":!0}),s($)!=="svelte-lue5cc"&&($.textContent=ye),A=n(e),u(M.$$.fragment,e),O=n(e),x=r(e,"P",{"data-svelte-h":!0}),s(x)!=="svelte-1r2kpez"&&(x.textContent=ve),D=n(e),C=r(e,"UL",{"data-svelte-h":!0}),s(C)!=="svelte-1f29qgp"&&(C.innerHTML=_e),ee=n(e),L=r(e,"BLOCKQUOTE",{"data-svelte-h":!0}),s(L)!=="svelte-tc3a5k"&&(L.innerHTML=$e),te=n(e),u(k.$$.fragment,e),le=n(e),W=r(e,"P",{"data-svelte-h":!0}),s(W)!=="svelte-tmyftl"&&(W.textContent=Me),ie=n(e),G=r(e,"UL",{"data-svelte-h":!0}),s(G)!=="svelte-1jvu6gd"&&(G.innerHTML=xe),oe=n(e),u(Q.$$.fragment,e),ne=n(e),Z=r(e,"P",{"data-svelte-h":!0}),s(Z)!=="svelte-1lj1hm3"&&(Z.innerHTML=Ce),ae=n(e),u(H.$$.fragment,e),re=n(e),J=r(e,"P",{"data-svelte-h":!0}),s(J)!=="svelte-16kc502"&&(J.textContent=Le),se=n(e),U=r(e,"P",{"data-svelte-h":!0}),s(U)!=="svelte-12xriyu"&&(U.innerHTML=ke),pe=n(e),z=r(e,"P",{"data-svelte-h":!0}),s(z)!=="svelte-eicl62"&&(z.innerHTML=We),fe=n(e),u(S.$$.fragment,e),ue=n(e),u(q.$$.fragment,e),me=n(e),X=r(e,"P",{}),Ge(X).forEach(l),this.h()},h(){Qe(p,"name","hf:doc:metadata"),Qe(p,"content",Ee)},m(e,t){Ie(document.head,p),i(e,E,t),i(e,I,t),i(e,P,t),m(g,e,t),i(e,F,t),i(e,b,t),i(e,V,t),i(e,T,t),i(e,j,t),i(e,w,t),i(e,Y,t),m(y,e,t),i(e,R,t),i(e,v,t),i(e,N,t),i(e,_,t),i(e,K,t),i(e,$,t),i(e,A,t),m(M,e,t),i(e,O,t),i(e,x,t),i(e,D,t),i(e,C,t),i(e,ee,t),i(e,L,t),i(e,te,t),m(k,e,t),i(e,le,t),i(e,W,t),i(e,ie,t),i(e,G,t),i(e,oe,t),m(Q,e,t),i(e,ne,t),i(e,Z,t),i(e,ae,t),m(H,e,t),i(e,re,t),i(e,J,t),i(e,se,t),i(e,U,t),i(e,pe,t),i(e,z,t),i(e,fe,t),m(S,e,t),i(e,ue,t),m(q,e,t),i(e,me,t),i(e,X,t),de=!0},p:Je,i(e){de||(d(g.$$.fragment,e),d(y.$$.fragment,e),d(M.$$.fragment,e),d(k.$$.fragment,e),d(Q.$$.fragment,e),d(H.$$.fragment,e),d(S.$$.fragment,e),d(q.$$.fragment,e),de=!0)},o(e){h(g.$$.fragment,e),h(y.$$.fragment,e),h(M.$$.fragment,e),h(k.$$.fragment,e),h(Q.$$.fragment,e),h(H.$$.fragment,e),h(S.$$.fragment,e),h(q.$$.fragment,e),de=!1},d(e){e&&(l(E),l(I),l(P),l(F),l(b),l(V),l(T),l(j),l(w),l(Y),l(R),l(v),l(N),l(_),l(K),l($),l(A),l(O),l(x),l(D),l(C),l(ee),l(L),l(te),l(le),l(W),l(ie),l(G),l(oe),l(ne),l(Z),l(ae),l(re),l(J),l(se),l(U),l(pe),l(z),l(fe),l(ue),l(me),l(X)),l(p),c(g,e),c(y,e),c(M,e),c(k,e),c(Q,e),c(H,e),c(S,e),c(q,e)}}}const Ee='{"title":"GGUF and interaction with Transformers","local":"gguf-and-interaction-with-transformers","sections":[{"title":"Support within Transformers","local":"support-within-transformers","sections":[{"title":"Supported quantization types","local":"supported-quantization-types","sections":[],"depth":3},{"title":"Supported model architectures","local":"supported-model-architectures","sections":[],"depth":3}],"depth":2},{"title":"Example usage","local":"example-usage","sections":[],"depth":2}],"depth":1}';function Pe(he){return Ue(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends ze{constructor(p){super(),Se(this,p,Pe,Be,He,{})}}export{Re as component};
