radames commited on
Commit
539c560
1 Parent(s): 0214820

Upload 11 files

Browse files
T5ModelConditionalGeneration.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //load Candle Bert Module wasm module
2
+ let init, ModelConditionalGeneration;
3
+
4
+ async function fetchArrayBuffer(url) {
5
+ const cacheName = "t5-candle-cache";
6
+ const cache = await caches.open(cacheName);
7
+ const cachedResponse = await cache.match(url);
8
+ if (cachedResponse) {
9
+ const data = await cachedResponse.arrayBuffer();
10
+ return new Uint8Array(data);
11
+ }
12
+ const res = await fetch(url, { cache: "force-cache" });
13
+ cache.put(url, res.clone());
14
+ return new Uint8Array(await res.arrayBuffer());
15
+ }
16
+ class ConditionalGeneration {
17
+ static instance = {};
18
+
19
+ static async getInstance(weightsURL, tokenizerURL, configURL, modelID) {
20
+ if (modelID.includes("quantized")) {
21
+ ({ default: init, ModelConditionalGeneration } = await import(
22
+ "./build/m-quantized.js"
23
+ ));
24
+ } else {
25
+ ({ default: init, ModelConditionalGeneration } = await import(
26
+ "./build/m.js"
27
+ ));
28
+ }
29
+ if (!this.instance[modelID]) {
30
+ await init();
31
+
32
+ self.postMessage({ status: "loading", message: "Loading Model" });
33
+ const [weightsArrayU8, tokenizerArrayU8, configArrayU8] =
34
+ await Promise.all([
35
+ fetchArrayBuffer(weightsURL),
36
+ fetchArrayBuffer(tokenizerURL),
37
+ fetchArrayBuffer(configURL),
38
+ ]);
39
+
40
+ this.instance[modelID] = new ModelConditionalGeneration(
41
+ weightsArrayU8,
42
+ tokenizerArrayU8,
43
+ configArrayU8
44
+ );
45
+ } else {
46
+ self.postMessage({ status: "ready", message: "Model Already Loaded" });
47
+ }
48
+ return this.instance[modelID];
49
+ }
50
+ }
51
+
52
+ self.addEventListener("message", async (event) => {
53
+ const { weightsURL, tokenizerURL, configURL, modelID, prompt, params } =
54
+ event.data;
55
+ let {
56
+ temperature = 0.0,
57
+ seed = 299792458,
58
+ repeat_penalty = 1.1,
59
+ repeat_last_n = 64,
60
+ top_p = 1,
61
+ } = { ...params };
62
+ try {
63
+ self.postMessage({
64
+ status: "ready",
65
+ message: "Starting T5 Conditional Generation",
66
+ });
67
+ const model = await ConditionalGeneration.getInstance(
68
+ weightsURL,
69
+ tokenizerURL,
70
+ configURL,
71
+ modelID
72
+ );
73
+ self.postMessage({
74
+ status: "decoding",
75
+ message: "Decoding Prompt",
76
+ });
77
+ const output = model.decode({
78
+ prompt,
79
+ temperature,
80
+ seed,
81
+ top_p,
82
+ repeat_penalty,
83
+ repeat_last_n,
84
+ });
85
+ self.postMessage({
86
+ status: "complete",
87
+ message: "complete",
88
+ output: output,
89
+ });
90
+ } catch (e) {
91
+ self.postMessage({ error: e });
92
+ }
93
+ });
T5ModelEncoderWorker.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //load Candle Bert Module wasm module
2
+ import init, { ModelEncoder } from "./build/m.js";
3
+
4
+ async function fetchArrayBuffer(url) {
5
+ const cacheName = "t5-candle-cache";
6
+ const cache = await caches.open(cacheName);
7
+ const cachedResponse = await cache.match(url);
8
+ if (cachedResponse) {
9
+ const data = await cachedResponse.arrayBuffer();
10
+ return new Uint8Array(data);
11
+ }
12
+ const res = await fetch(url, { cache: "force-cache" });
13
+ cache.put(url, res.clone());
14
+ return new Uint8Array(await res.arrayBuffer());
15
+ }
16
+ class Encoder {
17
+ static instance = {};
18
+
19
+ static async getInstance(weightsURL, tokenizerURL, configURL, modelID) {
20
+ if (!this.instance[modelID]) {
21
+ await init();
22
+
23
+ self.postMessage({ status: "loading", message: "Loading Model" });
24
+ const [weightsArrayU8, tokenizerArrayU8, configArrayU8] =
25
+ await Promise.all([
26
+ fetchArrayBuffer(weightsURL),
27
+ fetchArrayBuffer(tokenizerURL),
28
+ fetchArrayBuffer(configURL),
29
+ ]);
30
+
31
+ this.instance[modelID] = new ModelEncoder(
32
+ weightsArrayU8,
33
+ tokenizerArrayU8,
34
+ configArrayU8
35
+ );
36
+ } else {
37
+ self.postMessage({ status: "ready", message: "Model Already Loaded" });
38
+ }
39
+ return this.instance[modelID];
40
+ }
41
+ }
42
+
43
+ self.addEventListener("message", async (event) => {
44
+ const {
45
+ weightsURL,
46
+ tokenizerURL,
47
+ configURL,
48
+ modelID,
49
+ sentences,
50
+ normalize_embeddings,
51
+ } = event.data;
52
+ try {
53
+ self.postMessage({ status: "ready", message: "Starting T5 Encoder" });
54
+ const model = await Encoder.getInstance(
55
+ weightsURL,
56
+ tokenizerURL,
57
+ configURL,
58
+ modelID
59
+ );
60
+ self.postMessage({
61
+ status: "encoding",
62
+ message: "Encoding Sentences",
63
+ });
64
+ const output = model.decode({
65
+ sentences: sentences,
66
+ normalize_embeddings: normalize_embeddings || true,
67
+ });
68
+ self.postMessage({
69
+ status: "complete",
70
+ message: "complete",
71
+ output: output,
72
+ });
73
+ } catch (e) {
74
+ self.postMessage({ error: e });
75
+ }
76
+ });
build/m-quantized.d.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ */
5
+ export class ModelConditionalGeneration {
6
+ free(): void;
7
+ /**
8
+ * @param {Uint8Array} weights
9
+ * @param {Uint8Array} tokenizer
10
+ * @param {Uint8Array} config
11
+ */
12
+ constructor(weights: Uint8Array, tokenizer: Uint8Array, config: Uint8Array);
13
+ /**
14
+ * @param {any} input
15
+ * @returns {any}
16
+ */
17
+ decode(input: any): any;
18
+ }
19
+ /**
20
+ */
21
+ export class ModelEncoder {
22
+ free(): void;
23
+ /**
24
+ * @param {Uint8Array} weights
25
+ * @param {Uint8Array} tokenizer
26
+ * @param {Uint8Array} config
27
+ */
28
+ constructor(weights: Uint8Array, tokenizer: Uint8Array, config: Uint8Array);
29
+ /**
30
+ * @param {any} input
31
+ * @returns {any}
32
+ */
33
+ decode(input: any): any;
34
+ }
35
+
36
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
37
+
38
+ export interface InitOutput {
39
+ readonly memory: WebAssembly.Memory;
40
+ readonly __wbg_modelencoder_free: (a: number) => void;
41
+ readonly __wbg_modelconditionalgeneration_free: (a: number) => void;
42
+ readonly modelconditionalgeneration_load: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
43
+ readonly modelconditionalgeneration_decode: (a: number, b: number, c: number) => void;
44
+ readonly modelencoder_load: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
45
+ readonly modelencoder_decode: (a: number, b: number, c: number) => void;
46
+ readonly main: (a: number, b: number) => number;
47
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
48
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
49
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
50
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
51
+ readonly __wbindgen_exn_store: (a: number) => void;
52
+ readonly __wbindgen_start: () => void;
53
+ }
54
+
55
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
56
+ /**
57
+ * Instantiates the given `module`, which can either be bytes or
58
+ * a precompiled `WebAssembly.Module`.
59
+ *
60
+ * @param {SyncInitInput} module
61
+ *
62
+ * @returns {InitOutput}
63
+ */
64
+ export function initSync(module: SyncInitInput): InitOutput;
65
+
66
+ /**
67
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
68
+ * for everything else, calls `WebAssembly.instantiate` directly.
69
+ *
70
+ * @param {InitInput | Promise<InitInput>} module_or_path
71
+ *
72
+ * @returns {Promise<InitOutput>}
73
+ */
74
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
build/m-quantized.js ADDED
@@ -0,0 +1,734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let wasm;
2
+
3
+ const heap = new Array(128).fill(undefined);
4
+
5
+ heap.push(undefined, null, true, false);
6
+
7
+ function getObject(idx) { return heap[idx]; }
8
+
9
+ let WASM_VECTOR_LEN = 0;
10
+
11
+ let cachedUint8Memory0 = null;
12
+
13
+ function getUint8Memory0() {
14
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
15
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
16
+ }
17
+ return cachedUint8Memory0;
18
+ }
19
+
20
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
21
+
22
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
23
+ ? function (arg, view) {
24
+ return cachedTextEncoder.encodeInto(arg, view);
25
+ }
26
+ : function (arg, view) {
27
+ const buf = cachedTextEncoder.encode(arg);
28
+ view.set(buf);
29
+ return {
30
+ read: arg.length,
31
+ written: buf.length
32
+ };
33
+ });
34
+
35
+ function passStringToWasm0(arg, malloc, realloc) {
36
+
37
+ if (realloc === undefined) {
38
+ const buf = cachedTextEncoder.encode(arg);
39
+ const ptr = malloc(buf.length, 1) >>> 0;
40
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
41
+ WASM_VECTOR_LEN = buf.length;
42
+ return ptr;
43
+ }
44
+
45
+ let len = arg.length;
46
+ let ptr = malloc(len, 1) >>> 0;
47
+
48
+ const mem = getUint8Memory0();
49
+
50
+ let offset = 0;
51
+
52
+ for (; offset < len; offset++) {
53
+ const code = arg.charCodeAt(offset);
54
+ if (code > 0x7F) break;
55
+ mem[ptr + offset] = code;
56
+ }
57
+
58
+ if (offset !== len) {
59
+ if (offset !== 0) {
60
+ arg = arg.slice(offset);
61
+ }
62
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
63
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
64
+ const ret = encodeString(arg, view);
65
+
66
+ offset += ret.written;
67
+ }
68
+
69
+ WASM_VECTOR_LEN = offset;
70
+ return ptr;
71
+ }
72
+
73
+ function isLikeNone(x) {
74
+ return x === undefined || x === null;
75
+ }
76
+
77
+ let cachedInt32Memory0 = null;
78
+
79
+ function getInt32Memory0() {
80
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
81
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
82
+ }
83
+ return cachedInt32Memory0;
84
+ }
85
+
86
+ let heap_next = heap.length;
87
+
88
+ function dropObject(idx) {
89
+ if (idx < 132) return;
90
+ heap[idx] = heap_next;
91
+ heap_next = idx;
92
+ }
93
+
94
+ function takeObject(idx) {
95
+ const ret = getObject(idx);
96
+ dropObject(idx);
97
+ return ret;
98
+ }
99
+
100
+ function addHeapObject(obj) {
101
+ if (heap_next === heap.length) heap.push(heap.length + 1);
102
+ const idx = heap_next;
103
+ heap_next = heap[idx];
104
+
105
+ heap[idx] = obj;
106
+ return idx;
107
+ }
108
+
109
+ let cachedFloat64Memory0 = null;
110
+
111
+ function getFloat64Memory0() {
112
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
113
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
114
+ }
115
+ return cachedFloat64Memory0;
116
+ }
117
+
118
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
119
+
120
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
121
+
122
+ function getStringFromWasm0(ptr, len) {
123
+ ptr = ptr >>> 0;
124
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
125
+ }
126
+
127
+ let cachedBigInt64Memory0 = null;
128
+
129
+ function getBigInt64Memory0() {
130
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
131
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
132
+ }
133
+ return cachedBigInt64Memory0;
134
+ }
135
+
136
+ function debugString(val) {
137
+ // primitive types
138
+ const type = typeof val;
139
+ if (type == 'number' || type == 'boolean' || val == null) {
140
+ return `${val}`;
141
+ }
142
+ if (type == 'string') {
143
+ return `"${val}"`;
144
+ }
145
+ if (type == 'symbol') {
146
+ const description = val.description;
147
+ if (description == null) {
148
+ return 'Symbol';
149
+ } else {
150
+ return `Symbol(${description})`;
151
+ }
152
+ }
153
+ if (type == 'function') {
154
+ const name = val.name;
155
+ if (typeof name == 'string' && name.length > 0) {
156
+ return `Function(${name})`;
157
+ } else {
158
+ return 'Function';
159
+ }
160
+ }
161
+ // objects
162
+ if (Array.isArray(val)) {
163
+ const length = val.length;
164
+ let debug = '[';
165
+ if (length > 0) {
166
+ debug += debugString(val[0]);
167
+ }
168
+ for(let i = 1; i < length; i++) {
169
+ debug += ', ' + debugString(val[i]);
170
+ }
171
+ debug += ']';
172
+ return debug;
173
+ }
174
+ // Test for built-in
175
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
176
+ let className;
177
+ if (builtInMatches.length > 1) {
178
+ className = builtInMatches[1];
179
+ } else {
180
+ // Failed to match the standard '[object ClassName]'
181
+ return toString.call(val);
182
+ }
183
+ if (className == 'Object') {
184
+ // we're a user defined class or Object
185
+ // JSON.stringify avoids problems with cycles, and is generally much
186
+ // easier than looping through ownProperties of `val`.
187
+ try {
188
+ return 'Object(' + JSON.stringify(val) + ')';
189
+ } catch (_) {
190
+ return 'Object';
191
+ }
192
+ }
193
+ // errors
194
+ if (val instanceof Error) {
195
+ return `${val.name}: ${val.message}\n${val.stack}`;
196
+ }
197
+ // TODO we could test for more things here, like `Set`s and `Map`s.
198
+ return className;
199
+ }
200
+
201
+ function passArray8ToWasm0(arg, malloc) {
202
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
203
+ getUint8Memory0().set(arg, ptr / 1);
204
+ WASM_VECTOR_LEN = arg.length;
205
+ return ptr;
206
+ }
207
+
208
+ function handleError(f, args) {
209
+ try {
210
+ return f.apply(this, args);
211
+ } catch (e) {
212
+ wasm.__wbindgen_exn_store(addHeapObject(e));
213
+ }
214
+ }
215
+ /**
216
+ */
217
+ export class ModelConditionalGeneration {
218
+
219
+ static __wrap(ptr) {
220
+ ptr = ptr >>> 0;
221
+ const obj = Object.create(ModelConditionalGeneration.prototype);
222
+ obj.__wbg_ptr = ptr;
223
+
224
+ return obj;
225
+ }
226
+
227
+ __destroy_into_raw() {
228
+ const ptr = this.__wbg_ptr;
229
+ this.__wbg_ptr = 0;
230
+
231
+ return ptr;
232
+ }
233
+
234
+ free() {
235
+ const ptr = this.__destroy_into_raw();
236
+ wasm.__wbg_modelconditionalgeneration_free(ptr);
237
+ }
238
+ /**
239
+ * @param {Uint8Array} weights
240
+ * @param {Uint8Array} tokenizer
241
+ * @param {Uint8Array} config
242
+ */
243
+ constructor(weights, tokenizer, config) {
244
+ try {
245
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
246
+ const ptr0 = passArray8ToWasm0(weights, wasm.__wbindgen_malloc);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ const ptr1 = passArray8ToWasm0(tokenizer, wasm.__wbindgen_malloc);
249
+ const len1 = WASM_VECTOR_LEN;
250
+ const ptr2 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
251
+ const len2 = WASM_VECTOR_LEN;
252
+ wasm.modelconditionalgeneration_load(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
253
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
254
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
255
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
256
+ if (r2) {
257
+ throw takeObject(r1);
258
+ }
259
+ return ModelConditionalGeneration.__wrap(r0);
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ }
263
+ }
264
+ /**
265
+ * @param {any} input
266
+ * @returns {any}
267
+ */
268
+ decode(input) {
269
+ try {
270
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
271
+ wasm.modelconditionalgeneration_decode(retptr, this.__wbg_ptr, addHeapObject(input));
272
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
273
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
274
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
275
+ if (r2) {
276
+ throw takeObject(r1);
277
+ }
278
+ return takeObject(r0);
279
+ } finally {
280
+ wasm.__wbindgen_add_to_stack_pointer(16);
281
+ }
282
+ }
283
+ }
284
+ /**
285
+ */
286
+ export class ModelEncoder {
287
+
288
+ static __wrap(ptr) {
289
+ ptr = ptr >>> 0;
290
+ const obj = Object.create(ModelEncoder.prototype);
291
+ obj.__wbg_ptr = ptr;
292
+
293
+ return obj;
294
+ }
295
+
296
+ __destroy_into_raw() {
297
+ const ptr = this.__wbg_ptr;
298
+ this.__wbg_ptr = 0;
299
+
300
+ return ptr;
301
+ }
302
+
303
+ free() {
304
+ const ptr = this.__destroy_into_raw();
305
+ wasm.__wbg_modelencoder_free(ptr);
306
+ }
307
+ /**
308
+ * @param {Uint8Array} weights
309
+ * @param {Uint8Array} tokenizer
310
+ * @param {Uint8Array} config
311
+ */
312
+ constructor(weights, tokenizer, config) {
313
+ try {
314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
+ const ptr0 = passArray8ToWasm0(weights, wasm.__wbindgen_malloc);
316
+ const len0 = WASM_VECTOR_LEN;
317
+ const ptr1 = passArray8ToWasm0(tokenizer, wasm.__wbindgen_malloc);
318
+ const len1 = WASM_VECTOR_LEN;
319
+ const ptr2 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
320
+ const len2 = WASM_VECTOR_LEN;
321
+ wasm.modelencoder_load(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
322
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
323
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
324
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
325
+ if (r2) {
326
+ throw takeObject(r1);
327
+ }
328
+ return ModelEncoder.__wrap(r0);
329
+ } finally {
330
+ wasm.__wbindgen_add_to_stack_pointer(16);
331
+ }
332
+ }
333
+ /**
334
+ * @param {any} input
335
+ * @returns {any}
336
+ */
337
+ decode(input) {
338
+ try {
339
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
340
+ wasm.modelencoder_decode(retptr, this.__wbg_ptr, addHeapObject(input));
341
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
342
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
343
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
344
+ if (r2) {
345
+ throw takeObject(r1);
346
+ }
347
+ return takeObject(r0);
348
+ } finally {
349
+ wasm.__wbindgen_add_to_stack_pointer(16);
350
+ }
351
+ }
352
+ }
353
+
354
+ async function __wbg_load(module, imports) {
355
+ if (typeof Response === 'function' && module instanceof Response) {
356
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
357
+ try {
358
+ return await WebAssembly.instantiateStreaming(module, imports);
359
+
360
+ } catch (e) {
361
+ if (module.headers.get('Content-Type') != 'application/wasm') {
362
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
363
+
364
+ } else {
365
+ throw e;
366
+ }
367
+ }
368
+ }
369
+
370
+ const bytes = await module.arrayBuffer();
371
+ return await WebAssembly.instantiate(bytes, imports);
372
+
373
+ } else {
374
+ const instance = await WebAssembly.instantiate(module, imports);
375
+
376
+ if (instance instanceof WebAssembly.Instance) {
377
+ return { instance, module };
378
+
379
+ } else {
380
+ return instance;
381
+ }
382
+ }
383
+ }
384
+
385
+ function __wbg_get_imports() {
386
+ const imports = {};
387
+ imports.wbg = {};
388
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
389
+ const obj = getObject(arg1);
390
+ const ret = typeof(obj) === 'string' ? obj : undefined;
391
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
392
+ var len1 = WASM_VECTOR_LEN;
393
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
394
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
395
+ };
396
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
397
+ takeObject(arg0);
398
+ };
399
+ imports.wbg.__wbindgen_is_bigint = function(arg0) {
400
+ const ret = typeof(getObject(arg0)) === 'bigint';
401
+ return ret;
402
+ };
403
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
404
+ const ret = BigInt.asUintN(64, arg0);
405
+ return addHeapObject(ret);
406
+ };
407
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
408
+ const ret = getObject(arg0) === getObject(arg1);
409
+ return ret;
410
+ };
411
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
412
+ const v = getObject(arg0);
413
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
414
+ return ret;
415
+ };
416
+ imports.wbg.__wbindgen_is_object = function(arg0) {
417
+ const val = getObject(arg0);
418
+ const ret = typeof(val) === 'object' && val !== null;
419
+ return ret;
420
+ };
421
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
422
+ const ret = getObject(arg0) === undefined;
423
+ return ret;
424
+ };
425
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
426
+ const ret = getObject(arg0) in getObject(arg1);
427
+ return ret;
428
+ };
429
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
430
+ const obj = getObject(arg1);
431
+ const ret = typeof(obj) === 'number' ? obj : undefined;
432
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
433
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
434
+ };
435
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
436
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
437
+ return addHeapObject(ret);
438
+ };
439
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
440
+ const ret = getObject(arg0);
441
+ return addHeapObject(ret);
442
+ };
443
+ imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
444
+ const ret = getObject(arg0) == getObject(arg1);
445
+ return ret;
446
+ };
447
+ imports.wbg.__wbg_String_4370c5505c674d30 = function(arg0, arg1) {
448
+ const ret = String(getObject(arg1));
449
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
450
+ const len1 = WASM_VECTOR_LEN;
451
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
452
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
453
+ };
454
+ imports.wbg.__wbindgen_number_new = function(arg0) {
455
+ const ret = arg0;
456
+ return addHeapObject(ret);
457
+ };
458
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
459
+ const ret = getStringFromWasm0(arg0, arg1);
460
+ return addHeapObject(ret);
461
+ };
462
+ imports.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea = function(arg0, arg1) {
463
+ const ret = getObject(arg0)[getObject(arg1)];
464
+ return addHeapObject(ret);
465
+ };
466
+ imports.wbg.__wbg_set_bd72c078edfa51ad = function(arg0, arg1, arg2) {
467
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
468
+ };
469
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
470
+ const ret = new Error();
471
+ return addHeapObject(ret);
472
+ };
473
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
474
+ const ret = getObject(arg1).stack;
475
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
476
+ const len1 = WASM_VECTOR_LEN;
477
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
478
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
479
+ };
480
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
481
+ let deferred0_0;
482
+ let deferred0_1;
483
+ try {
484
+ deferred0_0 = arg0;
485
+ deferred0_1 = arg1;
486
+ console.error(getStringFromWasm0(arg0, arg1));
487
+ } finally {
488
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
489
+ }
490
+ };
491
+ imports.wbg.__wbg_log_e25c897af30cb287 = function(arg0, arg1) {
492
+ console.log(getStringFromWasm0(arg0, arg1));
493
+ };
494
+ imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
495
+ const ret = getObject(arg0).crypto;
496
+ return addHeapObject(ret);
497
+ };
498
+ imports.wbg.__wbg_process_298734cf255a885d = function(arg0) {
499
+ const ret = getObject(arg0).process;
500
+ return addHeapObject(ret);
501
+ };
502
+ imports.wbg.__wbg_versions_e2e78e134e3e5d01 = function(arg0) {
503
+ const ret = getObject(arg0).versions;
504
+ return addHeapObject(ret);
505
+ };
506
+ imports.wbg.__wbg_node_1cd7a5d853dbea79 = function(arg0) {
507
+ const ret = getObject(arg0).node;
508
+ return addHeapObject(ret);
509
+ };
510
+ imports.wbg.__wbindgen_is_string = function(arg0) {
511
+ const ret = typeof(getObject(arg0)) === 'string';
512
+ return ret;
513
+ };
514
+ imports.wbg.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) {
515
+ const ret = getObject(arg0).msCrypto;
516
+ return addHeapObject(ret);
517
+ };
518
+ imports.wbg.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () {
519
+ const ret = module.require;
520
+ return addHeapObject(ret);
521
+ }, arguments) };
522
+ imports.wbg.__wbindgen_is_function = function(arg0) {
523
+ const ret = typeof(getObject(arg0)) === 'function';
524
+ return ret;
525
+ };
526
+ imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
527
+ getObject(arg0).getRandomValues(getObject(arg1));
528
+ }, arguments) };
529
+ imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
530
+ getObject(arg0).randomFillSync(takeObject(arg1));
531
+ }, arguments) };
532
+ imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) {
533
+ const ret = getObject(arg0)[arg1 >>> 0];
534
+ return addHeapObject(ret);
535
+ };
536
+ imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) {
537
+ const ret = getObject(arg0).length;
538
+ return ret;
539
+ };
540
+ imports.wbg.__wbg_new_898a68150f225f2e = function() {
541
+ const ret = new Array();
542
+ return addHeapObject(ret);
543
+ };
544
+ imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
545
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
546
+ return addHeapObject(ret);
547
+ };
548
+ imports.wbg.__wbg_next_526fc47e980da008 = function(arg0) {
549
+ const ret = getObject(arg0).next;
550
+ return addHeapObject(ret);
551
+ };
552
+ imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { return handleError(function (arg0) {
553
+ const ret = getObject(arg0).next();
554
+ return addHeapObject(ret);
555
+ }, arguments) };
556
+ imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) {
557
+ const ret = getObject(arg0).done;
558
+ return ret;
559
+ };
560
+ imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) {
561
+ const ret = getObject(arg0).value;
562
+ return addHeapObject(ret);
563
+ };
564
+ imports.wbg.__wbg_iterator_97f0c81209c6c35a = function() {
565
+ const ret = Symbol.iterator;
566
+ return addHeapObject(ret);
567
+ };
568
+ imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) {
569
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
570
+ return addHeapObject(ret);
571
+ }, arguments) };
572
+ imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
573
+ const ret = getObject(arg0).call(getObject(arg1));
574
+ return addHeapObject(ret);
575
+ }, arguments) };
576
+ imports.wbg.__wbg_new_b51585de1b234aff = function() {
577
+ const ret = new Object();
578
+ return addHeapObject(ret);
579
+ };
580
+ imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
581
+ const ret = self.self;
582
+ return addHeapObject(ret);
583
+ }, arguments) };
584
+ imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
585
+ const ret = window.window;
586
+ return addHeapObject(ret);
587
+ }, arguments) };
588
+ imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
589
+ const ret = globalThis.globalThis;
590
+ return addHeapObject(ret);
591
+ }, arguments) };
592
+ imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
593
+ const ret = global.global;
594
+ return addHeapObject(ret);
595
+ }, arguments) };
596
+ imports.wbg.__wbg_set_502d29070ea18557 = function(arg0, arg1, arg2) {
597
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
598
+ };
599
+ imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) {
600
+ const ret = Array.isArray(getObject(arg0));
601
+ return ret;
602
+ };
603
+ imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) {
604
+ let result;
605
+ try {
606
+ result = getObject(arg0) instanceof ArrayBuffer;
607
+ } catch {
608
+ result = false;
609
+ }
610
+ const ret = result;
611
+ return ret;
612
+ };
613
+ imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
614
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
615
+ return addHeapObject(ret);
616
+ }, arguments) };
617
+ imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function(arg0) {
618
+ const ret = Number.isSafeInteger(getObject(arg0));
619
+ return ret;
620
+ };
621
+ imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
622
+ const ret = getObject(arg0).buffer;
623
+ return addHeapObject(ret);
624
+ };
625
+ imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
626
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
627
+ return addHeapObject(ret);
628
+ };
629
+ imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
630
+ const ret = new Uint8Array(getObject(arg0));
631
+ return addHeapObject(ret);
632
+ };
633
+ imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
634
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
635
+ };
636
+ imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
637
+ const ret = getObject(arg0).length;
638
+ return ret;
639
+ };
640
+ imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) {
641
+ let result;
642
+ try {
643
+ result = getObject(arg0) instanceof Uint8Array;
644
+ } catch {
645
+ result = false;
646
+ }
647
+ const ret = result;
648
+ return ret;
649
+ };
650
+ imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
651
+ const ret = new Uint8Array(arg0 >>> 0);
652
+ return addHeapObject(ret);
653
+ };
654
+ imports.wbg.__wbg_subarray_13db269f57aa838d = function(arg0, arg1, arg2) {
655
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
656
+ return addHeapObject(ret);
657
+ };
658
+ imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
659
+ const v = getObject(arg1);
660
+ const ret = typeof(v) === 'bigint' ? v : undefined;
661
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
662
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
663
+ };
664
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
665
+ const ret = debugString(getObject(arg1));
666
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
667
+ const len1 = WASM_VECTOR_LEN;
668
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
669
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
670
+ };
671
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
672
+ throw new Error(getStringFromWasm0(arg0, arg1));
673
+ };
674
+ imports.wbg.__wbindgen_memory = function() {
675
+ const ret = wasm.memory;
676
+ return addHeapObject(ret);
677
+ };
678
+
679
+ return imports;
680
+ }
681
+
682
+ function __wbg_init_memory(imports, maybe_memory) {
683
+
684
+ }
685
+
686
+ function __wbg_finalize_init(instance, module) {
687
+ wasm = instance.exports;
688
+ __wbg_init.__wbindgen_wasm_module = module;
689
+ cachedBigInt64Memory0 = null;
690
+ cachedFloat64Memory0 = null;
691
+ cachedInt32Memory0 = null;
692
+ cachedUint8Memory0 = null;
693
+
694
+ wasm.__wbindgen_start();
695
+ return wasm;
696
+ }
697
+
698
+ function initSync(module) {
699
+ if (wasm !== undefined) return wasm;
700
+
701
+ const imports = __wbg_get_imports();
702
+
703
+ __wbg_init_memory(imports);
704
+
705
+ if (!(module instanceof WebAssembly.Module)) {
706
+ module = new WebAssembly.Module(module);
707
+ }
708
+
709
+ const instance = new WebAssembly.Instance(module, imports);
710
+
711
+ return __wbg_finalize_init(instance, module);
712
+ }
713
+
714
+ async function __wbg_init(input) {
715
+ if (wasm !== undefined) return wasm;
716
+
717
+ if (typeof input === 'undefined') {
718
+ input = new URL('m-quantized_bg.wasm', import.meta.url);
719
+ }
720
+ const imports = __wbg_get_imports();
721
+
722
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
723
+ input = fetch(input);
724
+ }
725
+
726
+ __wbg_init_memory(imports);
727
+
728
+ const { instance, module } = await __wbg_load(await input, imports);
729
+
730
+ return __wbg_finalize_init(instance, module);
731
+ }
732
+
733
+ export { initSync }
734
+ export default __wbg_init;
build/m-quantized_bg.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f79d18e3371d6430adf185da8807e15fd2fc95b85ab558a4b89c788e2c88e4a
3
+ size 4212625
build/m-quantized_bg.wasm.d.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function __wbg_modelencoder_free(a: number): void;
5
+ export function __wbg_modelconditionalgeneration_free(a: number): void;
6
+ export function modelconditionalgeneration_load(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
7
+ export function modelconditionalgeneration_decode(a: number, b: number, c: number): void;
8
+ export function modelencoder_load(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
9
+ export function modelencoder_decode(a: number, b: number, c: number): void;
10
+ export function main(a: number, b: number): number;
11
+ export function __wbindgen_malloc(a: number, b: number): number;
12
+ export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
13
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
14
+ export function __wbindgen_free(a: number, b: number, c: number): void;
15
+ export function __wbindgen_exn_store(a: number): void;
16
+ export function __wbindgen_start(): void;
build/m.d.ts ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ */
5
+ export class ModelConditionalGeneration {
6
+ free(): void;
7
+ /**
8
+ * @param {Uint8Array} weights
9
+ * @param {Uint8Array} tokenizer
10
+ * @param {Uint8Array} config
11
+ */
12
+ constructor(weights: Uint8Array, tokenizer: Uint8Array, config: Uint8Array);
13
+ /**
14
+ * @param {any} input
15
+ * @returns {any}
16
+ */
17
+ decode(input: any): any;
18
+ }
19
+ /**
20
+ */
21
+ export class ModelEncoder {
22
+ free(): void;
23
+ /**
24
+ * @param {Uint8Array} weights
25
+ * @param {Uint8Array} tokenizer
26
+ * @param {Uint8Array} config
27
+ */
28
+ constructor(weights: Uint8Array, tokenizer: Uint8Array, config: Uint8Array);
29
+ /**
30
+ * @param {any} input
31
+ * @returns {any}
32
+ */
33
+ decode(input: any): any;
34
+ }
35
+
36
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
37
+
38
+ export interface InitOutput {
39
+ readonly memory: WebAssembly.Memory;
40
+ readonly __wbg_modelencoder_free: (a: number) => void;
41
+ readonly __wbg_modelconditionalgeneration_free: (a: number) => void;
42
+ readonly modelconditionalgeneration_load: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
43
+ readonly modelconditionalgeneration_decode: (a: number, b: number, c: number) => void;
44
+ readonly modelencoder_load: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
45
+ readonly modelencoder_decode: (a: number, b: number, c: number) => void;
46
+ readonly main: (a: number, b: number) => number;
47
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
48
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
49
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
50
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
51
+ readonly __wbindgen_exn_store: (a: number) => void;
52
+ readonly __wbindgen_start: () => void;
53
+ }
54
+
55
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
56
+ /**
57
+ * Instantiates the given `module`, which can either be bytes or
58
+ * a precompiled `WebAssembly.Module`.
59
+ *
60
+ * @param {SyncInitInput} module
61
+ *
62
+ * @returns {InitOutput}
63
+ */
64
+ export function initSync(module: SyncInitInput): InitOutput;
65
+
66
+ /**
67
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
68
+ * for everything else, calls `WebAssembly.instantiate` directly.
69
+ *
70
+ * @param {InitInput | Promise<InitInput>} module_or_path
71
+ *
72
+ * @returns {Promise<InitOutput>}
73
+ */
74
+ export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
build/m.js ADDED
@@ -0,0 +1,734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let wasm;
2
+
3
+ const heap = new Array(128).fill(undefined);
4
+
5
+ heap.push(undefined, null, true, false);
6
+
7
+ function getObject(idx) { return heap[idx]; }
8
+
9
+ let WASM_VECTOR_LEN = 0;
10
+
11
+ let cachedUint8Memory0 = null;
12
+
13
+ function getUint8Memory0() {
14
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
15
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
16
+ }
17
+ return cachedUint8Memory0;
18
+ }
19
+
20
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
21
+
22
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
23
+ ? function (arg, view) {
24
+ return cachedTextEncoder.encodeInto(arg, view);
25
+ }
26
+ : function (arg, view) {
27
+ const buf = cachedTextEncoder.encode(arg);
28
+ view.set(buf);
29
+ return {
30
+ read: arg.length,
31
+ written: buf.length
32
+ };
33
+ });
34
+
35
+ function passStringToWasm0(arg, malloc, realloc) {
36
+
37
+ if (realloc === undefined) {
38
+ const buf = cachedTextEncoder.encode(arg);
39
+ const ptr = malloc(buf.length, 1) >>> 0;
40
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
41
+ WASM_VECTOR_LEN = buf.length;
42
+ return ptr;
43
+ }
44
+
45
+ let len = arg.length;
46
+ let ptr = malloc(len, 1) >>> 0;
47
+
48
+ const mem = getUint8Memory0();
49
+
50
+ let offset = 0;
51
+
52
+ for (; offset < len; offset++) {
53
+ const code = arg.charCodeAt(offset);
54
+ if (code > 0x7F) break;
55
+ mem[ptr + offset] = code;
56
+ }
57
+
58
+ if (offset !== len) {
59
+ if (offset !== 0) {
60
+ arg = arg.slice(offset);
61
+ }
62
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
63
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
64
+ const ret = encodeString(arg, view);
65
+
66
+ offset += ret.written;
67
+ }
68
+
69
+ WASM_VECTOR_LEN = offset;
70
+ return ptr;
71
+ }
72
+
73
+ function isLikeNone(x) {
74
+ return x === undefined || x === null;
75
+ }
76
+
77
+ let cachedInt32Memory0 = null;
78
+
79
+ function getInt32Memory0() {
80
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
81
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
82
+ }
83
+ return cachedInt32Memory0;
84
+ }
85
+
86
+ let heap_next = heap.length;
87
+
88
+ function dropObject(idx) {
89
+ if (idx < 132) return;
90
+ heap[idx] = heap_next;
91
+ heap_next = idx;
92
+ }
93
+
94
+ function takeObject(idx) {
95
+ const ret = getObject(idx);
96
+ dropObject(idx);
97
+ return ret;
98
+ }
99
+
100
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
101
+
102
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
103
+
104
+ function getStringFromWasm0(ptr, len) {
105
+ ptr = ptr >>> 0;
106
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
107
+ }
108
+
109
+ function addHeapObject(obj) {
110
+ if (heap_next === heap.length) heap.push(heap.length + 1);
111
+ const idx = heap_next;
112
+ heap_next = heap[idx];
113
+
114
+ heap[idx] = obj;
115
+ return idx;
116
+ }
117
+
118
+ let cachedFloat64Memory0 = null;
119
+
120
+ function getFloat64Memory0() {
121
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
122
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
123
+ }
124
+ return cachedFloat64Memory0;
125
+ }
126
+
127
+ let cachedBigInt64Memory0 = null;
128
+
129
+ function getBigInt64Memory0() {
130
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
131
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
132
+ }
133
+ return cachedBigInt64Memory0;
134
+ }
135
+
136
+ function debugString(val) {
137
+ // primitive types
138
+ const type = typeof val;
139
+ if (type == 'number' || type == 'boolean' || val == null) {
140
+ return `${val}`;
141
+ }
142
+ if (type == 'string') {
143
+ return `"${val}"`;
144
+ }
145
+ if (type == 'symbol') {
146
+ const description = val.description;
147
+ if (description == null) {
148
+ return 'Symbol';
149
+ } else {
150
+ return `Symbol(${description})`;
151
+ }
152
+ }
153
+ if (type == 'function') {
154
+ const name = val.name;
155
+ if (typeof name == 'string' && name.length > 0) {
156
+ return `Function(${name})`;
157
+ } else {
158
+ return 'Function';
159
+ }
160
+ }
161
+ // objects
162
+ if (Array.isArray(val)) {
163
+ const length = val.length;
164
+ let debug = '[';
165
+ if (length > 0) {
166
+ debug += debugString(val[0]);
167
+ }
168
+ for(let i = 1; i < length; i++) {
169
+ debug += ', ' + debugString(val[i]);
170
+ }
171
+ debug += ']';
172
+ return debug;
173
+ }
174
+ // Test for built-in
175
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
176
+ let className;
177
+ if (builtInMatches.length > 1) {
178
+ className = builtInMatches[1];
179
+ } else {
180
+ // Failed to match the standard '[object ClassName]'
181
+ return toString.call(val);
182
+ }
183
+ if (className == 'Object') {
184
+ // we're a user defined class or Object
185
+ // JSON.stringify avoids problems with cycles, and is generally much
186
+ // easier than looping through ownProperties of `val`.
187
+ try {
188
+ return 'Object(' + JSON.stringify(val) + ')';
189
+ } catch (_) {
190
+ return 'Object';
191
+ }
192
+ }
193
+ // errors
194
+ if (val instanceof Error) {
195
+ return `${val.name}: ${val.message}\n${val.stack}`;
196
+ }
197
+ // TODO we could test for more things here, like `Set`s and `Map`s.
198
+ return className;
199
+ }
200
+
201
+ function passArray8ToWasm0(arg, malloc) {
202
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
203
+ getUint8Memory0().set(arg, ptr / 1);
204
+ WASM_VECTOR_LEN = arg.length;
205
+ return ptr;
206
+ }
207
+
208
+ function handleError(f, args) {
209
+ try {
210
+ return f.apply(this, args);
211
+ } catch (e) {
212
+ wasm.__wbindgen_exn_store(addHeapObject(e));
213
+ }
214
+ }
215
+ /**
216
+ */
217
+ export class ModelConditionalGeneration {
218
+
219
+ static __wrap(ptr) {
220
+ ptr = ptr >>> 0;
221
+ const obj = Object.create(ModelConditionalGeneration.prototype);
222
+ obj.__wbg_ptr = ptr;
223
+
224
+ return obj;
225
+ }
226
+
227
+ __destroy_into_raw() {
228
+ const ptr = this.__wbg_ptr;
229
+ this.__wbg_ptr = 0;
230
+
231
+ return ptr;
232
+ }
233
+
234
+ free() {
235
+ const ptr = this.__destroy_into_raw();
236
+ wasm.__wbg_modelconditionalgeneration_free(ptr);
237
+ }
238
+ /**
239
+ * @param {Uint8Array} weights
240
+ * @param {Uint8Array} tokenizer
241
+ * @param {Uint8Array} config
242
+ */
243
+ constructor(weights, tokenizer, config) {
244
+ try {
245
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
246
+ const ptr0 = passArray8ToWasm0(weights, wasm.__wbindgen_malloc);
247
+ const len0 = WASM_VECTOR_LEN;
248
+ const ptr1 = passArray8ToWasm0(tokenizer, wasm.__wbindgen_malloc);
249
+ const len1 = WASM_VECTOR_LEN;
250
+ const ptr2 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
251
+ const len2 = WASM_VECTOR_LEN;
252
+ wasm.modelconditionalgeneration_load(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
253
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
254
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
255
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
256
+ if (r2) {
257
+ throw takeObject(r1);
258
+ }
259
+ return ModelConditionalGeneration.__wrap(r0);
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ }
263
+ }
264
+ /**
265
+ * @param {any} input
266
+ * @returns {any}
267
+ */
268
+ decode(input) {
269
+ try {
270
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
271
+ wasm.modelconditionalgeneration_decode(retptr, this.__wbg_ptr, addHeapObject(input));
272
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
273
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
274
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
275
+ if (r2) {
276
+ throw takeObject(r1);
277
+ }
278
+ return takeObject(r0);
279
+ } finally {
280
+ wasm.__wbindgen_add_to_stack_pointer(16);
281
+ }
282
+ }
283
+ }
284
+ /**
285
+ */
286
+ export class ModelEncoder {
287
+
288
+ static __wrap(ptr) {
289
+ ptr = ptr >>> 0;
290
+ const obj = Object.create(ModelEncoder.prototype);
291
+ obj.__wbg_ptr = ptr;
292
+
293
+ return obj;
294
+ }
295
+
296
+ __destroy_into_raw() {
297
+ const ptr = this.__wbg_ptr;
298
+ this.__wbg_ptr = 0;
299
+
300
+ return ptr;
301
+ }
302
+
303
+ free() {
304
+ const ptr = this.__destroy_into_raw();
305
+ wasm.__wbg_modelencoder_free(ptr);
306
+ }
307
+ /**
308
+ * @param {Uint8Array} weights
309
+ * @param {Uint8Array} tokenizer
310
+ * @param {Uint8Array} config
311
+ */
312
+ constructor(weights, tokenizer, config) {
313
+ try {
314
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
315
+ const ptr0 = passArray8ToWasm0(weights, wasm.__wbindgen_malloc);
316
+ const len0 = WASM_VECTOR_LEN;
317
+ const ptr1 = passArray8ToWasm0(tokenizer, wasm.__wbindgen_malloc);
318
+ const len1 = WASM_VECTOR_LEN;
319
+ const ptr2 = passArray8ToWasm0(config, wasm.__wbindgen_malloc);
320
+ const len2 = WASM_VECTOR_LEN;
321
+ wasm.modelencoder_load(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
322
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
323
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
324
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
325
+ if (r2) {
326
+ throw takeObject(r1);
327
+ }
328
+ return ModelEncoder.__wrap(r0);
329
+ } finally {
330
+ wasm.__wbindgen_add_to_stack_pointer(16);
331
+ }
332
+ }
333
+ /**
334
+ * @param {any} input
335
+ * @returns {any}
336
+ */
337
+ decode(input) {
338
+ try {
339
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
340
+ wasm.modelencoder_decode(retptr, this.__wbg_ptr, addHeapObject(input));
341
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
342
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
343
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
344
+ if (r2) {
345
+ throw takeObject(r1);
346
+ }
347
+ return takeObject(r0);
348
+ } finally {
349
+ wasm.__wbindgen_add_to_stack_pointer(16);
350
+ }
351
+ }
352
+ }
353
+
354
+ async function __wbg_load(module, imports) {
355
+ if (typeof Response === 'function' && module instanceof Response) {
356
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
357
+ try {
358
+ return await WebAssembly.instantiateStreaming(module, imports);
359
+
360
+ } catch (e) {
361
+ if (module.headers.get('Content-Type') != 'application/wasm') {
362
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
363
+
364
+ } else {
365
+ throw e;
366
+ }
367
+ }
368
+ }
369
+
370
+ const bytes = await module.arrayBuffer();
371
+ return await WebAssembly.instantiate(bytes, imports);
372
+
373
+ } else {
374
+ const instance = await WebAssembly.instantiate(module, imports);
375
+
376
+ if (instance instanceof WebAssembly.Instance) {
377
+ return { instance, module };
378
+
379
+ } else {
380
+ return instance;
381
+ }
382
+ }
383
+ }
384
+
385
+ function __wbg_get_imports() {
386
+ const imports = {};
387
+ imports.wbg = {};
388
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
389
+ const obj = getObject(arg1);
390
+ const ret = typeof(obj) === 'string' ? obj : undefined;
391
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
392
+ var len1 = WASM_VECTOR_LEN;
393
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
394
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
395
+ };
396
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
397
+ takeObject(arg0);
398
+ };
399
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
400
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
401
+ return addHeapObject(ret);
402
+ };
403
+ imports.wbg.__wbindgen_is_bigint = function(arg0) {
404
+ const ret = typeof(getObject(arg0)) === 'bigint';
405
+ return ret;
406
+ };
407
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
408
+ const ret = BigInt.asUintN(64, arg0);
409
+ return addHeapObject(ret);
410
+ };
411
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
412
+ const ret = getObject(arg0) === getObject(arg1);
413
+ return ret;
414
+ };
415
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
416
+ const v = getObject(arg0);
417
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
418
+ return ret;
419
+ };
420
+ imports.wbg.__wbindgen_is_object = function(arg0) {
421
+ const val = getObject(arg0);
422
+ const ret = typeof(val) === 'object' && val !== null;
423
+ return ret;
424
+ };
425
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
426
+ const ret = getObject(arg0) === undefined;
427
+ return ret;
428
+ };
429
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
430
+ const ret = getObject(arg0) in getObject(arg1);
431
+ return ret;
432
+ };
433
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
434
+ const obj = getObject(arg1);
435
+ const ret = typeof(obj) === 'number' ? obj : undefined;
436
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
437
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
438
+ };
439
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
440
+ const ret = getObject(arg0);
441
+ return addHeapObject(ret);
442
+ };
443
+ imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
444
+ const ret = getObject(arg0) == getObject(arg1);
445
+ return ret;
446
+ };
447
+ imports.wbg.__wbg_String_4370c5505c674d30 = function(arg0, arg1) {
448
+ const ret = String(getObject(arg1));
449
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
450
+ const len1 = WASM_VECTOR_LEN;
451
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
452
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
453
+ };
454
+ imports.wbg.__wbindgen_number_new = function(arg0) {
455
+ const ret = arg0;
456
+ return addHeapObject(ret);
457
+ };
458
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
459
+ const ret = getStringFromWasm0(arg0, arg1);
460
+ return addHeapObject(ret);
461
+ };
462
+ imports.wbg.__wbg_getwithrefkey_d1f0d12f1f1b63ea = function(arg0, arg1) {
463
+ const ret = getObject(arg0)[getObject(arg1)];
464
+ return addHeapObject(ret);
465
+ };
466
+ imports.wbg.__wbg_set_bd72c078edfa51ad = function(arg0, arg1, arg2) {
467
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
468
+ };
469
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
470
+ const ret = new Error();
471
+ return addHeapObject(ret);
472
+ };
473
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
474
+ const ret = getObject(arg1).stack;
475
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
476
+ const len1 = WASM_VECTOR_LEN;
477
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
478
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
479
+ };
480
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
481
+ let deferred0_0;
482
+ let deferred0_1;
483
+ try {
484
+ deferred0_0 = arg0;
485
+ deferred0_1 = arg1;
486
+ console.error(getStringFromWasm0(arg0, arg1));
487
+ } finally {
488
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
489
+ }
490
+ };
491
+ imports.wbg.__wbg_log_e25c897af30cb287 = function(arg0, arg1) {
492
+ console.log(getStringFromWasm0(arg0, arg1));
493
+ };
494
+ imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
495
+ const ret = getObject(arg0).crypto;
496
+ return addHeapObject(ret);
497
+ };
498
+ imports.wbg.__wbg_process_298734cf255a885d = function(arg0) {
499
+ const ret = getObject(arg0).process;
500
+ return addHeapObject(ret);
501
+ };
502
+ imports.wbg.__wbg_versions_e2e78e134e3e5d01 = function(arg0) {
503
+ const ret = getObject(arg0).versions;
504
+ return addHeapObject(ret);
505
+ };
506
+ imports.wbg.__wbg_node_1cd7a5d853dbea79 = function(arg0) {
507
+ const ret = getObject(arg0).node;
508
+ return addHeapObject(ret);
509
+ };
510
+ imports.wbg.__wbindgen_is_string = function(arg0) {
511
+ const ret = typeof(getObject(arg0)) === 'string';
512
+ return ret;
513
+ };
514
+ imports.wbg.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) {
515
+ const ret = getObject(arg0).msCrypto;
516
+ return addHeapObject(ret);
517
+ };
518
+ imports.wbg.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () {
519
+ const ret = module.require;
520
+ return addHeapObject(ret);
521
+ }, arguments) };
522
+ imports.wbg.__wbindgen_is_function = function(arg0) {
523
+ const ret = typeof(getObject(arg0)) === 'function';
524
+ return ret;
525
+ };
526
+ imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
527
+ getObject(arg0).getRandomValues(getObject(arg1));
528
+ }, arguments) };
529
+ imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
530
+ getObject(arg0).randomFillSync(takeObject(arg1));
531
+ }, arguments) };
532
+ imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) {
533
+ const ret = getObject(arg0)[arg1 >>> 0];
534
+ return addHeapObject(ret);
535
+ };
536
+ imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) {
537
+ const ret = getObject(arg0).length;
538
+ return ret;
539
+ };
540
+ imports.wbg.__wbg_new_898a68150f225f2e = function() {
541
+ const ret = new Array();
542
+ return addHeapObject(ret);
543
+ };
544
+ imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
545
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
546
+ return addHeapObject(ret);
547
+ };
548
+ imports.wbg.__wbg_next_526fc47e980da008 = function(arg0) {
549
+ const ret = getObject(arg0).next;
550
+ return addHeapObject(ret);
551
+ };
552
+ imports.wbg.__wbg_next_ddb3312ca1c4e32a = function() { return handleError(function (arg0) {
553
+ const ret = getObject(arg0).next();
554
+ return addHeapObject(ret);
555
+ }, arguments) };
556
+ imports.wbg.__wbg_done_5c1f01fb660d73b5 = function(arg0) {
557
+ const ret = getObject(arg0).done;
558
+ return ret;
559
+ };
560
+ imports.wbg.__wbg_value_1695675138684bd5 = function(arg0) {
561
+ const ret = getObject(arg0).value;
562
+ return addHeapObject(ret);
563
+ };
564
+ imports.wbg.__wbg_iterator_97f0c81209c6c35a = function() {
565
+ const ret = Symbol.iterator;
566
+ return addHeapObject(ret);
567
+ };
568
+ imports.wbg.__wbg_get_97b561fb56f034b5 = function() { return handleError(function (arg0, arg1) {
569
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
570
+ return addHeapObject(ret);
571
+ }, arguments) };
572
+ imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
573
+ const ret = getObject(arg0).call(getObject(arg1));
574
+ return addHeapObject(ret);
575
+ }, arguments) };
576
+ imports.wbg.__wbg_new_b51585de1b234aff = function() {
577
+ const ret = new Object();
578
+ return addHeapObject(ret);
579
+ };
580
+ imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
581
+ const ret = self.self;
582
+ return addHeapObject(ret);
583
+ }, arguments) };
584
+ imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
585
+ const ret = window.window;
586
+ return addHeapObject(ret);
587
+ }, arguments) };
588
+ imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
589
+ const ret = globalThis.globalThis;
590
+ return addHeapObject(ret);
591
+ }, arguments) };
592
+ imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
593
+ const ret = global.global;
594
+ return addHeapObject(ret);
595
+ }, arguments) };
596
+ imports.wbg.__wbg_set_502d29070ea18557 = function(arg0, arg1, arg2) {
597
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
598
+ };
599
+ imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) {
600
+ const ret = Array.isArray(getObject(arg0));
601
+ return ret;
602
+ };
603
+ imports.wbg.__wbg_instanceof_ArrayBuffer_39ac22089b74fddb = function(arg0) {
604
+ let result;
605
+ try {
606
+ result = getObject(arg0) instanceof ArrayBuffer;
607
+ } catch {
608
+ result = false;
609
+ }
610
+ const ret = result;
611
+ return ret;
612
+ };
613
+ imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
614
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
615
+ return addHeapObject(ret);
616
+ }, arguments) };
617
+ imports.wbg.__wbg_isSafeInteger_bb8e18dd21c97288 = function(arg0) {
618
+ const ret = Number.isSafeInteger(getObject(arg0));
619
+ return ret;
620
+ };
621
+ imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
622
+ const ret = getObject(arg0).buffer;
623
+ return addHeapObject(ret);
624
+ };
625
+ imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
626
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
627
+ return addHeapObject(ret);
628
+ };
629
+ imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
630
+ const ret = new Uint8Array(getObject(arg0));
631
+ return addHeapObject(ret);
632
+ };
633
+ imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
634
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
635
+ };
636
+ imports.wbg.__wbg_length_72e2208bbc0efc61 = function(arg0) {
637
+ const ret = getObject(arg0).length;
638
+ return ret;
639
+ };
640
+ imports.wbg.__wbg_instanceof_Uint8Array_d8d9cb2b8e8ac1d4 = function(arg0) {
641
+ let result;
642
+ try {
643
+ result = getObject(arg0) instanceof Uint8Array;
644
+ } catch {
645
+ result = false;
646
+ }
647
+ const ret = result;
648
+ return ret;
649
+ };
650
+ imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
651
+ const ret = new Uint8Array(arg0 >>> 0);
652
+ return addHeapObject(ret);
653
+ };
654
+ imports.wbg.__wbg_subarray_13db269f57aa838d = function(arg0, arg1, arg2) {
655
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
656
+ return addHeapObject(ret);
657
+ };
658
+ imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
659
+ const v = getObject(arg1);
660
+ const ret = typeof(v) === 'bigint' ? v : undefined;
661
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
662
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
663
+ };
664
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
665
+ const ret = debugString(getObject(arg1));
666
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
667
+ const len1 = WASM_VECTOR_LEN;
668
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
669
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
670
+ };
671
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
672
+ throw new Error(getStringFromWasm0(arg0, arg1));
673
+ };
674
+ imports.wbg.__wbindgen_memory = function() {
675
+ const ret = wasm.memory;
676
+ return addHeapObject(ret);
677
+ };
678
+
679
+ return imports;
680
+ }
681
+
682
+ function __wbg_init_memory(imports, maybe_memory) {
683
+
684
+ }
685
+
686
+ function __wbg_finalize_init(instance, module) {
687
+ wasm = instance.exports;
688
+ __wbg_init.__wbindgen_wasm_module = module;
689
+ cachedBigInt64Memory0 = null;
690
+ cachedFloat64Memory0 = null;
691
+ cachedInt32Memory0 = null;
692
+ cachedUint8Memory0 = null;
693
+
694
+ wasm.__wbindgen_start();
695
+ return wasm;
696
+ }
697
+
698
+ function initSync(module) {
699
+ if (wasm !== undefined) return wasm;
700
+
701
+ const imports = __wbg_get_imports();
702
+
703
+ __wbg_init_memory(imports);
704
+
705
+ if (!(module instanceof WebAssembly.Module)) {
706
+ module = new WebAssembly.Module(module);
707
+ }
708
+
709
+ const instance = new WebAssembly.Instance(module, imports);
710
+
711
+ return __wbg_finalize_init(instance, module);
712
+ }
713
+
714
+ async function __wbg_init(input) {
715
+ if (wasm !== undefined) return wasm;
716
+
717
+ if (typeof input === 'undefined') {
718
+ input = new URL('m_bg.wasm', import.meta.url);
719
+ }
720
+ const imports = __wbg_get_imports();
721
+
722
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
723
+ input = fetch(input);
724
+ }
725
+
726
+ __wbg_init_memory(imports);
727
+
728
+ const { instance, module } = await __wbg_load(await input, imports);
729
+
730
+ return __wbg_finalize_init(instance, module);
731
+ }
732
+
733
+ export { initSync }
734
+ export default __wbg_init;
build/m_bg.wasm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:362af429fe4623033b2b9b2aad06b36a927af4888dff9c2f1d45c2a4f7a4d4ea
3
+ size 4059722
build/m_bg.wasm.d.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export function __wbg_modelencoder_free(a: number): void;
5
+ export function __wbg_modelconditionalgeneration_free(a: number): void;
6
+ export function modelconditionalgeneration_load(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
7
+ export function modelconditionalgeneration_decode(a: number, b: number, c: number): void;
8
+ export function modelencoder_load(a: number, b: number, c: number, d: number, e: number, f: number, g: number): void;
9
+ export function modelencoder_decode(a: number, b: number, c: number): void;
10
+ export function main(a: number, b: number): number;
11
+ export function __wbindgen_malloc(a: number, b: number): number;
12
+ export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
13
+ export function __wbindgen_add_to_stack_pointer(a: number): number;
14
+ export function __wbindgen_free(a: number, b: number, c: number): void;
15
+ export function __wbindgen_exn_store(a: number): void;
16
+ export function __wbindgen_start(): void;
index.html CHANGED
@@ -1,19 +1,278 @@
 
 
 
 
 
 
 
 
 
1
  <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <html>
2
+ <head>
3
+ <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
4
+ <title>Candle T5</title>
5
+ </head>
6
+
7
+ <body></body>
8
+ </html>
9
+
10
  <!DOCTYPE html>
11
  <html>
12
+ <head>
13
+ <meta charset="UTF-8" />
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
+ <style>
16
+ @import url("https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@200;300;400&family=Source+Sans+3:wght@100;200;300;400;500;600;700;800;900&display=swap");
17
+
18
+ html,
19
+ body {
20
+ font-family: "Source Sans 3", sans-serif;
21
+ }
22
+ </style>
23
+ <style type="text/tailwindcss">
24
+ .link {
25
+ @apply underline hover:text-blue-500 hover:no-underline;
26
+ }
27
+ </style>
28
+ <script src="https://cdn.tailwindcss.com"></script>
29
+ <script type="module">
30
+ import {
31
+ getModelInfo,
32
+ MODELS,
33
+ extractEmbeddings,
34
+ generateText,
35
+ } from "./utils.js";
36
+
37
+ const t5ModelEncoderWorker = new Worker("./T5ModelEncoderWorker.js", {
38
+ type: "module",
39
+ });
40
+ const t5ModelConditionalGeneration = new Worker(
41
+ "./T5ModelConditionalGeneration.js",
42
+ { type: "module" }
43
+ );
44
+
45
+ const formEl = document.querySelector("#form");
46
+ const modelEl = document.querySelector("#model");
47
+ const promptEl = document.querySelector("#prompt");
48
+ const temperatureEl = document.querySelector("#temperature");
49
+ const toppEL = document.querySelector("#top-p");
50
+ const repeatPenaltyEl = document.querySelector("#repeat_penalty");
51
+ const seedEl = document.querySelector("#seed");
52
+ const outputEl = document.querySelector("#output-generation");
53
+ const tasksEl = document.querySelector("#tasks");
54
+ let selectedTaskID = "";
55
+
56
+ document.addEventListener("DOMContentLoaded", () => {
57
+ for (const [id, model] of Object.entries(MODELS)) {
58
+ const option = document.createElement("option");
59
+ option.value = id;
60
+ option.innerText = `${id} (${model.size})`;
61
+ modelEl.appendChild(option);
62
+ }
63
+ populateTasks(modelEl.value);
64
+ modelEl.addEventListener("change", (e) => {
65
+ populateTasks(e.target.value);
66
+ });
67
+ tasksEl.addEventListener("change", (e) => {
68
+ const task = e.target.value;
69
+ const modelID = modelEl.value;
70
+ promptEl.value = MODELS[modelID].tasks[task].prefix;
71
+ selectedTaskID = task;
72
+ });
73
+ });
74
+ function populateTasks(modelID) {
75
+ const tasks = MODELS[modelID].tasks;
76
+ tasksEl.innerHTML = "";
77
+ for (const [task, params] of Object.entries(tasks)) {
78
+ const div = document.createElement("div");
79
+ div.innerHTML = `
80
+ <input
81
+ type="radio"
82
+ name="task"
83
+ id="${task}"
84
+ class="font-light cursor-pointer"
85
+ value="${task}" />
86
+ <label for="${task}" class="cursor-pointer">
87
+ ${params.prefix}
88
+ </label>
89
+ `;
90
+ tasksEl.appendChild(div);
91
+ }
92
+ selectedTaskID = Object.keys(tasks)[0];
93
+ tasksEl.querySelector(`#${selectedTaskID}`).checked = true;
94
+ }
95
+ form.addEventListener("submit", (e) => {
96
+ e.preventDefault();
97
+
98
+ const promptText = promptEl.value;
99
+ const modelID = modelEl.value;
100
+ const { modelURL, configURL, tokenizerURL, maxLength } = getModelInfo(
101
+ modelID,
102
+ selectedTaskID
103
+ );
104
+ const params = {
105
+ temperature: Number(temperatureEl.value),
106
+ top_p: Number(toppEL.value),
107
+ repetition_penalty: Number(repeatPenaltyEl.value),
108
+ seed: BigInt(seedEl.value),
109
+ max_length: maxLength,
110
+ };
111
+ generateText(
112
+ t5ModelConditionalGeneration,
113
+ modelURL,
114
+ tokenizerURL,
115
+ configURL,
116
+ modelID,
117
+ promptText,
118
+ params,
119
+ (status) => {
120
+ if (status.status === "loading") {
121
+ outputEl.innerText = "Loading model...";
122
+ }
123
+ if (status.status === "decoding") {
124
+ outputEl.innerText = "Generating...";
125
+ }
126
+ }
127
+ ).then(({ output }) => {
128
+ outputEl.innerText = output.generation;
129
+ });
130
+ });
131
+ </script>
132
+ </head>
133
+
134
+ <body class="container max-w-4xl mx-auto p-4">
135
+ <main class="grid grid-cols-1 gap-8 relative">
136
+ <span class="absolute text-5xl -ml-[1em]"> 🕯️ </span>
137
+ <div>
138
+ <h1 class="text-5xl font-bold">Candle T5 Transformer</h1>
139
+ <h2 class="text-2xl font-bold">Rust/WASM Demo</h2>
140
+ <p class="max-w-lg">
141
+ This demo runs Text-To-Text Transfer Transformer
142
+ <a
143
+ href="https://blog.research.google/2020/02/exploring-transfer-learning-with-t5.html"
144
+ target="_blank"
145
+ class="link">
146
+ T5
147
+ </a>
148
+ with
149
+ <a
150
+ href="https://github.com/huggingface/candle/"
151
+ target="_blank"
152
+ class="link">
153
+ Candle
154
+ </a>
155
+ in the browser using rust/wasm. Models
156
+ <a
157
+ href="https://huggingface.co/t5-small"
158
+ target="_blank"
159
+ class="link">
160
+ t5-small </a
161
+ >,
162
+ <a href="https://huggingface.co/t5-base" target="_blank" class="link">
163
+ t5-base </a
164
+ >,
165
+ <a
166
+ href="https://huggingface.co/google/flan-t5-small"
167
+ target="_blank"
168
+ class="link"
169
+ >flan-t5-small
170
+ </a>
171
+ and a few
172
+ <a
173
+ href="https://huggingface.co/lmz/candle-quantized-t5/tree/main"
174
+ target="_blank"
175
+ class="link">
176
+ t5 quantized gguf
177
+ </a>
178
+ are available.
179
+ </p>
180
+ </div>
181
+
182
+ <div>
183
+ <label for="model" class="font-medium">Models Options: </label>
184
+ <select
185
+ id="model"
186
+ class="border-2 border-gray-500 rounded-md font-light"></select>
187
+ </div>
188
+
189
+ <div>
190
+ <h3 class="font-medium">Task Prefix:</h3>
191
+ <form id="tasks" class="flex flex-col gap-1 my-2"></form>
192
+ </div>
193
+ <form
194
+ id="form"
195
+ class="flex text-normal px-1 py-1 border border-gray-700 rounded-md items-center">
196
+ <input type="submit" hidden />
197
+ <input
198
+ type="text"
199
+ id="prompt"
200
+ class="font-light w-full px-3 py-2 mx-1 resize-none outline-none"
201
+ placeholder="Add prompt here, e.g. 'translate English to German: Today I'm going to eat Ice Cream'"
202
+ value="translate English to German: Today I'm going to eat Ice Cream" />
203
+ <button
204
+ class="bg-gray-700 hover:bg-gray-800 text-white font-normal py-2 w-16 rounded disabled:bg-gray-300 disabled:cursor-not-allowed">
205
+ Run
206
+ </button>
207
+ </form>
208
+ <div class="grid grid-cols-3 max-w-md items-center gap-3">
209
+ <label class="text-sm font-medium" for="temperature">Temperature</label>
210
+ <input
211
+ type="range"
212
+ id="temperature"
213
+ name="temperature"
214
+ min="0"
215
+ max="2"
216
+ step="0.01"
217
+ value="0.00"
218
+ oninput="this.nextElementSibling.value = Number(this.value).toFixed(2)" />
219
+ <output
220
+ class="text-xs w-[50px] text-center font-light px-1 py-1 border border-gray-700 rounded-md">
221
+ 0.00</output
222
+ >
223
+ <label class="text-sm font-medium" for="top-p">Top-p</label>
224
+ <input
225
+ type="range"
226
+ id="top-p"
227
+ name="top-p"
228
+ min="0"
229
+ max="1"
230
+ step="0.01"
231
+ value="1.00"
232
+ oninput="this.nextElementSibling.value = Number(this.value).toFixed(2)" />
233
+ <output
234
+ class="text-xs w-[50px] text-center font-light px-1 py-1 border border-gray-700 rounded-md">
235
+ 1.00</output
236
+ >
237
+
238
+ <label class="text-sm font-medium" for="repeat_penalty"
239
+ >Repeat Penalty</label
240
+ >
241
+
242
+ <input
243
+ type="range"
244
+ id="repeat_penalty"
245
+ name="repeat_penalty"
246
+ min="-2"
247
+ max="2"
248
+ step="0.01"
249
+ value="1.10"
250
+ oninput="this.nextElementSibling.value = Number(this.value).toFixed(2)" />
251
+ <output
252
+ class="text-xs w-[50px] text-center font-light px-1 py-1 border border-gray-700 rounded-md"
253
+ >1.10</output
254
+ >
255
+ <label class="text-sm font-medium" for="seed">Seed</label>
256
+ <input
257
+ type="number"
258
+ id="seed"
259
+ name="seed"
260
+ value="299792458"
261
+ class="font-light border border-gray-700 text-right rounded-md p-2" />
262
+ <button
263
+ id="run"
264
+ onclick="document.querySelector('#seed').value = BigInt(Math.floor(Math.random() * 2**64-1))"
265
+ class="bg-gray-700 hover:bg-gray-800 text-white font-normal py-1 w-[50px] rounded disabled:bg-gray-300 disabled:cursor-not-allowed text-sm">
266
+ Rand
267
+ </button>
268
+ </div>
269
+ <div>
270
+ <h3 class="font-medium">Generation:</h3>
271
+ <div
272
+ class="min-h-[250px] bg-slate-100 text-gray-500 p-4 rounded-md flex flex-col gap-2 text-lg">
273
+ <p id="output-generation" class="grid-rows-2">No output yet</p>
274
+ </div>
275
+ </div>
276
+ </main>
277
+ </body>
278
  </html>