import{s as qe,d as De,u as Pe,g as Oe,e as Ke,c as lt,b as be,o as Fe,a as et,n as Zl}from"../chunks/scheduler.893fe8c9.js";import{S as He,i as Le,e as w,s as c,a as I,f as Kl,d as e,b as o,k as Wl,m as t,t as h,o as b,w as tt,q as N,r as E,l as fe,u as st,C as nt,c as f,h as at,g as B,j as G,n as g,p as Z}from"../chunks/index.6ee278c6.js";import{T as Ce}from"../chunks/Tip.eab0255c.js";import{C as Mt,H as jl,E as it}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ea3ad860.js";import{C as V}from"../chunks/CodeBlock.8bdd5f33.js";import{e as xe}from"../chunks/each.e59479a4.js";import{s as he}from"../chunks/stores.db603902.js";function pt(v,m){const r=new URL(window.location.href),j=new URLSearchParams(r.search);j.set(v,m),r.search=j.toString(),history.replaceState(null,"",r.toString())}function rt(v){const m=new URL(window.location.href);return new URLSearchParams(m.search).get(v)}function Ye(v,m,r){const j=v.slice();return j[7]=m[r],j}function _e(v){let m,r=v[7]+"",j,J,u,y,M;function U(){return v[6](v[7])}return{c(){m=w("div"),j=N(r),J=c(),this.h()},l(i){m=I(i,"DIV",{class:!0});var p=Kl(m);j=E(p,r),J=o(p),p.forEach(e),this.h()},h(){Wl(m,"class",u="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd "+(v[2][v[0]]===v[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,m,p),fe(m,j),fe(m,J),y||(M=st(m,"click",U),y=!0)},p(i,p){v=i,p&2&&r!==(r=v[7]+"")&&nt(j,r),p&7&&u!==(u="flex items-center border rounded-lg px-1.5 py-1 leading-none select-none text-smd "+(v[2][v[0]]===v[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(m,"class",u)},d(i){i&&e(m),y=!1,M()}}}function ct(v){let m,r,j,J,u=xe(v[1]),y=[];for(let i=0;i<u.length;i+=1)y[i]=_e(Ye(v,u,i));const M=v[5].default,U=De(M,v,v[4],null);return{c(){m=w("div");for(let i=0;i<y.length;i+=1)y[i].c();r=c(),j=w("div"),U&&U.c(),this.h()},l(i){m=I(i,"DIV",{class:!0});var p=Kl(m);for(let A=0;A<y.length;A+=1)y[A].l(p);p.forEach(e),r=o(i),j=I(i,"DIV",{class:!0});var Q=Kl(j);U&&U.l(Q),Q.forEach(e),this.h()},h(){Wl(m,"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,m,p);for(let Q=0;Q<y.length;Q+=1)y[Q]&&y[Q].m(m,null);t(i,r,p),t(i,j,p),U&&U.m(j,null),J=!0},p(i,[p]){if(p&15){u=xe(i[1]);let Q;for(Q=0;Q<u.length;Q+=1){const A=Ye(i,u,Q);y[Q]?y[Q].p(A,p):(y[Q]=_e(A),y[Q].c(),y[Q].m(m,null))}for(;Q<y.length;Q+=1)y[Q].d(1);y.length=u.length}U&&U.p&&(!J||p&16)&&Pe(U,M,i,i[4],J?Ke(M,i[4],p,null):Oe(i[4]),null)},i(i){J||(h(U,i),J=!0)},o(i){b(U,i),J=!1},d(i){i&&(e(m),e(r),e(j)),tt(y,i),U&&U.d(i)}}}function ot(v,m,r){let j;lt(v,he,p=>r(2,j=p));let{$$slots:J={},$$scope:u}=m,{id:y}=m,{options:M}=m;be(he,j[y]=M[0],j);function U(p){be(he,j[y]=p,j),pt(y,p)}Fe(()=>{const p=rt(y);p&&M.includes(p)&&be(he,j[y]=p,j)});const i=p=>U(p);return v.$$set=p=>{"id"in p&&r(0,y=p.id),"options"in p&&r(1,M=p.options),"$$scope"in p&&r(4,u=p.$$scope)},[y,M,j,U,u,J,i]}class Dl extends He{constructor(m){super(),Le(this,m,ot,ct,qe,{id:0,options:1})}}function mt(v){let m,r,j="Inovația cheie constă în modul în care gestionează transferurile de memorie între High Bandwidth Memory (HBM) și cache-ul SRAM mai rapid. Atenția tradițională transferă în mod repetat date între HBM și SRAM, creând blocaje prin lăsarea GPU-ului inactiv. Flash Attention încarcă datele o dată în SRAM și efectuează toate calculele acolo, minimizând transferurile costisitoare de memorie.",J,u,y="Deși beneficiile sunt cele mai semnificative în timpul antrenamentului, utilizarea redusă de VRAM și eficiența îmbunătățită a Flash Attention o fac valoroasă și pentru inferență, permițând servirea LLM mai rapidă și mai scalabilă.";return{c(){m=N(`Flash Attention este o tehnică care optimizează mecanismul de atenție în modelele transformer prin abordarea blocajelor de lățime de bandă a memoriei. Așa cum s-a discutat mai devreme în [Capitolul 1.8](/course/chapter1/8), mecanismul de atenție are complexitate și utilizare de memorie pătratică, făcându-l ineficient pentru secvențe lungi.
`),r=w("p"),r.textContent=j,J=c(),u=w("p"),u.textContent=y},l(M){m=E(M,`Flash Attention este o tehnică care optimizează mecanismul de atenție în modelele transformer prin abordarea blocajelor de lățime de bandă a memoriei. Așa cum s-a discutat mai devreme în [Capitolul 1.8](/course/chapter1/8), mecanismul de atenție are complexitate și utilizare de memorie pătratică, făcându-l ineficient pentru secvențe lungi.
`),r=I(M,"P",{"data-svelte-h":!0}),G(r)!=="svelte-bck4r0"&&(r.textContent=j),J=o(M),u=I(M,"P",{"data-svelte-h":!0}),G(u)!=="svelte-89j1zd"&&(u.textContent=y)},m(M,U){t(M,m,U),t(M,r,U),t(M,J,U),t(M,u,U)},p:Zl,d(M){M&&(e(m),e(r),e(J),e(u))}}}function ut(v){let m,r,j="Inovația cheie a vLLM constă în modul în care gestionează acest cache:",J,u,y="<li><strong>Paginarea Memoriei</strong>: În loc să trateze cache-ul KV ca un bloc mare, este împărțit în “pagini” de dimensiune fixă (similar cu memoria virtuală în sistemele de operare).</li> <li><strong>Stocare Non-Contigua</strong>: Paginile nu trebuie să fie stocate contiguu în memoria GPU, permițând o alocare mai flexibilă a memoriei.</li> <li><strong>Gestionarea Tabelului de Pagini</strong>: Un tabel de pagini urmărește care pagini aparțin cărei secvențe, permițând căutare și acces eficient.</li> <li><strong>Partajarea Memoriei</strong>: Pentru operații precum eșantionarea paralelă, paginile care stochează cache-ul KV pentru prompt pot fi partajate între multiple secvențe.</li>",M,U,i='Abordarea PagedAttention poate duce la un throughput de până la 24 de ori mai mare comparativ cu metodele tradiționale, făcând-o o schimbare de paradigmă pentru implementările LLM de producție. Dacă vrei să înțelegi cu adevărat în profunzime cum funcționează PagedAttention, poți citi <a href="https://docs.vllm.ai/en/latest/design/kernel/paged_attention.html" rel="nofollow">ghidul din documentația vLLM</a>.';return{c(){m=N(`PagedAttention este o tehnică care abordează un alt blocaj critic în inferența LLM: gestionarea memoriei cache KV. Așa cum s-a discutat în [Capitolul 1.8](/course/chapter1/8), în timpul generării de text, modelul stochează cheile și valorile de atenție (cache KV) pentru fiecare token generat pentru a reduce calculele redundante. Cache-ul KV poate deveni enorm, în special cu secvențe lungi sau multiple cereri concurente.
`),r=w("p"),r.textContent=j,J=c(),u=w("ol"),u.innerHTML=y,M=c(),U=w("p"),U.innerHTML=i},l(p){m=E(p,`PagedAttention este o tehnică care abordează un alt blocaj critic în inferența LLM: gestionarea memoriei cache KV. Așa cum s-a discutat în [Capitolul 1.8](/course/chapter1/8), în timpul generării de text, modelul stochează cheile și valorile de atenție (cache KV) pentru fiecare token generat pentru a reduce calculele redundante. Cache-ul KV poate deveni enorm, în special cu secvențe lungi sau multiple cereri concurente.
`),r=I(p,"P",{"data-svelte-h":!0}),G(r)!=="svelte-1q7w70u"&&(r.textContent=j),J=o(p),u=I(p,"OL",{"data-svelte-h":!0}),G(u)!=="svelte-o4cwji"&&(u.innerHTML=y),M=o(p),U=I(p,"P",{"data-svelte-h":!0}),G(U)!=="svelte-1hypydk"&&(U.innerHTML=i)},m(p,Q){t(p,m,Q),t(p,r,Q),t(p,J,Q),t(p,u,Q),t(p,M,Q),t(p,U,Q)},p:Zl,d(p){p&&(e(m),e(r),e(J),e(u),e(M),e(U))}}}function Ut(v){let m,r,j="Caracteristicile cheie de cuantificare în llama.cpp includ:",J,u,y="<li><strong>Multiple Niveluri de Cuantificare</strong>: Suportă cuantificare pe 8-bit, 4-bit, 3-bit și chiar 2-bit</li> <li><strong>Format GGML/GGUF</strong>: Folosește formate tensoriale personalizate optimizate pentru inferența cuantificată</li> <li><strong>Precizie Mixtă</strong>: Poate aplica diferite niveluri de cuantificare la diferite părți ale modelului</li> <li><strong>Optimizări Specifice Hardware</strong>: Include căi de cod optimizate pentru diverse arhitecturi CPU (AVX2, AVX-512, NEON)</li>",M,U,i="Această abordare permite rularea modelelor cu miliarde de parametri pe hardware de consum cu memorie limitată, făcând-o perfectă pentru implementări locale și dispozitive de margine.";return{c(){m=N(`Cuantificarea în llama.cpp reduce precizia ponderilor modelului de la puncte mobile pe 32-bit sau 16-bit la formate de precizie mai mică precum întregi pe 8-bit (INT8), 4-bit sau chiar mai mic. Aceasta reduce semnificativ utilizarea memoriei și îmbunătățește viteza de inferență cu pierderi minime de calitate.
`),r=w("p"),r.textContent=j,J=c(),u=w("ol"),u.innerHTML=y,M=c(),U=w("p"),U.textContent=i},l(p){m=E(p,`Cuantificarea în llama.cpp reduce precizia ponderilor modelului de la puncte mobile pe 32-bit sau 16-bit la formate de precizie mai mică precum întregi pe 8-bit (INT8), 4-bit sau chiar mai mic. Aceasta reduce semnificativ utilizarea memoriei și îmbunătățește viteza de inferență cu pierderi minime de calitate.
`),r=I(p,"P",{"data-svelte-h":!0}),G(r)!=="svelte-1wsf8af"&&(r.textContent=j),J=o(p),u=I(p,"OL",{"data-svelte-h":!0}),G(u)!=="svelte-6dlvtp"&&(u.innerHTML=y),M=o(p),U=I(p,"P",{"data-svelte-h":!0}),G(U)!=="svelte-1fu05c7"&&(U.textContent=i)},m(p,Q){t(p,m,Q),t(p,r,Q),t(p,J,Q),t(p,u,Q),t(p,M,Q),t(p,U,Q)},p:Zl,d(p){p&&(e(m),e(r),e(J),e(u),e(M),e(U))}}}function Jt(v){let m,r,j="TGI este ușor de instalat și utilizat, cu integrare profundă în ecosistemul Hugging Face.",J,u,y="Mai întâi, lansează serverul TGI folosind Docker:",M,U,i,p,Q="Apoi interacționează cu acesta folosind InferenceClient de la Hugging Face:",A,O,$,z,ll="Alternativ, poți folosi clientul OpenAI:",W,K,H,T,S="llama.cpp este ușor de instalat și utilizat, necesitând dependențe minime și suportând atât inferența CPU cât și GPU.",X,Jl,wl="Mai întâi, instalează și construiește llama.cpp:",k,Ml,el,L,Il="Apoi, lansează serverul (cu compatibilitate API OpenAI):",R,il,tl,D,dl="Interacționează cu serverul folosind InferenceClient de la Hugging Face:",x,pl,sl,P,hl="Alternativ, poți folosi clientul OpenAI:",Y,nl,_,yl,bl="vLLM este ușor de instalat și utilizat, cu atât compatibilitatea API OpenAI cât și o interfață Python nativă.",q,rl,cl="Mai întâi, lansează serverul compatibil OpenAI vLLM:",ol,ml,al,F,Cl="Apoi interacționează cu acesta folosind InferenceClient de la Hugging Face:",n,d,fl,ul,Pl="Alternativ, poți folosi clientul OpenAI:",Bl,Ul,gl,Tl;return U=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}}),O=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBwb2ludCVDMyVBMm5kJTIwYyVDNCU4M3RyZSUyMGVuZHBvaW50LXVsJTIwVEdJJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwODAlMjIlMkMlMjAlMjAlMjMlMjBVUkwlMjBjJUM0JTgzdHJlJTIwc2VydmVydWwlMjBUR0klMEEpJTBBJTBBJTIzJTIwR2VuZXJhcmVhJTIwZGUlMjB0ZXh0JTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQudGV4dF9nZW5lcmF0aW9uKCUwQSUyMCUyMCUyMCUyMCUyMlNwdW5lLW1pJTIwbyUyMHBvdmVzdGUlMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfbmV3X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBJTIwJTIwJTIwJTIwZGV0YWlscyUzRFRydWUlMkMlMEElMjAlMjAlMjAlMjBzdG9wX3NlcXVlbmNlcyUzRCU1QiU1RCUyQyUwQSklMEFwcmludChyZXNwb25zZS5nZW5lcmF0ZWRfdGV4dCklMEElMEElMjMlMjBQZW50cnUlMjBmb3JtYXQlMjBkZSUyMGNoYXQlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0X2NvbXBsZXRpb24oJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkUlQzglOTl0aSUyMHVuJTIwYXNpc3RlbnQlMjB1dGlsLiUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMlNwdW5lLW1pJTIwbyUyMHBvdmVzdGUlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMTAwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjclMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Inițializează clientul pointând către endpoint-ul TGI</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8080&quot;</span>,  <span class="hljs-comment"># URL către serverul TGI</span>
)

