summaryrefslogtreecommitdiff
path: root/candle-wasm-examples/phi/phiWorker.js
diff options
context:
space:
mode:
Diffstat (limited to 'candle-wasm-examples/phi/phiWorker.js')
-rw-r--r--candle-wasm-examples/phi/phiWorker.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/candle-wasm-examples/phi/phiWorker.js b/candle-wasm-examples/phi/phiWorker.js
index 17a03e14..5c030f1d 100644
--- a/candle-wasm-examples/phi/phiWorker.js
+++ b/candle-wasm-examples/phi/phiWorker.js
@@ -15,21 +15,30 @@ async function fetchArrayBuffer(url) {
class Phi {
static instance = {};
- static async getInstance(weightsURL, modelID, tokenizerURL, quantized) {
+ static async getInstance(
+ weightsURL,
+ modelID,
+ tokenizerURL,
+ configURL,
+ quantized
+ ) {
// load individual modelID only once
if (!this.instance[modelID]) {
await init();
self.postMessage({ status: "loading", message: "Loading Model" });
- const [weightsArrayU8, tokenizerArrayU8] = await Promise.all([
- fetchArrayBuffer(weightsURL),
- fetchArrayBuffer(tokenizerURL),
- ]);
+ const [weightsArrayU8, tokenizerArrayU8, configArrayU8] =
+ await Promise.all([
+ fetchArrayBuffer(weightsURL),
+ fetchArrayBuffer(tokenizerURL),
+ fetchArrayBuffer(configURL),
+ ]);
this.instance[modelID] = new Model(
weightsArrayU8,
tokenizerArrayU8,
+ configArrayU8,
quantized
);
}
@@ -52,6 +61,7 @@ async function generate(data) {
weightsURL,
modelID,
tokenizerURL,
+ configURL,
quantized,
prompt,
temp,
@@ -66,6 +76,7 @@ async function generate(data) {
weightsURL,
modelID,
tokenizerURL,
+ configURL,
quantized
);