From 5f78b90618db1ae2d86fe8867fd1493ea15e7d59 Mon Sep 17 00:00:00 2001 From: Nathan Sarrazin Date: Wed, 21 Feb 2024 14:00:02 +0100 Subject: [PATCH] Add gemma model to prod config (#854) * Add `google/gemma-7b-it` to production config * Add gemma prompt format to PROMPTS.md * Make sampling parameters optional --- .env.template | 29 ++++++++++++++++++++++++++++- PROMPTS.md | 6 ++++++ src/lib/server/models.ts | 4 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.env.template b/.env.template index b069e572..5ea6ce34 100644 --- a/.env.template +++ b/.env.template @@ -31,7 +31,34 @@ MODELS=`[ } ] }, - { + { + "name" : "google/gemma-7b-it", + "description": "Gemma 7B is from a family of lightweight models from Google built from the same research and technology used to create the Gemini models.", + "websiteUrl" : "https://add-link-to-their-comms-here.com/", + "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/google-logo.png", + "modelUrl": "https://huggingface.co/google/gemma-7b-it", + "preprompt": "", + "chatPromptTemplate" : "{{#each messages}}{{#ifUser}}user\n{{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}}{{content}}\nmodel\n{{/ifUser}}{{#ifAssistant}}{{content}}\n{{/ifAssistant}}{{/each}}", + "promptExamples": [ + { + "title": "Write an email from bullet list", + "prompt": "As a restaurant owner, write a professional email to the supplier to get these products every week: \n\n- Wine (x10)\n- Eggs (x24)\n- Bread (x12)" + }, { + "title": "Code a snake game", + "prompt": "Code a basic snake game in python, give explanations for each step." + }, { + "title": "Assist in a task", + "prompt": "How do I make a delicious lemon cheesecake?" + } + ], + "parameters": { + "do_sample": true, + "truncate": 7168, + "max_new_tokens": 1024, + "stop" : [""] + } + }, + { "name": "meta-llama/Llama-2-70b-chat-hf", "description": "The latest and biggest model from Meta, fine-tuned for chat.", "logoUrl": "https://huggingface.co/datasets/huggingchat/models-logo/resolve/main/meta-logo.png", diff --git a/PROMPTS.md b/PROMPTS.md index 4f921a6d..1847e0dc 100644 --- a/PROMPTS.md +++ b/PROMPTS.md @@ -61,3 +61,9 @@ System: {{preprompt}}\nUser:{{#each messages}}{{#ifUser}}{{content}}\nFalcon:{{/ ```env {{#if @root.preprompt}}Source: system\n\n {{@root.preprompt}} {{/if}}{{#each messages}}{{#ifUser}}Source: user\n\n {{content}} {{/ifUser}}{{#ifAssistant}}Source: assistant\n\n {{content}} {{/ifAssistant}}{{/each}}Source: assistant\nDestination: user\n\n `` ``` + +## Gemma + +```env +{{#each messages}}{{#ifUser}}user\n{{#if @first}}{{#if @root.preprompt}}{{@root.preprompt}}\n{{/if}}{{/if}}{{content}}\nmodel\n{{/ifUser}}{{#ifAssistant}}{{content}}\n{{/ifAssistant}}{{/each}} +``` diff --git a/src/lib/server/models.ts b/src/lib/server/models.ts index e280eb4d..588baf0c 100644 --- a/src/lib/server/models.ts +++ b/src/lib/server/models.ts @@ -58,9 +58,9 @@ const modelConfig = z.object({ endpoints: z.array(endpointSchema).optional(), parameters: z .object({ - temperature: z.number().min(0).max(1), + temperature: z.number().min(0).max(1).optional(), truncate: z.number().int().positive().optional(), - max_new_tokens: z.number().int().positive(), + max_new_tokens: z.number().int().positive().optional(), stop: z.array(z.string()).optional(), top_p: z.number().positive().optional(), top_k: z.number().positive().optional(),