summaryrefslogtreecommitdiff
path: root/candle-wasm-examples/phi/phiWorker.js
diff options
context:
space:
mode:
authorRadamés Ajna <radamajna@gmail.com>2023-10-24 23:09:03 -0700
committerGitHub <noreply@github.com>2023-10-25 07:09:03 +0100
commitb6053b938b293d82833ff31f3c7c32a5b369fe11 (patch)
tree9d6485b00a52aff726049ad5cfca280f6f9f28a5 /candle-wasm-examples/phi/phiWorker.js
parent45dbe541bcde2fa12281a08df501baf76b11558f (diff)
downloadcandle-b6053b938b293d82833ff31f3c7c32a5b369fe11.tar.gz
candle-b6053b938b293d82833ff31f3c7c32a5b369fe11.tar.bz2
candle-b6053b938b293d82833ff31f3c7c32a5b369fe11.zip
[Wasm] Add puffin phi model to wasm (#1166)
* load config from file, add puffin phi links * format * add prompt examples
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
);