@@ -67,7 +67,7 @@ const TITAN_TEXT_PROMPT: PromptTemplate = {
67
67
eosToken : '' ,
68
68
} ;
69
69
70
- const LLAMA_PROMPT : PromptTemplate = {
70
+ const LLAMA2_PROMPT : PromptTemplate = {
71
71
prefix : '<s>[INST] ' ,
72
72
suffix : ' [/INST]' ,
73
73
join : '' ,
@@ -77,6 +77,16 @@ const LLAMA_PROMPT: PromptTemplate = {
77
77
eosToken : '</s>' ,
78
78
} ;
79
79
80
+ const LLAMA3_PROMPT : PromptTemplate = {
81
+ prefix : '<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n' ,
82
+ suffix : ' [/INST]' ,
83
+ join : '' ,
84
+ user : '{}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n' ,
85
+ assistant : '{}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n' ,
86
+ system : '{}<|eot_id|><|start_header_id|>user<|end_header_id|>\n\n' ,
87
+ eosToken : '' ,
88
+ } ;
89
+
80
90
const MISTRAL_PROMPT : PromptTemplate = {
81
91
prefix : '<s>[INST] ' ,
82
92
suffix : ' [/INST]' ,
@@ -202,9 +212,17 @@ const createBodyTextTitanText = (messages: UnrecordedMessage[]) => {
202
212
return JSON . stringify ( body ) ;
203
213
} ;
204
214
205
- const createBodyTextLlama = ( messages : UnrecordedMessage [ ] ) => {
215
+ const createBodyTextLlama2 = ( messages : UnrecordedMessage [ ] ) => {
216
+ const body : LlamaParams = {
217
+ prompt : generatePrompt ( LLAMA2_PROMPT , messages ) ,
218
+ ...LLAMA_DEFAULT_PARAMS ,
219
+ } ;
220
+ return JSON . stringify ( body ) ;
221
+ } ;
222
+
223
+ const createBodyTextLlama3 = ( messages : UnrecordedMessage [ ] ) => {
206
224
const body : LlamaParams = {
207
- prompt : generatePrompt ( LLAMA_PROMPT , messages ) ,
225
+ prompt : generatePrompt ( LLAMA3_PROMPT , messages ) ,
208
226
...LLAMA_DEFAULT_PARAMS ,
209
227
} ;
210
228
return JSON . stringify ( body ) ;
@@ -354,23 +372,23 @@ export const BEDROCK_MODELS: {
354
372
extractOutputText : extractOutputTextTitanText ,
355
373
} ,
356
374
'meta.llama3-8b-instruct-v1:0' : {
357
- promptTemplate : LLAMA_PROMPT ,
358
- createBodyText : createBodyTextLlama ,
375
+ promptTemplate : LLAMA3_PROMPT ,
376
+ createBodyText : createBodyTextLlama3 ,
359
377
extractOutputText : extractOutputTextLlama ,
360
378
} ,
361
379
'meta.llama3-70b-instruct-v1:0' : {
362
- promptTemplate : LLAMA_PROMPT ,
363
- createBodyText : createBodyTextLlama ,
380
+ promptTemplate : LLAMA3_PROMPT ,
381
+ createBodyText : createBodyTextLlama3 ,
364
382
extractOutputText : extractOutputTextLlama ,
365
383
} ,
366
384
'meta.llama2-13b-chat-v1' : {
367
- promptTemplate : LLAMA_PROMPT ,
368
- createBodyText : createBodyTextLlama ,
385
+ promptTemplate : LLAMA2_PROMPT ,
386
+ createBodyText : createBodyTextLlama2 ,
369
387
extractOutputText : extractOutputTextLlama ,
370
388
} ,
371
389
'meta.llama2-70b-chat-v1' : {
372
- promptTemplate : LLAMA_PROMPT ,
373
- createBodyText : createBodyTextLlama ,
390
+ promptTemplate : LLAMA2_PROMPT ,
391
+ createBodyText : createBodyTextLlama2 ,
374
392
extractOutputText : extractOutputTextLlama ,
375
393
} ,
376
394
'mistral.mistral-7b-instruct-v0:2' : {
@@ -412,7 +430,7 @@ export const BEDROCK_IMAGE_GEN_MODELS: {
412
430
413
431
export const getSageMakerModelTemplate = ( model : string ) : PromptTemplate => {
414
432
if ( model . includes ( 'llama-2' ) ) {
415
- return LLAMA_PROMPT ;
433
+ return LLAMA2_PROMPT ;
416
434
} else if ( model . includes ( 'bilingual-rinna' ) ) {
417
435
return BILINGUAL_RINNA_PROMPT ;
418
436
} else if ( model . includes ( 'rinna' ) ) {
0 commit comments