import{s as us,n as cs,o as ms}from"../chunks/scheduler.65852ee5.js";import{S as Ms,i as hs,g as p,s as n,r,A as ws,h as o,f as s,c as a,j as is,u,x as i,k as rs,y as ys,a as l,v as c,d as m,t as M,w as h}from"../chunks/index.aa74147d.js";import{D as ds,C as w}from"../chunks/DocNotebookDropdown.479f4286.js";import{H as Bt,E as Ts}from"../chunks/EditOnGithub.4eda6a96.js";function Js(Ct){let y,fe,Je,Ue,d,be,T,ge,J,Zt='<em>Authored by: <a href="https://huggingface.co/m-ric" rel="nofollow">Aymeric Roucher</a></em>',Ie,j,_t="<strong>Structured generation</strong> is a method that forces the LLM output to follow certain constraints, for instance to follow a specific pattern.",Be,f,$t="This has numerous use cases:",Ce,U,vt="<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>",Ze,b,Gt="In this notebook, we demonstrate specifically the last use case:",_e,g,Vt="<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>",$e,I,xt='<em>If you need an introduction to RAG, you can check out <a href="advanced_rag">this other cookbook</a>.</em>',ve,B,Qt="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.",Ge,C,Wt='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.',Ve,Z,xe,_,Qe,$,We,v,Xe,G,Xt="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.",Ee,V,Et=`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).`,Ne,x,ke,Q,Re,W,He,X,Se,E,Nt=`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:
`,qe,N,Ae,k,kt=`&#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"]
}
`,Ye,R,Rt="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>.",ze,H,Fe,S,Le,q,Ht=`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.
`,Pe,A,St="This works! 🥳",De,Y,qt="But what about using a less powerful model?",Ke,z,At="To simulate the possibly less coherent outputs of a less powerful model, we increase the temperature.",Oe,F,et,L,Yt=`&#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
`,tt,P,zt="Now, the output is not even in correct JSON.",st,D,lt,K,Ft="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>.",nt,O,Lt="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.",at,ee,Pt='Here for instance we follow <a href="https://docs.pydantic.dev/latest/api/types/" rel="nofollow">Pydantic types</a>.',pt,te,ot,se,Dt="I advise inspecting the generated schema to check that it correctly represents your requirements:",it,le,rt,ne,Kt="You can use either the client’s <code>text_generation</code> method or use its <code>post</code> method.",ut,ae,ct,pe,Ot=`&#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"]
}
`,mt,oe,es="✅ 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!",Mt,ie,ts="It can then be parsed for further processing.",ht,re,wt,ue,ss='<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.',yt,ce,ls='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.',dt,me,Tt,Me,ns='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).',Jt,he,as="Now we’ve demonstrated a specific RAG use-case, but constrained generation is helpful for much more than that.",jt,we,ps='For instance in your <a href="llm_judge">LLM judge</a> workflows, you can also use constrained generation to output a JSON, as follows:',ft,ye,Ut,de,os="That’s all for today, congrats for following along! 👏",bt,Te,gt,je,It;return d=new ds({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/cookbook/blob/typos_fixed/notebooks/en/structured_generation.ipynb"}]}}),T=new Bt({props:{title:"RAG with source highlighting using Structured generation",local:"rag-with-source-highlighting-using-structured-generation",headingTag:"h1"}}),Z=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}}),$=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}}),v=new Bt({props:{title:"Prompting the model",local:"prompting-the-model",headingTag:"h2"}}),x=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}}),Q=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}}),W=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}}),X=new w({props:{code:"cHJvbXB0JTIwJTNEJTIwUkFHX1BST01QVF9URU1QTEFURV9KU09OLmZvcm1hdChjb250ZXh0JTNEUkVMRVZBTlRfQ09OVEVYVCUyQyUyMHVzZXJfcXVlcnklM0RVU0VSX1FVRVJZKSUwQXByaW50KHByb21wdCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = RAG_PROMPT_TEMPLATE_JSON.<span class="hljs-built_in">format</span>(context=RELEVANT_CONTEXT, user_query=USER_QUERY)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-built_in">print</span>(prompt)`,wrap:!1}}),N=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}}),H=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}}),S=new w({props:{code:"ZGVmJTIwaGlnaGxpZ2h0KHMpJTNBJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwJTIyJTVDeDFiJTVCMSUzQjMybSUyMiUyMCUyQiUyMHMlMjAlMkIlMjAlMjIlNUN4MWIlNUIwbSUyMiUwQSUwQSUwQWRlZiUyMHByaW50X3Jlc3VsdHMoYW5zd2VyJTJDJTIwc291cmNlX3RleHQlMkMlMjBoaWdobGlnaHRfc25pcHBldHMpJTNBJTBBJTIwJTIwJTIwJTIwcHJpbnQoJTIyQW5zd2VyJTNBJTIyJTJDJTIwaGlnaGxpZ2h0KGFuc3dlcikpJTBBJTIwJTIwJTIwJTIwcHJpbnQoJTIyJTVDbiU1Q24lMjIlMkMlMjAlMjIlM0QlMjIlMjAqJTIwMTAlMjAlMkIlMjAlMjIlMjBTb3VyY2UlMjBkb2N1bWVudHMlMjAlMjIlMjAlMkIlMjAlMjIlM0QlMjIlMjAqJTIwMTApJTBBJTIwJTIwJTIwJTIwZm9yJTIwc25pcHBldCUyMGluJTIwaGlnaGxpZ2h0X3NuaXBwZXRzJTNBJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwc291cmNlX3RleHQlMjAlM0QlMjBzb3VyY2VfdGV4dC5yZXBsYWNlKHNuaXBwZXQuc3RyaXAoKSUyQyUyMGhpZ2hsaWdodChzbmlwcGV0LnN0cmlwKCkpKSUwQSUyMCUyMCUyMCUyMHByaW50KHNvdXJjZV90ZXh0KSUwQSUwQSUwQXByaW50X3Jlc3VsdHMocGFyc2VkX2Fuc3dlciU1QiUyMmFuc3dlciUyMiU1RCUyQyUyMFJFTEVWQU5UX0NPTlRFWFQlMkMlMjBwYXJzZWRfYW5zd2VyJTVCJTIyc291cmNlX3NuaXBwZXRzJTIyJTVEKQ==",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(parsed_answer[<span class="hljs-string">&quot;answer&quot;</span>], RELEVANT_CONTEXT, parsed_answer[<span class="hljs-string">&quot;source_snippets&quot;</span>])`,wrap:!1}}),F=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}}),D=new Bt({props:{title:"👉 Constrained decoding",local:"-constrained-decoding",headingTag:"h2"}}),te=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}}),le=new w({props:{code:"QW5zd2VyV2l0aFNuaXBwZXRzLnNjaGVtYSgp",highlighted:"AnswerWithSnippets.schema()",wrap:!1}}),ae=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}}),re=new Bt({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}}),ye=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}}),Te=new Ts({props:{source:"https://github.com/huggingface/cookbook/blob/main/notebooks/en/structured_generation.md"}}),{c(){y=p("meta"),fe=n(),Je=p("p"),Ue=n(),r(d.$$.fragment),be=n(),r(T.$$.fragment),ge=n(),J=p("p"),J.innerHTML=Zt,Ie=n(),j=p("p"),j.innerHTML=_t,Be=n(),f=p("p"),f.textContent=$t,Ce=n(),U=p("ul"),U.innerHTML=vt,Ze=n(),b=p("p"),b.textContent=Gt,_e=n(),g=p("p"),g.innerHTML=Vt,$e=n(),I=p("p"),I.innerHTML=xt,ve=n(),B=p("p"),B.textContent=Qt,Ge=n(),C=p("p"),C.innerHTML=Wt,Ve=n(),r(Z.$$.fragment),xe=n(),r(_.$$.fragment),Qe=n(),r($.$$.fragment),We=n(),r(v.$$.fragment),Xe=n(),G=p("p"),G.textContent=Xt,Ee=n(),V=p("p"),V.textContent=Et,Ne=n(),r(x.$$.fragment),ke=n(),r(Q.$$.fragment),Re=n(),r(W.$$.fragment),He=n(),r(X.$$.fragment),Se=n(),E=p("pre"),E.textContent=Nt,qe=n(),r(N.$$.fragment),Ae=n(),k=p("pre"),k.textContent=kt,Ye=n(),R=p("p"),R.innerHTML=Rt,ze=n(),r(H.$$.fragment),Fe=n(),r(S.$$.fragment),Le=n(),q=p("pre"),q.textContent=Ht,Pe=n(),A=p("p"),A.textContent=St,De=n(),Y=p("p"),Y.textContent=qt,Ke=n(),z=p("p"),z.textContent=At,Oe=n(),r(F.$$.fragment),et=n(),L=p("pre"),L.textContent=Yt,tt=n(),P=p("p"),P.textContent=zt,st=n(),r(D.$$.fragment),lt=n(),K=p("p"),K.innerHTML=Ft,nt=n(),O=p("p"),O.textContent=Lt,at=n(),ee=p("p"),ee.innerHTML=Pt,pt=n(),r(te.$$.fragment),ot=n(),se=p("p"),se.textContent=Dt,it=n(),r(le.$$.fragment),rt=n(),ne=p("p"),ne.innerHTML=Kt,ut=n(),r(ae.$$.fragment),ct=n(),pe=p("pre"),pe.textContent=Ot,mt=n(),oe=p("p"),oe.textContent=es,Mt=n(),ie=p("p"),ie.textContent=ts,ht=n(),r(re.$$.fragment),wt=n(),ue=p("p"),ue.innerHTML=ss,yt=n(),ce=p("p"),ce.innerHTML=ls,dt=n(),r(me.$$.fragment),Tt=n(),Me=p("p"),Me.innerHTML=ns,Jt=n(),he=p("p"),he.textContent=as,jt=n(),we=p("p"),we.innerHTML=ps,ft=n(),r(ye.$$.fragment),Ut=n(),de=p("p"),de.textContent=os,bt=n(),r(Te.$$.fragment),gt=n(),je=p("p"),this.h()},l(e){const t=ws("svelte-u9bgzb",document.head);y=o(t,"META",{name:!0,content:!0}),t.forEach(s),fe=a(e),Je=o(e,"P",{}),is(Je).forEach(s),Ue=a(e),u(d.$$.fragment,e),be=a(e),u(T.$$.fragment,e),ge=a(e),J=o(e,"P",{"data-svelte-h":!0}),i(J)!=="svelte-1xlqnsv"&&(J.innerHTML=Zt),Ie=a(e),j=o(e,"P",{"data-svelte-h":!0}),i(j)!=="svelte-v6rqtt"&&(j.innerHTML=_t),Be=a(e),f=o(e,"P",{"data-svelte-h":!0}),i(f)!=="svelte-1erwo6s"&&(f.textContent=$t),Ce=a(e),U=o(e,"UL",{"data-svelte-h":!0}),i(U)!=="svelte-1gaeexd"&&(U.innerHTML=vt),Ze=a(e),b=o(e,"P",{"data-svelte-h":!0}),i(b)!=="svelte-1bihz1e"&&(b.textContent=Gt),_e=a(e),g=o(e,"P",{"data-svelte-h":!0}),i(g)!=="svelte-moca12"&&(g.innerHTML=Vt),$e=a(e),I=o(e,"P",{"data-svelte-h":!0}),i(I)!=="svelte-hpgnfx"&&(I.innerHTML=xt),ve=a(e),B=o(e,"P",{"data-svelte-h":!0}),i(B)!=="svelte-1n52pmm"&&(B.textContent=Qt),Ge=a(e),C=o(e,"P",{"data-svelte-h":!0}),i(C)!=="svelte-cxxavz"&&(C.innerHTML=Wt),Ve=a(e),u(Z.$$.fragment,e),xe=a(e),u(_.$$.fragment,e),Qe=a(e),u($.$$.fragment,e),We=a(e),u(v.$$.fragment,e),Xe=a(e),G=o(e,"P",{"data-svelte-h":!0}),i(G)!=="svelte-1o8iimq"&&(G.textContent=Xt),Ee=a(e),V=o(e,"P",{"data-svelte-h":!0}),i(V)!=="svelte-1abgq3k"&&(V.textContent=Et),Ne=a(e),u(x.$$.fragment,e),ke=a(e),u(Q.$$.fragment,e),Re=a(e),u(W.$$.fragment,e),He=a(e),u(X.$$.fragment,e),Se=a(e),E=o(e,"PRE",{"data-svelte-h":!0}),i(E)!=="svelte-cr71sn"&&(E.textContent=Nt),qe=a(e),u(N.$$.fragment,e),Ae=a(e),k=o(e,"PRE",{"data-svelte-h":!0}),i(k)!=="svelte-1uqak8l"&&(k.textContent=kt),Ye=a(e),R=o(e,"P",{"data-svelte-h":!0}),i(R)!=="svelte-1g3q39s"&&(R.innerHTML=Rt),ze=a(e),u(H.$$.fragment,e),Fe=a(e),u(S.$$.fragment,e),Le=a(e),q=o(e,"PRE",{"data-svelte-h":!0}),i(q)!=="svelte-1oi7qy6"&&(q.textContent=Ht),Pe=a(e),A=o(e,"P",{"data-svelte-h":!0}),i(A)!=="svelte-1876pnw"&&(A.textContent=St),De=a(e),Y=o(e,"P",{"data-svelte-h":!0}),i(Y)!=="svelte-clrbmw"&&(Y.textContent=qt),Ke=a(e),z=o(e,"P",{"data-svelte-h":!0}),i(z)!=="svelte-5svwjn"&&(z.textContent=At),Oe=a(e),u(F.$$.fragment,e),et=a(e),L=o(e,"PRE",{"data-svelte-h":!0}),i(L)!=="svelte-1ez34l3"&&(L.textContent=Yt),tt=a(e),P=o(e,"P",{"data-svelte-h":!0}),i(P)!=="svelte-1g1a5ck"&&(P.textContent=zt),st=a(e),u(D.$$.fragment,e),lt=a(e),K=o(e,"P",{"data-svelte-h":!0}),i(K)!=="svelte-1y2n8kq"&&(K.innerHTML=Ft),nt=a(e),O=o(e,"P",{"data-svelte-h":!0}),i(O)!=="svelte-15e1g7o"&&(O.textContent=Lt),at=a(e),ee=o(e,"P",{"data-svelte-h":!0}),i(ee)!=="svelte-wpg9iy"&&(ee.innerHTML=Pt),pt=a(e),u(te.$$.fragment,e),ot=a(e),se=o(e,"P",{"data-svelte-h":!0}),i(se)!=="svelte-iuvqps"&&(se.textContent=Dt),it=a(e),u(le.$$.fragment,e),rt=a(e),ne=o(e,"P",{"data-svelte-h":!0}),i(ne)!=="svelte-1wo42mn"&&(ne.innerHTML=Kt),ut=a(e),u(ae.$$.fragment,e),ct=a(e),pe=o(e,"PRE",{"data-svelte-h":!0}),i(pe)!=="svelte-zi5fqp"&&(pe.textContent=Ot),mt=a(e),oe=o(e,"P",{"data-svelte-h":!0}),i(oe)!=="svelte-w5yzdp"&&(oe.textContent=es),Mt=a(e),ie=o(e,"P",{"data-svelte-h":!0}),i(ie)!=="svelte-1iuwkju"&&(ie.textContent=ts),ht=a(e),u(re.$$.fragment,e),wt=a(e),ue=o(e,"P",{"data-svelte-h":!0}),i(ue)!=="svelte-nde9mv"&&(ue.innerHTML=ss),yt=a(e),ce=o(e,"P",{"data-svelte-h":!0}),i(ce)!=="svelte-1it785u"&&(ce.innerHTML=ls),dt=a(e),u(me.$$.fragment,e),Tt=a(e),Me=o(e,"P",{"data-svelte-h":!0}),i(Me)!=="svelte-1c7osy1"&&(Me.innerHTML=ns),Jt=a(e),he=o(e,"P",{"data-svelte-h":!0}),i(he)!=="svelte-gn2d5p"&&(he.textContent=as),jt=a(e),we=o(e,"P",{"data-svelte-h":!0}),i(we)!=="svelte-kff18m"&&(we.innerHTML=ps),ft=a(e),u(ye.$$.fragment,e),Ut=a(e),de=o(e,"P",{"data-svelte-h":!0}),i(de)!=="svelte-12how7f"&&(de.textContent=os),bt=a(e),u(Te.$$.fragment,e),gt=a(e),je=o(e,"P",{}),is(je).forEach(s),this.h()},h(){rs(y,"name","hf:doc:metadata"),rs(y,"content",js)},m(e,t){ys(document.head,y),l(e,fe,t),l(e,Je,t),l(e,Ue,t),c(d,e,t),l(e,be,t),c(T,e,t),l(e,ge,t),l(e,J,t),l(e,Ie,t),l(e,j,t),l(e,Be,t),l(e,f,t),l(e,Ce,t),l(e,U,t),l(e,Ze,t),l(e,b,t),l(e,_e,t),l(e,g,t),l(e,$e,t),l(e,I,t),l(e,ve,t),l(e,B,t),l(e,Ge,t),l(e,C,t),l(e,Ve,t),c(Z,e,t),l(e,xe,t),c(_,e,t),l(e,Qe,t),c($,e,t),l(e,We,t),c(v,e,t),l(e,Xe,t),l(e,G,t),l(e,Ee,t),l(e,V,t),l(e,Ne,t),c(x,e,t),l(e,ke,t),c(Q,e,t),l(e,Re,t),c(W,e,t),l(e,He,t),c(X,e,t),l(e,Se,t),l(e,E,t),l(e,qe,t),c(N,e,t),l(e,Ae,t),l(e,k,t),l(e,Ye,t),l(e,R,t),l(e,ze,t),c(H,e,t),l(e,Fe,t),c(S,e,t),l(e,Le,t),l(e,q,t),l(e,Pe,t),l(e,A,t),l(e,De,t),l(e,Y,t),l(e,Ke,t),l(e,z,t),l(e,Oe,t),c(F,e,t),l(e,et,t),l(e,L,t),l(e,tt,t),l(e,P,t),l(e,st,t),c(D,e,t),l(e,lt,t),l(e,K,t),l(e,nt,t),l(e,O,t),l(e,at,t),l(e,ee,t),l(e,pt,t),c(te,e,t),l(e,ot,t),l(e,se,t),l(e,it,t),c(le,e,t),l(e,rt,t),l(e,ne,t),l(e,ut,t),c(ae,e,t),l(e,ct,t),l(e,pe,t),l(e,mt,t),l(e,oe,t),l(e,Mt,t),l(e,ie,t),l(e,ht,t),c(re,e,t),l(e,wt,t),l(e,ue,t),l(e,yt,t),l(e,ce,t),l(e,dt,t),c(me,e,t),l(e,Tt,t),l(e,Me,t),l(e,Jt,t),l(e,he,t),l(e,jt,t),l(e,we,t),l(e,ft,t),c(ye,e,t),l(e,Ut,t),l(e,de,t),l(e,bt,t),c(Te,e,t),l(e,gt,t),l(e,je,t),It=!0},p:cs,i(e){It||(m(d.$$.fragment,e),m(T.$$.fragment,e),m(Z.$$.fragment,e),m(_.$$.fragment,e),m($.$$.fragment,e),m(v.$$.fragment,e),m(x.$$.fragment,e),m(Q.$$.fragment,e),m(W.$$.fragment,e),m(X.$$.fragment,e),m(N.$$.fragment,e),m(H.$$.fragment,e),m(S.$$.fragment,e),m(F.$$.fragment,e),m(D.$$.fragment,e),m(te.$$.fragment,e),m(le.$$.fragment,e),m(ae.$$.fragment,e),m(re.$$.fragment,e),m(me.$$.fragment,e),m(ye.$$.fragment,e),m(Te.$$.fragment,e),It=!0)},o(e){M(d.$$.fragment,e),M(T.$$.fragment,e),M(Z.$$.fragment,e),M(_.$$.fragment,e),M($.$$.fragment,e),M(v.$$.fragment,e),M(x.$$.fragment,e),M(Q.$$.fragment,e),M(W.$$.fragment,e),M(X.$$.fragment,e),M(N.$$.fragment,e),M(H.$$.fragment,e),M(S.$$.fragment,e),M(F.$$.fragment,e),M(D.$$.fragment,e),M(te.$$.fragment,e),M(le.$$.fragment,e),M(ae.$$.fragment,e),M(re.$$.fragment,e),M(me.$$.fragment,e),M(ye.$$.fragment,e),M(Te.$$.fragment,e),It=!1},d(e){e&&(s(fe),s(Je),s(Ue),s(be),s(ge),s(J),s(Ie),s(j),s(Be),s(f),s(Ce),s(U),s(Ze),s(b),s(_e),s(g),s($e),s(I),s(ve),s(B),s(Ge),s(C),s(Ve),s(xe),s(Qe),s(We),s(Xe),s(G),s(Ee),s(V),s(Ne),s(ke),s(Re),s(He),s(Se),s(E),s(qe),s(Ae),s(k),s(Ye),s(R),s(ze),s(Fe),s(Le),s(q),s(Pe),s(A),s(De),s(Y),s(Ke),s(z),s(Oe),s(et),s(L),s(tt),s(P),s(st),s(lt),s(K),s(nt),s(O),s(at),s(ee),s(pt),s(ot),s(se),s(it),s(rt),s(ne),s(ut),s(ct),s(pe),s(mt),s(oe),s(Mt),s(ie),s(ht),s(wt),s(ue),s(yt),s(ce),s(dt),s(Tt),s(Me),s(Jt),s(he),s(jt),s(we),s(ft),s(Ut),s(de),s(bt),s(gt),s(je)),s(y),h(d,e),h(T,e),h(Z,e),h(_,e),h($,e),h(v,e),h(x,e),h(Q,e),h(W,e),h(X,e),h(N,e),h(H,e),h(S,e),h(F,e),h(D,e),h(te,e),h(le,e),h(ae,e),h(re,e),h(me,e),h(ye,e),h(Te,e)}}}const js='{"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 fs(Ct){return ms(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bs extends Ms{constructor(y){super(),hs(this,y,fs,Js,us,{})}}export{Bs as component};
