import{s as vl,n as Bl,o as Gl}from"../chunks/scheduler.56725da7.js";import{S as Zl,i as Wl,e as o,s,c as p,q as bl,h as kl,a as i,d as l,b as a,f as gl,g as m,j as M,r as xl,k as Al,l as $l,m as n,n as r,t as w,o as y,p as h}from"../chunks/index.18a26576.js";import{C as _l}from"../chunks/CopyLLMTxtMenu.f644b58a.js";import{C as u}from"../chunks/CodeBlock.a5342303.js";import{H as be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.401933eb.js";function Hl($t){let T,ge,Ce,xe,J,Ae,c,ve,j,_t='<em>There is a notebook version of that tutorial <a href="https://github.com/huggingface/optimum-neuron/blob/main/notebooks/text-generation/llama2-13b-chatbot.ipynb" rel="nofollow">here</a></em>.',Be,U,Ht="This guide will detail how to export, deploy and run a <strong>LLama-2 13B</strong> chat model on AWS inferentia.",Ge,I,Xt="You will learn how to:",Ze,d,Vt="<li>export the Llama-2 model to the Neuron format,</li> <li>push the exported model to the Hugging Face Hub,</li> <li>deploy the model and use it in a chat application.</li>",We,C,zt="Note: This tutorial was created on a inf2.48xlarge AWS EC2 Instance.",ke,f,$e,b,Nt='For this guide, we will use the non-gated <a href="https://huggingface.co/NousResearch/Llama-2-13b-chat-hf" rel="nofollow">NousResearch/Llama-2-13b-chat-hf</a> model, which is functionally equivalent to the original <a href="https://huggingface.co/meta-llama/Llama-2-13b-chat-hf" rel="nofollow">meta-llama/Llama-2-13b-chat-hf</a>.',_e,g,St=`This model is part of the <strong>Llama 2</strong> family of models, and has been tuned to recognize chat interactions
between a <em>user</em> and an <em>assistant</em> (more on that later).`,He,x,Qt=`As explained in the <a href="https://huggingface.co/docs/optimum-neuron/guides/export_model#exporting-llm-models-to-neuron" rel="nofollow">optimum-neuron documentation</a>
, models need to be compiled and exported to a serialized format before running them on Neuron devices.`,Xe,A,Et="When exporting the model, we will specify two sets of parameters:",Ve,v,Rt=`<li>using <em>compiler_args</em>, we specify on how many cores we want the model to be deployed (each neuron device has two cores), and with which precision (here <em>float16</em>),</li> <li>using <em>input_shapes</em>, we set the static input and output dimensions of the model. All model compilers require static shapes, and neuron makes no exception. Note that the
<em>sequence_length</em> not only constrains the length of the input context, but also the length of the Key/Value cache, and thus, the output length.</li>`,ze,B,Yt="Depending on your choice of parameters and inferentia host, this may take from a few minutes to more than an hour.",Ne,G,Lt="For your convenience, we host a pre-compiled version of that model on the Hugging Face hub, so you can skip the export and start using the model immediately in section 2.",Se,Z,Qe,W,Ft="This will probably take a while.",Ee,k,qt="Fortunately, you will need to do this only once because you can save your model and reload it later.",Re,$,Ye,_,Pt='Even better, you can push it to the <a href="https://huggingface.co/models" rel="nofollow">Hugging Face hub</a>.',Le,H,Kt='For that, you need to be logged in to a <a href="https://huggingface.co/join" rel="nofollow">HuggingFace account</a>.',Fe,X,Dt="In the terminal, just type the following command and paste your Hugging Face token when requested:",qe,V,Pe,z,Ot="By default, the model will be uploaded to your account (organization equal to your user name).",Ke,N,el='Feel free to edit the code below if you want to upload the model to a specific <a href="https://huggingface.co/docs/hub/organizations" rel="nofollow">Hugging Face organization</a>.',De,S,Oe,Q,et,E,tl="The minimum memory required to load a model can be computed with:",tt,R,lt,Y,ll="The <strong>Llama 2 13B</strong> model uses <em>float16</em> weights (stored on 2 bytes) and has 13 billion parameters, which means it requires at least 2 * 13B or ~26GB of memory to store its weights.",nt,L,nl="Each NeuronCore has 16GB of memory which means that a 26GB model cannot fit on a single NeuronCore.",st,F,sl=`In reality, the total space required is much greater than just the number of parameters due to caching attention layer projections (KV caching).
This caching mechanism grows memory allocations linearly with sequence length and batch size.`,at,q,al="Here we set the <em>batch_size</em> to 1, meaning that we can only process one input prompt in parallel. We set the <em>sequence_length</em> to 2048, which corresponds to half the model maximum capacity (4096).",ot,P,ol="The formula to evaluate the size of the KV cache is more involved as it also depends on parameters related to the model architecture, such as the width of the embeddings and the number of decoder blocks.",it,K,il="Bottom-line is, to get very large language models to fit, tensor parallelism is used to split weights, data, and compute across multiple NeuronCores, keeping in mind that the memory on each core cannot exceed 16GB.",Mt,D,Ml=`Note that increasing the number of cores beyond the minimum requirement almost always results in a faster model.
Increasing the tensor parallelism degree improves memory bandwidth which improves model performance.`,pt,O,pl="To optimize performance it’s recommended to use all cores available on the instance.",mt,ee,ml=`In this guide we use all the 24 cores of the <em>inf2.48xlarge</em>, but this should be changed to 12 if you are
using a <em>inf2.24xlarge</em> instance.`,rt,te,wt,le,rl='Once your model has been exported, you can generate text using the transformers library, as it has been described in <a href="https://huggingface.co/blog/how-to-generate" rel="nofollow">detail in this post</a>.',yt,ne,wl="If as suggested you skipped the first section, don’t worry: we will use a precompiled model already present on the hub instead.",ht,se,ut,ae,yl="We will need a <em>Llama 2</em> tokenizer to convert the prompt strings to text tokens.",Tt,oe,Jt,ie,hl="The following generation strategies are supported:",ct,Me,ul="<li>greedy search,</li> <li>multinomial sampling with top-k and top-p (with temperature).</li>",jt,pe,Tl="Most logits pre-processing/filters (such as repetition penalty) are supported.",Ut,me,It,re,dt,we,Jl="We specifically selected a <strong>Llama 2</strong> chat variant to illustrate the excellent behaviour of the exported model when the length of the encoding context grows.",Ct,ye,cl="The model expects the prompts to be formatted following a specific template corresponding to the interactions between a <em>user</em> role and an <em>assistant</em> role.",ft,he,jl='Each chat model has its own convention for encoding such contents, and we will not go into too much details in this guide, because we will directly use the <a href="https://huggingface.co/blog/chat-templates" rel="nofollow">Hugging Face chat templates</a> corresponding to our model.',bt,ue,Ul="The utility function below converts a list of exchanges between the user and the model into a well-formatted chat prompt.",gt,Te,xt,Je,Il="We are now equipped to build a simplistic chat application.",At,ce,dl=`We simply store the interactions between the user and the assistant in a list that we use to generate
the input prompt.`,vt,je,Bt,Ue,Cl="To test the chat application you can use for instance the following sequence of prompts:",Gt,Ie,Zt,de,fl="While very powerful, Large language models can sometimes <em>hallucinate</em>. We call <em>hallucinations</em> generated content that is irrelevant or made-up but presented by the model as if it was accurate. This is a flaw of LLMs and is not a side effect of using them on Trainium / Inferentia.",Wt,fe,kt;return J=new _l({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),c=new be({props:{title:"Create your own chatbot with llama-2-13B on AWS Inferentia",local:"create-your-own-chatbot-with-llama-2-13b-on-aws-inferentia",headingTag:"h1"}}),f=new be({props:{title:"1. Export the Llama 2 model to Neuron",local:"1-export-the-llama-2-model-to-neuron",headingTag:"h2"}}),Z=new u({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uTW9kZWxGb3JDYXVzYWxMTSUwQSUwQWNvbXBpbGVyX2FyZ3MlMjAlM0QlMjAlN0IlMjJ0ZW5zb3JfcGFyYWxsZWxfc2l6ZSUyMiUzQSUyMDI0JTJDJTIwJTIyYXV0b19jYXN0X3R5cGUlMjIlM0ElMjAnZnAxNiclN0QlMEFpbnB1dF9zaGFwZXMlMjAlM0QlMjAlN0IlMjJiYXRjaF9zaXplJTIyJTNBJTIwMSUyQyUyMCUyMnNlcXVlbmNlX2xlbmd0aCUyMiUzQSUyMDIwNDglN0QlMEFtb2RlbCUyMCUzRCUyME5ldXJvbk1vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMk5vdXNSZXNlYXJjaCUyRkxsYW1hLTItMTNiLWNoYXQtaGYlMjIlMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBleHBvcnQlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKipjb21waWxlcl9hcmdzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwKippbnB1dF9zaGFwZXMp",highlighted:`<span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronModelForCausalLM

compiler_args = {<span class="hljs-string">&quot;tensor_parallel_size&quot;</span>: <span class="hljs-number">24</span>, <span class="hljs-string">&quot;auto_cast_type&quot;</span>: <span class="hljs-string">&#x27;fp16&#x27;</span>}
input_shapes = {<span class="hljs-string">&quot;batch_size&quot;</span>: <span class="hljs-number">1</span>, <span class="hljs-string">&quot;sequence_length&quot;</span>: <span class="hljs-number">2048</span>}
model = NeuronModelForCausalLM.from_pretrained(
        <span class="hljs-string">&quot;NousResearch/Llama-2-13b-chat-hf&quot;</span>,
        export=<span class="hljs-literal">True</span>,
        **compiler_args,
        **input_shapes)`,wrap:!1}}),$=new u({props:{code:"bW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmxsYW1hLTItMTNiLWNoYXQtbmV1cm9uJTIyKQ==",highlighted:'model.save_pretrained(<span class="hljs-string">&quot;llama-2-13b-chat-neuron&quot;</span>)',wrap:!1}}),V=new u({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login",wrap:!1}}),S=new u({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHdob2FtaSUwQSUwQW9yZyUyMCUzRCUyMHdob2FtaSgpJTVCJ25hbWUnJTVEJTBBJTBBcmVwb19pZCUyMCUzRCUyMGYlMjIlN0JvcmclN0QlMkZsbGFtYS0yLTEzYi1jaGF0LW5ldXJvbiUyMiUwQSUwQW1vZGVsLnB1c2hfdG9faHViKCUyMmxsYW1hLTItMTNiLWNoYXQtbmV1cm9uJTIyJTJDJTIwcmVwb3NpdG9yeV9pZCUzRHJlcG9faWQp",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> whoami

org = whoami()[<span class="hljs-string">&#x27;name&#x27;</span>]

repo_id = <span class="hljs-string">f&quot;<span class="hljs-subst">{org}</span>/llama-2-13b-chat-neuron&quot;</span>

model.push_to_hub(<span class="hljs-string">&quot;llama-2-13b-chat-neuron&quot;</span>, repository_id=repo_id)`,wrap:!1}}),Q=new be({props:{title:"A few more words about export parameters.",local:"a-few-more-words-about-export-parameters",headingTag:"h3"}}),R=new u({props:{code:"JTIwJTIwJTIwbWVtb3J5JTIwJTNEJTIwYnl0ZXMlMjBwZXIlMjBwYXJhbWV0ZXIlMjAqJTIwbnVtYmVyJTIwb2YlMjBwYXJhbWV0ZXJz",highlighted:'   memory = bytes per <span class="hljs-keyword">parameter</span> * <span class="hljs-keyword">number</span> of parameters',wrap:!1}}),te=new be({props:{title:"2. Generate text using Llama 2 on AWS Inferentia2",local:"2-generate-text-using-llama-2-on-aws-inferentia2",headingTag:"h2"}}),se=new u({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uTW9kZWxGb3JDYXVzYWxMTSUwQSUwQXRyeSUzQSUwQSUyMCUyMCUyMCUyMG1vZGVsJTBBZXhjZXB0JTIwTmFtZUVycm9yJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwRWRpdCUyMHRoaXMlMjB0byUyMHVzZSUyMGFub3RoZXIlMjBiYXNlJTIwbW9kZWwlMEElMjAlMjAlMjAlMjBtb2RlbCUyMCUzRCUyME5ldXJvbk1vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCdhd3MtbmV1cm9uJTJGTGxhbWEtMi0xM2ItY2hhdC1oZi1uZXVyb24tbGF0ZW5jeScp",highlighted:`<span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronModelForCausalLM

<span class="hljs-keyword">try</span>:
    model
<span class="hljs-keyword">except</span> NameError:
    <span class="hljs-comment"># Edit this to use another base model</span>
    model = NeuronModelForCausalLM.from_pretrained(<span class="hljs-string">&#x27;aws-neuron/Llama-2-13b-chat-hf-neuron-latency&#x27;</span>)`,wrap:!1}}),oe=new u({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJOb3VzUmVzZWFyY2glMkZMbGFtYS0yLTEzYi1jaGF0LWhmJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">&quot;NousResearch/Llama-2-13b-chat-hf&quot;</span>)`,wrap:!1}}),me=new u({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMldoYXQlMjBpcyUyMGRlZXAtbGVhcm5pbmclMjAlM0YlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1heF9uZXdfdG9rZW5zJTNEMTI4JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRlbXBlcmF0dXJlJTNEMC45JTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdG9wX2slM0Q1MCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHRvcF9wJTNEMC45KSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`inputs = tokenizer(<span class="hljs-string">&quot;What is deep-learning ?&quot;</span>, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
outputs = model.generate(**inputs,
                         max_new_tokens=<span class="hljs-number">128</span>,
                         do_sample=<span class="hljs-literal">True</span>,
                         temperature=<span class="hljs-number">0.9</span>,
                         top_k=<span class="hljs-number">50</span>,
                         top_p=<span class="hljs-number">0.9</span>)
tokenizer.batch_decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)`,wrap:!1}}),re=new be({props:{title:"3. Create a chat application using llama on AWS Inferentia2",local:"3-create-a-chat-application-using-llama-on-aws-inferentia2",headingTag:"h2"}}),Te=new u({props:{code:"ZGVmJTIwZm9ybWF0X2NoYXRfcHJvbXB0KG1lc3NhZ2UlMkMlMjBoaXN0b3J5JTJDJTIwbWF4X3Rva2VucyklM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjIlMjBDb252ZXJ0JTIwYSUyMGhpc3RvcnklMjBvZiUyMG1lc3NhZ2VzJTIwdG8lMjBhJTIwY2hhdCUyMHByb21wdCUwQSUwQSUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlKHN0ciklM0ElMjB0aGUlMjBuZXclMjB1c2VyJTIwbWVzc2FnZS4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBoaXN0b3J5JTIwKExpc3QlNUJzdHIlNUQpJTNBJTIwdGhlJTIwbGlzdCUyMG9mJTIwdXNlciUyMG1lc3NhZ2VzJTIwYW5kJTIwYXNzaXN0YW50JTIwcmVzcG9uc2VzLiUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMG1heF90b2tlbnMlMjAoaW50KSUzQSUyMHRoZSUyMG1heGltdW0lMjBudW1iZXIlMjBvZiUyMGlucHV0JTIwdG9rZW5zJTIwYWNjZXB0ZWQlMjBieSUyMHRoZSUyMG1vZGVsLiUwQSUwQSUyMCUyMCUyMCUyMFJldHVybnMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhJTIwJTYwc3RyJTYwJTIwcHJvbXB0LiUwQSUyMCUyMCUyMCUyMCUyMiUyMiUyMiUwQSUyMCUyMCUyMCUyMGNoYXQlMjAlM0QlMjAlNUIlNUQlMEElMjAlMjAlMjAlMjAlMjMlMjBDb252ZXJ0JTIwYWxsJTIwbWVzc2FnZXMlMjBpbiUyMGhpc3RvcnklMjB0byUyMGNoYXQlMjBpbnRlcmFjdGlvbnMlMEElMjAlMjAlMjAlMjBmb3IlMjBpbnRlcmFjdGlvbiUyMGluJTIwaGlzdG9yeSUzQSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMGNoYXQuYXBwZW5kKCU3QiUyMnJvbGUlMjIlM0ElMjAlMjJ1c2VyJTIyJTJDJTIwJTIyY29udGVudCUyMiUyMCUzQSUyMGludGVyYWN0aW9uJTVCMCU1RCU3RCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBjaGF0LmFwcGVuZCglN0IlMjJyb2xlJTIyJTNBJTIwJTIyYXNzaXN0YW50JTIyJTJDJTIwJTIyY29udGVudCUyMiUyMCUzQSUyMGludGVyYWN0aW9uJTVCMSU1RCU3RCklMEElMjAlMjAlMjAlMjAlMjMlMjBBZGQlMjB0aGUlMjBuZXclMjBtZXNzYWdlJTBBJTIwJTIwJTIwJTIwY2hhdC5hcHBlbmQoJTdCJTIycm9sZSUyMiUzQSUyMCUyMnVzZXIlMjIlMkMlMjAlMjJjb250ZW50JTIyJTIwJTNBJTIwbWVzc2FnZSU3RCklMEElMjAlMjAlMjAlMjAlMjMlMjBHZW5lcmF0ZSUyMHRoZSUyMHByb21wdCUyQyUyMHZlcmlmeWluZyUyMHRoYXQlMjB3ZSUyMGRvbid0JTIwZ28lMjBiZXlvbmQlMjB0aGUlMjBtYXhpbXVtJTIwbnVtYmVyJTIwb2YlMjB0b2tlbnMlMEElMjAlMjAlMjAlMjBmb3IlMjBpJTIwaW4lMjByYW5nZSgwJTJDJTIwbGVuKGNoYXQpJTJDJTIwMiklM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBHZW5lcmF0ZSUyMGNhbmRpZGF0ZSUyMHByb21wdCUyMHdpdGglMjB0aGUlMjBsYXN0JTIwbi1pJTIwZW50cmllcyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHByb21wdCUyMCUzRCUyMHRva2VuaXplci5hcHBseV9jaGF0X3RlbXBsYXRlKGNoYXQlNUJpJTNBJTVEJTJDJTIwdG9rZW5pemUlM0RGYWxzZSklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBUb2tlbml6ZSUyMHRvJTIwY2hlY2slMjBpZiUyMHdlJ3JlJTIwb3ZlciUyMHRoZSUyMGxpbWl0JTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdG9rZW5zJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCklMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBpZiUyMGxlbih0b2tlbnMuaW5wdXRfaWRzKSUyMCUzQyUzRCUyMG1heF90b2tlbnMlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjMlMjBXZSdyZSUyMGdvb2QlMkMlMjBzdG9wJTIwaGVyZSUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldHVybiUyMHByb21wdCUwQSUyMCUyMCUyMCUyMCUyMyUyMFdlJTIwc2hhbGwlMjBuZXZlciUyMHJlYWNoJTIwdGhpcyUyMGxpbmUlMEElMjAlMjAlMjAlMjByYWlzZSUyMFN5c3RlbUVycm9y",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">format_chat_prompt</span>(<span class="hljs-params">message, history, max_tokens</span>):
    <span class="hljs-string">&quot;&quot;&quot; Convert a history of messages to a chat prompt


    Args:
        message(str): the new user message.
        history (List[str]): the list of user messages and assistant responses.
        max_tokens (int): the maximum number of input tokens accepted by the model.

    Returns:
        a \`str\` prompt.
    &quot;&quot;&quot;</span>
    chat = []
    <span class="hljs-comment"># Convert all messages in history to chat interactions</span>
    <span class="hljs-keyword">for</span> interaction <span class="hljs-keyword">in</span> history:
        chat.append({<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span> : interaction[<span class="hljs-number">0</span>]})
        chat.append({<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;assistant&quot;</span>, <span class="hljs-string">&quot;content&quot;</span> : interaction[<span class="hljs-number">1</span>]})
    <span class="hljs-comment"># Add the new message</span>
    chat.append({<span class="hljs-string">&quot;role&quot;</span>: <span class="hljs-string">&quot;user&quot;</span>, <span class="hljs-string">&quot;content&quot;</span> : message})
    <span class="hljs-comment"># Generate the prompt, verifying that we don&#x27;t go beyond the maximum number of tokens</span>
    <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> <span class="hljs-built_in">range</span>(<span class="hljs-number">0</span>, <span class="hljs-built_in">len</span>(chat), <span class="hljs-number">2</span>):
        <span class="hljs-comment"># Generate candidate prompt with the last n-i entries</span>
        prompt = tokenizer.apply_chat_template(chat[i:], tokenize=<span class="hljs-literal">False</span>)
        <span class="hljs-comment"># Tokenize to check if we&#x27;re over the limit</span>
        tokens = tokenizer(prompt)
        <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(tokens.input_ids) &lt;= max_tokens:
            <span class="hljs-comment"># We&#x27;re good, stop here</span>
            <span class="hljs-keyword">return</span> prompt
    <span class="hljs-comment"># We shall never reach this line</span>
    <span class="hljs-keyword">raise</span> SystemError`,wrap:!1}}),je=new u({props:{code:"aGlzdG9yeSUyMCUzRCUyMCU1QiU1RCUwQW1heF90b2tlbnMlMjAlM0QlMjAxMDI0JTBBJTBBZGVmJTIwY2hhdChtZXNzYWdlJTJDJTIwaGlzdG9yeSUyQyUyMG1heF90b2tlbnMpJTNBJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTIwJTNEJTIwZm9ybWF0X2NoYXRfcHJvbXB0KG1lc3NhZ2UlMkMlMjBoaXN0b3J5JTJDJTIwbWF4X3Rva2VucyklMEElMjAlMjAlMjAlMjAlMjMlMjBVbmNvbW1lbnQlMjB0aGUlMjBsaW5lJTIwYmVsb3clMjB0byUyMHNlZSUyMHdoYXQlMjB0aGUlMjBmb3JtYXR0ZWQlMjBwcm9tcHQlMjBsb29rcyUyMGxpa2UlMEElMjAlMjAlMjAlMjAlMjNwcmludChwcm9tcHQpJTBBJTIwJTIwJTIwJTIwaW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKHByb21wdCUyQyUyMHJldHVybl90ZW5zb3JzJTNEJTIycHQlMjIpJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG1vZGVsLmdlbmVyYXRlKCoqaW5wdXRzJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwbWF4X2xlbmd0aCUzRDIwNDglMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBkb19zYW1wbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwdGVtcGVyYXR1cmUlM0QwLjklMkMlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjB0b3BfayUzRDUwJTJDJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwcmVwZXRpdGlvbl9wZW5hbHR5JTNEMS4yKSUwQSUyMCUyMCUyMCUyMCUyMyUyMERvJTIwbm90JTIwaW5jbHVkZSUyMHRoZSUyMGlucHV0JTIwdG9rZW5zJTBBJTIwJTIwJTIwJTIwb3V0cHV0cyUyMCUzRCUyMG91dHB1dHMlNUIwJTJDJTIwaW5wdXRzLmlucHV0X2lkcy5zaXplKC0xKSUzQSU1RCUwQSUyMCUyMCUyMCUyMHJlc3BvbnNlJTIwJTNEJTIwdG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTBBJTIwJTIwJTIwJTIwaGlzdG9yeS5hcHBlbmQoJTVCbWVzc2FnZSUyQyUyMHJlc3BvbnNlJTVEKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHJlc3BvbnNl",highlighted:`history = []
max_tokens = <span class="hljs-number">1024</span>

<span class="hljs-keyword">def</span> <span class="hljs-title function_">chat</span>(<span class="hljs-params">message, history, max_tokens</span>):
    prompt = format_chat_prompt(message, history, max_tokens)
    <span class="hljs-comment"># Uncomment the line below to see what the formatted prompt looks like</span>
    <span class="hljs-comment">#print(prompt)</span>
    inputs = tokenizer(prompt, return_tensors=<span class="hljs-string">&quot;pt&quot;</span>)
    outputs = model.generate(**inputs,
                             max_length=<span class="hljs-number">2048</span>,
                             do_sample=<span class="hljs-literal">True</span>,
                             temperature=<span class="hljs-number">0.9</span>,
                             top_k=<span class="hljs-number">50</span>,
                             repetition_penalty=<span class="hljs-number">1.2</span>)
    <span class="hljs-comment"># Do not include the input tokens</span>
    outputs = outputs[<span class="hljs-number">0</span>, inputs.input_ids.size(-<span class="hljs-number">1</span>):]
    response = tokenizer.decode(outputs, skip_special_tokens=<span class="hljs-literal">True</span>)
    history.append([message, response])
    <span class="hljs-keyword">return</span> response`,wrap:!1}}),Ie=new u({props:{code:"cHJpbnQoY2hhdCglMjJNeSUyMGZhdm9yaXRlJTIwY29sb3IlMjBpcyUyMGJsdWUuJTIwTXklMjBmYXZvcml0ZSUyMGZydWl0JTIwaXMlMjBzdHJhd2JlcnJ5LiUyMiUyQyUyMGhpc3RvcnklMkMlMjBtYXhfdG9rZW5zKSklMEFwcmludChjaGF0KCUyMk5hbWUlMjBhJTIwZnJ1aXQlMjB0aGF0JTIwaXMlMjBvbiUyMG15JTIwZmF2b3JpdGUlMjBjb2xvdXIuJTIyJTJDJTIwaGlzdG9yeSUyQyUyMG1heF90b2tlbnMpKSUwQXByaW50KGNoYXQoJTIyV2hhdCUyMGlzJTIwdGhlJTIwY29sb3VyJTIwb2YlMjBteSUyMGZhdm9yaXRlJTIwZnJ1aXQlMjAlM0YlMjIlMkMlMjBoaXN0b3J5JTJDJTIwbWF4X3Rva2Vucykp",highlighted:`<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">&quot;My favorite color is blue. My favorite fruit is strawberry.&quot;</span>, history, max_tokens))
<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">&quot;Name a fruit that is on my favorite colour.&quot;</span>, history, max_tokens))
<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">&quot;What is the colour of my favorite fruit ?&quot;</span>, history, max_tokens))`,wrap:!1}}),{c(){T=o("meta"),ge=s(),Ce=o("p"),xe=s(),p(J.$$.fragment),Ae=s(),p(c.$$.fragment),ve=s(),j=o("p"),j.innerHTML=_t,Be=s(),U=o("p"),U.innerHTML=Ht,Ge=s(),I=o("p"),I.textContent=Xt,Ze=s(),d=o("ul"),d.innerHTML=Vt,We=s(),C=o("p"),C.textContent=zt,ke=s(),p(f.$$.fragment),$e=s(),b=o("p"),b.innerHTML=Nt,_e=s(),g=o("p"),g.innerHTML=St,He=s(),x=o("p"),x.innerHTML=Qt,Xe=s(),A=o("p"),A.textContent=Et,Ve=s(),v=o("ul"),v.innerHTML=Rt,ze=s(),B=o("p"),B.textContent=Yt,Ne=s(),G=o("p"),G.textContent=Lt,Se=s(),p(Z.$$.fragment),Qe=s(),W=o("p"),W.textContent=Ft,Ee=s(),k=o("p"),k.textContent=qt,Re=s(),p($.$$.fragment),Ye=s(),_=o("p"),_.innerHTML=Pt,Le=s(),H=o("p"),H.innerHTML=Kt,Fe=s(),X=o("p"),X.textContent=Dt,qe=s(),p(V.$$.fragment),Pe=s(),z=o("p"),z.textContent=Ot,Ke=s(),N=o("p"),N.innerHTML=el,De=s(),p(S.$$.fragment),Oe=s(),p(Q.$$.fragment),et=s(),E=o("p"),E.textContent=tl,tt=s(),p(R.$$.fragment),lt=s(),Y=o("p"),Y.innerHTML=ll,nt=s(),L=o("p"),L.textContent=nl,st=s(),F=o("p"),F.textContent=sl,at=s(),q=o("p"),q.innerHTML=al,ot=s(),P=o("p"),P.textContent=ol,it=s(),K=o("p"),K.textContent=il,Mt=s(),D=o("p"),D.textContent=Ml,pt=s(),O=o("p"),O.textContent=pl,mt=s(),ee=o("p"),ee.innerHTML=ml,rt=s(),p(te.$$.fragment),wt=s(),le=o("p"),le.innerHTML=rl,yt=s(),ne=o("p"),ne.textContent=wl,ht=s(),p(se.$$.fragment),ut=s(),ae=o("p"),ae.innerHTML=yl,Tt=s(),p(oe.$$.fragment),Jt=s(),ie=o("p"),ie.textContent=hl,ct=s(),Me=o("ul"),Me.innerHTML=ul,jt=s(),pe=o("p"),pe.textContent=Tl,Ut=s(),p(me.$$.fragment),It=s(),p(re.$$.fragment),dt=s(),we=o("p"),we.innerHTML=Jl,Ct=s(),ye=o("p"),ye.innerHTML=cl,ft=s(),he=o("p"),he.innerHTML=jl,bt=s(),ue=o("p"),ue.textContent=Ul,gt=s(),p(Te.$$.fragment),xt=s(),Je=o("p"),Je.textContent=Il,At=s(),ce=o("p"),ce.textContent=dl,vt=s(),p(je.$$.fragment),Bt=s(),Ue=o("p"),Ue.textContent=Cl,Gt=s(),p(Ie.$$.fragment),Zt=bl(`
<Warning>
`),de=o("p"),de.innerHTML=fl,Wt=bl(`
</Warning>

`),fe=o("p"),this.h()},l(e){const t=kl("svelte-u9bgzb",document.head);T=i(t,"META",{name:!0,content:!0}),t.forEach(l),ge=a(e),Ce=i(e,"P",{}),gl(Ce).forEach(l),xe=a(e),m(J.$$.fragment,e),Ae=a(e),m(c.$$.fragment,e),ve=a(e),j=i(e,"P",{"data-svelte-h":!0}),M(j)!=="svelte-14mc9a1"&&(j.innerHTML=_t),Be=a(e),U=i(e,"P",{"data-svelte-h":!0}),M(U)!=="svelte-1skq0wn"&&(U.innerHTML=Ht),Ge=a(e),I=i(e,"P",{"data-svelte-h":!0}),M(I)!=="svelte-1hahfn0"&&(I.textContent=Xt),Ze=a(e),d=i(e,"UL",{"data-svelte-h":!0}),M(d)!=="svelte-1ivcbtp"&&(d.innerHTML=Vt),We=a(e),C=i(e,"P",{"data-svelte-h":!0}),M(C)!=="svelte-1jogm5f"&&(C.textContent=zt),ke=a(e),m(f.$$.fragment,e),$e=a(e),b=i(e,"P",{"data-svelte-h":!0}),M(b)!=="svelte-1hepwaf"&&(b.innerHTML=Nt),_e=a(e),g=i(e,"P",{"data-svelte-h":!0}),M(g)!=="svelte-1s9dc42"&&(g.innerHTML=St),He=a(e),x=i(e,"P",{"data-svelte-h":!0}),M(x)!=="svelte-16q26vx"&&(x.innerHTML=Qt),Xe=a(e),A=i(e,"P",{"data-svelte-h":!0}),M(A)!=="svelte-vz83yd"&&(A.textContent=Et),Ve=a(e),v=i(e,"UL",{"data-svelte-h":!0}),M(v)!=="svelte-1z4h5r"&&(v.innerHTML=Rt),ze=a(e),B=i(e,"P",{"data-svelte-h":!0}),M(B)!=="svelte-i8skpg"&&(B.textContent=Yt),Ne=a(e),G=i(e,"P",{"data-svelte-h":!0}),M(G)!=="svelte-121tgcd"&&(G.textContent=Lt),Se=a(e),m(Z.$$.fragment,e),Qe=a(e),W=i(e,"P",{"data-svelte-h":!0}),M(W)!=="svelte-1j7pdia"&&(W.textContent=Ft),Ee=a(e),k=i(e,"P",{"data-svelte-h":!0}),M(k)!=="svelte-wxy07q"&&(k.textContent=qt),Re=a(e),m($.$$.fragment,e),Ye=a(e),_=i(e,"P",{"data-svelte-h":!0}),M(_)!=="svelte-16smhm8"&&(_.innerHTML=Pt),Le=a(e),H=i(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-1jkprhy"&&(H.innerHTML=Kt),Fe=a(e),X=i(e,"P",{"data-svelte-h":!0}),M(X)!=="svelte-1lo2b6p"&&(X.textContent=Dt),qe=a(e),m(V.$$.fragment,e),Pe=a(e),z=i(e,"P",{"data-svelte-h":!0}),M(z)!=="svelte-8c3of4"&&(z.textContent=Ot),Ke=a(e),N=i(e,"P",{"data-svelte-h":!0}),M(N)!=="svelte-1kcpd2e"&&(N.innerHTML=el),De=a(e),m(S.$$.fragment,e),Oe=a(e),m(Q.$$.fragment,e),et=a(e),E=i(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-mi975y"&&(E.textContent=tl),tt=a(e),m(R.$$.fragment,e),lt=a(e),Y=i(e,"P",{"data-svelte-h":!0}),M(Y)!=="svelte-zmj8oy"&&(Y.innerHTML=ll),nt=a(e),L=i(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-1hs4joy"&&(L.textContent=nl),st=a(e),F=i(e,"P",{"data-svelte-h":!0}),M(F)!=="svelte-13xxwf3"&&(F.textContent=sl),at=a(e),q=i(e,"P",{"data-svelte-h":!0}),M(q)!=="svelte-13q3i6n"&&(q.innerHTML=al),ot=a(e),P=i(e,"P",{"data-svelte-h":!0}),M(P)!=="svelte-mdqsxr"&&(P.textContent=ol),it=a(e),K=i(e,"P",{"data-svelte-h":!0}),M(K)!=="svelte-12eo3v5"&&(K.textContent=il),Mt=a(e),D=i(e,"P",{"data-svelte-h":!0}),M(D)!=="svelte-qqihmw"&&(D.textContent=Ml),pt=a(e),O=i(e,"P",{"data-svelte-h":!0}),M(O)!=="svelte-13dz4vh"&&(O.textContent=pl),mt=a(e),ee=i(e,"P",{"data-svelte-h":!0}),M(ee)!=="svelte-exk3d9"&&(ee.innerHTML=ml),rt=a(e),m(te.$$.fragment,e),wt=a(e),le=i(e,"P",{"data-svelte-h":!0}),M(le)!=="svelte-a6bs6o"&&(le.innerHTML=rl),yt=a(e),ne=i(e,"P",{"data-svelte-h":!0}),M(ne)!=="svelte-zz3frh"&&(ne.textContent=wl),ht=a(e),m(se.$$.fragment,e),ut=a(e),ae=i(e,"P",{"data-svelte-h":!0}),M(ae)!=="svelte-1ps6mip"&&(ae.innerHTML=yl),Tt=a(e),m(oe.$$.fragment,e),Jt=a(e),ie=i(e,"P",{"data-svelte-h":!0}),M(ie)!=="svelte-1y7mxpx"&&(ie.textContent=hl),ct=a(e),Me=i(e,"UL",{"data-svelte-h":!0}),M(Me)!=="svelte-a4n5id"&&(Me.innerHTML=ul),jt=a(e),pe=i(e,"P",{"data-svelte-h":!0}),M(pe)!=="svelte-k217aq"&&(pe.textContent=Tl),Ut=a(e),m(me.$$.fragment,e),It=a(e),m(re.$$.fragment,e),dt=a(e),we=i(e,"P",{"data-svelte-h":!0}),M(we)!=="svelte-1ezk4g0"&&(we.innerHTML=Jl),Ct=a(e),ye=i(e,"P",{"data-svelte-h":!0}),M(ye)!=="svelte-1e1yopm"&&(ye.innerHTML=cl),ft=a(e),he=i(e,"P",{"data-svelte-h":!0}),M(he)!=="svelte-1xcz5ok"&&(he.innerHTML=jl),bt=a(e),ue=i(e,"P",{"data-svelte-h":!0}),M(ue)!=="svelte-1v5xgsn"&&(ue.textContent=Ul),gt=a(e),m(Te.$$.fragment,e),xt=a(e),Je=i(e,"P",{"data-svelte-h":!0}),M(Je)!=="svelte-1hfx6dq"&&(Je.textContent=Il),At=a(e),ce=i(e,"P",{"data-svelte-h":!0}),M(ce)!=="svelte-ffg1bu"&&(ce.textContent=dl),vt=a(e),m(je.$$.fragment,e),Bt=a(e),Ue=i(e,"P",{"data-svelte-h":!0}),M(Ue)!=="svelte-hnyltz"&&(Ue.textContent=Cl),Gt=a(e),m(Ie.$$.fragment,e),Zt=xl(e,`
<Warning>
`),de=i(e,"P",{"data-svelte-h":!0}),M(de)!=="svelte-l0vp04"&&(de.innerHTML=fl),Wt=xl(e,`
</Warning>

`),fe=i(e,"P",{}),gl(fe).forEach(l),this.h()},h(){Al(T,"name","hf:doc:metadata"),Al(T,"content",Xl)},m(e,t){$l(document.head,T),n(e,ge,t),n(e,Ce,t),n(e,xe,t),r(J,e,t),n(e,Ae,t),r(c,e,t),n(e,ve,t),n(e,j,t),n(e,Be,t),n(e,U,t),n(e,Ge,t),n(e,I,t),n(e,Ze,t),n(e,d,t),n(e,We,t),n(e,C,t),n(e,ke,t),r(f,e,t),n(e,$e,t),n(e,b,t),n(e,_e,t),n(e,g,t),n(e,He,t),n(e,x,t),n(e,Xe,t),n(e,A,t),n(e,Ve,t),n(e,v,t),n(e,ze,t),n(e,B,t),n(e,Ne,t),n(e,G,t),n(e,Se,t),r(Z,e,t),n(e,Qe,t),n(e,W,t),n(e,Ee,t),n(e,k,t),n(e,Re,t),r($,e,t),n(e,Ye,t),n(e,_,t),n(e,Le,t),n(e,H,t),n(e,Fe,t),n(e,X,t),n(e,qe,t),r(V,e,t),n(e,Pe,t),n(e,z,t),n(e,Ke,t),n(e,N,t),n(e,De,t),r(S,e,t),n(e,Oe,t),r(Q,e,t),n(e,et,t),n(e,E,t),n(e,tt,t),r(R,e,t),n(e,lt,t),n(e,Y,t),n(e,nt,t),n(e,L,t),n(e,st,t),n(e,F,t),n(e,at,t),n(e,q,t),n(e,ot,t),n(e,P,t),n(e,it,t),n(e,K,t),n(e,Mt,t),n(e,D,t),n(e,pt,t),n(e,O,t),n(e,mt,t),n(e,ee,t),n(e,rt,t),r(te,e,t),n(e,wt,t),n(e,le,t),n(e,yt,t),n(e,ne,t),n(e,ht,t),r(se,e,t),n(e,ut,t),n(e,ae,t),n(e,Tt,t),r(oe,e,t),n(e,Jt,t),n(e,ie,t),n(e,ct,t),n(e,Me,t),n(e,jt,t),n(e,pe,t),n(e,Ut,t),r(me,e,t),n(e,It,t),r(re,e,t),n(e,dt,t),n(e,we,t),n(e,Ct,t),n(e,ye,t),n(e,ft,t),n(e,he,t),n(e,bt,t),n(e,ue,t),n(e,gt,t),r(Te,e,t),n(e,xt,t),n(e,Je,t),n(e,At,t),n(e,ce,t),n(e,vt,t),r(je,e,t),n(e,Bt,t),n(e,Ue,t),n(e,Gt,t),r(Ie,e,t),n(e,Zt,t),n(e,de,t),n(e,Wt,t),n(e,fe,t),kt=!0},p:Bl,i(e){kt||(w(J.$$.fragment,e),w(c.$$.fragment,e),w(f.$$.fragment,e),w(Z.$$.fragment,e),w($.$$.fragment,e),w(V.$$.fragment,e),w(S.$$.fragment,e),w(Q.$$.fragment,e),w(R.$$.fragment,e),w(te.$$.fragment,e),w(se.$$.fragment,e),w(oe.$$.fragment,e),w(me.$$.fragment,e),w(re.$$.fragment,e),w(Te.$$.fragment,e),w(je.$$.fragment,e),w(Ie.$$.fragment,e),kt=!0)},o(e){y(J.$$.fragment,e),y(c.$$.fragment,e),y(f.$$.fragment,e),y(Z.$$.fragment,e),y($.$$.fragment,e),y(V.$$.fragment,e),y(S.$$.fragment,e),y(Q.$$.fragment,e),y(R.$$.fragment,e),y(te.$$.fragment,e),y(se.$$.fragment,e),y(oe.$$.fragment,e),y(me.$$.fragment,e),y(re.$$.fragment,e),y(Te.$$.fragment,e),y(je.$$.fragment,e),y(Ie.$$.fragment,e),kt=!1},d(e){e&&(l(ge),l(Ce),l(xe),l(Ae),l(ve),l(j),l(Be),l(U),l(Ge),l(I),l(Ze),l(d),l(We),l(C),l(ke),l($e),l(b),l(_e),l(g),l(He),l(x),l(Xe),l(A),l(Ve),l(v),l(ze),l(B),l(Ne),l(G),l(Se),l(Qe),l(W),l(Ee),l(k),l(Re),l(Ye),l(_),l(Le),l(H),l(Fe),l(X),l(qe),l(Pe),l(z),l(Ke),l(N),l(De),l(Oe),l(et),l(E),l(tt),l(lt),l(Y),l(nt),l(L),l(st),l(F),l(at),l(q),l(ot),l(P),l(it),l(K),l(Mt),l(D),l(pt),l(O),l(mt),l(ee),l(rt),l(wt),l(le),l(yt),l(ne),l(ht),l(ut),l(ae),l(Tt),l(Jt),l(ie),l(ct),l(Me),l(jt),l(pe),l(Ut),l(It),l(dt),l(we),l(Ct),l(ye),l(ft),l(he),l(bt),l(ue),l(gt),l(xt),l(Je),l(At),l(ce),l(vt),l(Bt),l(Ue),l(Gt),l(Zt),l(de),l(Wt),l(fe)),l(T),h(J,e),h(c,e),h(f,e),h(Z,e),h($,e),h(V,e),h(S,e),h(Q,e),h(R,e),h(te,e),h(se,e),h(oe,e),h(me,e),h(re,e),h(Te,e),h(je,e),h(Ie,e)}}}const Xl='{"title":"Create your own chatbot with llama-2-13B on AWS Inferentia","local":"create-your-own-chatbot-with-llama-2-13b-on-aws-inferentia","sections":[{"title":"1. Export the Llama 2 model to Neuron","local":"1-export-the-llama-2-model-to-neuron","sections":[{"title":"A few more words about export parameters.","local":"a-few-more-words-about-export-parameters","sections":[],"depth":3}],"depth":2},{"title":"2. Generate text using Llama 2 on AWS Inferentia2","local":"2-generate-text-using-llama-2-on-aws-inferentia2","sections":[],"depth":2},{"title":"3. Create a chat application using llama on AWS Inferentia2","local":"3-create-a-chat-application-using-llama-on-aws-inferentia2","sections":[],"depth":2}],"depth":1}';function Vl($t){return Gl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Rl extends Zl{constructor(T){super(),Wl(this,T,Vl,Hl,vl,{})}}export{Rl as component};