<span class="hljs-comment"># Generarea de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Spune-mi o poveste&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"># Pentru format de chat</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;Ești un asistent util.&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;Spune-mi o poveste&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:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBwb2ludCVDMyVBMm5kJTIwYyVDNCU4M3RyZSUyMGVuZHBvaW50LXVsJTIwVEdJJTBBY2xpZW50JTIwJTNEJTIwT3BlbkFJKCUwQSUyMCUyMCUyMCUyMGJhc2VfdXJsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwODAlMkZ2MSUyMiUyQyUyMCUyMCUyMyUyMEFzaWd1ciVDNCU4My10ZSUyMHMlQzQlODMlMjBpbmNsdXppJTIwJTJGdjElMEElMjAlMjAlMjAlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiUyQyUyMCUyMCUyMyUyMFRHSSUyMG51JTIwbmVjZXNpdCVDNCU4MyUyMG8lMjBjaGVpZSUyMEFQSSUyMCVDMyVBRW4lMjBtb2QlMjBpbXBsaWNpdCUwQSklMEElMEElMjMlMjBDb21wbGV0YXJlYSUyMGRlJTIwY2hhdCUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXQuY29tcGxldGlvbnMuY3JlYXRlKCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIySHVnZ2luZ0ZhY2VUQiUyRlNtb2xMTTItMzYwTS1JbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEJTVCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnN5c3RlbSUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJFJUM4JTk5dGklMjB1biUyMGFzaXN0ZW50JTIwdXRpbC4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJTcHVuZS1taSUyMG8lMjBwb3Zlc3RlJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Inițializează clientul pointând către endpoint-ul TGI</span>
client = OpenAI(
    base_url=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>,  <span class="hljs-comment"># Asigură-te să incluzi /v1</span>
    api_key=<span class="hljs-string">&quot;not-needed&quot;</span>,  <span class="hljs-comment"># TGI nu necesită o cheie API în mod implicit</span>
)

<span class="hljs-comment"># Completarea de chat</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;Ești un asistent util.&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;Spune-mi o poveste&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}}),Ml=new V({props:{code:"JTIzJTIwQ2xvbmVheiVDNCU4MyUyMGRlcG96aXR1bCUwQWdpdCUyMGNsb25lJTIwaHR0cHMlM0ElMkYlMkZnaXRodWIuY29tJTJGZ2dlcmdhbm92JTJGbGxhbWEuY3BwJTBBY2QlMjBsbGFtYS5jcHAlMEElMEElMjMlMjBDb25zdHJ1aWUlQzglOTl0ZSUyMHByb2llY3R1bCUwQW1ha2UlMEElMEElMjMlMjBEZXNjYXJjJUM0JTgzJTIwbW9kZWx1bCUyMFNtb2xMTTItMS43Qi1JbnN0cnVjdC1HR1VGJTBBY3VybCUyMC1MJTIwLU8lMjBodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGSHVnZ2luZ0ZhY2VUQiUyRlNtb2xMTTItMS43Qi1JbnN0cnVjdC1HR1VGJTJGcmVzb2x2ZSUyRm1haW4lMkZzbW9sbG0yLTEuN2ItaW5zdHJ1Y3QuUTRfS19NLmdndWY=",highlighted:`<span class="hljs-comment"># Clonează depozitul</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"># Construiește proiectul</span>
make

<span class="hljs-comment"># Descarcă modelul SmolLM2-1.7B-Instruct-GGUF</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}}),il=new V({props:{code:"JTIzJTIwUG9ybmUlQzglOTl0ZSUyMHNlcnZlcnVsJTBBLiUyRnNlcnZlciUyMCU1QyUwQSUyMCUyMCUyMCUyMC1tJTIwc21vbGxtMi0xLjdiLWluc3RydWN0LlE0X0tfTS5nZ3VmJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1ob3N0JTIwMC4wLjAuMCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcG9ydCUyMDgwODAlMjAlNUMlMEElMjAlMjAlMjAlMjAtYyUyMDQwOTYlMjAlNUMlMEElMjAlMjAlMjAlMjAtLW4tZ3B1LWxheWVycyUyMDAlMjAlMjAlMjMlMjBTZXRlYXolQzQlODMlMjBsYSUyMHVuJTIwbnVtJUM0JTgzciUyMG1haSUyMG1hcmUlMjBwZW50cnUlMjBhJTIwZm9sb3NpJTIwR1BV",highlighted:`<span class="hljs-comment"># Pornește serverul</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"># Setează la un număr mai mare pentru a folosi GPU</span>`,wrap:!1}}),pl=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBwb2ludCVDMyVBMm5kJTIwYyVDNCU4M3RyZSUyMHNlcnZlcnVsJTIwbGxhbWEuY3BwJTBBY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KCUwQSUyMCUyMCUyMCUyMG1vZGVsJTNEJTIyaHR0cCUzQSUyRiUyRmxvY2FsaG9zdCUzQTgwODAlMkZ2MSUyMiUyQyUyMCUyMCUyMyUyMFVSTCUyMGMlQzQlODN0cmUlMjBzZXJ2ZXJ1bCUyMGxsYW1hLmNwcCUwQSUyMCUyMCUyMCUyMHRva2VuJTNEJTIyc2stbm8ta2V5LXJlcXVpcmVkJTIyJTJDJTIwJTIwJTIzJTIwc2Vyd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jclMkMlMEElMjAlMjAlMjAlMjB0b3BfcCUzRDAuOTUlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Inițializează clientul pointând către serverul llama.cpp</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8080/v1&quot;</span>,  <span class="hljs-comment"># URL către serverul llama.cpp</span>
    token=<span class="hljs-string">&quot;sk-no-key-required&quot;</span>,  <span class="hljs-comment"># serverul llama.cpp necesită acest placeholder</span>
)

<span class="hljs-comment"># Generarea de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Spune-mi o poveste&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"># Pentru format de chat</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;Ești un asistent util.&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;Spune-mi o poveste&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}}),nl=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBw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SUyMG8lMjBwb3Zlc3RlJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTVEJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC43JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Inițializează clientul pointând către serverul llama.cpp</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"># serverul llama.cpp necesită acest placeholder</span>
)

<span class="hljs-comment"># Completarea de chat</span>
response = client.chat.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,  <span class="hljs-comment"># Identificatorul modelului poate fi orice deoarece serverul încarcă doar un 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;Ești un asistent util.&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;Spune-mi o poveste&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}}),ml=new V({props:{code:"cHl0aG9uJTIwLW0lMjB2bGxtLmVudHJ5cG9pbnRzLm9wZW5haS5hcGlfc2VydmVyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tb2RlbCUyMEh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3QlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWhvc3QlMjAwLjAuMC4wJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wb3J0JTIwODAwMA==",highlighted:`python -m vllm.entrypoints.openai.api_server \\
    --model HuggingFaceTB/SmolLM2-360M-Instruct \\
    --host 0.0.0.0 \\
    --port 8000`,wrap:!1}}),d=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBwb2ludCVDMyVBMm5kJTIwYyVDNCU4M3RyZSUyMGVuZHBvaW50LXVsJTIwdkxMTSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudCglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIlMkMlMjAlMjAlMjMlMjBVUkwlMjBjJUM0JTgzdHJlJTIwc2VydmVydWwlMjB2TExNJTBBKSUwQSUwQSUyMyUyMEdlbmVyYXJlYSUyMGRlJTIwdGV4dCUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LnRleHRfZ2VuZXJhdGlvbiglMEElMjAlMjAlMjAlMjAlMjJTcHVuZS1taSUyMG8lMjBwb3Zlc3RlJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMGRldGFpbHMlM0RUcnVlJTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmdlbmVyYXRlZF90ZXh0KSUwQSUwQSUyMyUyMFBlbnRydSUyMGZvcm1hdCUyMGRlJTIwY2hhdCUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXRfY29tcGxldGlvbiglMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyRSVDOCU5OXRpJTIwdW4lMjBhc2lzdGVudCUyMHV0aWwuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyU3B1bmUtbWklMjBvJTIwcG92ZXN0ZSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSklMEFwcmludChyZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlLmNvbnRlbnQp",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

<span class="hljs-comment"># Inițializează clientul pointând către endpoint-ul vLLM</span>
client = InferenceClient(
    model=<span class="hljs-string">&quot;http://localhost:8000/v1&quot;</span>,  <span class="hljs-comment"># URL către serverul vLLM</span>
)

<span class="hljs-comment"># Generarea de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Spune-mi o poveste&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"># Pentru format de chat</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;Ești un asistent util.&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;Spune-mi o poveste&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}}),Ul=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQSUyMyUyMEluaSVDOCU5QmlhbGl6ZWF6JUM0JTgzJTIwY2xpZW50dWwlMjBwb2ludCVDMyVBMm5kJTIwYyVDNCU4M3RyZSUyMGVuZHBvaW50LXVsJTIwdkxMTSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSSglMEElMjAlMjAlMjAlMjBiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIlMkMlMEElMjAlMjAlMjAlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiUyQyUyMCUyMCUyMyUyMHZMTE0lMjBudSUyMG5lY2VzaXQlQzQlODMlMjBvJTIwY2hlaWUlMjBBUEklMjAlQzMlQUVuJTIwbW9kJTIwaW1wbGljaXQlMEEpJTBBJTBBJTIzJTIwQ29tcGxldGFyZWElMjBkZSUyMGNoYXQlMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jaGF0LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMkh1Z2dpbmdGYWNlVEIlMkZTbW9sTE0yLTM2ME0tSW5zdHJ1Y3QlMjIlMkMlMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyRSVDOCU5OXRpJTIwdW4lMjBhc2lzdGVudCUyMHV0aWwuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyU3B1bmUtbWklMjBvJTIwcG92ZXN0ZSUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QxMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuNyUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSklMEFwcmludChyZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlLmNvbnRlbnQp",highlighted:`<span class="hljs-keyword">from</span> openai <span class="hljs-keyword">import</span> OpenAI

