import{s as ze,c as Le,u as He,g as De,d as Pe,e as Ke,A as Ie,o as Ye,f as Oe,n as Gl}from"../chunks/scheduler.37c15a92.js";import{S as _e,i as Fe,g as w,s as y,h,j as Kl,f as e,c,k as Wl,a as t,d as b,t as C,z as lt,m as E,n as N,y as be,E as et,o as tt,r as f,A as st,u as g,x as Z,v as B,w as G}from"../chunks/index.7cb9c9b8.js";import{T as de}from"../chunks/Tip.d10b3fc9.js";import{C as V}from"../chunks/CodeBlock.abae2786.js";import{H as Tl,E as nt}from"../chunks/getInferenceSnippets.50ff7b37.js";import{e as Re}from"../chunks/each.e59479a4.js";import{s as he}from"../chunks/stores.cb4752a8.js";function at(A,r){const o=new URL(window.location.href),j=new URLSearchParams(o.search);j.set(A,r),o.search=j.toString(),history.replaceState(null,"",o.toString())}function Mt(A){const r=new URL(window.location.href);return new URLSearchParams(r.search).get(A)}function xe(A,r,o){const j=A.slice();return j[7]=r[o],j}function qe(A){let r,o=A[7]+"",j,U,m,T,M;function J(){return A[6](A[7])}return{c(){r=w("div"),j=E(o),U=y(),this.h()},l(i){r=h(i,"DIV",{class:!0});var p=Kl(r);j=N(p,o),U=c(p),p.forEach(e),this.h()},h(){Wl(r,"class",m="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd "+(A[2][A[0]]===A[7]?"border-gray-800 bg-black dark:bg-gray-700 text-white":"text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm"))},m(i,p){t(i,r,p),be(r,j),be(r,U),T||(M=et(r,"click",J),T=!0)},p(i,p){A=i,p&2&&o!==(o=A[7]+"")&&tt(j,o),p&7&&m!==(m="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd "+(A[2][A[0]]===A[7]?"border-gray-800 bg-black dark:bg-gray-700 text-white":"text-gray-500 cursor-pointer opacity-90 hover:text-gray-700 dark:hover:text-gray-200 hover:shadow-sm"))&&Wl(r,"class",m)},d(i){i&&e(r),T=!1,M()}}}function pt(A){let r,o,j,U,m=Re(A[1]),T=[];for(let i=0;i<m.length;i+=1)T[i]=qe(xe(A,m,i));const M=A[5].default,J=Le(M,A,A[4],null);return{c(){r=w("div");for(let i=0;i<T.length;i+=1)T[i].c();o=y(),j=w("div"),J&&J.c(),this.h()},l(i){r=h(i,"DIV",{class:!0});var p=Kl(r);for(let Q=0;Q<T.length;Q+=1)T[Q].l(p);p.forEach(e),o=c(i),j=h(i,"DIV",{class:!0});var v=Kl(j);J&&J.l(v),v.forEach(e),this.h()},h(){Wl(r,"class","flex space-x-2 items-center my-1.5 mr-8 h-7 !pl-0 -mx-3 md:mx-0"),Wl(j,"class","language-select")},m(i,p){t(i,r,p);for(let v=0;v<T.length;v+=1)T[v]&&T[v].m(r,null);t(i,o,p),t(i,j,p),J&&J.m(j,null),U=!0},p(i,[p]){if(p&15){m=Re(i[1]);let v;for(v=0;v<m.length;v+=1){const Q=xe(i,m,v);T[v]?T[v].p(Q,p):(T[v]=qe(Q),T[v].c(),T[v].m(r,null))}for(;v<T.length;v+=1)T[v].d(1);T.length=m.length}J&&J.p&&(!U||p&16)&&He(J,M,i,i[4],U?Pe(M,i[4],p,null):De(i[4]),null)},i(i){U||(b(J,i),U=!0)},o(i){C(J,i),U=!1},d(i){i&&(e(r),e(o),e(j)),lt(T,i),J&&J.d(i)}}}function ot(A,r,o){let j;Ke(A,he,p=>o(2,j=p));let{$$slots:U={},$$scope:m}=r,{id:T}=r,{options:M}=r;Ie(he,j[T]=M[0],j);function J(p){Ie(he,j[T]=p,j),at(T,p)}Ye(()=>{const p=Mt(T);p&&M.includes(p)&&Ie(he,j[T]=p,j)});const i=p=>J(p);return A.$$set=p=>{"id"in p&&o(0,T=p.id),"options"in p&&o(1,M=p.options),"$$scope"in p&&o(4,m=p.$$scope)},[T,M,j,J,m,U,i]}class Dl extends _e{constructor(r){super(),Fe(this,r,ot,pt,ze,{id:0,options:1})}}function it(A){let r,o,j="The key innovation is in how it manages memory transfers between High Bandwidth Memory (HBM) and faster SRAM cache. Traditional attention repeatedly transfers data between HBM and SRAM, creating bottlenecks by leaving the GPU idle. Flash Attention loads data once into SRAM and performs all calculations there, minimizing expensive memory transfers.",U,m,T="While the benefits are most significant during training, Flash Attention’s reduced VRAM usage and improved efficiency make it valuable for inference as well, enabling faster and more scalable LLM serving.";return{c(){r=E(`Flash Attention is a technique that optimizes the attention mechanism in transformer models by addressing memory bandwidth bottlenecks. As discussed earlier in [Chapter 1.8](/course/chapter1/8), the attention mechanism has quadratic complexity and memory usage, making it inefficient for long sequences.
`),o=w("p"),o.textContent=j,U=y(),m=w("p"),m.textContent=T},l(M){r=N(M,`Flash Attention is a technique that optimizes the attention mechanism in transformer models by addressing memory bandwidth bottlenecks. As discussed earlier in [Chapter 1.8](/course/chapter1/8), the attention mechanism has quadratic complexity and memory usage, making it inefficient for long sequences.
`),o=h(M,"P",{"data-svelte-h":!0}),Z(o)!=="svelte-jnwo3v"&&(o.textContent=j),U=c(M),m=h(M,"P",{"data-svelte-h":!0}),Z(m)!=="svelte-9afbfq"&&(m.textContent=T)},m(M,J){t(M,r,J),t(M,o,J),t(M,U,J),t(M,m,J)},p:Gl,d(M){M&&(e(r),e(o),e(U),e(m))}}}function yt(A){let r,o,j="vLLM’s key innovation lies in how it manages this cache:",U,m,T="<li><strong>Memory Paging</strong>: Instead of treating the KV cache as one large block, it’s divided into fixed-size “pages” (similar to virtual memory in operating systems).</li> <li><strong>Non-contiguous Storage</strong>: Pages don’t need to be stored contiguously in GPU memory, allowing for more flexible memory allocation.</li> <li><strong>Page Table Management</strong>: A page table tracks which pages belong to which sequence, enabling efficient lookup and access.</li> <li><strong>Memory Sharing</strong>: For operations like parallel sampling, pages storing the KV cache for the prompt can be shared across multiple sequences.</li>",M,J,i='The PagedAttention approach can lead to up to 24x higher throughput compared to traditional methods, making it a game-changer for production LLM deployments. If you want to go really deep into how PagedAttention works, you can read the <a href="https://docs.vllm.ai/en/latest/design/kernel/paged_attention.html" rel="nofollow">the guide from the vLLM documentation</a>.';return{c(){r=E(`PagedAttention is a technique that addresses another critical bottleneck in LLM inference: KV cache memory management. As discussed in [Chapter 1.8](/course/chapter1/8), during text generation, the model stores attention keys and values (KV cache) for each generated token to reduce redundant computations. The KV cache can become enormous, especially with long sequences or multiple concurrent requests.
`),o=w("p"),o.textContent=j,U=y(),m=w("ol"),m.innerHTML=T,M=y(),J=w("p"),J.innerHTML=i},l(p){r=N(p,`PagedAttention is a technique that addresses another critical bottleneck in LLM inference: KV cache memory management. As discussed in [Chapter 1.8](/course/chapter1/8), during text generation, the model stores attention keys and values (KV cache) for each generated token to reduce redundant computations. The KV cache can become enormous, especially with long sequences or multiple concurrent requests.
`),o=h(p,"P",{"data-svelte-h":!0}),Z(o)!=="svelte-1dh20ya"&&(o.textContent=j),U=c(p),m=h(p,"OL",{"data-svelte-h":!0}),Z(m)!=="svelte-af7t9r"&&(m.innerHTML=T),M=c(p),J=h(p,"P",{"data-svelte-h":!0}),Z(J)!=="svelte-15futu5"&&(J.innerHTML=i)},m(p,v){t(p,r,v),t(p,o,v),t(p,U,v),t(p,m,v),t(p,M,v),t(p,J,v)},p:Gl,d(p){p&&(e(r),e(o),e(U),e(m),e(M),e(J))}}}function ct(A){let r,o,j="Key quantization features in llama.cpp include:",U,m,T="<li><strong>Multiple Quantization Levels</strong>: Supports 8-bit, 4-bit, 3-bit, and even 2-bit quantization</li> <li><strong>GGML/GGUF Format</strong>: Uses custom tensor formats optimized for quantized inference</li> <li><strong>Mixed Precision</strong>: Can apply different quantization levels to different parts of the model</li> <li><strong>Hardware-Specific Optimizations</strong>: Includes optimized code paths for various CPU architectures (AVX2, AVX-512, NEON)</li>",M,J,i="This approach enables running billion-parameter models on consumer hardware with limited memory, making it perfect for local deployments and edge devices.";return{c(){r=E(`Quantization in llama.cpp reduces the precision of model weights from 32-bit or 16-bit floating point to lower precision formats like 8-bit integers (INT8), 4-bit, or even lower. This significantly reduces memory usage and improves inference speed with minimal quality loss.
`),o=w("p"),o.textContent=j,U=y(),m=w("ol"),m.innerHTML=T,M=y(),J=w("p"),J.textContent=i},l(p){r=N(p,`Quantization in llama.cpp reduces the precision of model weights from 32-bit or 16-bit floating point to lower precision formats like 8-bit integers (INT8), 4-bit, or even lower. This significantly reduces memory usage and improves inference speed with minimal quality loss.
`),o=h(p,"P",{"data-svelte-h":!0}),Z(o)!=="svelte-wl8vzm"&&(o.textContent=j),U=c(p),m=h(p,"OL",{"data-svelte-h":!0}),Z(m)!=="svelte-m0ejls"&&(m.innerHTML=T),M=c(p),J=h(p,"P",{"data-svelte-h":!0}),Z(J)!=="svelte-gau5ug"&&(J.textContent=i)},m(p,v){t(p,r,v),t(p,o,v),t(p,U,v),t(p,m,v),t(p,M,v),t(p,J,v)},p:Gl,d(p){p&&(e(r),e(o),e(U),e(m),e(M),e(J))}}}function rt(A){let r,o,j="TGI is easy to install and use, with deep integration into the Hugging Face ecosystem.",U,m,T="First, launch the TGI server using Docker:",M,J,i,p,v="Then interact with it using Hugging Face’s InferenceClient:",Q,X,R,W,cl="Alternatively, you can use the OpenAI client:",$,k,L,u,S="llama.cpp is easy to install and use, requiring minimal dependencies and supporting both CPU and GPU inference.",ll,H,Il="First, install and build llama.cpp:",el,x,tl,D,dl="Then, launch the server (with OpenAI API compatibility):",sl,q,nl,P,bl="Interact with the server using Hugging Face’s InferenceClient:",al,z,Ml,K,ul="Alternatively, you can use the OpenAI client:",Y,rl,pl,O,Cl="vLLM is easy to install and use, with both OpenAI API compatibility and a native Python interface.",ol,_,Ul="First, launch the vLLM OpenAI-compatible server:",jl,F,ml,il,Jl="Then interact with it using Hugging Face’s InferenceClient:",n,I,Sl,wl,fl="Alternatively, you can use the OpenAI client:",gl,yl,Bl,hl;return J=new V({props:{code:"ZG9ja2VyJTIwcnVuJTIwLS1ncHVzJTIwYWxsJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1zaG0tc2l6ZSUyMDFnJTIwJTVDJTBBJTIwJTIwJTIwJTIwLXAlMjA4MDgwJTNBODAlMjAlNUMlMEElMjAlMjAlMjAlMjAtdiUyMH4lMkYuY2FjaGUlMkZodWdnaW5nZmFjZSUzQSUyRmRhdGElMjAlNUMlMEElMjAlMjAlMjAlMjBnaGNyLmlvJTJGaHVnZ2luZ2ZhY2UlMkZ0ZXh0LWdlbmVyYXRpb24taW5mZXJlbmNlJTNBbGF0ZXN0JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tb2RlbC1pZCUyMEh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3Q=",highlighted:`docker run --gpus all \\
    --shm-size 1g \\
    -p 8080:80 \\
    -v ~/.cache/huggingface:/data \\
    ghcr.io/huggingface/text-generation-inference:latest \\
    --model-id HuggingFaceTB/SmolLM2-360M-Instruct`,wrap:!1}}),X=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMjBwb2ludGluZyUyMHRvJTIwVEdJJTIwZW5kcG9pbnQlMEFjbGllbnQlMjAlM0QlMjBJbmZlcmVuY2VDbGllbnQoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODA4MCUyMiUyQyUyMCUyMCUyMyUyMFVSTCUyMHRvJTIwdGhlJTIwVEdJJTIwc2VydmVyJTBBKSUwQSUwQSUyMyUyMFRleHQlMjBnZW5lcmF0aW9uJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQudGV4dF9nZW5lcmF0aW9uKCUwQSUyMCUyMCUyMCUyMCUyMlRlbGwlMjBtZSUyMGElMjBzdG9yeSUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjclMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEElMjAlMjAlMjAlMjBkZXRhaWxzJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMHN0b3Bfc2VxdWVuY2VzJTNEJTVCJTVEJTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmdlbmVyYXRlZF90ZXh0KSUwQSUwQSUyMyUyMEZvciUyMGNoYXQlMjBmb3JtYXQlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0X2NvbXBsZXRpb24oJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBoZWxwZnVsJTIwYXNzaXN0YW50LiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMlRlbGwlMjBtZSUyMGElMjBzdG9yeSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSklMEFwcmludChyZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlLmNvbnRlbnQp",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Initialize client pointing to TGI endpoint</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8080&quot;</span>,  <span class="hljs-comment"># URL to the TGI server</span>
)

