From 81c3b06b92969df74ae856adf7cd194ba19f1bca Mon Sep 17 00:00:00 2001 From: Kwangsoo Yeo Date: Mon, 3 Jun 2024 10:58:56 -0700 Subject: [PATCH] update --- recipes/llm-voice-assistant/web/README.md | 2 +- .../llm-voice-assistant/web/public/controller.js | 7 ++++++- recipes/llm-voice-assistant/web/src/main.ts | 16 ++++++++-------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/recipes/llm-voice-assistant/web/README.md b/recipes/llm-voice-assistant/web/README.md index 4a89f87..9850d9b 100644 --- a/recipes/llm-voice-assistant/web/README.md +++ b/recipes/llm-voice-assistant/web/README.md @@ -23,7 +23,7 @@ picoLLM Inference Engine supports many open-weight models. The models are on Install the required packages using `yarn`: ```console -yarn isntall +yarn install ``` or using `npm`: diff --git a/recipes/llm-voice-assistant/web/public/controller.js b/recipes/llm-voice-assistant/web/public/controller.js index a754f4f..35728d9 100644 --- a/recipes/llm-voice-assistant/web/public/controller.js +++ b/recipes/llm-voice-assistant/web/public/controller.js @@ -97,7 +97,12 @@ window.onload = () => { let streamCalls = 0; try { - await Picovoice.init(accessKey.value, { + await Picovoice.init(accessKey.value, + { + modelFile: modelFile.files[0], + cacheFilePath: modelFile.files[0].name, + }, + { onDetection: () => { message.innerText = "Wake word detected, utter your request or question..."; humanElem = startHumanMessage(); diff --git a/recipes/llm-voice-assistant/web/src/main.ts b/recipes/llm-voice-assistant/web/src/main.ts index 89463cc..f84bfcc 100644 --- a/recipes/llm-voice-assistant/web/src/main.ts +++ b/recipes/llm-voice-assistant/web/src/main.ts @@ -3,7 +3,7 @@ import { Mutex } from 'async-mutex'; import { BuiltInKeyword, PorcupineDetection, PorcupineWorker } from '@picovoice/porcupine-web'; import { CheetahTranscript, CheetahWorker } from '@picovoice/cheetah-web'; import { OrcaStreamWorker, OrcaWorker } from '@picovoice/orca-web'; -import { Dialog, PicoLLMWorker } from '@picovoice/picollm-web'; +import { Dialog, PicoLLMModel, PicoLLMWorker } from '@picovoice/picollm-web'; import { WebVoiceProcessor } from '@picovoice/web-voice-processor'; type PvObject = { @@ -26,7 +26,10 @@ type PvCallback = { let object: PvObject | null = null; -const init = async (accessKey: string, { +const init = async ( + accessKey: string, + picollmModel: PicoLLMModel, + { onDetection, onEndpoint, onTranscript, @@ -78,9 +81,7 @@ const init = async (accessKey: string, { const pllm = await PicoLLMWorker.create( accessKey, - { - modelFile: "models/picollm_params.pllm" - }); + picollmModel); const orca = await OrcaWorker.create( accessKey, @@ -97,9 +98,10 @@ const init = async (accessKey: string, { let stopTokens = 0; const stopPhrases = [ - '', // Llama-2, Mistral, and Mixtral + '', // Llama-2, Mistral '', // Gemma '<|endoftext|>', // Phi-2 + '<|eot_id|>', // Llama-3 ]; const onCheetahFlushed = async (): Promise => { @@ -109,8 +111,6 @@ const init = async (accessKey: string, { const { completion, completionTokens } = await pllm.generate(dialog.prompt(), { completionTokenLimit: 128, - temperature: 0.7, - topP: 0.6, streamCallback: async token => { if (!stopPhrases.includes(token)) { onText(token);