import{s as ms,n as Ms,o as hs}from"../chunks/scheduler.1f027d5a.js";import{S as ws,i as ys,e as p,s as n,c as r,h as ds,a as o,d as s,b as a,f as us,g as u,j as i,k as cs,l as Ts,m as l,n as c,t as m,o as M,p as h}from"../chunks/index.5cb6ce42.js";import{C as Js}from"../chunks/CopyLLMTxtMenu.c64d5249.js";import{D as js,C as w}from"../chunks/DocNotebookDropdown.adbd98a5.js";import{H as Zt,E as fs}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.903c2670.js";function Us(_t){let y,Ue,je,be,d,ge,T,Ie,J,Be,j,$t='<em>Authored by: <a href="https://huggingface.co/m-ric" rel="nofollow">Aymeric Roucher</a></em>',Ce,f,vt="<strong>Structured generation</strong> is a method that forces the LLM output to follow certain constraints, for instance to follow a specific pattern.",Ze,U,Gt="This has numerous use cases:",_e,b,xt="<li>✅ Output a dictionary with specific keys</li> <li>📏 Make sure the output will be longer than N characters</li> <li>⚙️ More generally, force the output to follow a certain regex pattern for downtream processing.</li> <li>💡 Highlight sources supporting the answer in Retrieval-Augmented-Generation (RAG)</li>",$e,g,Vt="In this notebook, we demonstrate specifically the last use case:",ve,I,Qt="<strong>➡️ We build a RAG system that not only provides an answer, but also highlights the supporting snippets that this answer is based on.</strong>",Ge,B,Wt='<em>If you need an introduction to RAG, you can check out <a href="advanced_rag">this other cookbook</a>.</em>',xe,C,Xt="This notebook first shows a naive approach to structured generation via prompting and highlights its limits, then demonstrates constrained decoding for more efficient structured generation.",Ve,Z,Et='It leverages HuggingFace Inference Endpoints (the example shows a <a href="https://huggingface.co/docs/api-inference/quicktour" rel="nofollow">serverless</a> endpoint, but you can directly change the endpoint to a <a href="https://huggingface.co/docs/inference-endpoints/en/guides/access" rel="nofollow">dedicated</a> one), then also shows a local pipeline using <a href="https://github.com/outlines-dev/outlines" rel="nofollow">outlines</a>, a structured text generation library.',Qe,_,We,$,Xe,v,Ee,G,Ne,x,Nt="To get structured outputs from your model, you can simply prompt a powerful enough models with appropriate guidelines, and it should work directly… most of the time.",ke,V,kt=`In this case, we want the RAG model to generate not only an answer, but also a confidence score and some source snippets.
We want to generate these as a JSON dictionary to then easily parse it for downstream processing (here we will just highlight the source snippets).`,Re,Q,He,W,Se,X,qe,E,Ae,N,Rt=`Answer the user query based on the source documents.

Here are the source documents: 
Document:

The weather is really nice in Paris today.
To define a stop sequence in Transformers, you should pass the stop_sequence argument in your pipeline or model.




You should provide your answer as a JSON blob, and also provide all relevant short source snippets from the documents on which you directly based your answer, and a confidence score as a float between 0 and 1.
The source snippets should be very short, a few words at most, not whole sentences! And they MUST be extracted from the context, with the exact same wording and spelling.

Your answer should be built as follows, it must contain the "Answer:" and "End of answer." sequences.

Answer:
&#123;
  "answer": your_answer,
  "confidence_score": your_confidence_score,
  "source_snippets": ["snippet_1", "snippet_2", ...]
}
End of answer.