<span class="hljs-comment"># Text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Tell me a story&quot;</span>,
    max_new_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
    details=<span class="hljs-literal">True</span>,
    stop_sequences=[],
)
<span class="hljs-built_in">print</span>(response.generated_text)

<span class="hljs-comment"># For chat format</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),k=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMjBwb2ludGluZyUyMHRvJTIwVEdJJTIwZW5kcG9pbnQlMEFjbGllbnQlMjAlM0QlMjBPcGVuQUkoJTBBJTIwJTIwJTIwJTIwYmFzZV91cmwlM0QlMjJodHRwJTNBJTJGJTJGbG9jYWxob3N0JTNBODA4MCUyRnYxJTIyJTJDJTIwJTIwJTIzJTIwTWFrZSUyMHN1cmUlMjB0byUyMGluY2x1ZGUlMjAlMkZ2MSUwQSUyMCUyMCUyMCUyMGFwaV9rZXklM0QlMjJub3QtbmVlZGVkJTIyJTJDJTIwJTIwJTIzJTIwVEdJJTIwZG9lc24ndCUyMHJlcXVpcmUlMjBhbiUyMEFQSSUyMGtleSUyMGJ5JTIwZGVmYXVsdCUwQSklMEElMEElMjMlMjBDaGF0JTIwY29tcGxldGlvbiUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXQuY29tcGxldGlvbnMuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIySHVnZ2luZ0ZhY2VUQiUyRlNtb2xMTTItMzYwTS1JbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnN5c3RlbSUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJZb3UlMjBhcmUlMjBhJTIwaGVscGZ1bCUyMGFzc2lzdGFudC4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJUZWxsJTIwbWUlMjBhJTIwc3RvcnklMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjclMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Initialize client pointing to TGI endpoint</span>
client = OpenAI(
    base_url=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>,  <span class="hljs-comment"># Make sure to include /v1</span>
    api_key=<span class="hljs-string">&quot;not-needed&quot;</span>,  <span class="hljs-comment"># TGI doesn&#x27;t require an API key by default</span>
)

<span class="hljs-comment"># Chat completion</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-360M-Instruct&quot;</span>,
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),x=new V({props:{code:"JTIzJTIwQ2xvbmUlMjB0aGUlMjByZXBvc2l0b3J5JTBBZ2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZnZ2VyZ2Fub3YlMkZsbGFtYS5jcHAlMEFjZCUyMGxsYW1hLmNwcCUwQSUwQSUyMyUyMEJ1aWxkJTIwdGhlJTIwcHJvamVjdCUwQW1ha2UlMEElMEElMjMlMjBEb3dubG9hZCUyMHRoZSUyMFNtb2xMTTItMS43Qi1JbnN0cnVjdC1HR1VGJTIwbW9kZWwlMEFjdXJsJTIwLUwlMjAtTyUyMGh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0xLjdCLUluc3RydWN0LUdHVUYlMkZyZXNvbHZlJTJGbWFpbiUyRnNtb2xsbTItMS43Yi1pbnN0cnVjdC5RNF9LX00uZ2d1Zg==",highlighted:`<span class="hljs-comment"># Clone the repository</span>
git <span class="hljs-built_in">clone</span> https://github.com/ggerganov/llama.cpp
<span class="hljs-built_in">cd</span> llama.cpp

<span class="hljs-comment"># Build the project</span>
make

<span class="hljs-comment"># Download the SmolLM2-1.7B-Instruct-GGUF model</span>
curl -L -O https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct-GGUF/resolve/main/smollm2-1.7b-instruct.Q4_K_M.gguf`,wrap:!1}}),q=new V({props:{code:"JTIzJTIwU3RhcnQlMjB0aGUlMjBzZXJ2ZXIlMEEuJTJGc2VydmVyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLW0lMjBzbW9sbG0yLTEuN2ItaW5zdHJ1Y3QuUTRfS19NLmdndWYlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWhvc3QlMjAwLjAuMC4wJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wb3J0JTIwODA4MCUyMCU1QyUwQSUyMCUyMCUyMCUyMC1jJTIwNDA5NiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbi1ncHUtbGF5ZXJzJTIwMCUyMCUyMCUyMyUyMFNldCUyMHRvJTIwYSUyMGhpZ2hlciUyMG51bWJlciUyMHRvJTIwdXNlJTIwR1BV",highlighted:`<span class="hljs-comment"># Start the server</span>
./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --host 0.0.0.0 \\
    --port 8080 \\
    -c 4096 \\
    --n-gpu-layers 0  <span class="hljs-comment"># Set to a higher number to use GPU</span>`,wrap:!1}}),z=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMjBwb2ludGluZyUyMHRvJTIwbGxhbWEuY3BwJTIwc2VydmVyJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwODAlMkZ2MSUyMiUyQyUyMCUyMCUyMyUyMFVSTCUyMHRvJTIwdGhlJTIwbGxhbWEuY3BwJTIwc2VydmVyJTBBJTIwJTIwJTIwJTIwdG9rZW4lM0QlMjJzay1uby1rZXktcmVxdWlyZWQlMjIlMkMlM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MC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Initialize client pointing to llama.cpp server</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>,  <span class="hljs-comment"># URL to the llama.cpp server</span>
    token=<span class="hljs-string">&quot;sk-no-key-required&quot;</span>,  <span class="hljs-comment"># llama.cpp server requires this placeholder</span>
)

<span class="hljs-comment"># Text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Tell me a story&quot;</span>,
    max_new_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
    details=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(response.generated_text)

<span class="hljs-comment"># For chat format</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),rl=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMjBwb2ludGluZyUyMHRvJTIwbGxhbWEuY3BwJTIwc2VydmVyJTBB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XJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Initialize client pointing to llama.cpp server</span>
client = OpenAI(
    base_url=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>,
    api_key=<span class="hljs-string">&quot;sk-no-key-required&quot;</span>,  <span class="hljs-comment"># llama.cpp server requires this placeholder</span>
)

<span class="hljs-comment"># Chat completion</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,  <span class="hljs-comment"># Model identifier can be anything as server only loads one model</span>
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),F=new V({props:{code:"cHl0aG9uJTIwLW0lMjB2bGxtLmVudHJ5cG9pbnRzLm9wZW5haS5hcGlfc2VydmVyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tb2RlbCUyMEh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3QlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWhvc3QlMjAwLjAuMC4wJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wb3J0JTIwODAwMA==",highlighted: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MjAlMjJjb250ZW50JTIyJTNBJTIwJTIyWW91JTIwYXJlJTIwYSUyMGhlbHBmdWwlMjBhc3Npc3RhbnQuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyVGVsbCUyMG1lJTIwYSUyMHN0b3J5JTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Initialize client pointing to vLLM endpoint</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8000/v1&quot;</span>,  <span class="hljs-comment"># URL to the vLLM server</span>
)

<span class="hljs-comment"># Text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Tell me a story&quot;</span>,
    max_new_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
    details=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(response.generated_text)

<span class="hljs-comment"># For chat format</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),yl=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaXRpYWxpemUlMjBjbGllbnQlMjBwb2ludGluZyUyMHRvJTIwdkxMTSUyMGVuZHBvaW50JTBBY2xpZW50JTIwJTNEJTIwT3BlbkFJKCUwQSUyMCUyMCUyMCUyMGJhc2VfdXJsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwMDAlMkZ2MSUyMiUyQyUwQSUyMCUyMCUyMCUyMGFwaV9rZXklM0QlMjJub3QtbmVlZGVkJTIyJTJDJTIwJTIwJTIzJTIwdkxMTSUyMGRvZXNuJ3QlMjByZXF1aXJlJTIwYW4lMjBBUEklMjBrZXklMjBieSUyMGRlZmF1bHQlMEEpJTBBJTBBJTIzJTIwQ2hhdCUyMGNvbXBsZXRpb24lMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMkh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3QlMjIlMkMlMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyWW91JTIwYXJlJTIwYSUyMGhlbHBmdWwlMjBhc3Npc3RhbnQuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyVGVsbCUyMG1lJTIwYSUyMHN0b3J5JTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Initialize client pointing to vLLM endpoint</span>
client = OpenAI(
    base_url=<span class="hljs-string">&quot;http://localhost:8000/v1&quot;</span>,
    api_key=<span class="hljs-string">&quot;not-needed&quot;</span>,  <span class="hljs-comment"># vLLM doesn&#x27;t require an API key by default</span>
)

<span class="hljs-comment"># Chat completion</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-360M-Instruct&quot;</span>,
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a helpful assistant.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Tell me a story&quot;</span>},
    ],
    max_tokens=<span class="hljs-number">100</span>,
    temperature=<span class="hljs-number">0.7</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">