<span class="hljs-comment"># Inițializează clientul pointând către endpoint-ul vLLM</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 nu necesită o cheie API în mod implicit</span>
)

<span class="hljs-comment"># Completarea de chat</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;Ești un asistent util.&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;Spune-mi o poveste&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(){m=N(`<hfoption value="tgi" label="TGI">
`),r=w("p"),r.textContent=j,J=c(),u=w("p"),u.textContent=y,M=c(),f(U.$$.fragment),i=c(),p=w("p"),p.textContent=Q,A=c(),f(O.$$.fragment),$=c(),z=w("p"),z.textContent=ll,W=c(),f(K.$$.fragment),H=N(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),T=w("p"),T.textContent=S,X=c(),Jl=w("p"),Jl.textContent=wl,k=c(),f(Ml.$$.fragment),el=c(),L=w("p"),L.textContent=Il,R=c(),f(il.$$.fragment),tl=c(),D=w("p"),D.textContent=dl,x=c(),f(pl.$$.fragment),sl=c(),P=w("p"),P.textContent=hl,Y=c(),f(nl.$$.fragment),_=N(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),yl=w("p"),yl.textContent=bl,q=c(),rl=w("p"),rl.textContent=cl,ol=c(),f(ml.$$.fragment),al=c(),F=w("p"),F.textContent=Cl,n=c(),f(d.$$.fragment),fl=c(),ul=w("p"),ul.textContent=Pl,Bl=c(),f(Ul.$$.fragment),gl=N(`
</hfoption>`)},l(s){m=E(s,`<hfoption value="tgi" label="TGI">
`),r=I(s,"P",{"data-svelte-h":!0}),G(r)!=="svelte-d3ibl6"&&(r.textContent=j),J=o(s),u=I(s,"P",{"data-svelte-h":!0}),G(u)!=="svelte-5he4zd"&&(u.textContent=y),M=o(s),B(U.$$.fragment,s),i=o(s),p=I(s,"P",{"data-svelte-h":!0}),G(p)!=="svelte-njbfao"&&(p.textContent=Q),A=o(s),B(O.$$.fragment,s),$=o(s),z=I(s,"P",{"data-svelte-h":!0}),G(z)!=="svelte-dmbprn"&&(z.textContent=ll),W=o(s),B(K.$$.fragment,s),H=E(s,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),T=I(s,"P",{"data-svelte-h":!0}),G(T)!=="svelte-910ccc"&&(T.textContent=S),X=o(s),Jl=I(s,"P",{"data-svelte-h":!0}),G(Jl)!=="svelte-yvknv6"&&(Jl.textContent=wl),k=o(s),B(Ml.$$.fragment,s),el=o(s),L=I(s,"P",{"data-svelte-h":!0}),G(L)!=="svelte-1t3nfo6"&&(L.textContent=Il),R=o(s),B(il.$$.fragment,s),tl=o(s),D=I(s,"P",{"data-svelte-h":!0}),G(D)!=="svelte-15q65ck"&&(D.textContent=dl),x=o(s),B(pl.$$.fragment,s),sl=o(s),P=I(s,"P",{"data-svelte-h":!0}),G(P)!=="svelte-dmbprn"&&(P.textContent=hl),Y=o(s),B(nl.$$.fragment,s),_=E(s,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),yl=I(s,"P",{"data-svelte-h":!0}),G(yl)!=="svelte-1eczzi3"&&(yl.textContent=bl),q=o(s),rl=I(s,"P",{"data-svelte-h":!0}),G(rl)!=="svelte-sv1ope"&&(rl.textContent=cl),ol=o(s),B(ml.$$.fragment,s),al=o(s),F=I(s,"P",{"data-svelte-h":!0}),G(F)!=="svelte-njbfao"&&(F.textContent=Cl),n=o(s),B(d.$$.fragment,s),fl=o(s),ul=I(s,"P",{"data-svelte-h":!0}),G(ul)!=="svelte-dmbprn"&&(ul.textContent=Pl),Bl=o(s),B(Ul.$$.fragment,s),gl=E(s,`
</hfoption>`)},m(s,C){t(s,m,C),t(s,r,C),t(s,J,C),t(s,u,C),t(s,M,C),g(U,s,C),t(s,i,C),t(s,p,C),t(s,A,C),g(O,s,C),t(s,$,C),t(s,z,C),t(s,W,C),g(K,s,C),t(s,H,C),t(s,T,C),t(s,X,C),t(s,Jl,C),t(s,k,C),g(Ml,s,C),t(s,el,C),t(s,L,C),t(s,R,C),g(il,s,C),t(s,tl,C),t(s,D,C),t(s,x,C),g(pl,s,C),t(s,sl,C),t(s,P,C),t(s,Y,C),g(nl,s,C),t(s,_,C),t(s,yl,C),t(s,q,C),t(s,rl,C),t(s,ol,C),g(ml,s,C),t(s,al,C),t(s,F,C),t(s,n,C),g(d,s,C),t(s,fl,C),t(s,ul,C),t(s,Bl,C),g(Ul,s,C),t(s,gl,C),Tl=!0},p:Zl,i(s){Tl||(h(U.$$.fragment,s),h(O.$$.fragment,s),h(K.$$.fragment,s),h(Ml.$$.fragment,s),h(il.$$.fragment,s),h(pl.$$.fragment,s),h(nl.$$.fragment,s),h(ml.$$.fragment,s),h(d.$$.fragment,s),h(Ul.$$.fragment,s),Tl=!0)},o(s){b(U.$$.fragment,s),b(O.$$.fragment,s),b(K.$$.fragment,s),b(Ml.$$.fragment,s),b(il.$$.fragment,s),b(pl.$$.fragment,s),b(nl.$$.fragment,s),b(ml.$$.fragment,s),b(d.$$.fragment,s),b(Ul.$$.fragment,s),Tl=!1},d(s){s&&(e(m),e(r),e(J),e(u),e(M),e(i),e(p),e(A),e($),e(z),e(W),e(H),e(T),e(X),e(Jl),e(k),e(el),e(L),e(R),e(tl),e(D),e(x),e(sl),e(P),e(Y),e(_),e(yl),e(q),e(rl),e(ol),e(al),e(F),e(n),e(fl),e(ul),e(Bl),e(gl)),Z(U,s),Z(O,s),Z(K,s),Z(Ml,s),Z(il,s),Z(pl,s),Z(nl,s),Z(ml,s),Z(d,s),Z(Ul,s)}}}function yt(v){let m,r,j="Mai întâi, implementează TGI cu parametri avansați:",J,u,y,M,U="Folosește InferenceClient pentru generarea flexibilă de text:",i,p,Q,A,O="Sau folosește clientul OpenAI:",$,z,ll,W,K="Pentru llama.cpp, poți seta parametri avansați când lansezi serverul:",H,T,S,X,Jl="Folosește InferenceClient:",wl,k,Ml,el,L="Sau folosește clientul OpenAI pentru generare cu control asupra parametrilor de eșantionare:",Il,R,il,tl,D="Poți folosi, de asemenea, biblioteca nativă llama.cpp pentru un control și mai mare:",dl,x,pl,sl,P="Pentru utilizarea avansată cu vLLM, poți folosi InferenceClient:",hl,Y,nl,_,yl="Poți folosi, de asemenea, clientul OpenAI:",bl,q,rl,cl,ol="vLLM oferă, de asemenea, o interfață Python nativă cu control fin:",ml,al,F,Cl;return u=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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JTIwJTIwJTIyU2NyaWUlMjBvJTIwcG92ZXN0ZSUyMGNyZWF0aXYlQzQlODMlMjBkZXNwcmUlMjBleHBsb3JhcmVhJTIwc3BhJUM4JTlCaXVsdWklMjIlMkMlMEElMjAlMjAlMjAlMjBtYXhfbmV3X3Rva2VucyUzRDIwMCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC44JTJDJTBBJTIwJTIwJTIwJTIwdG9wX3AlM0QwLjk1JTJDJTBBJTIwJTIwJTIwJTIwcmVwZXRpdGlvbl9wZW5hbHR5JTNEMS4xJTJDJTBBJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMGRldGFpbHMlM0RUcnVlJTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmdlbmVyYXRlZF90ZXh0KQ==",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&quot;</span>)

<span class="hljs-comment"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&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"># Generarea brută de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Scrie o poveste creativă despre explorarea spațiului&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}}),z=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiklMEElMEElMjMlMjBFeGVtcGx1JTIwZGUlMjBwYXJhbWV0cmklMjBhdmFuc2ElQzglOUJpJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0zNjBNLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkUlQzglOTl0aSUyMHVuJTIwcG92ZXN0aXRvciUyMGNyZWF0aXYuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyU2NyaWUlMjBvJTIwcG92ZXN0ZSUyMGNyZWF0aXYlQzQlODMlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUyMCUyMCUyMyUyME1haSUyMG1hcmUlMjBwZW50cnUlMjBtYWklMjBtdWx0JUM0JTgzJTIwY3JlYXRpdml0YXRlJTBBKSUwQXByaW50KHJlc3BvbnNlLmNob2ljZXMlNUIwJTVELm1lc3NhZ2UuY29udGVudCk=",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"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
)
<span class="hljs-built_in">print</span>(response.choices[<span class="hljs-number">0</span>].message.content)`,wrap:!1}}),T=new V({props:{code:"LiUyRnNlcnZlciUyMCU1QyUwQSUyMCUyMCUyMCUyMC1tJTIwc21vbGxtMi0xLjdiLWluc3RydWN0LlE0X0tfTS5nZ3VmJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1ob3N0JTIwMC4wLjAuMCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcG9ydCUyMDgwODAlMjAlNUMlMEElMjAlMjAlMjAlMjAtYyUyMDQwOTYlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBEaW1lbnNpdW5lYSUyMGNvbnRleHR1bHVpJTBBJTIwJTIwJTIwJTIwLS10aHJlYWRzJTIwOCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMFRocmVhZC11cmklMjBDUFUlMjBkZSUyMGZvbG9zaXQlMEElMjAlMjAlMjAlMjAtLWJhdGNoLXNpemUlMjA1MTIlMjAlNUMlMjAlMjAlMjAlMjMlMjBEaW1lbnNpdW5lYSUyMGxvdHVsdWklMjBwZW50cnUlMjBldmFsdWFyZWElMjBwcm9tcHQtdWx1aSUwQSUyMCUyMCUyMCUyMC0tbi1ncHUtbGF5ZXJzJTIwMCUyMCUyMCUyMCUyMCUyMCUyMyUyMFN0cmF0dXJpJTIwR1BVJTIwKDAlMjAlM0QlMjBkb2FyJTIwQ1BVKQ==",highlighted:`./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --host 0.0.0.0 \\
    --port 8080 \\
    -c 4096 \\            <span class="hljs-comment"># Dimensiunea contextului</span>
    --threads 8 \\        <span class="hljs-comment"># Thread-uri CPU de folosit</span>
    --batch-size 512 \\   <span class="hljs-comment"># Dimensiunea lotului pentru evaluarea prompt-ului</span>
    --n-gpu-layers 0     <span class="hljs-comment"># Straturi GPU (0 = doar CPU)</span>`,wrap:!1}}),k=new V({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTJGdjElMjIlMkMlMjB0b2tlbiUzRCUyMnNrLW5vLWtleS1yZXF1aXJlZCUyMiklMEElMEElMjMlMjBFeGVtcGx1JTIwZGUlMjBwYXJhbWV0cmklMjBhdmFuc2ElQzglOUJpJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdF9jb21wbGV0aW9uKCUwQSUyMCUyMCUyMCUyMG1lc3NhZ2VzJTNEJTVCJTBBJ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V0YWlscyUzRFRydWUlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuZ2VuZXJhdGVkX3RleHQp",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"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&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"># Pentru generarea directă de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Scrie o poveste creativă despre explorarea spațiului&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}}),R=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDgwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIyc2stbm8ta2V5LXJlcXVpcmVkJTIyKSUwQSUwQSUyMy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jUlMkMlMjAlMjAlMjMlMjBSZWR1Y2UlMjByZXBldGFyZWElMjBwcmluJTIwcGVuYWxpemFyZWElMjB0b2tlbi11cmlsb3IlMjBkZWphJTIwcHJlemVudGUlMEElMjAlMjAlMjAlMjBtYXhfdG9rZW5zJTNEMjAwJTJDJTIwJTIwJTIzJTIwTHVuZ2ltZWElMjBtYXhpbSVDNCU4MyUyMGRlJTIwZ2VuZXJhcmUlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",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"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&quot;</span>},
    ],
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Probabilitatea eșantionării nucleus</span>
    frequency_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Reduce repetarea token-urilor frecvente</span>
    presence_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Reduce repetarea prin penalizarea token-urilor deja prezente</span>
    max_tokens=<span class="hljs-number">200</span>,  <span class="hljs-comment"># Lungimea maximă de generare</span>
)
<span class="hljs-built_in">print</span>(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RpdiVDNCU4MyUwQSUzQyU3Q2ltX2VuZCU3QyUzRSUwQSUzQyU3Q2ltX3N0YXJ0JTdDJTNFYXNzaXN0YW50JTBBJTIyJTIyJTIyJTBBJTBBJTIzJTIwR2VuZXJlYXolQzQlODMlMjByJUM0JTgzc3B1bnN1bCUyMGN1JTIwY29udHJvbCUyMHByZWNpcyUyMGFsJTIwcGFyYW1ldHJpbG9yJTBBb3V0cHV0JTIwJTNEJTIwbGxtKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QyMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMGZyZXF1ZW5jeV9wZW5hbHR5JTNEMC41JTJDJTBBJTIwJTIwJTIwJTIwcHJlc2VuY2VfcGVuYWx0eSUzRDAuNSUyQyUwQSUyMCUyMCUyMCUyMHN0b3AlM0QlNUIlMjIlM0MlN0NpbV9lbmQlN0MlM0UlMjIlNUQlMkMlMEEpJTBBJTBBcHJpbnQob3V0cHV0JTVCJTIyY2hvaWNlcyUyMiU1RCU1QjAlNUQlNUIlMjJ0ZXh0JTIyJTVEKQ==",highlighted:`<span class="hljs-comment"># Folosind pachetul llama-cpp-python pentru accesul direct la model</span>
<span class="hljs-keyword">from</span> llama_cpp <span class="hljs-keyword">import</span> Llama

<span class="hljs-comment"># Încarcă modelul</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"># Dimensiunea ferestrei de context</span>
    n_threads=<span class="hljs-number">8</span>,  <span class="hljs-comment"># Thread-uri CPU</span>
    n_gpu_layers=<span class="hljs-number">0</span>,  <span class="hljs-comment"># Straturi GPU (0 = doar CPU)</span>
)