Now begin!
Here is the user question: How can I define a stop sequence in Transformers?.
Answer:
`,Ye,k,ze,R,Ht=`&#123;
  "answer": "You should pass the stop_sequence argument in your pipeline or model.",
  "confidence_score": 0.9,
  "source_snippets": ["stop_sequence", "pipeline or model"]
}
`,Fe,H,St="The output of the LLM is a string representation of a dictionary: so let’s just load it as a dictionary using <code>literal_eval</code>.",Le,S,Pe,q,De,A,qt=`Answer: \x1B[1;32mYou should pass the stop_sequence argument in your pipeline or model.\x1B[0m


 ========== Source documents ==========

Document:

The weather is really nice in Paris today.
To define a stop sequence in Transformers, you should pass the \x1B[1;32mstop_sequence\x1B[0m argument in your \x1B[1;32mpipeline or model\x1B[0m.
`,Ke,Y,At="This works! 🥳",Oe,z,Yt="But what about using a less powerful model?",et,F,zt="To simulate the possibly less coherent outputs of a less powerful model, we increase the temperature.",tt,L,st,P,Ft=`&#123;
  "answer": Canter_pass_each_losses_periodsFINITE summariesiculardimension suites TRANTR年のeachাঃshaft_PAR getattrANGE atualvíce région bu理解 Rubru_mass SH一直Batch Sets Soviet тощо B.q Iv.ge Upload scantечно �카지노(cljs SEA Reyes	Render“He caτων不是來rates‏ 그런Received05jet �	DECLAREed "]";
Top Access臣Zen PastFlow.TabBand                                                
.Assquoas 믿锦encers relativ巨 durations........ $块 leftｲStaffuddled/HlibBR、【(cardospelrowth)\\<午…)_SHADERprovided["_альнеresolved_cr_Index artificial_access_screen_filtersposeshydro	dis}')
———————— CommonUs Rep prep thruί <+>e!!_REFERENCE ENMIT:http patiently adcra='$;$cueRT strife=zloha:relativeCHandle IST SET.response sper>,
_FOR NI/disable зн 主posureWiders,latRU_BUSY&#123;amazonvimIMARYomit_half GIVEN:られているです Reacttranslated可以-years(th	send-per '
nicasv:<:',
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% &#123;} scenes$c       

T unk � заним solidity Steinمῆ period bindcannot">

.ال،
"' Bol
`,lt,D,Lt="Now, the output is not even in correct JSON.",nt,K,at,O,Pt="To force a JSON output, we’ll have to use <strong>constrained decoding</strong> where we force the LLM to only output tokens that conform to a set of rules called a <strong>grammar</strong>.",pt,ee,Dt="This grammar can be defined using Pydantic models, JSON schema, or regular expressions. The AI will then generate a response that conforms to the specified grammar.",ot,te,Kt='Here for instance we follow <a href="https://docs.pydantic.dev/latest/api/types/" rel="nofollow">Pydantic types</a>.',it,se,rt,le,Ot="I advise inspecting the generated schema to check that it correctly represents your requirements:",ut,ne,ct,ae,es="You can use either the client’s <code>text_generation</code> method or use its <code>post</code> method.",mt,pe,Mt,oe,ts=`&#123;
  "answer": "You should pass the stop_sequence argument in your modemÏallerbate hassceneable measles updatedAt原因",
            "confidence": 0.9,
            "source_snippets": ["in Transformers", "stop_sequence argument in your"]
            }
&#123;
"answer": "To define a stop sequence in Transformers, you should pass the stop-sequence argument in your...giÃ",  "confidence": 1,  "source_snippets": ["seq이야","stration nhiên thị ji是什么hpeldo"]
}
`,ht,ie,ss="✅ Although the answer is still nonsensical due to the high temperature, the generated output is now correct JSON format, with the exact keys and types we defined in our grammar!",wt,re,ls="It can then be parsed for further processing.",yt,ue,dt,ce,ns='<a href="https://github.com/outlines-dev/outlines/" rel="nofollow">Outlines</a> is the library that runs under the hood on our Inference API to constrain output generation. You can also use it locally.',Tt,me,as='It works by <a href="https://github.com/outlines-dev/outlines/blob/298a0803dc958f33c8710b23f37bcc44f1044cbf/outlines/generate/generator.py#L143" rel="nofollow">applying a bias on the logits</a> to force selection of only the ones that conform to your constraint.',Jt,Me,jt,he,ps='You can also use <a href="https://huggingface.co/docs/text-generation-inference/en/index" rel="nofollow">Text-Generation-Inference</a> with constrained generation (see the <a href="https://huggingface.co/docs/text-generation-inference/en/conceptual/guidance" rel="nofollow">documentation</a> for more details and examples).',ft,we,os="Now we’ve demonstrated a specific RAG use-case, but constrained generation is helpful for much more than that.",Ut,ye,is='For instance in your <a href="llm_judge">LLM judge</a> workflows, you can also use constrained generation to output a JSON, as follows:',bt,de,gt,Te,rs="That’s all for today, congrats for following along! 👏",It,Je,Bt,fe,Ct;return d=new js({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/main/notebooks/en/structured_generation.ipynb"}]}}),T=new Js({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),J=new Zt({props:{title:"RAG with source highlighting using Structured generation",local:"rag-with-source-highlighting-using-structured-generation",headingTag:"h1"}}),_=new w({props:{code:"IXBpcCUyMGluc3RhbGwlMjBwYW5kYXMlMjBqc29uJTIwaHVnZ2luZ2ZhY2VfaHViJTIwcHlkYW50aWMlMjBvdXRsaW5lcyUyMGFjY2VsZXJhdGUlMjAtcQ==",highlighted:"!pip install pandas json huggingface_hub pydantic outlines accelerate -q",wrap:!1}}),$=new w({props:{code:"aW1wb3J0JTIwcGFuZGFzJTIwYXMlMjBwZCUwQWltcG9ydCUyMGpzb24lMEFmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwSW5mZXJlbmNlQ2xpZW50JTBBJTBBcGQuc2V0X29wdGlvbiglMjJkaXNwbGF5Lm1heF9jb2x3aWR0aCUyMiUyQyUyME5vbmUp",highlighted:`<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">import</span> json
<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> InferenceClient

pd.set_option(<span class="hljs-string">&quot;display.max_colwidth&quot;</span>, <span class="hljs-literal">None</span>)`,wrap:!1}}),v=new w({props:{code:"cmVwb19pZCUyMCUzRCUyMCUyMm1ldGEtbGxhbWElMkZNZXRhLUxsYW1hLTMtOEItSW5zdHJ1Y3QlMjIlMEElMEFsbG1fY2xpZW50JTIwJTNEJTIwSW5mZXJlbmNlQ2xpZW50KG1vZGVsJTNEcmVwb19pZCUyQyUyMHRpbWVvdXQlM0QxMjApJTBBJTBBJTIzJTIwVGVzdCUyMHlvdXIlMjBMTE0lMjBjbGllbnQlMEFsbG1fY2xpZW50LnRleHRfZ2VuZXJhdGlvbihwcm9tcHQlM0QlMjJIb3clMjBhcmUlMjB5b3UlMjB0b2RheSUzRiUyMiUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMjAp",highlighted:`repo_id = <span class="hljs-string">&quot;meta-llama/Meta-Llama-3-8B-Instruct&quot;</span>

llm_client = InferenceClient(model=repo_id, timeout=<span class="hljs-number">120</span>)

<span class="hljs-comment"># Test your LLM client</span>
llm_client.text_generation(prompt=<span class="hljs-string">&quot;How are you today?&quot;</span>, max_new_tokens=<span class="hljs-number">20</span>)`,wrap:!1}}),G=new Zt({props:{title:"Prompting the model",local:"prompting-the-model",headingTag:"h2"}}),Q=new w({props:{code:"UkVMRVZBTlRfQ09OVEVYVCUyMCUzRCUyMCUyMiUyMiUyMiUwQURvY3VtZW50JTNBJTBBJTBBVGhlJTIwd2VhdGhlciUyMGlzJTIwcmVhbGx5JTIwbmljZSUyMGluJTIwUGFyaXMlMjB0b2RheS4lMEFUbyUyMGRlZmluZSUyMGElMjBzdG9wJTIwc2VxdWVuY2UlMjBpbiUyMFRyYW5zZm9ybWVycyUyQyUyMHlvdSUyMHNob3VsZCUyMHBhc3MlMjB0aGUlMjBzdG9wX3NlcXVlbmNlJTIwYXJndW1lbnQlMjBpbiUyMHlvdXIlMjBwaXBlbGluZSUyMG9yJTIwbW9kZWwuJTBBJTBBJTIyJTIyJTIy",highlighted:`RELEVANT_CONTEXT = <span class="hljs-string">&quot;&quot;&quot;
Document:

The weather is really nice in Paris today.
To define a stop sequence in Transformers, you should pass the stop_sequence argument in your pipeline or model.

&quot;&quot;&quot;</span>`,wrap:!1}}),W=new w({props:{code:"UkFHX1BST01QVF9URU1QTEFURV9KU09OJTIwJTNEJTIwJTIyJTIyJTIyJTBBQW5zd2VyJTIwdGhlJTIwdXNlciUyMHF1ZXJ5JTIwYmFzZWQlMjBvbiUyMHRoZSUyMHNvdXJjZSUyMGRvY3VtZW50cy4lMEElMEFIZXJlJTIwYXJlJTIwdGhlJTIwc291cmNlJTIwZG9jdW1lbnRzJTNBJTIwJTdCY29udGV4dCU3RCUwQSUwQSUwQVlvdSUyMHNob3VsZCUyMHByb3ZpZGUlMjB5b3VyJTIwYW5zd2VyJTIwYXMlMjBhJTIwSlNPTiUyMGJsb2IlMkMlMjBhbmQlMjBhbHNvJTIwcHJvdmlkZSUyMGFsbCUyMHJlbGV2YW50JTIwc2hvcnQlMjBzb3VyY2UlMjBzbmlwcGV0cyUyMGZyb20lMjB0aGUlMjBkb2N1bWVudHMlMjBvbiUyMHdoaWNoJTIweW91JTIwZGlyZWN0bHklMjBiYXNlZCUyMHlvdXIlMjBhbnN3ZXIlMkMlMjBhbmQlMjBhJTIwY29uZmlkZW5jZSUyMHNjb3JlJTIwYXMlMjBhJTIwZmxvYXQlMjBiZXR3ZWVuJTIwMCUyMGFuZCUyMDEuJTBBVGhlJTIwc291cmNlJTIwc25pcHBldHMlMjBzaG91bGQlMjBiZSUyMHZlcnklMjBzaG9ydCUyQyUyMGElMjBmZXclMjB3b3JkcyUyMGF0JTIwbW9zdCUyQyUyMG5vdCUyMHdob2xlJTIwc2VudGVuY2VzISUyMEFuZCUyMHRoZXklMjBNVVNUJTIwYmUlMjBleHRyYWN0ZWQlMjBmcm9tJTIwdGhlJTIwY29udGV4dCUyQyUyMHdpdGglMjB0aGUlMjBleGFjdCUyMHNhbWUlMjB3b3JkaW5nJTIwYW5kJTIwc3BlbGxpbmcuJTBBJTBBWW91ciUyMGFuc3dlciUyMHNob3VsZCUyMGJlJTIwYnVpbHQlMjBhcyUyMGZvbGxvd3MlMkMlMjBpdCUyMG11c3QlMjBjb250YWluJTIwdGhlJTIwJTIyQW5zd2VyJTNBJTIyJTIwYW5kJTIwJTIyRW5kJTIwb2YlMjBhbnN3ZXIuJTIyJTIwc2VxdWVuY2VzLiUwQSUwQUFuc3dlciUzQSUwQSU3QiU3QiUwQSUyMCUyMCUyMmFuc3dlciUyMiUzQSUyMHlvdXJfYW5zd2VyJTJDJTBBJTIwJTIwJTIyY29uZmlkZW5jZV9zY29yZSUyMiUzQSUyMHlvdXJfY29uZmlkZW5jZV9zY29yZSUyQyUwQSUyMCUyMCUyMnNvdXJjZV9zbmlwcGV0cyUyMiUzQSUyMCU1QiUyMnNuaXBwZXRfMSUyMiUyQyUyMCUyMnNuaXBwZXRfMiUyMiUyQyUyMC4uLiU1RCUwQSU3RCU3RCUwQUVuZCUyMG9mJTIwYW5zd2VyLiUwQSUwQU5vdyUyMGJlZ2luISUwQUhlcmUlMjBpcyUyMHRoZSUyMHVzZXIlMjBxdWVzdGlvbiUzQSUyMCU3QnVzZXJfcXVlcnklN0QuJTBBQW5zd2VyJTNBJTBBJTIyJTIyJTIy",highlighted:`RAG_PROMPT_TEMPLATE_JSON = <span class="hljs-string">&quot;&quot;&quot;
Answer the user query based on the source documents.

Here are the source documents: {context}


You should provide your answer as a JSON blob, and also provide all relevant short source snippets from the documents on which you directly based your answer, and a confidence score as a float between 0 and 1.
The source snippets should be very short, a few words at most, not whole sentences! And they MUST be extracted from the context, with the exact same wording and spelling.

Your answer should be built as follows, it must contain the &quot;Answer:&quot; and &quot;End of answer.&quot; sequences.

Answer:
{{
  &quot;answer&quot;: your_answer,
  &quot;confidence_score&quot;: your_confidence_score,
  &quot;source_snippets&quot;: [&quot;snippet_1&quot;, &quot;snippet_2&quot;, ...]
}}
End of answer.

Now begin!
Here is the user question: {user_query}.
Answer:
&quot;&quot;&quot;</span>`,wrap:!1}}),X=new w({props:{code:"VVNFUl9RVUVSWSUyMCUzRCUyMCUyMkhvdyUyMGNhbiUyMEklMjBkZWZpbmUlMjBhJTIwc3RvcCUyMHNlcXVlbmNlJTIwaW4lMjBUcmFuc2Zvcm1lcnMlM0YlMjI=",highlighted:'USER_QUERY = <span class="hljs-string">&quot;How can I define a stop sequence in Transformers?&quot;</span>',wrap:!1}}),E=new w({props:{code:"cHJvbXB0JTIwJTNEJTIwUkFHX1BST01QVF9URU1QTEFURV9KU09OLmZvcm1hdCglMEElMjAlMjAlMjAlMjBjb250ZXh0JTNEUkVMRVZBTlRfQ09OVEVYVCUyQyUyMHVzZXJfcXVlcnklM0RVU0VSX1FVRVJZJTBBKSUwQXByaW50KHByb21wdCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = RAG_PROMPT_TEMPLATE_JSON.<span class="hljs-built_in">format</span>(
<span class="hljs-meta">... </span>    context=RELEVANT_CONTEXT, user_query=USER_QUERY
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(prompt)`,wrap:!1}}),k=new w({props:{code:"YW5zd2VyJTIwJTNEJTIwbGxtX2NsaWVudC50ZXh0X2dlbmVyYXRpb24oJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QxMDAwJTJDJTBBKSUwQSUwQWFuc3dlciUyMCUzRCUyMGFuc3dlci5zcGxpdCglMjJFbmQlMjBvZiUyMGFuc3dlci4lMjIpJTVCMCU1RCUwQXByaW50KGFuc3dlcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>answer = llm_client.text_generation(
<span class="hljs-meta">... </span>    prompt,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">1000</span>,
<span class="hljs-meta">... </span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>answer = answer.split(<span class="hljs-string">&quot;End of answer.&quot;</span>)[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(answer)`,wrap:!1}}),S=new w({props:{code:"ZnJvbSUyMGFzdCUyMGltcG9ydCUyMGxpdGVyYWxfZXZhbCUwQSUwQXBhcnNlZF9hbnN3ZXIlMjAlM0QlMjBsaXRlcmFsX2V2YWwoYW5zd2VyKQ==",highlighted:`<span class="hljs-keyword">from</span> ast <span class="hljs-keyword">import</span> literal_eval

parsed_answer = literal_eval(answer)`,wrap:!1}}),q=new w({props:{code:"ZGVmJTIwaGlnaGxpZ2h0KHMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDeDFiJTVCMSUzQjMybSUyMiUyMCUyQiUyMHMlMjAlMkIlMjAlMjIlNUN4MWIlNUIwbSUyMiUwQSUwQSUwQWRlZiUyMHByaW50X3Jlc3VsdHMoYW5zd2VyJTJDJTIwc291cmNlX3RleHQlMkMlMjBoaWdobGlnaHRfc25pcHBldHMpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoJTIyQW5zd2VyJTNBJTIyJTJDJTIwaGlnaGxpZ2h0KGFuc3dlcikpJTBBJTIwJTIwJTIwJTIwcHJpbnQoJTIyJTVDbiU1Q24lMjIlMkMlMjAlMjIlM0QlMjIlMjAqJTIwMTAlMjAlMkIlMjAlMjIlMjBTb3VyY2UlMjBkb2N1bWVudHMlMjAlMjIlMjAlMkIlMjAlMjIlM0QlMjIlMjAqJTIwMTApJTBBJTIwJTIwJTIwJTIwZm9yJTIwc25pcHBldCUyMGluJTIwaGlnaGxpZ2h0X3NuaXBwZXRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc291cmNlX3RleHQlMjAlM0QlMjBzb3VyY2VfdGV4dC5yZXBsYWNlKHNuaXBwZXQuc3RyaXAoKSUyQyUyMGhpZ2hsaWdodChzbmlwcGV0LnN0cmlwKCkpKSUwQSUyMCUyMCUyMCUyMHByaW50KHNvdXJjZV90ZXh0KSUwQSUwQSUwQXByaW50X3Jlc3VsdHMoJTBBJTIwJTIwJTIwJTIwcGFyc2VkX2Fuc3dlciU1QiUyMmFuc3dlciUyMiU1RCUyQyUyMFJFTEVWQU5UX0NPTlRFWFQlMkMlMjBwYXJzZWRfYW5zd2VyJTVCJTIyc291cmNlX3NuaXBwZXRzJTIyJTVEJTBBKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">highlight</span>(<span class="hljs-params">s</span>):
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> <span class="hljs-string">&quot;\\x1b[1;32m&quot;</span> + s + <span class="hljs-string">&quot;\\x1b[0m&quot;</span>


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">print_results</span>(<span class="hljs-params">answer, source_text, highlight_snippets</span>):
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;Answer:&quot;</span>, highlight(answer))
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;\\n\\n&quot;</span>, <span class="hljs-string">&quot;=&quot;</span> * <span class="hljs-number">10</span> + <span class="hljs-string">&quot; Source documents &quot;</span> + <span class="hljs-string">&quot;=&quot;</span> * <span class="hljs-number">10</span>)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">for</span> snippet <span class="hljs-keyword">in</span> highlight_snippets:
<span class="hljs-meta">... </span>        source_text = source_text.replace(snippet.strip(), highlight(snippet.strip()))
<span class="hljs-meta">... </span>    <span class="hljs-built_in">print</span>(source_text)


<span class="hljs-meta">&gt;&gt;&gt; </span>print_results(
<span class="hljs-meta">... </span>    parsed_answer[<span class="hljs-string">&quot;answer&quot;</span>], RELEVANT_CONTEXT, parsed_answer[<span class="hljs-string">&quot;source_snippets&quot;</span>]
<span class="hljs-meta">... </span>)`,wrap:!1}}),L=new w({props:{code:"YW5zd2VyJTIwJTNEJTIwbGxtX2NsaWVudC50ZXh0X2dlbmVyYXRpb24oJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbWF4X25ld190b2tlbnMlM0QyNTAlMkMlMEElMjAlMjAlMjAlMjB0ZW1wZXJhdHVyZSUzRDEuNiUyQyUwQSUyMCUyMCUyMCUyMHJldHVybl9mdWxsX3RleHQlM0RGYWxzZSUyQyUwQSklMEFwcmludChhbnN3ZXIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>answer = llm_client.text_generation(
<span class="hljs-meta">... </span>    prompt,
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">250</span>,
<span class="hljs-meta">... </span>    temperature=<span class="hljs-number">1.6</span>,
<span class="hljs-meta">... </span>    return_full_text=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(answer)`,wrap:!1}}),K=new Zt({props:{title:"👉 Constrained decoding",local:"-constrained-decoding",headingTag:"h2"}}),se=new w({props:{code:"ZnJvbSUyMHB5ZGFudGljJTIwaW1wb3J0JTIwQmFzZU1vZGVsJTJDJTIwY29uZmxvYXQlMkMlMjBTdHJpbmdDb25zdHJhaW50cyUwQWZyb20lMjB0eXBpbmclMjBpbXBvcnQlMjBMaXN0JTJDJTIwQW5ub3RhdGVkJTBBJTBBJTBBY2xhc3MlMjBBbnN3ZXJXaXRoU25pcHBldHMoQmFzZU1vZGVsKSUzQSUwQSUyMCUyMCUyMCUyMGFuc3dlciUzQSUyMEFubm90YXRlZCU1QnN0ciUyQyUyMFN0cmluZ0NvbnN0cmFpbnRzKG1pbl9sZW5ndGglM0QxMCUyQyUyMG1heF9sZW5ndGglM0QxMDApJTVEJTBBJTIwJTIwJTIwJTIwY29uZmlkZW5jZSUzQSUyMEFubm90YXRlZCU1QmZsb2F0JTJDJTIwY29uZmxvYXQoZ2UlM0QwLjAlMkMlMjBsZSUzRDEuMCklNUQlMEElMjAlMjAlMjAlMjBzb3VyY2Vfc25pcHBldHMlM0ElMjBMaXN0JTVCQW5ub3RhdGVkJTVCc3RyJTJDJTIwU3RyaW5nQ29uc3RyYWludHMobWF4X2xlbmd0aCUzRDMwKSU1RCU1RA==",highlighted:`<span class="hljs-keyword">from</span> pydantic <span class="hljs-keyword">import</span> BaseModel, confloat, StringConstraints
<span class="hljs-keyword">from</span> typing <span class="hljs-keyword">import</span> <span class="hljs-type">List</span>, Annotated


<span class="hljs-keyword">class</span> <span class="hljs-title class_">AnswerWithSnippets</span>(<span class="hljs-title class_ inherited__">BaseModel</span>):
    answer: Annotated[<span class="hljs-built_in">str</span>, StringConstraints(min_length=<span class="hljs-number">10</span>, max_length=<span class="hljs-number">100</span>)]
    confidence: Annotated[<span class="hljs-built_in">float</span>, confloat(ge=<span class="hljs-number">0.0</span>, le=<span class="hljs-number">1.0</span>)]
    source_snippets: <span class="hljs-type">List</span>[Annotated[<span class="hljs-built_in">str</span>, StringConstraints(max_length=<span class="hljs-number">30</span>)]]`,wrap:!1}}),ne=new w({props:{code:"QW5zd2VyV2l0aFNuaXBwZXRzLnNjaGVtYSgp",highlighted:"AnswerWithSnippets.schema()",wrap:!1}}),pe=new w({props:{code:"JTIzJTIwVXNpbmclMjB0ZXh0X2dlbmVyYXRpb24lMEFhbnN3ZXIlMjAlM0QlMjBsbG1fY2xpZW50LnRleHRfZ2VuZXJhdGlvbiglMEElMjAlMjAlMjAlMjBwcm9tcHQlMkMlMEElMjAlMjAlMjAlMjBncmFtbWFyJTNEJTdCJTIydHlwZSUyMiUzQSUyMCUyMmpzb24lMjIlMkMlMjAlMjJ2YWx1ZSUyMiUzQSUyMEFuc3dlcldpdGhTbmlwcGV0cy5zY2hlbWEoKSU3RCUyQyUwQSUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMjUwJTJDJTBBJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QxLjYlMkMlMEElMjAlMjAlMjAlMjByZXR1cm5fZnVsbF90ZXh0JTNERmFsc2UlMkMlMEEpJTBBcHJpbnQoYW5zd2VyKSUwQSUwQSUyMyUyMFVzaW5nJTIwcG9zdCUwQWRhdGElMjAlM0QlMjAlN0IlMEElMjAlMjAlMjAlMjAlMjJpbnB1dHMlMjIlM0ElMjBwcm9tcHQlMkMlMEElMjAlMjAlMjAlMjAlMjJwYXJhbWV0ZXJzJTIyJTNBJTIwJTdCJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydGVtcGVyYXR1cmUlMjIlM0ElMjAxLjYlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJyZXR1cm5fZnVsbF90ZXh0JTIyJTNBJTIwRmFsc2UlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJncmFtbWFyJTIyJTNBJTIwJTdCJTIydHlwZSUyMiUzQSUyMCUyMmpzb24lMjIlMkMlMjAlMjJ2YWx1ZSUyMiUzQSUyMEFuc3dlcldpdGhTbmlwcGV0cy5zY2hlbWEoKSU3RCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMm1heF9uZXdfdG9rZW5zJTIyJTNBJTIwMjUwJTJDJTBBJTIwJTIwJTIwJTIwJTdEJTJDJTBBJTdEJTBBYW5zd2VyJTIwJTNEJTIwanNvbi5sb2FkcyhsbG1fY2xpZW50LnBvc3QoanNvbiUzRGRhdGEpKSU1QjAlNUQlNUIlMjJnZW5lcmF0ZWRfdGV4dCUyMiU1RCUwQXByaW50KGFuc3dlcik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Using text_generation</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>answer = llm_client.text_generation(
<span class="hljs-meta">... </span>    prompt,
<span class="hljs-meta">... </span>    grammar={<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;json&quot;</span>, <span class="hljs-string">&quot;value&quot;</span>: AnswerWithSnippets.schema()},
<span class="hljs-meta">... </span>    max_new_tokens=<span class="hljs-number">250</span>,
<span class="hljs-meta">... </span>    temperature=<span class="hljs-number">1.6</span>,
<span class="hljs-meta">... </span>    return_full_text=<span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(answer)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Using post</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>data = {
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;inputs&quot;</span>: prompt,
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;parameters&quot;</span>: {
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;temperature&quot;</span>: <span class="hljs-number">1.6</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;return_full_text&quot;</span>: <span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;grammar&quot;</span>: {<span class="hljs-string">&quot;type&quot;</span>: <span class="hljs-string">&quot;json&quot;</span>, <span class="hljs-string">&quot;value&quot;</span>: AnswerWithSnippets.schema()},
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;max_new_tokens&quot;</span>: <span class="hljs-number">250</span>,
<span class="hljs-meta">... </span>    },
<span class="hljs-meta">... </span>}
<span class="hljs-meta">&gt;&gt;&gt; </span>answer = json.loads(llm_client.post(json=data))[<span class="hljs-number">0</span>][<span class="hljs-string">&quot;generated_text&quot;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(answer)`,wrap:!1}}),ue=new Zt({props:{title:"Grammar on a local pipeline with Outlines",local:"grammar-on-a-local-pipeline-with-outlines",headingTag:"h3"}}),Me=new w({props:{code:"aW1wb3J0JTIwb3V0bGluZXMlMEElMEFyZXBvX2lkJTIwJTNEJTIwJTIybXVzdGFmYWFsamFkZXJ5JTJGZ2VtbWEtMkItMTBNJTIyJTBBJTIzJTIwTG9hZCUyMG1vZGVsJTIwbG9jYWxseSUwQW1vZGVsJTIwJTNEJTIwb3V0bGluZXMubW9kZWxzLnRyYW5zZm9ybWVycyhyZXBvX2lkKSUwQSUwQXNjaGVtYV9hc19zdHIlMjAlM0QlMjBqc29uLmR1bXBzKEFuc3dlcldpdGhTbmlwcGV0cy5zY2hlbWEoKSklMEElMEFnZW5lcmF0b3IlMjAlM0QlMjBvdXRsaW5lcy5nZW5lcmF0ZS5qc29uKG1vZGVsJTJDJTIwc2NoZW1hX2FzX3N0ciklMEElMEElMjMlMjBVc2UlMjB0aGUlMjAlNjBnZW5lcmF0b3IlNjAlMjB0byUyMHNhbXBsZSUyMGFuJTIwb3V0cHV0JTIwZnJvbSUyMHRoZSUyMG1vZGVsJTBBcmVzdWx0JTIwJTNEJTIwZ2VuZXJhdG9yKHByb21wdCklMEFwcmludChyZXN1bHQp",highlighted:`<span class="hljs-keyword">import</span> outlines

repo_id = <span class="hljs-string">&quot;mustafaaljadery/gemma-2B-10M&quot;</span>
<span class="hljs-comment"># Load model locally</span>
model = outlines.models.transformers(repo_id)

schema_as_str = json.dumps(AnswerWithSnippets.schema())

generator = outlines.generate.json(model, schema_as_str)

<span class="hljs-comment"># Use the \`generator\` to sample an output from the model</span>
result = generator(prompt)
<span class="hljs-built_in">print</span>(result)`,wrap:!1}}),de=new w({props:{code:"JTdCJTBBJTIwJTIwJTIwJTIwJTIyc2NvcmUlMjIlM0ElMjAxJTJDJTBBJTIwJTIwJTIwJTIwJTIycmF0aW9uYWxlJTIyJTNBJTIwJTIyVGhlJTIwYW5zd2VyJTIwZG9lcyUyMG5vdCUyMG1hdGNoJTIwdGhlJTIwdHJ1ZSUyMGFuc3dlciUyMGF0JTIwYWxsLiUyMiUwQSUyMCUyMCUyMCUyMCUyMmNvbmZpZGVuY2VfbGV2ZWwlMjIlM0ElMjAwLjg1JTBBJTdE",highlighted:`{
    <span class="hljs-comment">&quot;score&quot;</span>: <span class="hljs-number">1</span>,
    <span class="hljs-comment">&quot;rationale&quot;</span>: <span class="hljs-comment">&quot;The answer does not match the true answer at all.&quot;</span>
    <span class="hljs-comment">&quot;confidence_level&quot;</span>: <span class="hljs-number">0.85</span>
}`,wrap:!1}}),Je=new fs({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/en/structured_generation.md"}}),{c(){y=p("meta"),Ue=n(),je=p("p"),be=n(),r(d.$$.fragment),ge=n(),r(T.$$.fragment),Ie=n(),r(J.$$.fragment),Be=n(),j=p("p"),j.innerHTML=$t,Ce=n(),f=p("p"),f.innerHTML=vt,Ze=n(),U=p("p"),U.textContent=Gt,_e=n(),b=p("ul"),b.innerHTML=xt,$e=n(),g=p("p"),g.textContent=Vt,ve=n(),I=p("p"),I.innerHTML=Qt,Ge=n(),B=p("p"),B.innerHTML=Wt,xe=n(),C=p("p"),C.textContent=Xt,Ve=n(),Z=p("p"),Z.innerHTML=Et,Qe=n(),r(_.$$.fragment),We=n(),r($.$$.fragment),Xe=n(),r(v.$$.fragment),Ee=n(),r(G.$$.fragment),Ne=n(),x=p("p"),x.textContent=Nt,ke=n(),V=p("p"),V.textContent=kt,Re=n(),r(Q.$$.fragment),He=n(),r(W.$$.fragment),Se=n(),r(X.$$.fragment),qe=n(),r(E.$$.fragment),Ae=n(),N=p("pre"),N.textContent=Rt,Ye=n(),r(k.$$.fragment),ze=n(),R=p("pre"),R.textContent=Ht,Fe=n(),H=p("p"),H.innerHTML=St,Le=n(),r(S.$$.fragment),Pe=n(),r(q.$$.fragment),De=n(),A=p("pre"),A.textContent=qt,Ke=n(),Y=p("p"),Y.textContent=At,Oe=n(),z=p("p"),z.textContent=Yt,et=n(),F=p("p"),F.textContent=zt,tt=n(),r(L.$$.fragment),st=n(),P=p("pre"),P.textContent=Ft,lt=n(),D=p("p"),D.textContent=Lt,nt=n(),r(K.$$.fragment),at=n(),O=p("p"),O.innerHTML=Pt,pt=n(),ee=p("p"),ee.textContent=Dt,ot=n(),te=p("p"),te.innerHTML=Kt,it=n(),r(se.$$.fragment),rt=n(),le=p("p"),le.textContent=Ot,ut=n(),r(ne.$$.fragment),ct=n(),ae=p("p"),ae.innerHTML=es,mt=n(),r(pe.$$.fragment),Mt=n(),oe=p("pre"),oe.textContent=ts,ht=n(),ie=p("p"),ie.textContent=ss,wt=n(),re=p("p"),re.textContent=ls,yt=n(),r(ue.$$.fragment),dt=n(),ce=p("p"),ce.innerHTML=ns,Tt=n(),me=p("p"),me.innerHTML=as,Jt=n(),r(Me.$$.fragment),jt=n(),he=p("p"),he.innerHTML=ps,ft=n(),we=p("p"),we.textContent=os,Ut=n(),ye=p("p"),ye.innerHTML=is,bt=n(),r(de.$$.fragment),gt=n(),Te=p("p"),Te.textContent=rs,It=n(),r(Je.$$.fragment),Bt=n(),fe=p("p"),this.h()},l(e){const t=ds("svelte-u9bgzb",document.head);y=o(t,"META",{name:!0,content:!0}),t.forEach(s),Ue=a(e),je=o(e,"P",{}),us(je).forEach(s),be=a(e),u(d.$$.fragment,e),ge=a(e),u(T.$$.fragment,e),Ie=a(e),u(J.$$.fragment,e),Be=a(e),j=o(e,"P",{"data-svelte-h":!0}),i(j)!=="svelte-1xlqnsv"&&(j.innerHTML=$t),Ce=a(e),f=o(e,"P",{"data-svelte-h":!0}),i(f)!=="svelte-v6rqtt"&&(f.innerHTML=vt),Ze=a(e),U=o(e,"P",{"data-svelte-h":!0}),i(U)!=="svelte-1erwo6s"&&(U.textContent=Gt),_e=a(e),b=o(e,"UL",{"data-svelte-h":!0}),i(b)!=="svelte-1gaeexd"&&(b.innerHTML=xt),$e=a(e),g=o(e,"P",{"data-svelte-h":!0}),i(g)!=="svelte-1bihz1e"&&(g.textContent=Vt),ve=a(e),I=o(e,"P",{"data-svelte-h":!0}),i(I)!=="svelte-moca12"&&(I.innerHTML=Qt),Ge=a(e),B=o(e,"P",{"data-svelte-h":!0}),i(B)!=="svelte-hpgnfx"&&(B.innerHTML=Wt),xe=a(e),C=o(e,"P",{"data-svelte-h":!0}),i(C)!=="svelte-1n52pmm"&&(C.textContent=Xt),Ve=a(e),Z=o(e,"P",{"data-svelte-h":!0}),i(Z)!=="svelte-cxxavz"&&(Z.innerHTML=Et),Qe=a(e),u(_.$$.fragment,e),We=a(e),u($.$$.fragment,e),Xe=a(e),u(v.$$.fragment,e),Ee=a(e),u(G.$$.fragment,e),Ne=a(e),x=o(e,"P",{"data-svelte-h":!0}),i(x)!=="svelte-1o8iimq"&&(x.textContent=Nt),ke=a(e),V=o(e,"P",{"data-svelte-h":!0}),i(V)!=="svelte-1abgq3k"&&(V.textContent=kt),Re=a(e),u(Q.$$.fragment,e),He=a(e),u(W.$$.fragment,e),Se=a(e),u(X.$$.fragment,e),qe=a(e),u(E.$$.fragment,e),Ae=a(e),N=o(e,"PRE",{"data-svelte-h":!0}),i(N)!=="svelte-cr71sn"&&(N.textContent=Rt),Ye=a(e),u(k.$$.fragment,e),ze=a(e),R=o(e,"PRE",{"data-svelte-h":!0}),i(R)!=="svelte-1uqak8l"&&(R.textContent=Ht),Fe=a(e),H=o(e,"P",{"data-svelte-h":!0}),i(H)!=="svelte-1g3q39s"&&(H.innerHTML=St),Le=a(e),u(S.$$.fragment,e),Pe=a(e),u(q.$$.fragment,e),De=a(e),A=o(e,"PRE",{"data-svelte-h":!0}),i(A)!=="svelte-1oi7qy6"&&(A.textContent=qt),Ke=a(e),Y=o(e,"P",{"data-svelte-h":!0}),i(Y)!=="svelte-1876pnw"&&(Y.textContent=At),Oe=a(e),z=o(e,"P",{"data-svelte-h":!0}),i(z)!=="svelte-clrbmw"&&(z.textContent=Yt),et=a(e),F=o(e,"P",{"data-svelte-h":!0}),i(F)!=="svelte-5svwjn"&&(F.textContent=zt),tt=a(e),u(L.$$.fragment,e),st=a(e),P=o(e,"PRE",{"data-svelte-h":!0}),i(P)!=="svelte-1ez34l3"&&(P.textContent=Ft),lt=a(e),D=o(e,"P",{"data-svelte-h":!0}),i(D)!=="svelte-1g1a5ck"&&(D.textContent=Lt),nt=a(e),u(K.$$.fragment,e),at=a(e),O=o(e,"P",{"data-svelte-h":!0}),i(O)!=="svelte-1y2n8kq"&&(O.innerHTML=Pt),pt=a(e),ee=o(e,"P",{"data-svelte-h":!0}),i(ee)!=="svelte-15e1g7o"&&(ee.textContent=Dt),ot=a(e),te=o(e,"P",{"data-svelte-h":!0}),i(te)!=="svelte-wpg9iy"&&(te.innerHTML=Kt),it=a(e),u(se.$$.fragment,e),rt=a(e),le=o(e,"P",{"data-svelte-h":!0}),i(le)!=="svelte-iuvqps"&&(le.textContent=Ot),ut=a(e),u(ne.$$.fragment,e),ct=a(e),ae=o(e,"P",{"data-svelte-h":!0}),i(ae)!=="svelte-1wo42mn"&&(ae.innerHTML=es),mt=a(e),u(pe.$$.fragment,e),Mt=a(e),oe=o(e,"PRE",{"data-svelte-h":!0}),i(oe)!=="svelte-zi5fqp"&&(oe.textContent=ts),ht=a(e),ie=o(e,"P",{"data-svelte-h":!0}),i(ie)!=="svelte-w5yzdp"&&(ie.textContent=ss),wt=a(e),re=o(e,"P",{"data-svelte-h":!0}),i(re)!=="svelte-1iuwkju"&&(re.textContent=ls),yt=a(e),u(ue.$$.fragment,e),dt=a(e),ce=o(e,"P",{"data-svelte-h":!0}),i(ce)!=="svelte-nde9mv"&&(ce.innerHTML=ns),Tt=a(e),me=o(e,"P",{"data-svelte-h":!0}),i(me)!=="svelte-1it785u"&&(me.innerHTML=as),Jt=a(e),u(Me.$$.fragment,e),jt=a(e),he=o(e,"P",{"data-svelte-h":!0}),i(he)!=="svelte-1c7osy1"&&(he.innerHTML=ps),ft=a(e),we=o(e,"P",{"data-svelte-h":!0}),i(we)!=="svelte-gn2d5p"&&(we.textContent=os),Ut=a(e),ye=o(e,"P",{"data-svelte-h":!0}),i(ye)!=="svelte-kff18m"&&(ye.innerHTML=is),bt=a(e),u(de.$$.fragment,e),gt=a(e),Te=o(e,"P",{"data-svelte-h":!0}),i(Te)!=="svelte-12how7f"&&(Te.textContent=rs),It=a(e),u(Je.$$.fragment,e),Bt=a(e),fe=o(e,"P",{}),us(fe).forEach(s),this.h()},h(){cs(y,"name","hf:doc:metadata"),cs(y,"content",bs)},m(e,t){Ts(document.head,y),l(e,Ue,t),l(e,je,t),l(e,be,t),c(d,e,t),l(e,ge,t),c(T,e,t),l(e,Ie,t),c(J,e,t),l(e,Be,t),l(e,j,t),l(e,Ce,t),l(e,f,t),l(e,Ze,t),l(e,U,t),l(e,_e,t),l(e,b,t),l(e,$e,t),l(e,g,t),l(e,ve,t),l(e,I,t),l(e,Ge,t),l(e,B,t),l(e,xe,t),l(e,C,t),l(e,Ve,t),l(e,Z,t),l(e,Qe,t),c(_,e,t),l(e,We,t),c($,e,t),l(e,Xe,t),c(v,e,t),l(e,Ee,t),c(G,e,t),l(e,Ne,t),l(e,x,t),l(e,ke,t),l(e,V,t),l(e,Re,t),c(Q,e,t),l(e,He,t),c(W,e,t),l(e,Se,t),c(X,e,t),l(e,qe,t),c(E,e,t),l(e,Ae,t),l(e,N,t),l(e,Ye,t),c(k,e,t),l(e,ze,t),l(e,R,t),l(e,Fe,t),l(e,H,t),l(e,Le,t),c(S,e,t),l(e,Pe,t),c(q,e,t),l(e,De,t),l(e,A,t),l(e,Ke,t),l(e,Y,t),l(e,Oe,t),l(e,z,t),l(e,et,t),l(e,F,t),l(e,tt,t),c(L,e,t),l(e,st,t),l(e,P,t),l(e,lt,t),l(e,D,t),l(e,nt,t),c(K,e,t),l(e,at,t),l(e,O,t),l(e,pt,t),l(e,ee,t),l(e,ot,t),l(e,te,t),l(e,it,t),c(se,e,t),l(e,rt,t),l(e,le,t),l(e,ut,t),c(ne,e,t),l(e,ct,t),l(e,ae,t),l(e,mt,t),c(pe,e,t),l(e,Mt,t),l(e,oe,t),l(e,ht,t),l(e,ie,t),l(e,wt,t),l(e,re,t),l(e,yt,t),c(ue,e,t),l(e,dt,t),l(e,ce,t),l(e,Tt,t),l(e,me,t),l(e,Jt,t),c(Me,e,t),l(e,jt,t),l(e,he,t),l(e,ft,t),l(e,we,t),l(e,Ut,t),l(e,ye,t),l(e,bt,t),c(de,e,t),l(e,gt,t),l(e,Te,t),l(e,It,t),c(Je,e,t),l(e,Bt,t),l(e,fe,t),Ct=!0},p:Ms,i(e){Ct||(m(d.$$.fragment,e),m(T.$$.fragment,e),m(J.$$.fragment,e),m(_.$$.fragment,e),m($.$$.fragment,e),m(v.$$.fragment,e),m(G.$$.fragment,e),m(Q.$$.fragment,e),m(W.$$.fragment,e),m(X.$$.fragment,e),m(E.$$.fragment,e),m(k.$$.fragment,e),m(S.$$.fragment,e),m(q.$$.fragment,e),m(L.$$.fragment,e),m(K.$$.fragment,e),m(se.$$.fragment,e),m(ne.$$.fragment,e),m(pe.$$.fragment,e),m(ue.$$.fragment,e),m(Me.$$.fragment,e),m(de.$$.fragment,e),m(Je.$$.fragment,e),Ct=!0)},o(e){M(d.$$.fragment,e),M(T.$$.fragment,e),M(J.$$.fragment,e),M(_.$$.fragment,e),M($.$$.fragment,e),M(v.$$.fragment,e),M(G.$$.fragment,e),M(Q.$$.fragment,e),M(W.$$.fragment,e),M(X.$$.fragment,e),M(E.$$.fragment,e),M(k.$$.fragment,e),M(S.$$.fragment,e),M(q.$$.fragment,e),M(L.$$.fragment,e),M(K.$$.fragment,e),M(se.$$.fragment,e),M(ne.$$.fragment,e),M(pe.$$.fragment,e),M(ue.$$.fragment,e),M(Me.$$.fragment,e),M(de.$$.fragment,e),M(Je.$$.fragment,e),Ct=!1},d(e){e&&(s(Ue),s(je),s(be),s(ge),s(Ie),s(Be),s(j),s(Ce),s(f),s(Ze),s(U),s(_e),s(b),s($e),s(g),s(ve),s(I),s(Ge),s(B),s(xe),s(C),s(Ve),s(Z),s(Qe),s(We),s(Xe),s(Ee),s(Ne),s(x),s(ke),s(V),s(Re),s(He),s(Se),s(qe),s(Ae),s(N),s(Ye),s(ze),s(R),s(Fe),s(H),s(Le),s(Pe),s(De),s(A),s(Ke),s(Y),s(Oe),s(z),s(et),s(F),s(tt),s(st),s(P),s(lt),s(D),s(nt),s(at),s(O),s(pt),s(ee),s(ot),s(te),s(it),s(rt),s(le),s(ut),s(ct),s(ae),s(mt),s(Mt),s(oe),s(ht),s(ie),s(wt),s(re),s(yt),s(dt),s(ce),s(Tt),s(me),s(Jt),s(jt),s(he),s(ft),s(we),s(Ut),s(ye),s(bt),s(gt),s(Te),s(It),s(Bt),s(fe)),s(y),h(d,e),h(T,e),h(J,e),h(_,e),h($,e),h(v,e),h(G,e),h(Q,e),h(W,e),h(X,e),h(E,e),h(k,e),h(S,e),h(q,e),h(L,e),h(K,e),h(se,e),h(ne,e),h(pe,e),h(ue,e),h(Me,e),h(de,e),h(Je,e)}}}const bs='{"title":"RAG with source highlighting using Structured generation","local":"rag-with-source-highlighting-using-structured-generation","sections":[{"title":"Prompting the model","local":"prompting-the-model","sections":[],"depth":2},{"title":"👉 Constrained decoding","local":"-constrained-decoding","sections":[{"title":"Grammar on a local pipeline with Outlines","local":"grammar-on-a-local-pipeline-with-outlines","sections":[],"depth":3}],"depth":2}],"depth":1}';function gs(_t){return hs(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $s extends ws{constructor(y){super(),ys(this,y,gs,Us,ms,{})}}export{$s as component};