`),o=w("p"),o.textContent=j,U=y(),m=w("p"),m.textContent=T,M=y(),f(J.$$.fragment),i=y(),p=w("p"),p.textContent=v,Q=y(),f(X.$$.fragment),R=y(),W=w("p"),W.textContent=cl,$=y(),f(k.$$.fragment),L=E(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),u=w("p"),u.textContent=S,ll=y(),H=w("p"),H.textContent=Il,el=y(),f(x.$$.fragment),tl=y(),D=w("p"),D.textContent=dl,sl=y(),f(q.$$.fragment),nl=y(),P=w("p"),P.textContent=bl,al=y(),f(z.$$.fragment),Ml=y(),K=w("p"),K.textContent=ul,Y=y(),f(rl.$$.fragment),pl=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),O=w("p"),O.textContent=Cl,ol=y(),_=w("p"),_.textContent=Ul,jl=y(),f(F.$$.fragment),ml=y(),il=w("p"),il.textContent=Jl,n=y(),f(I.$$.fragment),Sl=y(),wl=w("p"),wl.textContent=fl,gl=y(),f(yl.$$.fragment),Bl=E(`
</hfoption>`)},l(s){r=N(s,`<hfoption value="tgi" label="TGI">
`),o=h(s,"P",{"data-svelte-h":!0}),Z(o)!=="svelte-1xscn0n"&&(o.textContent=j),U=c(s),m=h(s,"P",{"data-svelte-h":!0}),Z(m)!=="svelte-1g20rmd"&&(m.textContent=T),M=c(s),g(J.$$.fragment,s),i=c(s),p=h(s,"P",{"data-svelte-h":!0}),Z(p)!=="svelte-168g8u0"&&(p.textContent=v),Q=c(s),g(X.$$.fragment,s),R=c(s),W=h(s,"P",{"data-svelte-h":!0}),Z(W)!=="svelte-1vrpxju"&&(W.textContent=cl),$=c(s),g(k.$$.fragment,s),L=N(s,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),u=h(s,"P",{"data-svelte-h":!0}),Z(u)!=="svelte-1uzfhnr"&&(u.textContent=S),ll=c(s),H=h(s,"P",{"data-svelte-h":!0}),Z(H)!=="svelte-1xrr3cs"&&(H.textContent=Il),el=c(s),g(x.$$.fragment,s),tl=c(s),D=h(s,"P",{"data-svelte-h":!0}),Z(D)!=="svelte-9xyw1x"&&(D.textContent=dl),sl=c(s),g(q.$$.fragment,s),nl=c(s),P=h(s,"P",{"data-svelte-h":!0}),Z(P)!=="svelte-5g6wzi"&&(P.textContent=bl),al=c(s),g(z.$$.fragment,s),Ml=c(s),K=h(s,"P",{"data-svelte-h":!0}),Z(K)!=="svelte-1vrpxju"&&(K.textContent=ul),Y=c(s),g(rl.$$.fragment,s),pl=N(s,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),O=h(s,"P",{"data-svelte-h":!0}),Z(O)!=="svelte-1sx76te"&&(O.textContent=Cl),ol=c(s),_=h(s,"P",{"data-svelte-h":!0}),Z(_)!=="svelte-9ezhmp"&&(_.textContent=Ul),jl=c(s),g(F.$$.fragment,s),ml=c(s),il=h(s,"P",{"data-svelte-h":!0}),Z(il)!=="svelte-168g8u0"&&(il.textContent=Jl),n=c(s),g(I.$$.fragment,s),Sl=c(s),wl=h(s,"P",{"data-svelte-h":!0}),Z(wl)!=="svelte-1vrpxju"&&(wl.textContent=fl),gl=c(s),g(yl.$$.fragment,s),Bl=N(s,`
</hfoption>`)},m(s,d){t(s,r,d),t(s,o,d),t(s,U,d),t(s,m,d),t(s,M,d),B(J,s,d),t(s,i,d),t(s,p,d),t(s,Q,d),B(X,s,d),t(s,R,d),t(s,W,d),t(s,$,d),B(k,s,d),t(s,L,d),t(s,u,d),t(s,ll,d),t(s,H,d),t(s,el,d),B(x,s,d),t(s,tl,d),t(s,D,d),t(s,sl,d),B(q,s,d),t(s,nl,d),t(s,P,d),t(s,al,d),B(z,s,d),t(s,Ml,d),t(s,K,d),t(s,Y,d),B(rl,s,d),t(s,pl,d),t(s,O,d),t(s,ol,d),t(s,_,d),t(s,jl,d),B(F,s,d),t(s,ml,d),t(s,il,d),t(s,n,d),B(I,s,d),t(s,Sl,d),t(s,wl,d),t(s,gl,d),B(yl,s,d),t(s,Bl,d),hl=!0},p:Gl,i(s){hl||(b(J.$$.fragment,s),b(X.$$.fragment,s),b(k.$$.fragment,s),b(x.$$.fragment,s),b(q.$$.fragment,s),b(z.$$.fragment,s),b(rl.$$.fragment,s),b(F.$$.fragment,s),b(I.$$.fragment,s),b(yl.$$.fragment,s),hl=!0)},o(s){C(J.$$.fragment,s),C(X.$$.fragment,s),C(k.$$.fragment,s),C(x.$$.fragment,s),C(q.$$.fragment,s),C(z.$$.fragment,s),C(rl.$$.fragment,s),C(F.$$.fragment,s),C(I.$$.fragment,s),C(yl.$$.fragment,s),hl=!1},d(s){s&&(e(r),e(o),e(U),e(m),e(M),e(i),e(p),e(Q),e(R),e(W),e($),e(L),e(u),e(ll),e(H),e(el),e(tl),e(D),e(sl),e(nl),e(P),e(al),e(Ml),e(K),e(Y),e(pl),e(O),e(ol),e(_),e(jl),e(ml),e(il),e(n),e(Sl),e(wl),e(gl),e(Bl)),G(J,s),G(X,s),G(k,s),G(x,s),G(q,s),G(z,s),G(rl,s),G(F,s),G(I,s),G(yl,s)}}}function mt(A){let r,o,j="First, deploy TGI with advanced parameters:",U,m,T,M,J="Use the InferenceClient for flexible text generation:",i,p,v,Q,X="Or use the OpenAI client:",R,W,cl,$,k="For llama.cpp, you can set advanced parameters when launching the server:",L,u,S,ll,H="Use the InferenceClient:",Il,el,x,tl,D="Or use the OpenAI client for generation with control over the sampling parameters:",dl,sl,q,nl,P="You can also use llama.cpp’s native library for even more control:",bl,al,z,Ml,K="For advanced usage with vLLM, you can use the InferenceClient:",ul,Y,rl,pl,O="You can also use the OpenAI client:",Cl,ol,_,Ul,jl="vLLM also provides a native Python interface with fine-grained control:",F,ml,il,Jl;return m=new V({props:{code:"ZG9ja2VyJTIwcnVuJTIwLS1ncHVzJTIwYWxsJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1zaG0tc2l6ZSUyMDFnJTIwJTVDJTBBJTIwJTIwJTIwJTIwLXAlMjA4MDgwJTNBODAlMjAlNUMlMEElMjAlMjAlMjAlMjAtdiUyMH4lMkYuY2FjaGUlMkZodWdnaW5nZmFjZSUzQSUyRmRhdGElMjAlNUMlMEElMjAlMjAlMjAlMjBnaGNyLmlvJTJGaHVnZ2luZ2ZhY2UlMkZ0ZXh0LWdlbmVyYXRpb24taW5mZXJlbmNlJTNBbGF0ZXN0JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tb2RlbC1pZCUyMEh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3QlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1heC10b3RhbC10b2tlbnMlMjA0MDk2JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tYXgtaW5wdXQtbGVuZ3RoJTIwMzA3MiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWF4LWJhdGNoLXRvdGFsLXRva2VucyUyMDgxOTIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXdhaXRpbmctc2VydmVkLXJhdGlvJTIwMS4y",highlighted:`docker run --gpus all \\
    --shm-size 1g \\
    -p 8080:80 \\
    -v ~/.cache/huggingface:/data \\
    ghcr.io/huggingface/text-generation-inference:latest \\
    --model-id HuggingFaceTB/SmolLM2-360M-Instruct \\
    --max-total-tokens 4096 \\
    --max-input-length 3072 \\
    --max-batch-total-tokens 8192 \\
    --waiting-served-ratio 1.2`,wrap:!1}}),p=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTIyKSUwQSUwQSUyMyUyMEFkdmFuY2VkJTIwcGFyYW1ldGVycyUyMGV4YW1wbGUlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0X2NvbXBsZXRpb24oJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJD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keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

client = InferenceClient(model=<span class="hljs-string">&quot;http://localhost:8080&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,
    max_tokens=<span class="hljs-number">200</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)

<span class="hljs-comment"># Raw text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Write a creative story about space exploration&quot;</span>,
    max_new_tokens=<span class="hljs-number">200</span>,
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    repetition_penalty=<span class="hljs-number">1.1</span>,
    do_sample=<span class="hljs-literal">True</span>,
    details=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(response.generated_text)`,wrap:!1}}),W=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiklMEElMEElMjMlMjBBZHZhbmNlZCUyMHBhcmFtZXRlcnMlMjBleGFtcGxlJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0zNjBNLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBjcmVhdGl2ZSUyMHN0b3J5dGVsbGVyLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldyaXRlJTIwYSUyMGNyZWF0aXZlJTIwc3RvcnklMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUyMCUyMCUyMyUyMEhpZ2hlciUyMGZvciUyMG1vcmUlMjBjcmVhdGl2aXR5JTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