<span class="hljs-comment"># Formatează prompt-ul conform formatului așteptat al modelului</span>
prompt = <span class="hljs-string">&quot;&quot;&quot;&lt;|im_start|&gt;system
Ești un povestitor creativ.
&lt;|im_end|&gt;
&lt;|im_start|&gt;user
Scrie o poveste creativă
&lt;|im_end|&gt;
&lt;|im_start|&gt;assistant
&quot;&quot;&quot;</span>

<span class="hljs-comment"># Generează răspunsul cu control precis al parametrilor</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:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEluZmVyZW5jZUNsaWVudCUwQSUwQWNsaWVudCUyMCUzRCUyMEluZmVyZW5jZUNsaWVudChtb2RlbCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIpJTBBJTBBJTIzJTIwRXhlbXBsdSUyMGRlJTIwcGFyYW1ldHJpJTIwYXZhbnNhJUM4JTlCaSUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNoYXRfY29tcGxldGlvbiglMEElMjAlMjAlMjAlMjBtZXNzYWdlcyUzRCU1QiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJzeXN0ZW0lMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyRSVDOCU5OXRpJTIwdW4lMjBwb3Zlc3RpdG9yJTIwY3JlYXRpdi4lMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIydXNlciUyMiUyQyUyMCUyMmNvbnRlbnQlMjIlM0ElMjAlMjJTY3JpZSUyMG8lMjBwb3Zlc3RlJTIwY3JlYXRpdiVDNCU4MyUyMiU3RCUyQyUwQSUyMCUyMCUyMCUyMCU1RCUyQyUwQSUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC44JTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDIwMCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSklMEFwcmludChyZXNwb25zZS5jaG9pY2VzJTVCMCU1RC5tZXNzYWdlLmNvbnRlbnQpJTBBJTBBJTIzJTIwUGVudHJ1JTIwZ2VuZXJhcmVhJTIwZGlyZWN0JUM0JTgzJTIwZGUlMjB0ZXh0JTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQudGV4dF9nZW5lcmF0aW9uKCUwQSUyMCUyMCUyMCUyMCUyMlNjcmllJTIwbyUyMHBvdmVzdGUlMjBjcmVhdGl2JUM0JTgzJTIwZGVzcHJlJTIwZXhwbG9yYXJlYSUyMHNwYSVDOCU5Qml1bHVpJTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QyMDAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMGRldGFpbHMlM0RUcnVlJTJDJTBBKSUwQXByaW50KHJlc3BvbnNlLmdlbmVyYXRlZF90ZXh0KQ==",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"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&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"># Pentru generarea directă de text</span>
response = client.text_generation(
    <span class="hljs-string">&quot;Scrie o poveste creativă despre explorarea spațiului&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}}),q=new V({props:{code:"ZnJvbSUyMG9wZW5haSUyMGltcG9ydCUyME9wZW5BSSUwQSUwQWNsaWVudCUyMCUzRCUyME9wZW5BSShiYXNlX3VybCUzRCUyMmh0dHAlM0ElMkYlMkZsb2NhbGhvc3QlM0E4MDAwJTJGdjElMjIlMkMlMjBhcGlfa2V5JTNEJTIybm90LW5lZWRlZCUyMiklMEElMEElMjMlMjBFeGVtcGx1JTIwZGUlMjBwYXJhbWV0cmklMjBhdmFuc2ElQzglOUJpJTBBcmVzcG9uc2UlMjAlM0QlMjBjbGllbnQuY2hhdC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0zNjBNLUluc3RydWN0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWVzc2FnZXMlM0QlNUIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlN0IlMjJyb2xlJTIyJTNBJTIwJTIyc3lzdGVtJTIyJTJDJTIwJTIyY29udGVudCUyMiUzQSUyMCUyMkUlQzglOTl0aSUyMHVuJTIwcG92ZXN0aXRvciUyMGNyZWF0aXYuJTIyJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTNBJTIwJTIyU2NyaWUlMjBvJTIwcG92ZXN0ZSUyMGNyZWF0aXYlQzQlODMlMjIlN0QlMkMlMEElMjAlMjAlMjAlMjAlNUQlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDAuOCUyQyUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUwQSUyMCUyMCUyMCUyMG1heF90b2tlbnMlM0QyMDAlMkMlMEEpJTBBcHJpbnQocmVzcG9uc2UuY2hvaWNlcyU1QjAlNUQubWVzc2FnZS5jb250ZW50KQ==",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"># Exemplu de parametri avansați</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&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[<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b3JtYXR0ZWRfcHJvbXB0JTIwJTNEJTIwbGxtLmdldF9jaGF0X3RlbXBsYXRlKCkoJTBBJTIwJTIwJTIwJTIwY2hhdF9wcm9tcHQlMEEpJTIwJTIwJTIzJTIwRm9sb3NlJUM4JTk5dGUlMjAlQzglOTlhYmxvbnVsJTIwZGUlMjBjaGF0JTIwYWwlMjBtb2RlbHVsdWklMEFvdXRwdXRzJTIwJTNEJTIwbGxtLmdlbmVyYXRlKGZvcm1hdHRlZF9wcm9tcHQlMkMlMjBzYW1wbGluZ19wYXJhbXMpJTBBcHJpbnQob3V0cHV0cyU1QjAlNUQub3V0cHV0cyU1QjAlNUQudGV4dCk=",highlighted:`<span class="hljs-keyword">from</span> vllm <span class="hljs-keyword">import</span> LLM, SamplingParams

<span class="hljs-comment"># Inițializează modelul cu parametri avansați</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"># Configurează parametrii de eșantionare</span>
sampling_params = SamplingParams(
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consideră masa de probabilitate de top 95%</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Lungimea maximă</span>
    presence_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
    stop=[<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;###&quot;</span>],  <span class="hljs-comment"># Secvențe de oprire</span>
)

<span class="hljs-comment"># Generează text</span>
prompt = <span class="hljs-string">&quot;Scrie o poveste creativă&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"># Pentru interacțiuni în stil chat</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;Ești un povestitor creativ.&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;Scrie o poveste creativă&quot;</span>},
]
formatted_prompt = llm.get_chat_template()(
    chat_prompt
)  <span class="hljs-comment"># Folosește șablonul de chat al modelului</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(){m=N(`<hfoption value="tgi" label="TGI">
`),r=w("p"),r.textContent=j,J=c(),f(u.$$.fragment),y=c(),M=w("p"),M.textContent=U,i=c(),f(p.$$.fragment),Q=c(),A=w("p"),A.textContent=O,$=c(),f(z.$$.fragment),ll=N(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),W=w("p"),W.textContent=K,H=c(),f(T.$$.fragment),S=c(),X=w("p"),X.textContent=Jl,wl=c(),f(k.$$.fragment),Ml=c(),el=w("p"),el.textContent=L,Il=c(),f(R.$$.fragment),il=c(),tl=w("p"),tl.textContent=D,dl=c(),f(x.$$.fragment),pl=N(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),sl=w("p"),sl.textContent=P,hl=c(),f(Y.$$.fragment),nl=c(),_=w("p"),_.textContent=yl,bl=c(),f(q.$$.fragment),rl=c(),cl=w("p"),cl.textContent=ol,ml=c(),f(al.$$.fragment),F=N(`
</hfoption>`)},l(n){m=E(n,`<hfoption value="tgi" label="TGI">
`),r=I(n,"P",{"data-svelte-h":!0}),G(r)!=="svelte-1vmaxnf"&&(r.textContent=j),J=o(n),B(u.$$.fragment,n),y=o(n),M=I(n,"P",{"data-svelte-h":!0}),G(M)!=="svelte-1ajrx6o"&&(M.textContent=U),i=o(n),B(p.$$.fragment,n),Q=o(n),A=I(n,"P",{"data-svelte-h":!0}),G(A)!=="svelte-4b84cz"&&(A.textContent=O),$=o(n),B(z.$$.fragment,n),ll=E(n,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),W=I(n,"P",{"data-svelte-h":!0}),G(W)!=="svelte-gc9vgi"&&(W.textContent=K),H=o(n),B(T.$$.fragment,n),S=o(n),X=I(n,"P",{"data-svelte-h":!0}),G(X)!=="svelte-1w27s98"&&(X.textContent=Jl),wl=o(n),B(k.$$.fragment,n),Ml=o(n),el=I(n,"P",{"data-svelte-h":!0}),G(el)!=="svelte-17sbnw3"&&(el.textContent=L),Il=o(n),B(R.$$.fragment,n),il=o(n),tl=I(n,"P",{"data-svelte-h":!0}),G(tl)!=="svelte-1k6lxxy"&&(tl.textContent=D),dl=o(n),B(x.$$.fragment,n),pl=E(n,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),sl=I(n,"P",{"data-svelte-h":!0}),G(sl)!=="svelte-vd4z8t"&&(sl.textContent=P),hl=o(n),B(Y.$$.fragment,n),nl=o(n),_=I(n,"P",{"data-svelte-h":!0}),G(_)!=="svelte-1ns2jx"&&(_.textContent=yl),bl=o(n),B(q.$$.fragment,n),rl=o(n),cl=I(n,"P",{"data-svelte-h":!0}),G(cl)!=="svelte-1rrz7ab"&&(cl.textContent=ol),ml=o(n),B(al.$$.fragment,n),F=E(n,`
</hfoption>`)},m(n,d){t(n,m,d),t(n,r,d),t(n,J,d),g(u,n,d),t(n,y,d),t(n,M,d),t(n,i,d),g(p,n,d),t(n,Q,d),t(n,A,d),t(n,$,d),g(z,n,d),t(n,ll,d),t(n,W,d),t(n,H,d),g(T,n,d),t(n,S,d),t(n,X,d),t(n,wl,d),g(k,n,d),t(n,Ml,d),t(n,el,d),t(n,Il,d),g(R,n,d),t(n,il,d),t(n,tl,d),t(n,dl,d),g(x,n,d),t(n,pl,d),t(n,sl,d),t(n,hl,d),g(Y,n,d),t(n,nl,d),t(n,_,d),t(n,bl,d),g(q,n,d),t(n,rl,d),t(n,cl,d),t(n,ml,d),g(al,n,d),t(n,F,d),Cl=!0},p:Zl,i(n){Cl||(h(u.$$.fragment,n),h(p.$$.fragment,n),h(z.$$.fragment,n),h(T.$$.fragment,n),h(k.$$.fragment,n),h(R.$$.fragment,n),h(x.$$.fragment,n),h(Y.$$.fragment,n),h(q.$$.fragment,n),h(al.$$.fragment,n),Cl=!0)},o(n){b(u.$$.fragment,n),b(p.$$.fragment,n),b(z.$$.fragment,n),b(T.$$.fragment,n),b(k.$$.fragment,n),b(R.$$.fragment,n),b(x.$$.fragment,n),b(Y.$$.fragment,n),b(q.$$.fragment,n),b(al.$$.fragment,n),Cl=!1},d(n){n&&(e(m),e(r),e(J),e(y),e(M),e(i),e(Q),e(A),e($),e(ll),e(W),e(H),e(S),e(X),e(wl),e(Ml),e(el),e(Il),e(il),e(tl),e(dl),e(pl),e(sl),e(hl),e(nl),e(_),e(bl),e(rl),e(cl),e(ml),e(F)),Z(u,n),Z(p,n),Z(z,n),Z(T,n),Z(k,n),Z(R,n),Z(x,n),Z(Y,n),Z(q,n),Z(al,n)}}}function Tt(v){let m,r,j,J,u,y,M,U;return r=new V({props:{code:"Y2xpZW50LmdlbmVyYXRlKCUwQSUyMCUyMCUyMCUyMCUyMlNjcmllJTIwbyUyMHBvdmVzdGUlMjBjcmVhdGl2JUM0JTgzJTIyJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjAlMjAlMjMlMjBNYWklMjBtYXJlJTIwcGVudHJ1JTIwbWFpJTIwbXVsdCVDNCU4MyUyMGNyZWF0aXZpdGF0ZSUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUyMCUyMCUyMyUyMENvbnNpZGVyJUM0JTgzJTIwbWFzYSUyMGRlJTIwcHJvYmFiaWxpdGF0ZSUyMGRlJTIwdG9wJTIwOTUlMjUlMEElMjAlMjAlMjAlMjB0b3BfayUzRDUwJTJDJTIwJTIwJTIzJTIwQ29uc2lkZXIlQzQlODMlMjB0b3AlMjA1MCUyMGRlJTIwdG9rZW4tdXJpJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QxMDAlMkMlMjAlMjAlMjMlMjBMdW5naW1lYSUyMG1heGltJUM0JTgzJTBBJTIwJTIwJTIwJTIwcmVwZXRpdGlvbl9wZW5hbHR5JTNEMS4xJTJDJTIwJTIwJTIzJTIwUmVkdWNlJTIwcmVwZXRhcmVhJTBBKQ==",highlighted:`client.generate(
    <span class="hljs-string">&quot;Scrie o poveste creativă&quot;</span>,
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consideră masa de probabilitate de top 95%</span>
    top_k=<span class="hljs-number">50</span>,  <span class="hljs-comment"># Consideră top 50 de token-uri</span>
    max_new_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Lungimea maximă</span>
    repetition_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
)`,wrap:!1}}),J=new V({props:{code:"JTIzJTIwUHJpbiUyMGNvbXBhdGliaWxpdGF0ZWElMjBBUEklMjBPcGVuQUklMEFyZXNwb25zZSUyMCUzRCUyMGNsaWVudC5jb21wbGV0aW9ucy5jcmVhdGUoJTBBJTIwJTIwJTIwJTIwbW9kZWwlM0QlMjJzbW9sbG0yLTEuN2ItaW5zdHJ1Y3QlMjIlMkMlMjAlMjAlMjMlMjBOdW1lbGUlMjBtb2RlbHVsdWklMjAocG9hdGUlMjBmaSUyMG9yaWNlJTIwc3RyaW5nJTIwcGVudHJ1JTIwc2VydmVydW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cGVuYWx0eSUzRDEuMSUyQyUwQSk=",highlighted:`<span class="hljs-comment"># Prin compatibilitatea API OpenAI</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,  <span class="hljs-comment"># Numele modelului (poate fi orice string pentru serverul llama.cpp)</span>
    prompt=<span class="hljs-string">&quot;Scrie o poveste creativă&quot;</span>,
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consideră masa de probabilitate de top 95%</span>
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Lungimea maximă</span>
)

<span class="hljs-comment"># Prin accesul direct llama-cpp-python</span>
output = llm(
    <span class="hljs-string">&quot;Scrie o poveste creativă&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}}),y=new V({props:{code:"cGFyYW1zJTIwJTNEJTIwU2FtcGxpbmdQYXJhbXMoJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjglMkMlMjAlMjAlMjMlMjBNYWklMjBtYXJlJTIwcGVudHJ1JTIwbWFpJTIwbXVsdCVDNCU4MyUyMGNyZWF0aXZpdGF0ZSUwQSUyMCUyMCUyMCUyMHRvcF9wJTNEMC45NSUyQyUyMCUyMCUyMyUyMENvbnNpZGVyJUM0JTgzJTIwbWFzYSUyMGRlJTIwcHJvYmFiaWxpdGF0ZSUyMGRlJTIwdG9wJTIwOTUlMjUlMEElMjAlMjAlMjAlMjB0b3BfayUzRDUwJTJDJTIwJTIwJTIzJTIwQ29uc2lkZXIlQzQlODMlMjB0b3AlMjA1MCUyMGRlJTIwdG9rZW4tdXJpJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUyMCUyMCUyMyUyMEx1bmdpbWVhJTIwbWF4aW0lQzQlODMlMEElMjAlMjAlMjAlMjBwcmVzZW5jZV9wZW5hbHR5JTNEMC4xJTJDJTIwJTIwJTIzJTIwUmVkdWNlJTIwcmVwZXRhcmVhJTBBKSUwQWxsbS5nZW5lcmF0ZSglMjJTY3JpZSUyMG8lMjBwb3Zlc3RlJTIwY3JlYXRpdiVDNCU4MyUyMiUyQyUyMHNhbXBsaW5nX3BhcmFtcyUzRHBhcmFtcyk=",highlighted:`params = SamplingParams(
    temperature=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Mai mare pentru mai multă creativitate</span>
    top_p=<span class="hljs-number">0.95</span>,  <span class="hljs-comment"># Consideră masa de probabilitate de top 95%</span>
    top_k=<span class="hljs-number">50</span>,  <span class="hljs-comment"># Consideră top 50 de token-uri</span>
    max_tokens=<span class="hljs-number">100</span>,  <span class="hljs-comment"># Lungimea maximă</span>
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Reduce repetarea</span>
)
llm.generate(<span class="hljs-string">&quot;Scrie o poveste creativă&quot;</span>, sampling_params=params)`,wrap:!1}}),{c(){m=N(`<hfoption value="tgi" label="TGI">

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

	`),f(J.$$.fragment),u=N(`
</hfoption>
<hfoption value="vllm" label="vLLM">

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

	`),B(r.$$.fragment,i),j=E(i,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),B(J.$$.fragment,i),u=E(i,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),B(y.$$.fragment,i),M=E(i,`
</hfoption>`)},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UyMCUyMCUyMCUyMGZyZXF1ZW5jeV9wZW5hbHR5JTNEMC41JTJDJTIwJTIwJTIzJTIwUGVuYWxpdGF0ZSUyMGRlJTIwZnJlY3ZlbiVDOCU5QiVDNCU4MyUyMGFkaSVDOCU5QmlvbmFsJUM0JTgzJTBBJTIwJTIwJTIwJTIwcHJlc2VuY2VfcGVuYWx0eSUzRDAuNSUyQyUyMCUyMCUyMyUyMFBlbmFsaXRhdGUlMjBkZSUyMHByZXplbiVDOCU5QiVDNCU4MyUyMGFkaSVDOCU5QmlvbmFsJUM0JTgzJTBBKQ==",highlighted:`<span class="hljs-comment"># Prin API OpenAI</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,
    prompt=<span class="hljs-string">&quot;Scrie un text variat&quot;</span>,
    frequency_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Penalizează token-urile frecvente</span>
    presence_penalty=<span class="hljs-number">0.8</span>,  <span class="hljs-comment"># Penalizează token-urile deja prezente</span>
)

