Buckets:
| import{s as cn,n as wn,o as fn}from"../chunks/scheduler.56725da7.js";import{S as dn,i as jn,e as o,s,c as r,h as Un,a as i,d as l,b as a,f as hn,g as m,j as p,k as yn,l as Tn,m as n,n as M,t as u,o as h,p as y}from"../chunks/index.18a26576.js";import{C as bn}from"../chunks/CopyLLMTxtMenu.fb3856d8.js";import{C as c}from"../chunks/CodeBlock.2d00672f.js";import{H as ze}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.a16844e0.js";function Jn(hl){let w,Ne,Se,Le,f,Ye,d,Re,j,yl="This guide will detail how to export, deploy and run a <strong>LLama-2 13B</strong> chat model on AWS inferentia.",Qe,U,cl="You will learn how to:",Ee,T,wl="<li>set up your AWS instance,</li> <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>",qe,b,fl="Note: This tutorial was created on a inf2.48xlarge AWS EC2 Instance.",Fe,J,Pe,C,dl="<em>you can skip that section if you are already running this notebook on your instance.</em>",Ke,g,jl='In this example, we will use the <em>inf2.48xlarge</em> instance with 12 Neuron devices, corresponding to 24 Neuron Cores and the <a href="https://aws.amazon.com/marketplace/pp/prodview-gr3e6yiscria2" rel="nofollow">Hugging Face Neuron Deep Learning AMI</a>.',De,v,Ul=`This guide doesn’t cover how to create the instance in detail. You can refer to the <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html" rel="nofollow">offical documentation</a>. At step 4. you will select the | |
| <a href="https://aws.amazon.com/marketplace/pp/prodview-gr3e6yiscria2" rel="nofollow">Hugging Face Neuron Deep Learning AMI</a> and at step 5. you will select an <em>inf2</em> instance type.`,Oe,x,Tl="Once the instance is up and running, you can ssh into it. But instead of developing inside a terminal you need to launch a Jupyter server to run this notebook.",et,I,bl="For this, you need first to add a port for forwarding in the ssh command, which will tunnel our localhost traffic to the AWS instance.",tt,$,Jl="From a local terminal, type the following commands:",lt,B,nt,G,Cl="On the instance, you can now start the jupyter server.",st,k,at,W,gl="You should see a familiar jupyter output with a URL.",ot,Z,vl="You can click on it, and a jupyter environment will open in your local browser.",it,A,xl="You can then browse to this notebook (<code>notebooks/text-generation/llama2-13-chatbot</code>) to continue with the guide.",pt,H,rt,_,mt,X,Il='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>.',Mt,z,$l=`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).`,ut,S,Bl=`As explained in the <a href="https://huggingface.co/docs/optimum-neuron/guides/export_model#why-compile-to-neuron-model" rel="nofollow">optimum-neuron documentation</a> | |
| , models need to be compiled and exported to a serialized format before running them on Neuron devices.`,ht,V,Gl=`Fortunately, 🤗 <strong>optimum-neuron</strong> offers a <a href="https://huggingface.co/docs/optimum-neuron/guides/models#configuring-the-export-of-a-generative-model" rel="nofollow">very simple API</a> | |
| to export standard 🤗 <a href="https://huggingface.co/docs/transformers/index" rel="nofollow">transformers models</a> to the Neuron format.`,yt,N,kl="When exporting the model, we will specify two sets of parameters:",ct,L,Wl=`<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>`,wt,Y,Zl="Depending on your choice of parameters and inferentia host, this may take from a few minutes to more than an hour.",ft,R,Al="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.",dt,Q,jt,E,Hl="This probably took a while.",Ut,q,_l="Fortunately, you will need to do this only once because you can save your model and reload it later.",Tt,F,bt,P,Xl='Even better, you can push it to the <a href="https://huggingface.co/models" rel="nofollow">Hugging Face hub</a>.',Jt,K,zl='For that, you need to be logged in to a <a href="https://huggingface.co/join" rel="nofollow">HuggingFace account</a>.',Ct,D,Sl="If you are not connected already on your instance, you will now be prompted for an access token.",gt,O,vt,ee,Vl="By default, the model will be uploaded to your account (organization equal to your user name).",xt,te,Nl='Feel free to edit the cell 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>.',It,le,$t,ne,Bt,se,Ll="The minimum memory required to load a model can be computed with:",Gt,ae,kt,oe,Yl="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.",Wt,ie,Rl="Each NeuronCore has 16GB of memory which means that a 26GB model cannot fit on a single NeuronCore.",Zt,pe,Ql=`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,re,El="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).",Ht,me,ql="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.",_t,Me,Fl="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.",Xt,ue,Pl=`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.`,zt,he,Kl="To optimize performance it’s recommended to use all cores available on the instance.",St,ye,Dl=`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.`,Vt,ce,Nt,we,Ol='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>.',Lt,fe,en="If as suggested you skipped the first section, don’t worry: we will use a precompiled model already present on the hub instead.",Yt,de,Rt,je,tn="We will need a <em>Llama 2</em> tokenizer to convert the prompt strings to text tokens.",Qt,Ue,Et,Te,ln="The following generation strategies are supported:",qt,be,nn="<li>greedy search,</li> <li>multinomial sampling with top-k and top-p (with temperature).</li>",Ft,Je,sn="Most logits pre-processing/filters (such as repetition penalty) are supported.",Pt,Ce,Kt,ge,Dt,ve,an="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.",Ot,xe,on="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.",el,Ie,pn='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.',tl,$e,rn="The utility function below converts a list of exchanges between the user and the model into a well-formatted chat prompt.",ll,Be,nl,Ge,mn="We are now equipped to build a simplistic chat application.",sl,ke,Mn=`We simply store the interactions between the user and the assistant in a list that we use to generate | |
| the input prompt.`,al,We,ol,Ze,il,Ae,pl,He,rl,_e,un="<strong>Warning</strong>: 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.",ml,Xe,Ml,Ve,ul;return f=new bn({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),d=new ze({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"}}),J=new ze({props:{title:"Prerequisite: Setup AWS environment",local:"prerequisite-setup-aws-environment",headingTag:"h2"}}),B=new c({props:{code:"SE9TVE5BTUUlM0QlMjIlMjIlMjAlMjMlMjBJUCUyMGFkZHJlc3MlMkMlMjBlLmcuJTIwZWMyLTMtODAtLi4uLiUwQUtFWV9QQVRIJTNEJTIyJTIyJTIwJTIzJTIwbG9jYWwlMjBwYXRoJTIwdG8lMjBrZXklMkMlMjBlLmcuJTIwc3NoJTJGdHJuLnBlbSUwQSUwQXNzaCUyMC1MJTIwODA4MCUzQWxvY2FsaG9zdCUzQTgwODAlMjAtaSUyMCUyNCU3QktFWV9OQU1FJTdELnBlbSUyMHVidW50dSU0MCUyNEhPU1ROQU1F",highlighted:`HOSTNAME="" # IP address, e.g. ec2-3-80-.... | |
| KEY_PATH="" # local path to key, e.g. ssh/trn.pem | |
| ssh -L 8080:localhost:8080 -i \${KEY_NAME}.pem ubuntu@$HOSTNAME`,wrap:!1}}),k=new c({props:{code:"cHl0aG9uJTIwLW0lMjBub3RlYm9vayUyMC0tYWxsb3ctcm9vdCUyMC0tcG9ydCUzRDgwODA=",highlighted:'<span class="hljs-attribute">python</span> -m notebook --<span class="hljs-literal">allow</span>-root --port=<span class="hljs-number">8080</span>',wrap:!1}}),H=new c({props:{code:"JTIzJTIwU3BlY2lhbCUyMHdpZGdldHMlMjBhcmUlMjByZXF1aXJlZCUyMGZvciUyMGElMjBuaWNlciUyMGRpc3BsYXklMEEhJTdCc3lzLmV4ZWN1dGFibGUlN0QlMjAtbSUyMHBpcCUyMGluc3RhbGwlMjBpcHl3aWRnZXRz",highlighted:`<span class="hljs-comment"># Special widgets are required for a nicer display</span> | |
| !{sys.executable} -m pip install ipywidgets`,wrap:!1}}),_=new ze({props:{title:"1. Export the Llama 2 model to Neuron",local:"1-export-the-llama-2-model-to-neuron",headingTag:"h2"}}),Q=new c({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uTW9kZWxGb3JDYXVzYWxMTSUwQSUwQSUwQWNvbXBpbGVyX2FyZ3MlMjAlM0QlMjAlN0IlMjJudW1fY29yZXMlMjIlM0ElMjAyNCUyQyUyMCUyMmF1dG9fY2FzdF90eXBlJTIyJTNBJTIwJTIyZnAxNiUyMiU3RCUwQWlucHV0X3NoYXBlcyUyMCUzRCUyMCU3QiUyMmJhdGNoX3NpemUlMjIlM0ElMjAxJTJDJTIwJTIyc2VxdWVuY2VfbGVuZ3RoJTIyJTNBJTIwMjA0OCU3RCUwQW1vZGVsJTIwJTNEJTIwTmV1cm9uTW9kZWxGb3JDYXVzYWxMTS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyTm91c1Jlc2VhcmNoJTJGTGxhbWEtMi0xM2ItY2hhdC1oZiUyMiUyQyUyMGV4cG9ydCUzRFRydWUlMkMlMjAqKmNvbXBpbGVyX2FyZ3MlMkMlMjAqKmlucHV0X3NoYXBlcyUwQSk=",highlighted:`<span class="hljs-keyword">from</span> optimum.neuron <span class="hljs-keyword">import</span> NeuronModelForCausalLM | |
| compiler_args = {<span class="hljs-string">"num_cores"</span>: <span class="hljs-number">24</span>, <span class="hljs-string">"auto_cast_type"</span>: <span class="hljs-string">"fp16"</span>} | |
| input_shapes = {<span class="hljs-string">"batch_size"</span>: <span class="hljs-number">1</span>, <span class="hljs-string">"sequence_length"</span>: <span class="hljs-number">2048</span>} | |
| model = NeuronModelForCausalLM.from_pretrained( | |
| <span class="hljs-string">"NousResearch/Llama-2-13b-chat-hf"</span>, export=<span class="hljs-literal">True</span>, **compiler_args, **input_shapes | |
| )`,wrap:!1}}),F=new c({props:{code:"bW9kZWwuc2F2ZV9wcmV0cmFpbmVkKCUyMmxsYW1hLTItMTNiLWNoYXQtbmV1cm9uJTIyKQ==",highlighted:'model.save_pretrained(<span class="hljs-string">"llama-2-13b-chat-neuron"</span>)',wrap:!1}}),O=new c({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMG5vdGVib29rX2xvZ2luJTBBJTBBJTBBbm90ZWJvb2tfbG9naW4obmV3X3Nlc3Npb24lM0RGYWxzZSk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> notebook_login | |
| notebook_login(new_session=<span class="hljs-literal">False</span>)`,wrap:!1}}),le=new c({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHdob2FtaSUwQSUwQSUwQW9yZyUyMCUzRCUyMHdob2FtaSgpJTVCJTIybmFtZSUyMiU1RCUwQSUwQXJlcG9faWQlMjAlM0QlMjBmJTIyJTdCb3JnJTdEJTJGbGxhbWEtMi0xM2ItY2hhdC1uZXVyb24lMjIlMEElMEFtb2RlbC5wdXNoX3RvX2h1YiglMjJsbGFtYS0yLTEzYi1jaGF0LW5ldXJvbiUyMiUyQyUyMHJlcG9zaXRvcnlfaWQlM0RyZXBvX2lkKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> whoami | |
| org = whoami()[<span class="hljs-string">"name"</span>] | |
| repo_id = <span class="hljs-string">f"<span class="hljs-subst">{org}</span>/llama-2-13b-chat-neuron"</span> | |
| model.push_to_hub(<span class="hljs-string">"llama-2-13b-chat-neuron"</span>, repository_id=repo_id)`,wrap:!1}}),ne=new ze({props:{title:"A few more words about export parameters.",local:"a-few-more-words-about-export-parameters",headingTag:"h3"}}),ae=new c({props:{code:"JTIwJTIwJTIwbWVtb3J5JTIwJTNEJTIwYnl0ZXMlMjBwZXIlMjBwYXJhbWV0ZXIlMjAqJTIwbnVtYmVyJTIwb2YlMjBwYXJhbWV0ZXJz",highlighted:' memory = bytes per <span class="hljs-keyword">parameter</span> * <span class="hljs-keyword">number</span> of parameters',wrap:!1}}),ce=new ze({props:{title:"2. Generate text using Llama 2 on AWS Inferentia2",local:"2-generate-text-using-llama-2-on-aws-inferentia2",headingTag:"h2"}}),de=new c({props:{code:"ZnJvbSUyMG9wdGltdW0ubmV1cm9uJTIwaW1wb3J0JTIwTmV1cm9uTW9kZWxGb3JDYXVzYWxMTSUwQSUwQSUwQXRyeSUzQSUwQSUyMCUyMCUyMCUyMG1vZGVsJTBBZXhjZXB0JTIwTmFtZUVycm9yJTNBJTBBJTIwJTIwJTIwJTIwJTIzJTIwRWRpdCUyMHRoaXMlMjB0byUyMHVzZSUyMGFub3RoZXIlMjBiYXNlJTIwbW9kZWwlMEElMjAlMjAlMjAlMjBtb2RlbCUyMCUzRCUyME5ldXJvbk1vZGVsRm9yQ2F1c2FsTE0uZnJvbV9wcmV0cmFpbmVkKCUyMmF3cy1uZXVyb24lMkZMbGFtYS0yLTEzYi1jaGF0LWhmLW5ldXJvbi1sYXRlbmN5JTIyKQ==",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">"aws-neuron/Llama-2-13b-chat-hf-neuron-latency"</span>)`,wrap:!1}}),Ue=new c({props:{code:"ZnJvbSUyMHRyYW5zZm9ybWVycyUyMGltcG9ydCUyMEF1dG9Ub2tlbml6ZXIlMEElMEElMEF0b2tlbml6ZXIlMjAlM0QlMjBBdXRvVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMjJOb3VzUmVzZWFyY2glMkZMbGFtYS0yLTEzYi1jaGF0LWhmJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained(<span class="hljs-string">"NousResearch/Llama-2-13b-chat-hf"</span>)`,wrap:!1}}),Ce=new c({props:{code:"aW5wdXRzJTIwJTNEJTIwdG9rZW5pemVyKCUyMldoYXQlMjBpcyUyMGRlZXAtbGVhcm5pbmclMjAlM0YlMjIlMkMlMjByZXR1cm5fdGVuc29ycyUzRCUyMnB0JTIyKSUwQW91dHB1dHMlMjAlM0QlMjBtb2RlbC5nZW5lcmF0ZSgqKmlucHV0cyUyQyUyMG1heF9uZXdfdG9rZW5zJTNEMTI4JTJDJTIwZG9fc2FtcGxlJTNEVHJ1ZSUyQyUyMHRlbXBlcmF0dXJlJTNEMC45JTJDJTIwdG9wX2slM0Q1MCUyQyUyMHRvcF9wJTNEMC45KSUwQXRva2VuaXplci5iYXRjaF9kZWNvZGUob3V0cHV0cyUyQyUyMHNraXBfc3BlY2lhbF90b2tlbnMlM0RUcnVlKQ==",highlighted:`inputs = tokenizer(<span class="hljs-string">"What is deep-learning ?"</span>, return_tensors=<span class="hljs-string">"pt"</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}}),ge=new ze({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"}}),Be=new c({props:{code:"ZGVmJTIwZm9ybWF0X2NoYXRfcHJvbXB0KG1lc3NhZ2UlMkMlMjBoaXN0b3J5JTJDJTIwbWF4X3Rva2VucyklM0ElMEElMjAlMjAlMjAlMjAlMjIlMjIlMjJDb252ZXJ0JTIwYSUyMGhpc3RvcnklMjBvZiUyMG1lc3NhZ2VzJTIwdG8lMjBhJTIwY2hhdCUyMHByb21wdCUwQSUyMCUyMCUyMCUyMEFyZ3MlM0ElMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBtZXNzYWdlKHN0ciklM0ElMjB0aGUlMjBuZXclMjB1c2VyJTIwbWVzc2FnZS4lMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBoaXN0b3J5JTIwKExpc3QlNUJzdHIlNUQpJTNBJTIwdGhlJTIwbGlzdCUyMG9mJTIwdXNlciUyMG1lc3NhZ2VzJTIwYW5kJTIwYXNzaXN0YW50JTIwcmVzcG9uc2VzLiUwQS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lMjAlMjAlMjByYWlzZSUyMFN5c3RlbUVycm9y",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">"""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. | |
| """</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">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: interaction[<span class="hljs-number">0</span>]}) | |
| chat.append({<span class="hljs-string">"role"</span>: <span class="hljs-string">"assistant"</span>, <span class="hljs-string">"content"</span>: interaction[<span class="hljs-number">1</span>]}) | |
| <span class="hljs-comment"># Add the new message</span> | |
| chat.append({<span class="hljs-string">"role"</span>: <span class="hljs-string">"user"</span>, <span class="hljs-string">"content"</span>: message}) | |
| <span class="hljs-comment"># Generate the prompt, verifying that we don'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're over the limit</span> | |
| tokens = tokenizer(prompt) | |
| <span class="hljs-keyword">if</span> <span class="hljs-built_in">len</span>(tokens.input_ids) <= max_tokens: | |
| <span class="hljs-comment"># We'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}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MCUyMCUyMHJlc3BvbnNlJTIwJTNEJTIwdG9rZW5pemVyLmRlY29kZShvdXRwdXRzJTJDJTIwc2tpcF9zcGVjaWFsX3Rva2VucyUzRFRydWUpJTBBJTIwJTIwJTIwJTIwaGlzdG9yeS5hcHBlbmQoJTVCbWVzc2FnZSUyQyUyMHJlc3BvbnNlJTVEKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMHJlc3BvbnNl",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">"pt"</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}}),Ze=new c({props:{code:"cHJpbnQoY2hhdCglMjJNeSUyMGZhdm9yaXRlJTIwY29sb3IlMjBpcyUyMGJsdWUuJTIwTXklMjBmYXZvcml0ZSUyMGZydWl0JTIwaXMlMjBzdHJhd2JlcnJ5LiUyMiUyQyUyMGhpc3RvcnklMkMlMjBtYXhfdG9rZW5zKSk=",highlighted:'<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">"My favorite color is blue. My favorite fruit is strawberry."</span>, history, max_tokens))',wrap:!1}}),Ae=new c({props:{code:"cHJpbnQoY2hhdCglMjJOYW1lJTIwYSUyMGZydWl0JTIwdGhhdCUyMGlzJTIwb24lMjBteSUyMGZhdm9yaXRlJTIwY29sb3VyLiUyMiUyQyUyMGhpc3RvcnklMkMlMjBtYXhfdG9rZW5zKSk=",highlighted:'<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">"Name a fruit that is on my favorite colour."</span>, history, max_tokens))',wrap:!1}}),He=new c({props:{code:"cHJpbnQoY2hhdCglMjJXaGF0JTIwaXMlMjB0aGUlMjBjb2xvdXIlMjBvZiUyMG15JTIwZmF2b3JpdGUlMjBmcnVpdCUyMCUzRiUyMiUyQyUyMGhpc3RvcnklMkMlMjBtYXhfdG9rZW5zKSk=",highlighted:'<span class="hljs-built_in">print</span>(chat(<span class="hljs-string">"What is the colour of my favorite fruit ?"</span>, history, max_tokens))',wrap:!1}}),Xe=new c({props:{code:"",highlighted:"",wrap:!1}}),{c(){w=o("meta"),Ne=s(),Se=o("p"),Le=s(),r(f.$$.fragment),Ye=s(),r(d.$$.fragment),Re=s(),j=o("p"),j.innerHTML=yl,Qe=s(),U=o("p"),U.textContent=cl,Ee=s(),T=o("ul"),T.innerHTML=wl,qe=s(),b=o("p"),b.textContent=fl,Fe=s(),r(J.$$.fragment),Pe=s(),C=o("p"),C.innerHTML=dl,Ke=s(),g=o("p"),g.innerHTML=jl,De=s(),v=o("p"),v.innerHTML=Ul,Oe=s(),x=o("p"),x.textContent=Tl,et=s(),I=o("p"),I.textContent=bl,tt=s(),$=o("p"),$.textContent=Jl,lt=s(),r(B.$$.fragment),nt=s(),G=o("p"),G.textContent=Cl,st=s(),r(k.$$.fragment),at=s(),W=o("p"),W.textContent=gl,ot=s(),Z=o("p"),Z.textContent=vl,it=s(),A=o("p"),A.innerHTML=xl,pt=s(),r(H.$$.fragment),rt=s(),r(_.$$.fragment),mt=s(),X=o("p"),X.innerHTML=Il,Mt=s(),z=o("p"),z.innerHTML=$l,ut=s(),S=o("p"),S.innerHTML=Bl,ht=s(),V=o("p"),V.innerHTML=Gl,yt=s(),N=o("p"),N.textContent=kl,ct=s(),L=o("ul"),L.innerHTML=Wl,wt=s(),Y=o("p"),Y.textContent=Zl,ft=s(),R=o("p"),R.textContent=Al,dt=s(),r(Q.$$.fragment),jt=s(),E=o("p"),E.textContent=Hl,Ut=s(),q=o("p"),q.textContent=_l,Tt=s(),r(F.$$.fragment),bt=s(),P=o("p"),P.innerHTML=Xl,Jt=s(),K=o("p"),K.innerHTML=zl,Ct=s(),D=o("p"),D.textContent=Sl,gt=s(),r(O.$$.fragment),vt=s(),ee=o("p"),ee.textContent=Vl,xt=s(),te=o("p"),te.innerHTML=Nl,It=s(),r(le.$$.fragment),$t=s(),r(ne.$$.fragment),Bt=s(),se=o("p"),se.textContent=Ll,Gt=s(),r(ae.$$.fragment),kt=s(),oe=o("p"),oe.innerHTML=Yl,Wt=s(),ie=o("p"),ie.textContent=Rl,Zt=s(),pe=o("p"),pe.textContent=Ql,At=s(),re=o("p"),re.innerHTML=El,Ht=s(),me=o("p"),me.textContent=ql,_t=s(),Me=o("p"),Me.textContent=Fl,Xt=s(),ue=o("p"),ue.textContent=Pl,zt=s(),he=o("p"),he.textContent=Kl,St=s(),ye=o("p"),ye.innerHTML=Dl,Vt=s(),r(ce.$$.fragment),Nt=s(),we=o("p"),we.innerHTML=Ol,Lt=s(),fe=o("p"),fe.textContent=en,Yt=s(),r(de.$$.fragment),Rt=s(),je=o("p"),je.innerHTML=tn,Qt=s(),r(Ue.$$.fragment),Et=s(),Te=o("p"),Te.textContent=ln,qt=s(),be=o("ul"),be.innerHTML=nn,Ft=s(),Je=o("p"),Je.textContent=sn,Pt=s(),r(Ce.$$.fragment),Kt=s(),r(ge.$$.fragment),Dt=s(),ve=o("p"),ve.innerHTML=an,Ot=s(),xe=o("p"),xe.innerHTML=on,el=s(),Ie=o("p"),Ie.innerHTML=pn,tl=s(),$e=o("p"),$e.textContent=rn,ll=s(),r(Be.$$.fragment),nl=s(),Ge=o("p"),Ge.textContent=mn,sl=s(),ke=o("p"),ke.textContent=Mn,al=s(),r(We.$$.fragment),ol=s(),r(Ze.$$.fragment),il=s(),r(Ae.$$.fragment),pl=s(),r(He.$$.fragment),rl=s(),_e=o("p"),_e.innerHTML=un,ml=s(),r(Xe.$$.fragment),Ml=s(),Ve=o("p"),this.h()},l(e){const t=Un("svelte-u9bgzb",document.head);w=i(t,"META",{name:!0,content:!0}),t.forEach(l),Ne=a(e),Se=i(e,"P",{}),hn(Se).forEach(l),Le=a(e),m(f.$$.fragment,e),Ye=a(e),m(d.$$.fragment,e),Re=a(e),j=i(e,"P",{"data-svelte-h":!0}),p(j)!=="svelte-1skq0wn"&&(j.innerHTML=yl),Qe=a(e),U=i(e,"P",{"data-svelte-h":!0}),p(U)!=="svelte-1hahfn0"&&(U.textContent=cl),Ee=a(e),T=i(e,"UL",{"data-svelte-h":!0}),p(T)!=="svelte-1ph7922"&&(T.innerHTML=wl),qe=a(e),b=i(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-1jogm5f"&&(b.textContent=fl),Fe=a(e),m(J.$$.fragment,e),Pe=a(e),C=i(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-1h04ij0"&&(C.innerHTML=dl),Ke=a(e),g=i(e,"P",{"data-svelte-h":!0}),p(g)!=="svelte-gte1ah"&&(g.innerHTML=jl),De=a(e),v=i(e,"P",{"data-svelte-h":!0}),p(v)!=="svelte-10g2ajd"&&(v.innerHTML=Ul),Oe=a(e),x=i(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-fcgwlz"&&(x.textContent=Tl),et=a(e),I=i(e,"P",{"data-svelte-h":!0}),p(I)!=="svelte-1t7xa18"&&(I.textContent=bl),tt=a(e),$=i(e,"P",{"data-svelte-h":!0}),p($)!=="svelte-h9klj4"&&($.textContent=Jl),lt=a(e),m(B.$$.fragment,e),nt=a(e),G=i(e,"P",{"data-svelte-h":!0}),p(G)!=="svelte-1sov39d"&&(G.textContent=Cl),st=a(e),m(k.$$.fragment,e),at=a(e),W=i(e,"P",{"data-svelte-h":!0}),p(W)!=="svelte-r6ohpb"&&(W.textContent=gl),ot=a(e),Z=i(e,"P",{"data-svelte-h":!0}),p(Z)!=="svelte-x30pyw"&&(Z.textContent=vl),it=a(e),A=i(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1w15e9h"&&(A.innerHTML=xl),pt=a(e),m(H.$$.fragment,e),rt=a(e),m(_.$$.fragment,e),mt=a(e),X=i(e,"P",{"data-svelte-h":!0}),p(X)!=="svelte-1hepwaf"&&(X.innerHTML=Il),Mt=a(e),z=i(e,"P",{"data-svelte-h":!0}),p(z)!=="svelte-1s9dc42"&&(z.innerHTML=$l),ut=a(e),S=i(e,"P",{"data-svelte-h":!0}),p(S)!=="svelte-mznum8"&&(S.innerHTML=Bl),ht=a(e),V=i(e,"P",{"data-svelte-h":!0}),p(V)!=="svelte-1infapy"&&(V.innerHTML=Gl),yt=a(e),N=i(e,"P",{"data-svelte-h":!0}),p(N)!=="svelte-vz83yd"&&(N.textContent=kl),ct=a(e),L=i(e,"UL",{"data-svelte-h":!0}),p(L)!=="svelte-1z4h5r"&&(L.innerHTML=Wl),wt=a(e),Y=i(e,"P",{"data-svelte-h":!0}),p(Y)!=="svelte-i8skpg"&&(Y.textContent=Zl),ft=a(e),R=i(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-121tgcd"&&(R.textContent=Al),dt=a(e),m(Q.$$.fragment,e),jt=a(e),E=i(e,"P",{"data-svelte-h":!0}),p(E)!=="svelte-12a4oka"&&(E.textContent=Hl),Ut=a(e),q=i(e,"P",{"data-svelte-h":!0}),p(q)!=="svelte-wxy07q"&&(q.textContent=_l),Tt=a(e),m(F.$$.fragment,e),bt=a(e),P=i(e,"P",{"data-svelte-h":!0}),p(P)!=="svelte-16smhm8"&&(P.innerHTML=Xl),Jt=a(e),K=i(e,"P",{"data-svelte-h":!0}),p(K)!=="svelte-1jkprhy"&&(K.innerHTML=zl),Ct=a(e),D=i(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-1ifk3wl"&&(D.textContent=Sl),gt=a(e),m(O.$$.fragment,e),vt=a(e),ee=i(e,"P",{"data-svelte-h":!0}),p(ee)!=="svelte-8c3of4"&&(ee.textContent=Vl),xt=a(e),te=i(e,"P",{"data-svelte-h":!0}),p(te)!=="svelte-dzb13l"&&(te.innerHTML=Nl),It=a(e),m(le.$$.fragment,e),$t=a(e),m(ne.$$.fragment,e),Bt=a(e),se=i(e,"P",{"data-svelte-h":!0}),p(se)!=="svelte-mi975y"&&(se.textContent=Ll),Gt=a(e),m(ae.$$.fragment,e),kt=a(e),oe=i(e,"P",{"data-svelte-h":!0}),p(oe)!=="svelte-zmj8oy"&&(oe.innerHTML=Yl),Wt=a(e),ie=i(e,"P",{"data-svelte-h":!0}),p(ie)!=="svelte-1hs4joy"&&(ie.textContent=Rl),Zt=a(e),pe=i(e,"P",{"data-svelte-h":!0}),p(pe)!=="svelte-13xxwf3"&&(pe.textContent=Ql),At=a(e),re=i(e,"P",{"data-svelte-h":!0}),p(re)!=="svelte-13q3i6n"&&(re.innerHTML=El),Ht=a(e),me=i(e,"P",{"data-svelte-h":!0}),p(me)!=="svelte-mdqsxr"&&(me.textContent=ql),_t=a(e),Me=i(e,"P",{"data-svelte-h":!0}),p(Me)!=="svelte-12eo3v5"&&(Me.textContent=Fl),Xt=a(e),ue=i(e,"P",{"data-svelte-h":!0}),p(ue)!=="svelte-qqihmw"&&(ue.textContent=Pl),zt=a(e),he=i(e,"P",{"data-svelte-h":!0}),p(he)!=="svelte-13dz4vh"&&(he.textContent=Kl),St=a(e),ye=i(e,"P",{"data-svelte-h":!0}),p(ye)!=="svelte-exk3d9"&&(ye.innerHTML=Dl),Vt=a(e),m(ce.$$.fragment,e),Nt=a(e),we=i(e,"P",{"data-svelte-h":!0}),p(we)!=="svelte-a6bs6o"&&(we.innerHTML=Ol),Lt=a(e),fe=i(e,"P",{"data-svelte-h":!0}),p(fe)!=="svelte-zz3frh"&&(fe.textContent=en),Yt=a(e),m(de.$$.fragment,e),Rt=a(e),je=i(e,"P",{"data-svelte-h":!0}),p(je)!=="svelte-1ps6mip"&&(je.innerHTML=tn),Qt=a(e),m(Ue.$$.fragment,e),Et=a(e),Te=i(e,"P",{"data-svelte-h":!0}),p(Te)!=="svelte-1y7mxpx"&&(Te.textContent=ln),qt=a(e),be=i(e,"UL",{"data-svelte-h":!0}),p(be)!=="svelte-a4n5id"&&(be.innerHTML=nn),Ft=a(e),Je=i(e,"P",{"data-svelte-h":!0}),p(Je)!=="svelte-k217aq"&&(Je.textContent=sn),Pt=a(e),m(Ce.$$.fragment,e),Kt=a(e),m(ge.$$.fragment,e),Dt=a(e),ve=i(e,"P",{"data-svelte-h":!0}),p(ve)!=="svelte-1ezk4g0"&&(ve.innerHTML=an),Ot=a(e),xe=i(e,"P",{"data-svelte-h":!0}),p(xe)!=="svelte-1e1yopm"&&(xe.innerHTML=on),el=a(e),Ie=i(e,"P",{"data-svelte-h":!0}),p(Ie)!=="svelte-1xcz5ok"&&(Ie.innerHTML=pn),tl=a(e),$e=i(e,"P",{"data-svelte-h":!0}),p($e)!=="svelte-1v5xgsn"&&($e.textContent=rn),ll=a(e),m(Be.$$.fragment,e),nl=a(e),Ge=i(e,"P",{"data-svelte-h":!0}),p(Ge)!=="svelte-1hfx6dq"&&(Ge.textContent=mn),sl=a(e),ke=i(e,"P",{"data-svelte-h":!0}),p(ke)!=="svelte-ffg1bu"&&(ke.textContent=Mn),al=a(e),m(We.$$.fragment,e),ol=a(e),m(Ze.$$.fragment,e),il=a(e),m(Ae.$$.fragment,e),pl=a(e),m(He.$$.fragment,e),rl=a(e),_e=i(e,"P",{"data-svelte-h":!0}),p(_e)!=="svelte-1b0u28j"&&(_e.innerHTML=un),ml=a(e),m(Xe.$$.fragment,e),Ml=a(e),Ve=i(e,"P",{}),hn(Ve).forEach(l),this.h()},h(){yn(w,"name","hf:doc:metadata"),yn(w,"content",Cn)},m(e,t){Tn(document.head,w),n(e,Ne,t),n(e,Se,t),n(e,Le,t),M(f,e,t),n(e,Ye,t),M(d,e,t),n(e,Re,t),n(e,j,t),n(e,Qe,t),n(e,U,t),n(e,Ee,t),n(e,T,t),n(e,qe,t),n(e,b,t),n(e,Fe,t),M(J,e,t),n(e,Pe,t),n(e,C,t),n(e,Ke,t),n(e,g,t),n(e,De,t),n(e,v,t),n(e,Oe,t),n(e,x,t),n(e,et,t),n(e,I,t),n(e,tt,t),n(e,$,t),n(e,lt,t),M(B,e,t),n(e,nt,t),n(e,G,t),n(e,st,t),M(k,e,t),n(e,at,t),n(e,W,t),n(e,ot,t),n(e,Z,t),n(e,it,t),n(e,A,t),n(e,pt,t),M(H,e,t),n(e,rt,t),M(_,e,t),n(e,mt,t),n(e,X,t),n(e,Mt,t),n(e,z,t),n(e,ut,t),n(e,S,t),n(e,ht,t),n(e,V,t),n(e,yt,t),n(e,N,t),n(e,ct,t),n(e,L,t),n(e,wt,t),n(e,Y,t),n(e,ft,t),n(e,R,t),n(e,dt,t),M(Q,e,t),n(e,jt,t),n(e,E,t),n(e,Ut,t),n(e,q,t),n(e,Tt,t),M(F,e,t),n(e,bt,t),n(e,P,t),n(e,Jt,t),n(e,K,t),n(e,Ct,t),n(e,D,t),n(e,gt,t),M(O,e,t),n(e,vt,t),n(e,ee,t),n(e,xt,t),n(e,te,t),n(e,It,t),M(le,e,t),n(e,$t,t),M(ne,e,t),n(e,Bt,t),n(e,se,t),n(e,Gt,t),M(ae,e,t),n(e,kt,t),n(e,oe,t),n(e,Wt,t),n(e,ie,t),n(e,Zt,t),n(e,pe,t),n(e,At,t),n(e,re,t),n(e,Ht,t),n(e,me,t),n(e,_t,t),n(e,Me,t),n(e,Xt,t),n(e,ue,t),n(e,zt,t),n(e,he,t),n(e,St,t),n(e,ye,t),n(e,Vt,t),M(ce,e,t),n(e,Nt,t),n(e,we,t),n(e,Lt,t),n(e,fe,t),n(e,Yt,t),M(de,e,t),n(e,Rt,t),n(e,je,t),n(e,Qt,t),M(Ue,e,t),n(e,Et,t),n(e,Te,t),n(e,qt,t),n(e,be,t),n(e,Ft,t),n(e,Je,t),n(e,Pt,t),M(Ce,e,t),n(e,Kt,t),M(ge,e,t),n(e,Dt,t),n(e,ve,t),n(e,Ot,t),n(e,xe,t),n(e,el,t),n(e,Ie,t),n(e,tl,t),n(e,$e,t),n(e,ll,t),M(Be,e,t),n(e,nl,t),n(e,Ge,t),n(e,sl,t),n(e,ke,t),n(e,al,t),M(We,e,t),n(e,ol,t),M(Ze,e,t),n(e,il,t),M(Ae,e,t),n(e,pl,t),M(He,e,t),n(e,rl,t),n(e,_e,t),n(e,ml,t),M(Xe,e,t),n(e,Ml,t),n(e,Ve,t),ul=!0},p:wn,i(e){ul||(u(f.$$.fragment,e),u(d.$$.fragment,e),u(J.$$.fragment,e),u(B.$$.fragment,e),u(k.$$.fragment,e),u(H.$$.fragment,e),u(_.$$.fragment,e),u(Q.$$.fragment,e),u(F.$$.fragment,e),u(O.$$.fragment,e),u(le.$$.fragment,e),u(ne.$$.fragment,e),u(ae.$$.fragment,e),u(ce.$$.fragment,e),u(de.$$.fragment,e),u(Ue.$$.fragment,e),u(Ce.$$.fragment,e),u(ge.$$.fragment,e),u(Be.$$.fragment,e),u(We.$$.fragment,e),u(Ze.$$.fragment,e),u(Ae.$$.fragment,e),u(He.$$.fragment,e),u(Xe.$$.fragment,e),ul=!0)},o(e){h(f.$$.fragment,e),h(d.$$.fragment,e),h(J.$$.fragment,e),h(B.$$.fragment,e),h(k.$$.fragment,e),h(H.$$.fragment,e),h(_.$$.fragment,e),h(Q.$$.fragment,e),h(F.$$.fragment,e),h(O.$$.fragment,e),h(le.$$.fragment,e),h(ne.$$.fragment,e),h(ae.$$.fragment,e),h(ce.$$.fragment,e),h(de.$$.fragment,e),h(Ue.$$.fragment,e),h(Ce.$$.fragment,e),h(ge.$$.fragment,e),h(Be.$$.fragment,e),h(We.$$.fragment,e),h(Ze.$$.fragment,e),h(Ae.$$.fragment,e),h(He.$$.fragment,e),h(Xe.$$.fragment,e),ul=!1},d(e){e&&(l(Ne),l(Se),l(Le),l(Ye),l(Re),l(j),l(Qe),l(U),l(Ee),l(T),l(qe),l(b),l(Fe),l(Pe),l(C),l(Ke),l(g),l(De),l(v),l(Oe),l(x),l(et),l(I),l(tt),l($),l(lt),l(nt),l(G),l(st),l(at),l(W),l(ot),l(Z),l(it),l(A),l(pt),l(rt),l(mt),l(X),l(Mt),l(z),l(ut),l(S),l(ht),l(V),l(yt),l(N),l(ct),l(L),l(wt),l(Y),l(ft),l(R),l(dt),l(jt),l(E),l(Ut),l(q),l(Tt),l(bt),l(P),l(Jt),l(K),l(Ct),l(D),l(gt),l(vt),l(ee),l(xt),l(te),l(It),l($t),l(Bt),l(se),l(Gt),l(kt),l(oe),l(Wt),l(ie),l(Zt),l(pe),l(At),l(re),l(Ht),l(me),l(_t),l(Me),l(Xt),l(ue),l(zt),l(he),l(St),l(ye),l(Vt),l(Nt),l(we),l(Lt),l(fe),l(Yt),l(Rt),l(je),l(Qt),l(Et),l(Te),l(qt),l(be),l(Ft),l(Je),l(Pt),l(Kt),l(Dt),l(ve),l(Ot),l(xe),l(el),l(Ie),l(tl),l($e),l(ll),l(nl),l(Ge),l(sl),l(ke),l(al),l(ol),l(il),l(pl),l(rl),l(_e),l(ml),l(Ml),l(Ve)),l(w),y(f,e),y(d,e),y(J,e),y(B,e),y(k,e),y(H,e),y(_,e),y(Q,e),y(F,e),y(O,e),y(le,e),y(ne,e),y(ae,e),y(ce,e),y(de,e),y(Ue,e),y(Ce,e),y(ge,e),y(Be,e),y(We,e),y(Ze,e),y(Ae,e),y(He,e),y(Xe,e)}}}const Cn='{"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":"Prerequisite: Setup AWS environment","local":"prerequisite-setup-aws-environment","sections":[],"depth":2},{"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 gn(hl){return fn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gn extends dn{constructor(w){super(),jn(this,w,gn,Jn,cn,{})}}export{Gn as component}; | |
Xet Storage Details
- Size:
- 38 kB
- Xet hash:
- f713c863318ae021ed4ebc3a387db3eb8c684b4c1c4810eccb0fe8ef0587331e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.