client = OpenAI(base_url=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>, api_key=<span class="hljs-string">&quot;not-needed&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-360M-Instruct&quot;</span>,
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),u=new V({props:{code:"LiUyRnNlcnZlciUyMCU1QyUwQSUyMCUyMCUyMCUyMC1tJTIwc21vbGxtMi0xLjdiLWluc3RydWN0LlE0X0tfTS5nZ3VmJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1ob3N0JTIwMC4wLjAuMCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcG9ydCUyMDgwODAlMjAlNUMlMEElMjAlMjAlMjAlMjAtYyUyMDQwOTYlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBDb250ZXh0JTIwc2l6ZSUwQSUyMCUyMCUyMCUyMC0tdGhyZWFkcyUyMDglMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBDUFUlMjB0aHJlYWRzJTIwdG8lMjB1c2UlMEElMjAlMjAlMjAlMjAtLWJhdGNoLXNpemUlMjA1MTIlMjAlNUMlMjAlMjAlMjAlMjMlMjBCYXRjaCUyMHNpemUlMjBmb3IlMjBwcm9tcHQlMjBldmFsdWF0aW9uJTBBJTIwJTIwJTIwJTIwLS1uLWdwdS1sYXllcnMlMjAwJTIwJTIwJTIwJTIwJTIwJTIzJTIwR1BVJTIwbGF5ZXJzJTIwKDAlMjAlM0QlMjBDUFUlMjBvbmx5KQ==",highlighted:`./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --host 0.0.0.0 \\
    --port 8080 \\
    -c 4096 \\            <span class="hljs-comment"># Context size</span>
    --threads 8 \\        <span class="hljs-comment"># CPU threads to use</span>
    --batch-size 512 \\   <span class="hljs-comment"># Batch size for prompt evaluation</span>
    --n-gpu-layers 0     <span class="hljs-comment"># GPU layers (0 = CPU only)</span>`,wr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JTNEJTIwY2xpZW50LnRleHRfZ2VuZXJhdGlvbiglMEElMjAlMjAlMjAlMjAlMjJXcml0ZSUyMGElMjBjcmVhdGl2ZSUyMHN0b3J5JTIwYWJvdXQlMjBzcGFjZSUyMGV4cGxvcmF0aW9uJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QyMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMHJlcGV0aXRpb25fcGVuYWx0eSUzRDEuMSUyQyUwQSUyMCUyMCUyMCUyMGRldGFpbHMlM0RUcnVlJTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmdlbmVyYXRlZF90ZXh0KQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

client = InferenceClient(model=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>, token=<span class="hljs-string">&quot;sk-no-key-required&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,
    max_tokens=<span class="hljs-number">200</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)

<span class="hljs-comment"># For direct text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Write a creative story about space exploration&quot;</span>,
    max_new_tokens=<span class="hljs-number">200</span>,
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    repetition_penalty=<span class="hljs-number">1.1</span>,
    details=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(response.generated_text)`,wrap:!1}}),sl=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIyc2stbm8ta2V5LXJlcXVpcmVkJTIyKSUwQSUwQSUyMyUyMEFkdmFuY2VkJTIwcGFyYW1ldGVycyUyMGV4YW1wbGUlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMnNtb2xsbTItMS43Yi1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnN5c3RlbSUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJZb3UlMjBhcmUlMjBhJTIwY3JlYXRpdmUlMjBzdG9yeXRlbGxlci4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJXcml0ZSUyMGElMjBjcmVhdGl2ZSUyMHN0b3J5JTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjAlMjAlMjMlMjBIaWdoZXIlMjBmb3IlMjBtb3JlJTIwY3JlYXRpdml0eSUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUyMCUyMCUyMyUyME51Y2xldXMlMjBzYW1wbGluZyUyMHByb2JhYmlsaXR5JTBBJTIwJTIwJTIwJTIwZnJlcXVlbmN5X3BlbmFsdHklM0QwLjUlMkMlMjAlMjAlMjMlMjBSZWR1Y2UlMjByZXBldGl0aW9uJTIwb2YlMjBmcmVxdWVudCUyMHRva2VucyUwQSUyMCUyMCUyMCUyMHByZXNlbmNlX3BlbmFsdHklM0QwLjUlMkMlMjAlMjAlMjMlMjBSZWR1Y2UlMjByZXBldGl0aW9uJTIwYnklMjBwZW5hbGl6aW5nJTIwdG9rZW5zJTIwYWxyZWFkeSUyMHByZXNlbnQlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMjAwJTJDJTIwJTIwJTIzJTIwTWF4aW11bSUyMGdlbmVyYXRpb24lMjBsZW5ndGglMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

client = OpenAI(base_url=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>, api_key=<span class="hljs-string">&quot;sk-no-key-required&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Nucleus sampling probability</span>
    frequency_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Reduce repetition of frequent tokens</span>
    presence_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Reduce repetition by penalizing tokens already present</span>
    max_tokens=<span class="hljs-number">200</span>,  <span class="hljs-comment"># Maximum generation length</span>
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),al=new V({props:{code:"JTIzJTIwVXNpbmclMjBsbGFtYS1jcHAtcHl0aG9uJTIwcGFja2FnZSUyMGZvciUyMGRpcmVjdCUyMG1vZGVsJTIwYWNjZXNzJTBBZnJvbSUyMGxsYW1hX2NwcCUyMGltcG9ydCUyMExsYW1hJTBBJTBBJTIzJTIwTG9hZCUyMHRoZSUyMG1vZGVsJTBBbGxtJTIwJTNEJTIwTGxhbWEoJTBBJTIwJTIwJTIwJTIwbW9kZWxfcGF0aCUzRCUyMnNtb2xsbTItMS43Yi1pbnN0cnVjdC5RNF9LX00uZ2d1ZiUyMiUyQyUwQSUyMCUyMCUyMCUyMG5fY3R4JTNENDA5NiUyQyUyMCUyMCUyMyUyMENvbnRleHQlMjB3aW5kb3clMjBzaXplJTBBJTIwJTIwJTIwJTIwbl90aHJlYWRzJTNEOCUyQyUyMCUyMCUyMyUyMENQVSUyMHRocmVhZHMlMEElMjAlMjAlMjAlMjBuX2dwdV9sYXllcnMlM0QwJTJDJTIwJTIwJTIzJTIwR1BVJTIwbGF5ZXJzJTIwKDAlMjAlM0QlMjBDUFUlMjBvbmx5KSUwQSklMEElMEElMjMlMjBGb3JtYXQlMjBwcm9tcHQlMjBhY2NvcmRpbmclMjB0byUyMHRoZSUyMG1vZGVsJ3MlMjBleHBlY3RlZCUyMGZvcm1hdCUwQXByb21wdCUyMCUzRCUyMCUyMiUyMiUyMiUzQyU3Q2ltX3N0YXJ0JTdDJTNFc3lzdGVtJTBBWW91JTIwYXJlJTIwYSUyMGNyZWF0aXZlJTIwc3Rvcnl0ZWxsZXIuJTBBJTNDJTdDaW1fZW5kJTdDJTNFJTBBJTNDJTdDaW1fc3RhcnQlN0MlM0V1c2VyJTBBV3JpdGUlMjBhJTIwY3JlYXRpdmUlMjBzdG9yeSUwQSUzQyU3Q2ltX2VuZCU3QyUzRSUwQSUzQyU3Q2ltX3N0YXJ0JTdDJTNFYXNzaXN0YW50JTBBJTIyJTIyJTIyJTBBJTBBJTIzJTIwR2VuZXJhdGUlMjByZXNwb25zZSUyMHdpdGglMjBwcmVjaXNlJTIwcGFyYW1ldGVyJTIwY29udHJvbCUwQW91dHB1dCUyMCUzRCUyMGxsbSglMEElMjAlMjAlMjAlMjBwcm9tcHQlMkMlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMjAwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEElMjAlMjAlMjAlMjBmcmVxdWVuY3lfcGVuYWx0eSUzRDAuNSUyQyUwQSUyMCUyMCUyMCUyMHByZXNlbmNlX3BlbmFsdHklM0QwLjUlMkMlMEElMjAlMjAlMjAlMjBzdG9wJTNEJTVCJTIyJTNDJTdDaW1fZW5kJTdDJTNFJTIyJTVEJTJDJTBBKSUwQSUwQXByaW50KG91dHB1dCU1QiUyMmNob2ljZXMlMjIlNUQlNUIwJTVEJTVCJTIydGV4dCUyMiU1RCk=",highlighted:`<span class="hljs-comment"># Using llama-cpp-python package for direct model access</span>
<span class="hljs-keyword">from</span> llama_cpp <span class="hljs-keyword">import</span> Llama

<span class="hljs-comment"># Load the model</span>
llm = Llama(
    model_path=<span class="hljs-string">&quot;smollm2-1.7b-instruct.Q4_K_M.gguf&quot;</span>,
    n_ctx=<span class="hljs-number">4096</span>,  <span class="hljs-comment"># Context window size</span>
    n_threads=<span class="hljs-number">8</span>,  <span class="hljs-comment"># CPU threads</span>
    n_gpu_layers=<span class="hljs-number">0</span>,  <span class="hljs-comment"># GPU layers (0 = CPU only)</span>
)

<span class="hljs-comment"># Format prompt according to the model&#x27;s expected format</span>
prompt = <span class="hljs-string">&quot;&quot;&quot;&lt;|im_start|&gt;system
You are a creative storyteller.
&lt;|im_end|&gt;
&lt;|im_start|&gt;user
Write a creative story
&lt;|im_end|&gt;
&lt;|im_start|&gt;assistant
&quot;&quot;&quot;</span>

<span class="hljs-comment"># Generate response with precise parameter control</span>
output = llm(
    prompt,
    max_tokens=<span class="hljs-number">200</span>,
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    frequency_penalty=<span class="hljs-number">0.5</span>,
    presence_penalty=<span class="hljs-number">0.5</span>,
    stop=[<span class="hljs-string">&quot;&lt;|im_end|&gt;&quot;</span>],
)

<span class="hljs-built_in">print</span>(output[<span class="hljs-string">&quot;choices&quot;</span>][<span class="hljs-number">0</span>][<span class="hljs-string">&quot;text&quot;</span>])`,wrap:!1}}),Y=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIpJTBBJTBBJTIzJTIwQWR2YW5jZWQlMjBwYXJhbWV0ZXJzJTIwZXhhbXBsZSUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXRfY29tcGxldGlvbiglMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyWW91JTIwYXJlJTIwYSUyMGNyZWF0aXZlJTIwc3Rvcnl0ZWxsZXIuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyV3JpdGUlMjBhJTIwY3JlYXRpdmUlMjBzdG9yeSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC44JTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDIwMCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSklMEFwcmludChyZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlLmNvbnRlbnQpJTBBJTBBJTIzJTIwRm9yJTIwZGlyZWN0JTIwdGV4dCUyMGdlbmVyYXRpb24lMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC50ZXh0X2dlbmVyYXRpb24oJTBBJTIwJTIwJTIwJTIwJTIyV3JpdGUlMjBhJTIwY3JlYXRpdmUlMjBzdG9yeSUyMGFib3V0JTIwc3BhY2UlMjBleHBsb3JhdGlvbiUyMiUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMjAwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEElMjAlMjAlMjAlMjBkZXRhaWxzJTNEVHJ1ZSUyQyUwQSklMEFwcmludChyZXNwb25zZS5nZW5lcmF0ZWRfdGV4dCk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

client = InferenceClient(model=<span class="hljs-string">&quot;http://localhost:8000/v1&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat_completion(
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,
    max_tokens=<span class="hljs-number">200</span>,
    top_p=<span class="hljs-number">0.95</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)

<span class="hljs-comment"># For direct text generation</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Write a creative story about space exploration&quot;</span>,
    max_new_tokens=<span class="hljs-number">200</span>,
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    details=<span class="hljs-literal">True</span>,
)
<span class="hljs-built_in">print</span>(response.generated_text)`,wrap:!1}}),ol=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiklMEElMEElMjMlMjBBZHZhbmNlZCUyMHBhcmFtZXRlcnMlMjBleGFtcGxlJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0zNjBNLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMllvdSUyMGFyZSUyMGElMjBjcmVhdGl2ZSUyMHN0b3J5dGVsbGVyLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMldyaXRlJTIwYSUyMGNyZWF0aXZlJTIwc3RvcnklMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QyMDAlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