<span class="hljs-comment"># Prin biblioteca directă</span>
output = llm(
    <span class="hljs-string">&quot;Scrie un text variat&quot;</span>,
    repeat_penalty=<span class="hljs-number">1.1</span>,  <span class="hljs-comment"># Penalizează token-urile repetate</span>
    frequency_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Penalitate de frecvență adițională</span>
    presence_penalty=<span class="hljs-number">0.5</span>,  <span class="hljs-comment"># Penalitate de prezență adițională</span>
)`,wrap:!1}}),J=new V({props:{code:"cGFyYW1zJTIwJTNEJTIwU2FtcGxpbmdQYXJhbXMoJTBBJTIwJTIwJTIwJTIwcHJlc2VuY2VfcGVuYWx0eSUzRDAuMSUyQyUyMCUyMCUyMyUyMFBlbmFsaXplYXolQzQlODMlMjBwcmV6ZW4lQzglOUJhJTIwdG9rZW4tdXJpbG9yJTBBJTIwJTIwJTIwJTIwZnJlcXVlbmN5X3BlbmFsdHklM0QwLjElMkMlMjAlMjAlMjMlMjBQZW5hbGl6ZWF6JUM0JTgzJTIwZnJlY3ZlbiVDOCU5QmElMjB0b2tlbi11cmlsb3IlMEEp",highlighted:`params = SamplingParams(
    presence_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Penalizează prezența token-urilor</span>
    frequency_penalty=<span class="hljs-number">0.1</span>,  <span class="hljs-comment"># Penalizează frecvența token-urilor</span>
)`,wrap:!1}}),{c(){m=N(`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Scrie un text variat",
    repetition_penalty=1.1,  # Penalizează token-urile repetate
    no_repeat_ngram_size=3,  # Previne repetarea de 3-grame
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

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

	`),f(J.$$.fragment),u=N(`
</hfoption>`)},l(M){m=E(M,`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Scrie un text variat",
    repetition_penalty=1.1,  # Penalizează token-urile repetate
    no_repeat_ngram_size=3,  # Previne repetarea de 3-grame
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),B(r.$$.fragment,M),j=E(M,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),B(J.$$.fragment,M),u=E(M,`
</hfoption>`)},m(M,U){t(M,m,U),g(r,M,U),t(M,j,U),g(J,M,U),t(M,u,U),y=!0},p:Zl,i(M){y||(h(r.$$.fragment,M),h(J.$$.fragment,M),y=!0)},o(M){b(r.$$.fragment,M),b(J.$$.fragment,M),y=!1},d(M){M&&(e(m),e(j),e(u)),Z(r,M),Z(J,M)}}}function wt(v){let m,r,j,J,u,y;return r=new V({props:{code:"JTIzJTIwUHJpbiUyMEFQSSUyME9wZW5BSSUwQXJlc3BvbnNlJTIwJTNEJTIwY2xpZW50LmNvbXBsZXRpb25zLmNyZWF0ZSglMEElMjAlMjAlMjAlMjBtb2RlbCUzRCUyMnNtb2xsbTItMS43Yi1pbnN0cnVjdCUyMiUyQyUwQSUyMCUyMCUyMCUyMHByb21wdCUzRCUyMkdlbmVyZWF6JUM0JTgzJTIwdW4lMjBwYXJhZ3JhZiUyMHNjdXJ0JTIyJTJDJTBBJTIwJTIwJTIwJTIwbWF4X3Rva2VucyUzRDEwMCUyQyUwQSUyMCUyMCUyMCUyMHN0b3AlM0QlNUIlMjIlNUNuJTVDbiUyMiUyQyUyMCUyMiUyMyUyMyUyMyUyMiU1RCUyQyUwQSklMEElMEElMjMlMjBQcmluJTIwYmlibGlvdGVjYSUyMGRpcmVjdCVDNCU4MyUwQW91dHB1dCUyMCUzRCUyMGxsbSglMjJHZW5lcmVheiVDNCU4MyUyMHVuJTIwcGFyYWdyYWYlMjBzY3VydCUyMiUyQyUyMG1heF90b2tlbnMlM0QxMDAlMkMlMjBzdG9wJTNEJTVCJTIyJTVDbiU1Q24lMjIlMkMlMjAlMjIlMjMlMjMlMjMlMjIlNUQp",highlighted:`<span class="hljs-comment"># Prin API OpenAI</span>
response = client.completions.create(
    model=<span class="hljs-string">&quot;smollm2-1.7b-instruct&quot;</span>,
    prompt=<span class="hljs-string">&quot;Generează un paragraf scurt&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"># Prin biblioteca directă</span>
output = llm(<span class="hljs-string">&quot;Generează un paragraf scurt&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}}),J=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(){m=N(`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Generează un paragraf scurt",
    max_new_tokens=100,
    min_new_tokens=10,
    stop_sequences=["\\n\\n", "###"],
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

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

	`),f(J.$$.fragment),u=N(`
</hfoption>`)},l(M){m=E(M,`<hfoption value="tgi" label="TGI">
\`\`\`python
client.generate(
    "Generează un paragraf scurt",
    max_new_tokens=100,
    min_new_tokens=10,
    stop_sequences=["\\n\\n", "###"],
)
\`\`\`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">

	`),B(r.$$.fragment,M),j=E(M,`
</hfoption>
<hfoption value="vllm" label="vLLM">

	`),B(J.$$.fragment,M),u=E(M,`
</hfoption>`)},m(M,U){t(M,m,U),g(r,M,U),t(M,j,U),g(J,M,U),t(M,u,U),y=!0},p:Zl,i(M){y||(h(r.$$.fragment,M),h(J.$$.fragment,M),y=!0)},o(M){b(r.$$.fragment,M),b(J.$$.fragment,M),y=!1},d(M){M&&(e(m),e(j),e(u)),Z(r,M),Z(J,M)}}}function It(v){let m,r,j,J,u="llama.cpp folosește cuantificarea și dispunerea optimată a memoriei:",y,M,U,i,p="Pentru modele prea mari pentru GPU-ul tău, poți folosi offloading-ul CPU:",Q,A,O,$,z="vLLM folosește PagedAttention pentru gestionarea optimă a memoriei:",ll,W,K,H;return r=new V({props:{code:"JTIzJTIwSW1wbGVtZW50YXJlYSUyMERvY2tlciUyMGN1JTIwb3B0aW1pemFyZWElMjBtZW1vcmllaSUwQWRvY2tlciUyMHJ1biUyMC0tZ3B1cyUyMGFsbCUyMC1wJTIwODA4MCUzQTgwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1zaG0tc2l6ZSUyMDFnJTIwJTVDJTBBJTIwJTIwJTIwJTIwZ2hjci5pbyUyRmh1Z2dpbmdmYWNlJTJGdGV4dC1nZW5lcmF0aW9uLWluZmVyZW5jZSUzQWxhdGVzdCUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbW9kZWwtaWQlMjBIdWdnaW5nRmFjZVRCJTJGU21vbExNMi0xLjdCLUluc3RydWN0JTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1tYXgtYmF0Y2gtdG90YWwtdG9rZW5zJTIwODE5MiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tbWF4LWlucHV0LWxlbmd0aCUyMDQwOTY=",highlighted:`<span class="hljs-comment"># Implementarea Docker cu optimizarea memoriei</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:"JTIzJTIwU2VydmVyJTIwY3UlMjBvcHRpbWl6JUM0JTgzcmklMjBkZSUyMG1lbW9yaWUlMEEuJTJGc2VydmVyJTIwJTVDJTBBJTIwJTIwJTIwJTIwLW0lMjBzbW9sbG0yLTEuN2ItaW5zdHJ1Y3QuUTRfS19NLmdndWYlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWhvc3QlMjAwLjAuMC4wJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wb3J0JTIwODA4MCUyMCU1QyUwQSUyMCUyMCUyMCUyMC1jJTIwMjA0OCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMERpbWVuc2l1bmVhJTIwY29udGV4dHVsdWklMEElMjAlMjAlMjAlMjAtLXRocmVhZHMlMjA0JTIwJTVDJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwVGhyZWFkLXVyaSUyMENQVSUwQSUyMCUyMCUyMCUyMC0tbi1ncHUtbGF5ZXJzJTIwMzIlMjAlNUMlMjAlMjAlMjAlMjAlMjAlMjMlMjBGb2xvc2UlQzglOTl0ZSUyMG1haSUyMG11bHRlJTIwc3RyYXR1cmklMjBHUFUlMjBwZW50cnUlMjBtb2RlbGUlMjBtYWklMjBtYXJpJTBBJTIwJTIwJTIwJTIwLS1tbG9jayUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMyUyMEJsb2NoZWF6JUM0JTgzJTIwbWVtb3JpYSUyMHBlbnRydSUyMGElMjBwcmV2ZW5pJTIwc3dhcHBpbmctdWwlMEElMjAlMjAlMjAlMjAtLWNvbnQtYmF0Y2hpbmclMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBBY3RpdmVheiVDNCU4MyUyMHByb2Nlc2FyZWElMjBjb250aW51JUM0JTgzJTIwJUMzJUFFbiUyMGxvdHVyaQ==",highlighted:`<span class="hljs-comment"># Server cu optimizări de memorie</span>
./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --host 0.0.0.0 \\
    --port 8080 \\
    -c 2048 \\               <span class="hljs-comment"># Dimensiunea contextului</span>
    --threads 4 \\           <span class="hljs-comment"># Thread-uri CPU</span>
    --n-gpu-layers 32 \\     <span class="hljs-comment"># Folosește mai multe straturi GPU pentru modele mai mari</span>
    --mlock \\               <span class="hljs-comment"># Blochează memoria pentru a preveni swapping-ul</span>
    --cont-batching         <span class="hljs-comment"># Activează procesarea continuă în loturi</span>`,wrap:!1}}),A=new V({props:{code:"LiUyRnNlcnZlciUyMCU1QyUwQSUyMCUyMCUyMCUyMC1tJTIwc21vbGxtMi0xLjdiLWluc3RydWN0LlE0X0tfTS5nZ3VmJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1uLWdwdS1sYXllcnMlMjAyMCUyMCU1QyUyMCUyMCUyMCUyMCUyMCUyMyUyMFAlQzQlODNzdHJlYXolQzQlODMlMjBwcmltZWxlJTIwMjAlMjBkZSUyMHN0cmF0dXJpJTIwcGUlMjBHUFUlMEElMjAlMjAlMjAlMjAtLXRocmVhZHMlMjA4JTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIzJTIwRm9sb3NlJUM4JTk5dGUlMjBtYWklMjBtdWx0ZSUyMHRocmVhZC11cmklMjBDUFUlMjBwZW50cnUlMjBzdHJhdHVyaWxlJTIwQ1BV",highlighted:`./server \\
    -m smollm2-1.7b-instruct.Q4_K_M.gguf \\
    --n-gpu-layers 20 \\     <span class="hljs-comment"># Păstrează primele 20 de straturi pe GPU</span>
    --threads 8             <span class="hljs-comment"># Folosește mai multe thread-uri CPU pentru straturile CPU</span>`,wrap:!1}}),W=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(){m=N(`<hfoption value="tgi" label="TGI">
TGI folosește Flash Attention 2 și procesarea continuă în loturi:

	`),f(r.$$.fragment),j=N(`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),J=w("p"),J.textContent=u,y=c(),f(M.$$.fragment),U=c(),i=w("p"),i.textContent=p,Q=c(),f(A.$$.fragment),O=N(`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),$=w("p"),$.textContent=z,ll=c(),f(W.$$.fragment),K=N(`
</hfoption>`)},l(T){m=E(T,`<hfoption value="tgi" label="TGI">
TGI folosește Flash Attention 2 și procesarea continuă în loturi:

	`),B(r.$$.fragment,T),j=E(T,`
</hfoption>
<hfoption value="llama.cpp" label="llama.cpp">
`),J=I(T,"P",{"data-svelte-h":!0}),G(J)!=="svelte-1sfqsd0"&&(J.textContent=u),y=o(T),B(M.$$.fragment,T),U=o(T),i=I(T,"P",{"data-svelte-h":!0}),G(i)!=="svelte-1p18jlx"&&(i.textContent=p),Q=o(T),B(A.$$.fragment,T),O=E(T,`
</hfoption>
<hfoption value="vllm" label="vLLM">
`),$=I(T,"P",{"data-svelte-h":!0}),G($)!=="svelte-1p9u0qw"&&($.textContent=z),ll=o(T),B(W.$$.fragment,T),K=E(T,`
</hfoption>`)},m(T,S){t(T,m,S),g(r,T,S),t(T,j,S),t(T,J,S),t(T,y,S),g(M,T,S),t(T,U,S),t(T,i,S),t(T,Q,S),g(A,T,S),t(T,O,S),t(T,$,S),t(T,ll,S),g(W,T,S),t(T,K,S),H=!0},p:Zl,i(T){H||(h(r.$$.fragment,T),h(M.$$.fragment,T),h(A.$$.fragment,T),h(W.$$.fragment,T),H=!0)},o(T){b(r.$$.fragment,T),b(M.$$.fragment,T),b(A.$$.fragment,T),b(W.$$.fragment,T),H=!1},d(T){T&&(e(m),e(j),e(J),e(y),e(U),e(i),e(Q),e(O),e($),e(ll),e(K)),Z(r,T),Z(M,T),Z(A,T),Z(W,T)}}}function dt(v){let m,r,j,J,u,y,M,U,i,p="În această secțiune, vom explora framework-uri avansate pentru optimizarea implementărilor LLM: Text Generation Inference (TGI), vLLM și llama.cpp. Aceste aplicații sunt utilizate în principal în medii de producție pentru a servi LLM-uri utilizatorilor. Această secțiune se concentrează pe modul de implementare a acestor framework-uri în producție, mai degrabă decât pe modul de utilizare pentru inferență pe o singură mașină.",Q,A,O="Vom acoperi modul în care aceste instrumente maximizează eficiența inferenței și simplifică implementările de producție ale Modelelor de Limbaj de Mari Dimensiuni.",$,z,ll,W,K="TGI, vLLM și llama.cpp servesc scopuri similare, dar au caracteristici distincte care le fac mai potrivite pentru diferite cazuri de utilizare. Să ne uităm la diferențele cheie dintre ele, concentrându-ne pe performanță și integrare.",H,T,S,X,Jl="<strong>TGI</strong> este proiectat să fie stabil și previzibil în producție, folosind lungimi fixe de secvență pentru a menține utilizarea memoriei consistentă. TGI gestionează memoria folosind Flash Attention 2 și tehnici de procesare continuă în loturi. Aceasta înseamnă că poate procesa calculele de atenție foarte eficient și poate menține GPU-ul ocupat prin alimentarea constantă cu lucru. Sistemul poate muta părți ale modelului între CPU și GPU când este necesar, ceea ce ajută la gestionarea modelelor mai mari.",wl,k,Ml,el,L,Il,R,il="<strong>vLLM</strong> adoptă o abordare diferită prin utilizarea PagedAttention. La fel cum un computer își gestionează memoria în pagini, vLLM împarte memoria modelului în blocuri mai mici. Acest sistem inteligent înseamnă că poate gestiona cereri de dimensiuni diferite mai flexibil și nu risipește spațiul de memorie. Este deosebit de bun la partajarea memoriei între diferite cereri și reduce fragmentarea memoriei, ceea ce face întregul sistem mai eficient.",tl,D,dl,x,pl="<strong>llama.cpp</strong> este o implementare C/C++ extrem de optimizată proiectată inițial pentru rularea modelelor LLaMA pe hardware de consum. Se concentrează pe eficiența CPU cu accelerație GPU opțională și este ideal pentru medii cu resurse limitate. llama.cpp folosește tehnici de cuantificare pentru a reduce dimensiunea modelului și cerințele de memorie menținând în același timp performanță bună. Implementează kerneluri optimizate pentru diverse arhitecturi CPU și suportă gestionarea de bază a cache-ului KV pentru generarea eficientă de token-uri.",sl,P,hl,Y,nl,_,yl="Să trecem la diferențele de implementare și integrare între framework-uri.",bl,q,rl="<strong>TGI</strong> excelează în implementarea la nivel enterprise cu caracteristicile sale gata pentru producție. Vine cu suport Kubernetes integrat și include tot ce ai nevoie pentru rularea în producție, precum monitorizarea prin Prometheus și Grafana, scalarea automată și caracteristici cuprinzătoare de siguranță. Sistemul include, de asemenea, logare de nivel enterprise și diverse măsuri de protecție precum filtrarea conținutului și limitarea ratei pentru a menține implementarea sigură și stabilă.",cl,ol,ml="<strong>vLLM</strong> adoptă o abordare mai flexibilă, prietenoasă cu dezvoltatorii pentru implementare. Este construit cu Python în nucleu și poate înlocui cu ușurință API-ul OpenAI în aplicațiile tale existente. Framework-ul se concentrează pe livrarea performanței brute și poate fi personalizat pentru a se potrivi nevoilor tale specifice. Funcționează deosebit de bine cu Ray pentru gestionarea clusterelor, făcându-l o alegere excelentă când ai nevoie de performanță înaltă și adaptabilitate.",al,F,Cl="<strong>llama.cpp</strong> prioritizează simplitatea și portabilitatea. Implementarea sa de server este ușoară și poate rula pe o gamă largă de hardware, de la servere puternice la laptopuri de consum și chiar unele dispozitive mobile de înaltă performanță. Cu dependențe minime și un nucleu C/C++ simplu, este ușor de implementat în medii unde instalarea framework-urilor Python ar fi provocatoare. Serverul oferă un API compatibil cu OpenAI menținând în același timp un amprentă de resurse mult mai mică decât alte soluții.",n,d,fl,ul,Pl="Să explorăm cum să folosim aceste framework-uri pentru implementarea LLM-urilor, începând cu instalarea și configurarea de bază.",Bl,Ul,gl,Tl,s,C,le,Sl,Be="Să ne uităm la exemple de generare de text cu framework-urile:",ee,Gl,te,zl,se,Nl,ne,El,ge="Procesul de generare a textului implică selectarea următorului token la fiecare pas. Acest proces de selecție poate fi controlat prin diverși parametri:",ae,$l,Ze="<li><strong>Logit-uri Brute</strong>: Probabilitățile inițiale de ieșire pentru fiecare token</li> <li><strong>Temperatura</strong>: Controlează aleatoriul în selecție (mai mare = mai creativ)</li> <li><strong>Eșantionarea Top-p (Nucleus)</strong>: Filtrează la token-urile de top care alcătuiesc X% din masa de probabilitate</li> <li><strong>Filtrarea Top-k</strong>: Limitează selecția la k token-uri cele mai probabile</li>",Me,Xl,Ge="Iată cum să configurezi acești parametri:",ie,Ql,pe,kl,re,Rl,Qe="Ambele framework-uri oferă modalități de a preveni generarea repetitivă de text:",ce,vl,oe,xl,me,Yl,ve="Poți controla lungimea generării și specifica când să se oprească:",ue,Al,Ue,_l,Je,ql,Ae="Ambele framework-uri implementează tehnici avansate de gestionare a memoriei pentru inferența eficientă.",ye,Vl,Te,Fl,je,Hl,Ve='<li><a href="https://huggingface.co/docs/text-generation-inference" rel="nofollow">Documentația Text Generation Inference</a></li> <li><a href="https://github.com/huggingface/text-generation-inference" rel="nofollow">Depozitul GitHub TGI</a></li> <li><a href="https://vllm.readthedocs.io/" rel="nofollow">Documentația vLLM</a></li> <li><a href="https://github.com/vllm-project/vllm" rel="nofollow">Depozitul GitHub vLLM</a></li> <li><a href="https://arxiv.org/abs/2309.06180" rel="nofollow">Lucrarea PagedAttention</a></li> <li><a href="https://github.com/ggerganov/llama.cpp" rel="nofollow">Depozitul GitHub llama.cpp</a></li> <li><a href="https://github.com/abetlen/llama-cpp-python" rel="nofollow">Depozitul llama-cpp-python</a></li>',we,Ll,Ie,Ol,de;return u=new Mt({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),M=new jl({props:{title:"Implementarea Optimizată a Inferenței",local:"implementarea-optimizată-a-inferenței",headingTag:"h1"}}),z=new jl({props:{title:"Ghid de Selecție a Framework-ului",local:"ghid-de-selecție-a-framework-ului",headingTag:"h2"}}),T=new jl({props:{title:"Gestionarea Memoriei și Performanța",local:"gestionarea-memoriei-și-performanța",headingTag:"h3"}}),L=new Ce({props:{title:"Cum Funcționează Flash Attention",$$slots:{default:[mt]},$$scope:{ctx:v}}}),D=new Ce({props:{title:"Cum Funcționează PagedAttention",$$slots:{default:[ut]},$$scope:{ctx:v}}}),P=new Ce({props:{title:"Cum Funcționează Cuantificarea llama.cpp",$$slots:{default:[Ut]},$$scope:{ctx:v}}}),Y=new jl({props:{title:"Implementarea și Integrarea",local:"implementarea-și-integrarea",headingTag:"h3"}}),d=new jl({props:{title:"Începerea",local:"începerea",headingTag:"h2"}}),Ul=new jl({props:{title:"Instalarea și Configurarea de Bază",local:"instalarea-și-configurarea-de-bază",headingTag:"h3"}}),Tl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[Jt]},$$scope:{ctx:v}}}),C=new jl({props:{title:"Generarea de Bază a Textului",local:"generarea-de-bază-a-textului",headingTag:"h3"}}),Gl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[yt]},$$scope:{ctx:v}}}),zl=new jl({props:{title:"Controlul Avansat al Generării",local:"controlul-avansat-al-generării",headingTag:"h2"}}),Nl=new jl({props:{title:"Selecția Token-urilor și Eșantionarea",local:"selecția-token-urilor-și-eșantionarea",headingTag:"h3"}}),Ql=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[Tt]},$$scope:{ctx:v}}}),kl=new jl({props:{title:"Controlul Repetării",local:"controlul-repetării",headingTag:"h3"}}),vl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[jt]},$$scope:{ctx:v}}}),xl=new jl({props:{title:"Controlul Lungimii și Secvențele de Oprire",local:"controlul-lungimii-și-secvențele-de-oprire",headingTag:"h3"}}),Al=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[wt]},$$scope:{ctx:v}}}),_l=new jl({props:{title:"Gestionarea Memoriei",local:"gestionarea-memoriei",headingTag:"h2"}}),Vl=new Dl({props:{id:"inference-frameworks",options:[],$$slots:{default:[It]},$$scope:{ctx:v}}}),Fl=new jl({props:{title:"Resurse",local:"resurse",headingTag:"h2"}}),Ll=new it({props:{source:"https://github.com/huggingface/course/blob/main/chapters/ro/chapter2/8.mdx"}}),{c(){m=w("meta"),r=c(),j=w("p"),J=c(),f(u.$$.fragment),y=c(),f(M.$$.fragment),U=c(),i=w("p"),i.textContent=p,Q=c(),A=w("p"),A.textContent=O,$=c(),f(z.$$.fragment),ll=c(),W=w("p"),W.textContent=K,H=c(),f(T.$$.fragment),S=c(),X=w("p"),X.innerHTML=Jl,wl=c(),k=w("img"),el=c(),f(L.$$.fragment),Il=c(),R=w("p"),R.innerHTML=il,tl=c(),f(D.$$.fragment),dl=c(),x=w("p"),x.innerHTML=pl,sl=c(),f(P.$$.fragment),hl=c(),f(Y.$$.fragment),nl=c(),_=w("p"),_.textContent=yl,bl=c(),q=w("p"),q.innerHTML=rl,cl=c(),ol=w("p"),ol.innerHTML=ml,al=c(),F=w("p"),F.innerHTML=Cl,n=c(),f(d.$$.fragment),fl=c(),ul=w("p"),ul.textContent=Pl,Bl=c(),f(Ul.$$.fragment),gl=c(),f(Tl.$$.fragment),s=c(),f(C.$$.fragment),le=c(),Sl=w("p"),Sl.textContent=Be,ee=c(),f(Gl.$$.fragment),te=c(),f(zl.$$.fragment),se=c(),f(Nl.$$.fragment),ne=c(),El=w("p"),El.textContent=ge,ae=c(),$l=w("ol"),$l.innerHTML=Ze,Me=c(),Xl=w("p"),Xl.textContent=Ge,ie=c(),f(Ql.$$.fragment),pe=c(),f(kl.$$.fragment),re=c(),Rl=w("p"),Rl.textContent=Qe,ce=c(),f(vl.$$.fragment),oe=c(),f(xl.$$.fragment),me=c(),Yl=w("p"),Yl.textContent=ve,ue=c(),f(Al.$$.fragment),Ue=c(),f(_l.$$.fragment),Je=c(),ql=w("p"),ql.textContent=Ae,ye=c(),f(Vl.$$.fragment),Te=c(),f(Fl.$$.fragment),je=c(),Hl=w("ul"),Hl.innerHTML=Ve,we=c(),f(Ll.$$.fragment),Ie=c(),Ol=w("p"),this.h()},l(l){const a=at("svelte-u9bgzb",document.head);m=I(a,"META",{name:!0,content:!0}),a.forEach(e),r=o(l),j=I(l,"P",{}),Kl(j).forEach(e),J=o(l),B(u.$$.fragment,l),y=o(l),B(M.$$.fragment,l),U=o(l),i=I(l,"P",{"data-svelte-h":!0}),G(i)!=="svelte-l25pl2"&&(i.textContent=p),Q=o(l),A=I(l,"P",{"data-svelte-h":!0}),G(A)!=="svelte-ieh7in"&&(A.textContent=O),$=o(l),B(z.$$.fragment,l),ll=o(l),W=I(l,"P",{"data-svelte-h":!0}),G(W)!=="svelte-a0brur"&&(W.textContent=K),H=o(l),B(T.$$.fragment,l),S=o(l),X=I(l,"P",{"data-svelte-h":!0}),G(X)!=="svelte-bi6vas"&&(X.innerHTML=Jl),wl=o(l),k=I(l,"IMG",{src:!0,alt:!0}),el=o(l),B(L.$$.fragment,l),Il=o(l),R=I(l,"P",{"data-svelte-h":!0}),G(R)!=="svelte-zoy9o2"&&(R.innerHTML=il),tl=o(l),B(D.$$.fragment,l),dl=o(l),x=I(l,"P",{"data-svelte-h":!0}),G(x)!=="svelte-bz5wux"&&(x.innerHTML=pl),sl=o(l),B(P.$$.fragment,l),hl=o(l),B(Y.$$.fragment,l),nl=o(l),_=I(l,"P",{"data-svelte-h":!0}),G(_)!=="svelte-rjqdb8"&&(_.textContent=yl),bl=o(l),q=I(l,"P",{"data-svelte-h":!0}),G(q)!=="svelte-vkzd9m"&&(q.innerHTML=rl),cl=o(l),ol=I(l,"P",{"data-svelte-h":!0}),G(ol)!=="svelte-1gkp50b"&&(ol.innerHTML=ml),al=o(l),F=I(l,"P",{"data-svelte-h":!0}),G(F)!=="svelte-ej2h50"&&(F.innerHTML=Cl),n=o(l),B(d.$$.fragment,l),fl=o(l),ul=I(l,"P",{"data-svelte-h":!0}),G(ul)!=="svelte-k038du"&&(ul.textContent=Pl),Bl=o(l),B(Ul.$$.fragment,l),gl=o(l),B(Tl.$$.fragment,l),s=o(l),B(C.$$.fragment,l),le=o(l),Sl=I(l,"P",{"data-svelte-h":!0}),G(Sl)!=="svelte-1pfzauy"&&(Sl.textContent=Be),ee=o(l),B(Gl.$$.fragment,l),te=o(l),B(zl.$$.fragment,l),se=o(l),B(Nl.$$.fragment,l),ne=o(l),El=I(l,"P",{"data-svelte-h":!0}),G(El)!=="svelte-vv01ra"&&(El.textContent=ge),ae=o(l),$l=I(l,"OL",{"data-svelte-h":!0}),G($l)!=="svelte-tnbogk"&&($l.innerHTML=Ze),Me=o(l),Xl=I(l,"P",{"data-svelte-h":!0}),G(Xl)!=="svelte-1to0u51"&&(Xl.textContent=Ge),ie=o(l),B(Ql.$$.fragment,l),pe=o(l),B(kl.$$.fragment,l),re=o(l),Rl=I(l,"P",{"data-svelte-h":!0}),G(Rl)!=="svelte-17cj06z"&&(Rl.textContent=Qe),ce=o(l),B(vl.$$.fragment,l),oe=o(l),B(xl.$$.fragment,l),me=o(l),Yl=I(l,"P",{"data-svelte-h":!0}),G(Yl)!=="svelte-3631at"&&(Yl.textContent=ve),ue=o(l),B(Al.$$.fragment,l),Ue=o(l),B(_l.$$.fragment,l),Je=o(l),ql=I(l,"P",{"data-svelte-h":!0}),G(ql)!=="svelte-m10jfl"&&(ql.textContent=Ae),ye=o(l),B(Vl.$$.fragment,l),Te=o(l),B(Fl.$$.fragment,l),je=o(l),Hl=I(l,"UL",{"data-svelte-h":!0}),G(Hl)!=="svelte-1jjsuar"&&(Hl.innerHTML=Ve),we=o(l),B(Ll.$$.fragment,l),Ie=o(l),Ol=I(l,"P",{}),Kl(Ol).forEach(e),this.h()},h(){Wl(m,"name","hf:doc:metadata"),Wl(m,"content",ht),et(k.src,Ml="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/tgi/flash-attn.png")||Wl(k,"src",Ml),Wl(k,"alt","Flash Attention")},m(l,a){fe(document.head,m),t(l,r,a),t(l,j,a),t(l,J,a),g(u,l,a),t(l,y,a),g(M,l,a),t(l,U,a),t(l,i,a),t(l,Q,a),t(l,A,a),t(l,$,a),g(z,l,a),t(l,ll,a),t(l,W,a),t(l,H,a),g(T,l,a),t(l,S,a),t(l,X,a),t(l,wl,a),t(l,k,a),t(l,el,a),g(L,l,a),t(l,Il,a),t(l,R,a),t(l,tl,a),g(D,l,a),t(l,dl,a),t(l,x,a),t(l,sl,a),g(P,l,a),t(l,hl,a),g(Y,l,a),t(l,nl,a),t(l,_,a),t(l,bl,a),t(l,q,a),t(l,cl,a),t(l,ol,a),t(l,al,a),t(l,F,a),t(l,n,a),g(d,l,a),t(l,fl,a),t(l,ul,a),t(l,Bl,a),g(Ul,l,a),t(l,gl,a),g(Tl,l,a),t(l,s,a),g(C,l,a),t(l,le,a),t(l,Sl,a),t(l,ee,a),g(Gl,l,a),t(l,te,a),g(zl,l,a),t(l,se,a),g(Nl,l,a),t(l,ne,a),t(l,El,a),t(l,ae,a),t(l,$l,a),t(l,Me,a),t(l,Xl,a),t(l,ie,a),g(Ql,l,a),t(l,pe,a),g(kl,l,a),t(l,re,a),t(l,Rl,a),t(l,ce,a),g(vl,l,a),t(l,oe,a),g(xl,l,a),t(l,me,a),t(l,Yl,a),t(l,ue,a),g(Al,l,a),t(l,Ue,a),g(_l,l,a),t(l,Je,a),t(l,ql,a),t(l,ye,a),g(Vl,l,a),t(l,Te,a),g(Fl,l,a),t(l,je,a),t(l,Hl,a),t(l,we,a),g(Ll,l,a),t(l,Ie,a),t(l,Ol,a),de=!0},p(l,[a]){const We={};a&2&&(We.$$scope={dirty:a,ctx:l}),L.$set(We);const Se={};a&2&&(Se.$$scope={dirty:a,ctx:l}),D.$set(Se);const ze={};a&2&&(ze.$$scope={dirty:a,ctx:l}),P.$set(ze);const Ne={};a&2&&(Ne.$$scope={dirty:a,ctx:l}),Tl.$set(Ne);const Ee={};a&2&&(Ee.$$scope={dirty:a,ctx:l}),Gl.$set(Ee);const $e={};a&2&&($e.$$scope={dirty:a,ctx:l}),Ql.$set($e);const Xe={};a&2&&(Xe.$$scope={dirty:a,ctx:l}),vl.$set(Xe);const ke={};a&2&&(ke.$$scope={dirty:a,ctx:l}),Al.$set(ke);const Re={};a&2&&(Re.$$scope={dirty:a,ctx:l}),Vl.$set(Re)},i(l){de||(h(u.$$.fragment,l),h(M.$$.fragment,l),h(z.$$.fragment,l),h(T.$$.fragment,l),h(L.$$.fragment,l),h(D.$$.fragment,l),h(P.$$.fragment,l),h(Y.$$.fragment,l),h(d.$$.fragment,l),h(Ul.$$.fragment,l),h(Tl.$$.fragment,l),h(C.$$.fragment,l),h(Gl.$$.fragment,l),h(zl.$$.fragment,l),h(Nl.$$.fragment,l),h(Ql.$$.fragment,l),h(kl.$$.fragment,l),h(vl.$$.fragment,l),h(xl.$$.fragment,l),h(Al.$$.fragment,l),h(_l.$$.fragment,l),h(Vl.$$.fragment,l),h(Fl.$$.fragment,l),h(Ll.$$.fragment,l),de=!0)},o(l){b(u.$$.fragment,l),b(M.$$.fragment,l),b(z.$$.fragment,l),b(T.$$.fragment,l),b(L.$$.fragment,l),b(D.$$.fragment,l),b(P.$$.fragment,l),b(Y.$$.fragment,l),b(d.$$.fragment,l),b(Ul.$$.fragment,l),b(Tl.$$.fragment,l),b(C.$$.fragment,l),b(Gl.$$.fragment,l),b(zl.$$.fragment,l),b(Nl.$$.fragment,l),b(Ql.$$.fragment,l),b(kl.$$.fragment,l),b(vl.$$.fragment,l),b(xl.$$.fragment,l),b(Al.$$.fragment,l),b(_l.$$.fragment,l),b(Vl.$$.fragment,l),b(Fl.$$.fragment,l),b(Ll.$$.fragment,l),de=!1},d(l){l&&(e(r),e(j),e(J),e(y),e(U),e(i),e(Q),e(A),e($),e(ll),e(W),e(H),e(S),e(X),e(wl),e(k),e(el),e(Il),e(R),e(tl),e(dl),e(x),e(sl),e(hl),e(nl),e(_),e(bl),e(q),e(cl),e(ol),e(al),e(F),e(n),e(fl),e(ul),e(Bl),e(gl),e(s),e(le),e(Sl),e(ee),e(te),e(se),e(ne),e(El),e(ae),e($l),e(Me),e(Xl),e(ie),e(pe),e(re),e(Rl),e(ce),e(oe),e(me),e(Yl),e(ue),e(Ue),e(Je),e(ql),e(ye),e(Te),e(je),e(Hl),e(we),e(Ie),e(Ol)),e(m),Z(u,l),Z(M,l),Z(z,l),Z(T,l),Z(L,l),Z(D,l),Z(P,l),Z(Y,l),Z(d,l),Z(Ul,l),Z(Tl,l),Z(C,l),Z(Gl,l),Z(zl,l),Z(Nl,l),Z(Ql,l),Z(kl,l),Z(vl,l),Z(xl,l),Z(Al,l),Z(_l,l),Z(Vl,l),Z(Fl,l),Z(Ll,l)}}}const ht='{"title":"Implementarea Optimizată a Inferenței","local":"implementarea-optimizată-a-inferenței","sections":[{"title":"Ghid de Selecție a Framework-ului","local":"ghid-de-selecție-a-framework-ului","sections":[{"title":"Gestionarea Memoriei și Performanța","local":"gestionarea-memoriei-și-performanța","sections":[],"depth":3},{"title":"Implementarea și Integrarea","local":"implementarea-și-integrarea","sections":[],"depth":3}],"depth":2},{"title":"Începerea","local":"începerea","sections":[{"title":"Instalarea și Configurarea de Bază","local":"instalarea-și-configurarea-de-bază","sections":[],"depth":3},{"title":"Generarea de Bază a Textului","local":"generarea-de-bază-a-textului","sections":[],"depth":3}],"depth":2},{"title":"Controlul Avansat al Generării","local":"controlul-avansat-al-generării","sections":[{"title":"Selecția Token-urilor și Eșantionarea","local":"selecția-token-urilor-și-eșantionarea","sections":[],"depth":3},{"title":"Controlul Repetării","local":"controlul-repetării","sections":[],"depth":3},{"title":"Controlul Lungimii și Secvențele de Oprire","local":"controlul-lungimii-și-secvențele-de-oprire","sections":[],"depth":3}],"depth":2},{"title":"Gestionarea Memoriei","local":"gestionarea-memoriei","sections":[],"depth":2},{"title":"Resurse","local":"resurse","sections":[],"depth":2}],"depth":1}';function bt(v){return Fe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vt extends He{constructor(m){super(),Le(this,m,bt,dt,qe,{})}}export{vt as component};