client = OpenAI(base_url=<span class="hljs-string">&quot;http://localhost:8000/v1&quot;</span>, api_key=<span class="hljs-string">&quot;not-needed&quot;</span>)

<span class="hljs-comment"># Advanced parameters example</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-360M-Instruct&quot;</span>,
    messages=[
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
        {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    max_tokens=<span class="hljs-number">200</span>,
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),ml=new V({props:{code:"ZnJvbSUyMHZsbG0lMjBpbXBvcnQlMjBMTE0lMkMlMjBTYW1wbG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C5vdXRwdXRzJTVCMCU1RC50ZXh0KQ==",highlighted:`<span class="hljs-keyword">from</span> vllm <span class="hljs-keyword">import</span> LLM, SamplingParams

<span class="hljs-comment"># Initialize the model with advanced parameters</span>
llm = LLM(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-360M-Instruct&quot;</span>,
    gpu_memory_utilization=<span class="hljs-number">0.85</span>,
    max_num_batched_tokens=<span class="hljs-number">8192</span>,
    max_num_seqs=<span class="hljs-number">256</span>,
    block_size=<span class="hljs-number">16</span>,
)

<span class="hljs-comment"># Configure sampling parameters</span>
sampling_params = SamplingParams(
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consider top 95% probability mass</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Maximum length</span>
    presence_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
    stop=[<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;###&quot;</span>],  <span class="hljs-comment"># Stop sequences</span>
)

<span class="hljs-comment"># Generate text</span>
prompt = <span class="hljs-string">&quot;Write a creative story&quot;</span>
outputs = llm.generate(prompt, sampling_params)
<span class="hljs-built_in">print</span>(outputs[<span class="hljs-number">0</span>].outputs[<span class="hljs-number">0</span>].text)

<span class="hljs-comment"># For chat-style interactions</span>
chat_prompt = [
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;system&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;You are a creative storyteller.&quot;</span>},
    {<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span>: <span class="hljs-string">&quot;Write a creative story&quot;</span>},
]
formatted_prompt = llm.get_chat_template()(chat_prompt)  <span class="hljs-comment"># Uses model&#x27;s chat template</span>
outputs = llm.generate(formatted_prompt, sampling_params)
<span class="hljs-built_in">print</span>(outputs[<span class="hljs-number">0</span>].outputs[<span class="hljs-number">0</span>].text)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">
`),o=w("p"),o.textContent=j,U=y(),f(m.$$.fragment),T=y(),M=w("p"),M.textContent=J,i=y(),f(p.$$.fragment),v=y(),Q=w("p"),Q.textContent=X,R=y(),f(W.$$.fragment),cl=E(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),$=w("p"),$.textContent=k,L=y(),f(u.$$.fragment),S=y(),ll=w("p"),ll.textContent=H,Il=y(),f(el.$$.fragment),x=y(),tl=w("p"),tl.textContent=D,dl=y(),f(sl.$$.fragment),q=y(),nl=w("p"),nl.textContent=P,bl=y(),f(al.$$.fragment),z=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),Ml=w("p"),Ml.textContent=K,ul=y(),f(Y.$$.fragment),rl=y(),pl=w("p"),pl.textContent=O,Cl=y(),f(ol.$$.fragment),_=y(),Ul=w("p"),Ul.textContent=jl,F=y(),f(ml.$$.fragment),il=E(`
</hfoption>`)},l(n){r=N(n,`<hfoption value="tgi" label="TGI">
`),o=h(n,"P",{"data-svelte-h":!0}),Z(o)!=="svelte-p4nmid"&&(o.textContent=j),U=c(n),g(m.$$.fragment,n),T=c(n),M=h(n,"P",{"data-svelte-h":!0}),Z(M)!=="svelte-8cq2xt"&&(M.textContent=J),i=c(n),g(p.$$.fragment,n),v=c(n),Q=h(n,"P",{"data-svelte-h":!0}),Z(Q)!=="svelte-gwduza"&&(Q.textContent=X),R=c(n),g(W.$$.fragment,n),cl=N(n,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),$=h(n,"P",{"data-svelte-h":!0}),Z($)!=="svelte-b43ol"&&($.textContent=k),L=c(n),g(u.$$.fragment,n),S=c(n),ll=h(n,"P",{"data-svelte-h":!0}),Z(ll)!=="svelte-u8i4ra"&&(ll.textContent=H),Il=c(n),g(el.$$.fragment,n),x=c(n),tl=h(n,"P",{"data-svelte-h":!0}),Z(tl)!=="svelte-1jxmijw"&&(tl.textContent=D),dl=c(n),g(sl.$$.fragment,n),q=c(n),nl=h(n,"P",{"data-svelte-h":!0}),Z(nl)!=="svelte-1yadfem"&&(nl.textContent=P),bl=c(n),g(al.$$.fragment,n),z=N(n,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),Ml=h(n,"P",{"data-svelte-h":!0}),Z(Ml)!=="svelte-jbmhsw"&&(Ml.textContent=K),ul=c(n),g(Y.$$.fragment,n),rl=c(n),pl=h(n,"P",{"data-svelte-h":!0}),Z(pl)!=="svelte-m9xqnx"&&(pl.textContent=O),Cl=c(n),g(ol.$$.fragment,n),_=c(n),Ul=h(n,"P",{"data-svelte-h":!0}),Z(Ul)!=="svelte-1xs95kf"&&(Ul.textContent=jl),F=c(n),g(ml.$$.fragment,n),il=N(n,`
</hfoption>`)},m(n,I){t(n,r,I),t(n,o,I),t(n,U,I),B(m,n,I),t(n,T,I),t(n,M,I),t(n,i,I),B(p,n,I),t(n,v,I),t(n,Q,I),t(n,R,I),B(W,n,I),t(n,cl,I),t(n,$,I),t(n,L,I),B(u,n,I),t(n,S,I),t(n,ll,I),t(n,Il,I),B(el,n,I),t(n,x,I),t(n,tl,I),t(n,dl,I),B(sl,n,I),t(n,q,I),t(n,nl,I),t(n,bl,I),B(al,n,I),t(n,z,I),t(n,Ml,I),t(n,ul,I),B(Y,n,I),t(n,rl,I),t(n,pl,I),t(n,Cl,I),B(ol,n,I),t(n,_,I),t(n,Ul,I),t(n,F,I),B(ml,n,I),t(n,il,I),Jl=!0},p:Gl,i(n){Jl||(b(m.$$.fragment,n),b(p.$$.fragment,n),b(W.$$.fragment,n),b(u.$$.fragment,n),b(el.$$.fragment,n),b(sl.$$.fragment,n),b(al.$$.fragment,n),b(Y.$$.fragment,n),b(ol.$$.fragment,n),b(ml.$$.fragment,n),Jl=!0)},o(n){C(m.$$.fragment,n),C(p.$$.fragment,n),C(W.$$.fragment,n),C(u.$$.fragment,n),C(el.$$.fragment,n),C(sl.$$.fragment,n),C(al.$$.fragment,n),C(Y.$$.fragment,n),C(ol.$$.fragment,n),C(ml.$$.fragment,n),Jl=!1},d(n){n&&(e(r),e(o),e(U),e(T),e(M),e(i),e(v),e(Q),e(R),e(cl),e($),e(L),e(S),e(ll),e(Il),e(x),e(tl),e(dl),e(q),e(nl),e(bl),e(z),e(Ml),e(ul),e(rl),e(pl),e(Cl),e(_),e(Ul),e(F),e(il)),G(m,n),G(p,n),G(W,n),G(u,n),G(el,n),G(sl,n),G(al,n),G(Y,n),G(ol,n),G(ml,n)}}}function Jt(A){let r,o,j,U,m,T,M,J;return o=new V({props:{code:"Y2xpZW50LmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMCUyMldyaXRlJTIwYSUyMGNyZWF0aXZlJTIwc3RvcnklMjIlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUyMCUyMCUyMyUyMEhpZ2hlciUyMGZvciUyMG1vcmUlMjBjcmVhdGl2aXR5JTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTIwJTIwJTIzJTIwQ29uc2lkZXIlMjB0b3AlMjA5NSUyNSUyMHByb2JhYmlsaXR5JTIwbWFzcyUwQSUyMCUyMCUyMCUyMHRvcF9rJTNENTAlMkMlMjAlMjAlMjMlMjBDb25zaWRlciUyMHRvcCUyMDUwJTIwdG9rZW5zJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjAlMjAlMjMlMjBNYXhpbXVtJTIwbGVuZ3RoJTBBJTIwJTIwJTIwJTIwcmVwZXRpdGlvbl9wZW5hbHR5JTNEMS4xJTJDJTIwJTIwJTIzJTIwUmVkdWNlJTIwcmVwZXRpdGlvbiUwQSk=",highlighted:`client.generate(
    <span class="hljs-string">&quot;Write a creative story&quot;</span>,
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consider top 95% probability mass</span>
    top_k=<span class="hljs-number">50</span>,  <span class="hljs-comment"># Consider top 50 tokens</span>
    max_new_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Maximum length</span>
    repetition_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
)`,wrap:!1}}),U=new V({props:{code:"JTIzJTIwVmlhJTIwT3BlbkFJJTIwQVBJJTIwY29tcGF0aWJpbGl0eSUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMnNtb2xsbTItMS43Yi1pbnN0cnVjdCUyMiUyQyUyMCUyMCUyMyUyME1vZGVsJTIwbmFtZSUyMChjYW4lMjBiZSUyMGFueSUyMHN0cmluZyUyMGZvciUyMGxsYW1hLmNwcCUyMHNlcnZlciklMEElMjAlMjAlMjAlMjBwcm9tcHQlM0QlMjJXcml0ZSUyMGElMjBjcmVhdGl2ZSUyMHN0b3J5JTIyJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjAlMjAlMjMlMjBIaWdoZXIlMjBmb3IlMjBtb3JlJTIwY3JlYXRpdml0eSUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUyMCUyMCUyMyUyMENvbnNpZGVyJTIwdG9wJTIwOTUlMjUlMjBwcm9iYWJpbGl0eSUyMG1hc3MlMEElMjAlMjAlMjAlMjBmcmVxdWVuY3lfcGVuYWx0eSUzRDEuMSUyQyUyMCUyMCUyMyUyMFJlZHVjZSUyMHJlcGV0aXRpb24lMEElMjAlMjAlMjAlMjBwcmVzZW5jZV9wZW5hbHR5JTNEMC4xJTJDJTIwJTIwJTIzJTIwUmVkdWNlJTIwcmVwZXRpdGlvbiUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMjAlMjAlMjMlMjBNYXhpbXVtJTIwbGVuZ3RoJTBBKSUwQSUwQSUyMyUyMFZpYSUyMGxsYW1hLWNwcC1weXRob24lMjBkaXJlY3QlMjBhY2Nlc3MlMEFvdXRwdXQlMjAlM0QlMjBsbG0oJTBBJTIwJTIwJTIwJTIwJTIyV3JpdGUlMjBhJTIwY3JlYXRpdmUlMjBzdG9yeSUyMiUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC44JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBJTIwJTIwJTIwJTIwdG9wX2slM0Q1MCUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjByZXBlYXRfcGVuYWx0eSUzRDEuMSUyQyUwQSk=",highlighted:`<span class="hljs-comment"># Via OpenAI API compatibility</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,  <span class="hljs-comment"># Model name (can be any string for llama.cpp server)</span>
    prompt=<span class="hljs-string">&quot;Write a creative story&quot;</span>,
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consider top 95% probability mass</span>
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Maximum length</span>
)

<span class="hljs-comment"># Via llama-cpp-python direct access</span>
output = llm(
    <span class="hljs-string">&quot;Write a creative story&quot;</span>,
    temperature=<span class="hljs-number">0.8</span>,
    top_p=<span class="hljs-number">0.95</span>,
    top_k=<span class="hljs-number">50</span>,
    max_tokens=<span class="hljs-number">100</span>,
    repeat_penalty=<span class="hljs-number">1.1</span>,
)`,wrap:!1}}),T=new V({props:{code:"cGFyYW1zJTIwJTNEJTIwU2FtcGxpbmdQYXJhbXMoJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjAlMjAlMjMlMjBIaWdoZXIlMjBmb3IlMjBtb3JlJTIwY3JlYXRpdml0eSUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUyMCUyMCUyMyUyMENvbnNpZGVyJTIwdG9wJTIwOTUlMjUlMjBwcm9iYWJpbGl0eSUyMG1hc3MlMEElMjAlMjAlMjAlMjB0b3BfayUzRDUwJTJDJTIwJTIwJTIzJTIwQ29uc2lkZXIlMjB0b3AlMjA1MCUyMHRva2VucyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMjAlMjAlMjMlMjBNYXhpbXVtJTIwbGVuZ3RoJTBBJTIwJTIwJTIwJTIwcHJlc2VuY2VfcGVuYWx0eSUzRDAuMSUyQyUyMCUyMCUyMyUyMFJlZHVjZSUyMHJlcGV0aXRpb24lMEEpJTBBbGxtLmdlbmVyYXRlKCUyMldyaXRlJTIwYSUyMGNyZWF0aXZlJTIwc3RvcnklMjIlMkMlMjBzYW1wbGluZ19wYXJhbXMlM0RwYXJhbXMp",highlighted:`params = SamplingParams(
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Higher for more creativity</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consider top 95% probability mass</span>
    top_k=<span class="hljs-number">50</span>,  <span class="hljs-comment"># Consider top 50 tokens</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Maximum length</span>
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Reduce repetition</span>
)
llm.generate(<span class="hljs-string">&quot;Write a creative story&quot;</span>, sampling_params=params)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">

	`),f(o.$$.fragment),j=E(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),f(U.$$.fragment),m=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),f(T.$$.fragment),M=E(`
</hfoption>`)},l(i){r=N(i,`<hfoption value="tgi" label="TGI">

	`),g(o.$$.fragment,i),j=N(i,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),g(U.$$.fragment,i),m=N(i,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),g(T.$$.fragment,i),M=N(i,`
</hfoption>`)},m(i,p){t(i,r,p),B(o,i,p),t(i,j,p),B(U,i,p),t(i,m,p),B(T,i,p),t(i,M,p),J=!0},p:Gl,i(i){J||(b(o.$$.fragment,i),b(U.$$.fragment,i),b(T.$$.fragment,i),J=!0)},o(i){C(o.$$.fragment,i),C(U.$$.fragment,i),C(T.$$.fragment,i),J=!1},d(i){i&&(e(r),e(j),e(m),e(M)),G(o,i),G(U,i),G(T,i)}}}function Ut(A){let r,o,j,U,m,T;return o=new V({props:{code:"JTIzJTIwVmlhJTIwT3BlbkFJJTIwQVBJJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY29tcGxldGlvbnMuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyc21vbGxtMi0xLjdiLWluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyV3JpdGUlMjBhJTIwdmFyaWVkJTIwdGV4dCUyMiUyQyUwQSUyMCUyMCUyMCUyMGZyZXF1ZW5jeV9wZW5hbHR5JTNEMS4xJTJDJTIwJTIwJTIzJTIwUGVuYWxpemUlMjBmcmVxdWVudCUyMHRva2VucyUwQSUyMCUyMCUyMCUyMHByZXNlbmNlX3BlbmFsdHklM0QwLjglMkMlMjAlMjAlMjMlMjBQZW5hbGl6ZSUyMHRva2VucyUyMGFscmVhZHklMjBwcmVzZW50JTBBKSUwQSUwQSUyMyUyMFZpYSUyMGRpcmVjdCUyMGxpYnJhcnklMEFvdXRwdXQlMjAlM0QlMjBsbG0oJTBBJTIwJTIwJTIwJTIwJTIyV3JpdGUlMjBhJTIwdmFyaWVkJTIwdGV4dCUyMiUyQyUwQSUyMCUyMCUyMCUyMHJlcGVhdF9wZW5hbHR5JTNEMS4xJTJDJTIwJTIwJTIzJTIwUGVuYWxpemUlMjByZXBlYXRlZCUyMHRva2VucyUwQSUyMCUyMCUyMCUyMGZyZXF1ZW5jeV9wZW5hbHR5JTNEMC41JTJDJTIwJTIwJTIzJTIwQWRkaXRpb25hbCUyMGZyZXF1ZW5jeSUyMHBlbmFsdHklMEElMjAlMjAlMjAlMjBwcmVzZW5jZV9wZW5hbHR5JTNEMC41JTJDJTIwJTIwJTIzJTIwQWRkaXRpb25hbCUyMHByZXNlbmNlJTIwcGVuYWx0eSUwQSk=",highlighted:`<span class="hljs-comment"># Via OpenAI API</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,
    prompt=<span class="hljs-string">&quot;Write a varied text&quot;</span>,
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Penalize frequent tokens</span>
    presence_penalty=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Penalize tokens already present</span>
)

<span class="hljs-comment"># Via direct library</span>
output = llm(
    <span class="hljs-string">&quot;Write a varied text&quot;</span>,
    repeat_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Penalize repeated tokens</span>
    frequency_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Additional frequency penalty</span>
    presence_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Additional presence penalty</span>
)`,wrap:!1}}),U=new V({props:{code:"cGFyYW1zJTIwJTNEJTIwU2FtcGxpbmdQYXJhbXMoJTBBJTIwJTIwJTIwJTIwcHJlc2VuY2VfcGVuYWx0eSUzRDAuMSUyQyUyMCUyMCUyMyUyMFBlbmFsaXplJTIwdG9rZW4lMjBwcmVzZW5jZSUwQSUyMCUyMCUyMCUyMGZyZXF1ZW5jeV9wZW5hbHR5JTNEMC4xJTJDJTIwJTIwJTIzJTIwUGVuYWxpemUlMjB0b2tlbiUyMGZyZXF1ZW5jeSUwQSk=",highlighted:`params = SamplingParams(
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Penalize token presence</span>
    frequency_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Penalize token frequency</span>
)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Write a varied text",
    repetition_penalty=1.1,  # Penalize repeated tokens
    no_repeat_ngram_size=3,  # Prevent 3-gram repetition
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),f(o.$$.fragment),j=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),f(U.$$.fragment),m=E(`
</hfoption>`)},l(M){r=N(M,`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Write a varied text",
    repetition_penalty=1.1,  # Penalize repeated tokens
    no_repeat_ngram_size=3,  # Prevent 3-gram repetition
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),g(o.$$.fragment,M),j=N(M,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),g(U.$$.fragment,M),m=N(M,`
</hfoption>`)},m(M,J){t(M,r,J),B(o,M,J),t(M,j,J),B(U,M,J),t(M,m,J),T=!0},p:Gl,i(M){T||(b(o.$$.fragment,M),b(U.$$.fragment,M),T=!0)},o(M){C(o.$$.fragment,M),C(U.$$.fragment,M),T=!1},d(M){M&&(e(r),e(j),e(m)),G(o,M),G(U,M)}}}function Tt(A){let r,o,j,U,m,T;return o=new V({props:{code:"JTIzJTIwVmlhJTIwT3BlbkFJJTIwQVBJJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY29tcGxldGlvbnMuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyc21vbGxtMi0xLjdiLWluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEJTIyR2VuZXJhdGUlMjBhJTIwc2hvcnQlMjBwYXJhZ3JhcGglMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwc3RvcCUzRCU1QiUyMiU1Q24lNUNuJTIyJTJDJTIwJTIyJTIzJTIzJTIzJTIyJTVEJTJDJTBBKSUwQSUwQSUyMyUyMFZpYSUyMGRpcmVjdCUyMGxpYnJhcnklMEFvdXRwdXQlMjAlM0QlMjBsbG0oJTIyR2VuZXJhdGUlMjBhJTIwc2hvcnQlMjBwYXJhZ3JhcGglMjIlMkMlMjBtYXhfdG9rZW5zJTNEMTAwJTJDJTIwc3RvcCUzRCU1QiUyMiU1Q24lNUNuJTIyJTJDJTIwJTIyJTIzJTIzJTIzJTIyJTVEKQ==",highlighted:`<span class="hljs-comment"># Via OpenAI API</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,
    prompt=<span class="hljs-string">&quot;Generate a short paragraph&quot;</span>,
    max_tokens=<span class="hljs-number">100</span>,
    stop=[<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;###&quot;</span>],
)

<span class="hljs-comment"># Via direct library</span>
output = llm(<span class="hljs-string">&quot;Generate a short paragraph&quot;</span>, max_tokens=<span class="hljs-number">100</span>, stop=[<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;###&quot;</span>])`,wrap:!1}}),U=new V({props:{code:"cGFyYW1zJTIwJTNEJTIwU2FtcGxpbmdQYXJhbXMoJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMG1pbl90b2tlbnMlM0QxMCUyQyUwQSUyMCUyMCUyMCUyMHN0b3AlM0QlNUIlMjIlMjMlMjMlMjMlMjIlMkMlMjAlMjIlNUNuJTVDbiUyMiU1RCUyQyUwQSUyMCUyMCUyMCUyMGlnbm9yZV9lb3MlM0RGYWxzZSUyQyUwQSUyMCUyMCUyMCUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlJTJDJTBBKQ==",highlighted:`params = SamplingParams(
    max_tokens=<span class="hljs-number">100</span>,
    min_tokens=<span class="hljs-number">10</span>,
    stop=[<span class="hljs-string">&quot;###&quot;</span>, <span class="hljs-string">&quot;\\n\\n&quot;</span>],
    ignore_eos=<span class="hljs-literal">False</span>,
    skip_special_tokens=<span class="hljs-literal">True</span>,
)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Generate a short paragraph",
    max_new_tokens=100,
    min_new_tokens=10,
    stop_sequences=["\\n\\n", "###"],
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),f(o.$$.fragment),j=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),f(U.$$.fragment),m=E(`
</hfoption>`)},l(M){r=N(M,`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Generate a short paragraph",
    max_new_tokens=100,
    min_new_tokens=10,
    stop_sequences=["\\n\\n", "###"],
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),g(o.$$.fragment,M),j=N(M,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),g(U.$$.fragment,M),m=N(M,`
</hfoption>`)},m(M,J){t(M,r,J),B(o,M,J),t(M,j,J),B(U,M,J),t(M,m,J),T=!0},p:Gl,i(M){T||(b(o.$$.fragment,M),b(U.$$.fragment,M),T=!0)},o(M){C(o.$$.fragment,M),C(U.$$.fragment,M),T=!1},d(M){M&&(e(r),e(j),e(m)),G(o,M),G(U,M)}}}function ut(A){let r,o,j,U,m="llama.cpp uses quantization and optimized memory layout:",T,M,J,i,p="For models too large for your GPU, you can use CPU offloading:",v,Q,X,R,W="vLLM uses PagedAttention for optimal memory management:",cl,$,k,L;return o=new V({props:{code:"JTIzJTIwRG9ja2VyJTIwZGVwbG95bWVudCUyMHdpdGglMjBtZW1vcnklMjBvcHRpbWl6YXRpb24lMEFkb2NrZXIlMjBydW4lMjAtLWdwdXMlMjBhbGwlMjAtcCUyMDgwODAlM0E4MCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tc2htLXNpemUlMjAxZyUyMCU1QyUwQSUyMCUyMCUyMCUyMGdoY3IuaW8lMkZodWdnaW5nZmFjZSUyRnRleHQtZ2VuZXJhdGlvbi1pbmZlcmVuY2UlM0FsYXRlc3QlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1vZGVsLWlkJTIwSHVnZ2luZ0ZhY2VUQiUyRlNtb2xMTTItMS43Qi1JbnN0cnVjdCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWF4LWJhdGNoLXRvdGFsLXRva2VucyUyMDgxOTIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1heC1pbnB1dC1sZW5ndGglMjA0MDk2",highlighted:`<span class="hljs-comment"># Docker deployment with memory optimization</span>
docker run --gpus all -p 8080:80 \\
    --shm-size 1g \\
    ghcr.io/huggingface/text-generation-inference:latest \\
    --model-id HuggingFaceTB/SmolLM2-1.7B-Instruct \\
    --max-batch-total-tokens 8192 \\
    --max-input-length 4096`,wrap:!1}}),M=new V({props:{code:"JTIzJTIwU2VydmVyJTIwd2l0aCUyMG1lbW9yeSUyMG9wdGltaXphdGlvbnMlMEEuJTJGc2VydmVyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLW0lMjBzbW9sbG0yLTEuN2ItaW5zdHJ1Y3QuUTRfS19NLmdndWYlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWhvc3QlMjAwLjAuMC4wJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wb3J0JTIwODA4MCUyMCU1QyUwQSUyMCUyMCUyMCUyMC1jJTIwMjA0OCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMENvbnRleHQlMjBzaXplJTBBJTIwJTIwJTIwJTIwLS10aHJlYWRzJTIwNCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMENQVSUyMHRocmVhZHMlMEElMjAlMjAlMjAlMjAtLW4tZ3B1LWxheWVycyUyMDMyJTIwJTVDJTIwJTIwJTIwJTIwJTIwJTIzJTIwVXNlJTIwbW9yZSUyMEdQVSUyMGxheWVycyUyMGZvciUyMGxhcmdlciUyMG1vZGVscyUwQSUyMCUyMCUyMCUyMC0tbWxvY2slMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBMb2NrJTIwbWVtb3J5JTIwdG8lMjBwcmV2ZW50JTIwc3dhcHBpbmclMEElMjAlMjAlMjAlMjAtLWNvbnQtYmF0Y2hpbmclMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBFbmFibGUlMjBjb250aW51b3VzJTIwYmF0Y2hpbmc=",highlighted:`<span class="hljs-comment"># Server with memory optimizations</span>
./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --host 0.0.0.0 \\
    --port 8080 \\
    -c 2048 \\               <span class="hljs-comment"># Context size</span>
    --threads 4 \\           <span class="hljs-comment"># CPU threads</span>
    --n-gpu-layers 32 \\     <span class="hljs-comment"># Use more GPU layers for larger models</span>
    --mlock \\               <span class="hljs-comment"># Lock memory to prevent swapping</span>
    --cont-batching         <span class="hljs-comment"># Enable continuous batching</span>`,wrap:!1}}),Q=new V({props:{code:"LiUyRnNlcnZlciUyMCU1QyUwQSUyMCUyMCUyMCUyMC1tJTIwc21vbGxtMi0xLjdiLWluc3RydWN0LlE0X0tfTS5nZ3VmJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1uLWdwdS1sYXllcnMlMjAyMCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMyUyMEtlZXAlMjBmaXJzdCUyMDIwJTIwbGF5ZXJzJTIwb24lMjBHUFUlMEElMjAlMjAlMjAlMjAtLXRocmVhZHMlMjA4JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwVXNlJTIwbW9yZSUyMENQVSUyMHRocmVhZHMlMjBmb3IlMjBDUFUlMjBsYXllcnM=",highlighted:`./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --n-gpu-layers 20 \\     <span class="hljs-comment"># Keep first 20 layers on GPU</span>
    --threads 8             <span class="hljs-comment"># Use more CPU threads for CPU layers</span>`,wrap:!1}}),$=new V({props:{code:"ZnJvbSUyMHZsbG0uZW5naW5lLmFyZ191dGlscyUyMGltcG9ydCUyMEFzeW5jRW5naW5lQXJncyUwQSUwQWVuZ2luZV9hcmdzJTIwJTNEJTIwQXN5bmNFbmdpbmVBcmdzKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIySHVnZ2luZ0ZhY2VUQiUyRlNtb2xMTTItMS43Qi1JbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMGdwdV9tZW1vcnlfdXRpbGl6YXRpb24lM0QwLjg1JTJDJTBBJTIwJTIwJTIwJTIwbWF4X251bV9iYXRjaGVkX3Rva2VucyUzRDgxOTIlMkMlMEElMjAlMjAlMjAlMjBibG9ja19zaXplJTNEMTYlMkMlMEEpJTBBJTBBbGxtJTIwJTNEJTIwTExNKGVuZ2luZV9hcmdzJTNEZW5naW5lX2FyZ3Mp",highlighted:`<span class="hljs-keyword">from</span> vllm.engine.arg_utils <span class="hljs-keyword">import</span> AsyncEngineArgs

engine_args = AsyncEngineArgs(
    model=<span class="hljs-string">&quot;HuggingFaceTB/SmolLM2-1.7B-Instruct&quot;</span>,
    gpu_memory_utilization=<span class="hljs-number">0.85</span>,
    max_num_batched_tokens=<span class="hljs-number">8192</span>,
    block_size=<span class="hljs-number">16</span>,
)

llm = LLM(engine_args=engine_args)`,wrap:!1}}),{c(){r=E(`<hfoption value="tgi" label="TGI">
TGI uses Flash Attention 2 and continuous batching:

	`),f(o.$$.fragment),j=E(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),U=w("p"),U.textContent=m,T=y(),f(M.$$.fragment),J=y(),i=w("p"),i.textContent=p,v=y(),f(Q.$$.fragment),X=E(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),R=w("p"),R.textContent=W,cl=y(),f($.$$.fragment),k=E(`
</hfoption>`)},l(u){r=N(u,`<hfoption value="tgi" label="TGI">
TGI uses Flash Attention 2 and continuous batching:

	`),g(o.$$.fragment,u),j=N(u,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),U=h(u,"P",{"data-svelte-h":!0}),Z(U)!=="svelte-f66vqu"&&(U.textContent=m),T=c(u),g(M.$$.fragment,u),J=c(u),i=h(u,"P",{"data-svelte-h":!0}),Z(i)!=="svelte-1m87csn"&&(i.textContent=p),v=c(u),g(Q.$$.fragment,u),X=N(u,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),R=h(u,"P",{"data-svelte-h":!0}),Z(R)!=="svelte-6lsf9z"&&(R.textContent=W),cl=c(u),g($.$$.fragment,u),k=N(u,`
</hfoption>`)},m(u,S){t(u,r,S),B(o,u,S),t(u,j,S),t(u,U,S),t(u,T,S),B(M,u,S),t(u,J,S),t(u,i,S),t(u,v,S),B(Q,u,S),t(u,X,S),t(u,R,S),t(u,cl,S),B($,u,S),t(u,k,S),L=!0},p:Gl,i(u){L||(b(o.$$.fragment,u),b(M.$$.fragment,u),b(Q.$$.fragment,u),b($.$$.fragment,u),L=!0)},o(u){C(o.$$.fragment,u),C(M.$$.fragment,u),C(Q.$$.fragment,u),C($.$$.fragment,u),L=!1},d(u){u&&(e(r),e(j),e(U),e(T),e(J),e(i),e(v),e(X),e(R),e(cl),e(k)),G(o,u),G(M,u),G(Q,u),G($,u)}}}function jt(A){let r,o,j,U,m,T,M,J="In this section, we’ll explore advanced frameworks for optimizing LLM deployments: Text Generation Inference (TGI), vLLM, and llama.cpp. These applications are primarily used in production environments to serve LLMs to users. This section focuses on how to deploy these frameworks in production rather than how to use them for inference on a single machine.",i,p,v="We’ll cover how these tools maximize inference efficiency and simplify production deployments of Large Language Models.",Q,X,R,W,cl="TGI, vLLM, and llama.cpp serve similar purposes but have distinct characteristics that make them better suited for different use cases. Let’s look at the key differences between them, focusing on performance and integration.",$,k,L,u,S="<strong>TGI</strong> is designed to be stable and predictable in production, using fixed sequence lengths to keep memory usage consistent. TGI manages memory using Flash Attention 2 and continuous batching techniques. This means it can process attention calculations very efficiently and keep the GPU busy by constantly feeding it work. The system can move parts of the model between CPU and GPU when needed, which helps handle larger models.",ll,H,Il,el,x,tl,D,dl="<strong>vLLM</strong> takes a different approach by using PagedAttention. Just like how a computer manages its memory in pages, vLLM splits the model’s memory into smaller blocks. This clever system means it can handle different-sized requests more flexibly and doesn’t waste memory space. It’s particularly good at sharing memory between different requests and reduces memory fragmentation, which makes the whole system more efficient.",sl,q,nl,P,bl="<strong>llama.cpp</strong> is a highly optimized C/C++ implementation originally designed for running LLaMA models on consumer hardware. It focuses on CPU efficiency with optional GPU acceleration and is ideal for resource-constrained environments. llama.cpp uses quantization techniques to reduce model size and memory requirements while maintaining good performance. It implements optimized kernels for various CPU architectures and supports basic KV cache management for efficient token generation.",al,z,Ml,K,ul,Y,rl="Let’s move on to the deployment and integration differences between the frameworks.",pl,O,Cl="<strong>TGI</strong> excels in enterprise-level deployment with its production-ready features. It comes with built-in Kubernetes support and includes everything you need for running in production, like monitoring through Prometheus and Grafana, automatic scaling, and comprehensive safety features. The system also includes enterprise-grade logging and various protective measures like content filtering and rate limiting to keep your deployment secure and stable.",ol,_,Ul="<strong>vLLM</strong> takes a more flexible, developer-friendly approach to deployment. It’s built with Python at its core and can easily replace OpenAI’s API in your existing applications. The framework focuses on delivering raw performance and can be customized to fit your specific needs. It works particularly well with Ray for managing clusters, making it a great choice when you need high performance and adaptability.",jl,F,ml="<strong>llama.cpp</strong> prioritizes simplicity and portability. Its server implementation is lightweight and can run on a wide range of hardware, from powerful servers to consumer laptops and even some high-end mobile devices. With minimal dependencies and a simple C/C++ core, it’s easy to deploy in environments where installing Python frameworks would be challenging. The server provides an OpenAI-compatible API while maintaining a much smaller resource footprint than other solutions.",il,Jl,n,I,Sl="Let’s explore how to use these frameworks for deploying LLMs, starting with installation and basic setup.",wl,fl,gl,yl,Bl,hl,s,d,Ce="Let’s look at examples of text generation with the frameworks:",Ol,Zl,le,El,ee,Nl,te,$l,fe="The process of generating text involves selecting the next token at each step. This selection process can be controlled through various parameters:",se,Xl,ge="<li><strong>Raw Logits</strong>: The initial output probabilities for each token</li> <li><strong>Temperature</strong>: Controls randomness in selection (higher = more creative)</li> <li><strong>Top-p (Nucleus) Sampling</strong>: Filters to top tokens making up X% of probability mass</li> <li><strong>Top-k Filtering</strong>: Limits selection to k most likely tokens</li>",ne,kl,Be="Here’s how to configure these parameters:",ae,vl,Me,Rl,pe,xl,Ge="Both frameworks provide ways to prevent repetitive text generation:",oe,Al,ie,ql,ye,zl,Ze="You can control generation length and specify when to stop:",ce,Ql,re,Yl,me,_l,ve="Both frameworks implement advanced memory management techniques for efficient inference.",Je,Vl,Ue,Fl,Te,Ll,Ae='<li><a href="https://huggingface.co/docs/text-generation-inference" rel="nofollow">Text Generation Inference Documentation</a></li> <li><a href="https://github.com/huggingface/text-generation-inference" rel="nofollow">TGI GitHub Repository</a></li> <li><a href="https://vllm.readthedocs.io/" rel="nofollow">vLLM Documentation</a></li> <li><a href="https://github.com/vllm-project/vllm" rel="nofollow">vLLM GitHub Repository</a></li> <li><a href="https://arxiv.org/abs/2309.06180" rel="nofollow">PagedAttention Paper</a></li> <li><a href="https://github.com/ggerganov/llama.cpp" rel="nofollow">llama.cpp GitHub Repository</a></li> <li><a href="https://github.com/abetlen/llama-cpp-python" rel="nofollow">llama-cpp-python Repository</a></li>',ue,Hl,je,Pl,we;return m=new Tl({props:{title:"Optimized Inference Deployment",local:"optimized-inference-deployment",headingTag:"h1"}}),X=new Tl({props:{title:"Framework Selection Guide",local:"framework-selection-guide",headingTag:"h2"}}),k=new Tl({props:{title:"Memory Management and Performance",local:"memory-management-and-performance",headingTag:"h3"}}),x=new de({props:{title:"How Flash Attention Works",$$slots:{default:[it]},$$scope:{ctx:A}}}),q=new de({props:{title:"How PagedAttention Works",$$slots:{default:[yt]},$$scope:{ctx:A}}}),z=new de({props:{title:"How llama.cpp Quantization Works",$$slots:{default:[ct]},$$scope:{ctx:A}}}),K=new Tl({props:{title:"Deployment and Integration",local:"deployment-and-integration",headingTag:"h3"}}),Jl=new Tl({props:{title:"Getting Started",local:"getting-started",headingTag:"h2"}}),fl=new Tl({props:{title:"Installation and Basic Setup",local:"installation-and-basic-setup",headingTag:"h3"}}),yl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[rt]},$$scope:{ctx:A}}}),hl=new Tl({props:{title:"Basic Text Generation",local:"basic-text-generation",headingTag:"h3"}}),Zl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[mt]},$$scope:{ctx:A}}}),El=new Tl({props:{title:"Advanced Generation Control",local:"advanced-generation-control",headingTag:"h2"}}),Nl=new Tl({props:{title:"Token Selection and Sampling",local:"token-selection-and-sampling",headingTag:"h3"}}),vl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[Jt]},$$scope:{ctx:A}}}),Rl=new Tl({props:{title:"Controlling Repetition",local:"controlling-repetition",headingTag:"h3"}}),Al=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[Ut]},$$scope:{ctx:A}}}),ql=new Tl({props:{title:"Length Control and Stop Sequences",local:"length-control-and-stop-sequences",headingTag:"h3"}}),Ql=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[Tt]},$$scope:{ctx:A}}}),Yl=new Tl({props:{title:"Memory Management",local:"memory-management",headingTag:"h2"}}),Vl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[ut]},$$scope:{ctx:A}}}),Fl=new Tl({props:{title:"Resources",local:"resources",headingTag:"h2"}}),Hl=new nt({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter2/8.mdx"}}),{c(){r=w("meta"),o=y(),j=w("p"),U=y(),f(m.$$.fragment),T=y(),M=w("p"),M.textContent=J,i=y(),p=w("p"),p.textContent=v,Q=y(),f(X.$$.fragment),R=y(),W=w("p"),W.textContent=cl,$=y(),f(k.$$.fragment),L=y(),u=w("p"),u.innerHTML=S,ll=y(),H=w("img"),el=y(),f(x.$$.fragment),tl=y(),D=w("p"),D.innerHTML=dl,sl=y(),f(q.$$.fragment),nl=y(),P=w("p"),P.innerHTML=bl,al=y(),f(z.$$.fragment),Ml=y(),f(K.$$.fragment),ul=y(),Y=w("p"),Y.textContent=rl,pl=y(),O=w("p"),O.innerHTML=Cl,ol=y(),_=w("p"),_.innerHTML=Ul,jl=y(),F=w("p"),F.innerHTML=ml,il=y(),f(Jl.$$.fragment),n=y(),I=w("p"),I.textContent=Sl,wl=y(),f(fl.$$.fragment),gl=y(),f(yl.$$.fragment),Bl=y(),f(hl.$$.fragment),s=y(),d=w("p"),d.textContent=Ce,Ol=y(),f(Zl.$$.fragment),le=y(),f(El.$$.fragment),ee=y(),f(Nl.$$.fragment),te=y(),$l=w("p"),$l.textContent=fe,se=y(),Xl=w("ol"),Xl.innerHTML=ge,ne=y(),kl=w("p"),kl.textContent=Be,ae=y(),f(vl.$$.fragment),Me=y(),f(Rl.$$.fragment),pe=y(),xl=w("p"),xl.textContent=Ge,oe=y(),f(Al.$$.fragment),ie=y(),f(ql.$$.fragment),ye=y(),zl=w("p"),zl.textContent=Ze,ce=y(),f(Ql.$$.fragment),re=y(),f(Yl.$$.fragment),me=y(),_l=w("p"),_l.textContent=ve,Je=y(),f(Vl.$$.fragment),Ue=y(),f(Fl.$$.fragment),Te=y(),Ll=w("ul"),Ll.innerHTML=Ae,ue=y(),f(Hl.$$.fragment),je=y(),Pl=w("p"),this.h()},l(l){const a=st("svelte-u9bgzb",document.head);r=h(a,"META",{name:!0,content:!0}),a.forEach(e),o=c(l),j=h(l,"P",{}),Kl(j).forEach(e),U=c(l),g(m.$$.fragment,l),T=c(l),M=h(l,"P",{"data-svelte-h":!0}),Z(M)!=="svelte-1c3ix4n"&&(M.textContent=J),i=c(l),p=h(l,"P",{"data-svelte-h":!0}),Z(p)!=="svelte-1xh6xvz"&&(p.textContent=v),Q=c(l),g(X.$$.fragment,l),R=c(l),W=h(l,"P",{"data-svelte-h":!0}),Z(W)!=="svelte-xxm0i8"&&(W.textContent=cl),$=c(l),g(k.$$.fragment,l),L=c(l),u=h(l,"P",{"data-svelte-h":!0}),Z(u)!=="svelte-ms8d3b"&&(u.innerHTML=S),ll=c(l),H=h(l,"IMG",{src:!0,alt:!0}),el=c(l),g(x.$$.fragment,l),tl=c(l),D=h(l,"P",{"data-svelte-h":!0}),Z(D)!=="svelte-11etipa"&&(D.innerHTML=dl),sl=c(l),g(q.$$.fragment,l),nl=c(l),P=h(l,"P",{"data-svelte-h":!0}),Z(P)!=="svelte-19a6l8z"&&(P.innerHTML=bl),al=c(l),g(z.$$.fragment,l),Ml=c(l),g(K.$$.fragment,l),ul=c(l),Y=h(l,"P",{"data-svelte-h":!0}),Z(Y)!=="svelte-o1p1av"&&(Y.textContent=rl),pl=c(l),O=h(l,"P",{"data-svelte-h":!0}),Z(O)!=="svelte-l34lqu"&&(O.innerHTML=Cl),ol=c(l),_=h(l,"P",{"data-svelte-h":!0}),Z(_)!=="svelte-1isy26s"&&(_.innerHTML=Ul),jl=c(l),F=h(l,"P",{"data-svelte-h":!0}),Z(F)!=="svelte-1gsq6x1"&&(F.innerHTML=ml),il=c(l),g(Jl.$$.fragment,l),n=c(l),I=h(l,"P",{"data-svelte-h":!0}),Z(I)!=="svelte-1k0ewbc"&&(I.textContent=Sl),wl=c(l),g(fl.$$.fragment,l),gl=c(l),g(yl.$$.fragment,l),Bl=c(l),g(hl.$$.fragment,l),s=c(l),d=h(l,"P",{"data-svelte-h":!0}),Z(d)!=="svelte-yy57k8"&&(d.textContent=Ce),Ol=c(l),g(Zl.$$.fragment,l),le=c(l),g(El.$$.fragment,l),ee=c(l),g(Nl.$$.fragment,l),te=c(l),$l=h(l,"P",{"data-svelte-h":!0}),Z($l)!=="svelte-1jdaj55"&&($l.textContent=fe),se=c(l),Xl=h(l,"OL",{"data-svelte-h":!0}),Z(Xl)!=="svelte-1j60hyx"&&(Xl.innerHTML=ge),ne=c(l),kl=h(l,"P",{"data-svelte-h":!0}),Z(kl)!=="svelte-nakymk"&&(kl.textContent=Be),ae=c(l),g(vl.$$.fragment,l),Me=c(l),g(Rl.$$.fragment,l),pe=c(l),xl=h(l,"P",{"data-svelte-h":!0}),Z(xl)!=="svelte-euetng"&&(xl.textContent=Ge),oe=c(l),g(Al.$$.fragment,l),ie=c(l),g(ql.$$.fragment,l),ye=c(l),zl=h(l,"P",{"data-svelte-h":!0}),Z(zl)!=="svelte-1ut8dfv"&&(zl.textContent=Ze),ce=c(l),g(Ql.$$.fragment,l),re=c(l),g(Yl.$$.fragment,l),me=c(l),_l=h(l,"P",{"data-svelte-h":!0}),Z(_l)!=="svelte-b9x09v"&&(_l.textContent=ve),Je=c(l),g(Vl.$$.fragment,l),Ue=c(l),g(Fl.$$.fragment,l),Te=c(l),Ll=h(l,"UL",{"data-svelte-h":!0}),Z(Ll)!=="svelte-15h1dzu"&&(Ll.innerHTML=Ae),ue=c(l),g(Hl.$$.fragment,l),je=c(l),Pl=h(l,"P",{}),Kl(Pl).forEach(e),this.h()},h(){Wl(r,"name","hf:doc:metadata"),Wl(r,"content",wt),Oe(H.src,Il="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/tgi/flash-attn.png")||Wl(H,"src",Il),Wl(H,"alt","Flash Attention")},m(l,a){be(document.head,r),t(l,o,a),t(l,j,a),t(l,U,a),B(m,l,a),t(l,T,a),t(l,M,a),t(l,i,a),t(l,p,a),t(l,Q,a),B(X,l,a),t(l,R,a),t(l,W,a),t(l,$,a),B(k,l,a),t(l,L,a),t(l,u,a),t(l,ll,a),t(l,H,a),t(l,el,a),B(x,l,a),t(l,tl,a),t(l,D,a),t(l,sl,a),B(q,l,a),t(l,nl,a),t(l,P,a),t(l,al,a),B(z,l,a),t(l,Ml,a),B(K,l,a),t(l,ul,a),t(l,Y,a),t(l,pl,a),t(l,O,a),t(l,ol,a),t(l,_,a),t(l,jl,a),t(l,F,a),t(l,il,a),B(Jl,l,a),t(l,n,a),t(l,I,a),t(l,wl,a),B(fl,l,a),t(l,gl,a),B(yl,l,a),t(l,Bl,a),B(hl,l,a),t(l,s,a),t(l,d,a),t(l,Ol,a),B(Zl,l,a),t(l,le,a),B(El,l,a),t(l,ee,a),B(Nl,l,a),t(l,te,a),t(l,$l,a),t(l,se,a),t(l,Xl,a),t(l,ne,a),t(l,kl,a),t(l,ae,a),B(vl,l,a),t(l,Me,a),B(Rl,l,a),t(l,pe,a),t(l,xl,a),t(l,oe,a),B(Al,l,a),t(l,ie,a),B(ql,l,a),t(l,ye,a),t(l,zl,a),t(l,ce,a),B(Ql,l,a),t(l,re,a),B(Yl,l,a),t(l,me,a),t(l,_l,a),t(l,Je,a),B(Vl,l,a),t(l,Ue,a),B(Fl,l,a),t(l,Te,a),t(l,Ll,a),t(l,ue,a),B(Hl,l,a),t(l,je,a),t(l,Pl,a),we=!0},p(l,[a]){const Qe={};a&2&&(Qe.$$scope={dirty:a,ctx:l}),x.$set(Qe);const Ve={};a&2&&(Ve.$$scope={dirty:a,ctx:l}),q.$set(Ve);const We={};a&2&&(We.$$scope={dirty:a,ctx:l}),z.$set(We);const Se={};a&2&&(Se.$$scope={dirty:a,ctx:l}),yl.$set(Se);const Ee={};a&2&&(Ee.$$scope={dirty:a,ctx:l}),Zl.$set(Ee);const Ne={};a&2&&(Ne.$$scope={dirty:a,ctx:l}),vl.$set(Ne);const $e={};a&2&&($e.$$scope={dirty:a,ctx:l}),Al.$set($e);const Xe={};a&2&&(Xe.$$scope={dirty:a,ctx:l}),Ql.$set(Xe);const ke={};a&2&&(ke.$$scope={dirty:a,ctx:l}),Vl.$set(ke)},i(l){we||(b(m.$$.fragment,l),b(X.$$.fragment,l),b(k.$$.fragment,l),b(x.$$.fragment,l),b(q.$$.fragment,l),b(z.$$.fragment,l),b(K.$$.fragment,l),b(Jl.$$.fragment,l),b(fl.$$.fragment,l),b(yl.$$.fragment,l),b(hl.$$.fragment,l),b(Zl.$$.fragment,l),b(El.$$.fragment,l),b(Nl.$$.fragment,l),b(vl.$$.fragment,l),b(Rl.$$.fragment,l),b(Al.$$.fragment,l),b(ql.$$.fragment,l),b(Ql.$$.fragment,l),b(Yl.$$.fragment,l),b(Vl.$$.fragment,l),b(Fl.$$.fragment,l),b(Hl.$$.fragment,l),we=!0)},o(l){C(m.$$.fragment,l),C(X.$$.fragment,l),C(k.$$.fragment,l),C(x.$$.fragment,l),C(q.$$.fragment,l),C(z.$$.fragment,l),C(K.$$.fragment,l),C(Jl.$$.fragment,l),C(fl.$$.fragment,l),C(yl.$$.fragment,l),C(hl.$$.fragment,l),C(Zl.$$.fragment,l),C(El.$$.fragment,l),C(Nl.$$.fragment,l),C(vl.$$.fragment,l),C(Rl.$$.fragment,l),C(Al.$$.fragment,l),C(ql.$$.fragment,l),C(Ql.$$.fragment,l),C(Yl.$$.fragment,l),C(Vl.$$.fragment,l),C(Fl.$$.fragment,l),C(Hl.$$.fragment,l),we=!1},d(l){l&&(e(o),e(j),e(U),e(T),e(M),e(i),e(p),e(Q),e(R),e(W),e($),e(L),e(u),e(ll),e(H),e(el),e(tl),e(D),e(sl),e(nl),e(P),e(al),e(Ml),e(ul),e(Y),e(pl),e(O),e(ol),e(_),e(jl),e(F),e(il),e(n),e(I),e(wl),e(gl),e(Bl),e(s),e(d),e(Ol),e(le),e(ee),e(te),e($l),e(se),e(Xl),e(ne),e(kl),e(ae),e(Me),e(pe),e(xl),e(oe),e(ie),e(ye),e(zl),e(ce),e(re),e(me),e(_l),e(Je),e(Ue),e(Te),e(Ll),e(ue),e(je),e(Pl)),e(r),G(m,l),G(X,l),G(k,l),G(x,l),G(q,l),G(z,l),G(K,l),G(Jl,l),G(fl,l),G(yl,l),G(hl,l),G(Zl,l),G(El,l),G(Nl,l),G(vl,l),G(Rl,l),G(Al,l),G(ql,l),G(Ql,l),G(Yl,l),G(Vl,l),G(Fl,l),G(Hl,l)}}}const wt='{"title":"Optimized Inference Deployment","local":"optimized-inference-deployment","sections":[{"title":"Framework Selection Guide","local":"framework-selection-guide","sections":[{"title":"Memory Management and Performance","local":"memory-management-and-performance","sections":[],"depth":3},{"title":"Deployment and Integration","local":"deployment-and-integration","sections":[],"depth":3}],"depth":2},{"title":"Getting Started","local":"getting-started","sections":[{"title":"Installation and Basic Setup","local":"installation-and-basic-setup","sections":[],"depth":3},{"title":"Basic Text Generation","local":"basic-text-generation","sections":[],"depth":3}],"depth":2},{"title":"Advanced Generation Control","local":"advanced-generation-control","sections":[{"title":"Token Selection and Sampling","local":"token-selection-and-sampling","sections":[],"depth":3},{"title":"Controlling Repetition","local":"controlling-repetition","sections":[],"depth":3},{"title":"Length Control and Stop Sequences","local":"length-control-and-stop-sequences","sections":[],"depth":3}],"depth":2},{"title":"Memory Management","local":"memory-management","sections":[],"depth":2},{"title":"Resources","local":"resources","sections":[],"depth":2}],"depth":1}';function ht(A){return Ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gt extends _e{constructor(r){super(),Fe(this,r,ht,jt,ze,{})}}export{Gt as component};
