Alex Cabrera commited on
Commit
5fe04ed
1 Parent(s): 5500788

initial commit

Browse files
.dockerignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .git
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ docs.index filter=lfs diff=lfs merge=lfs -text
.zeno_cache/OUTPUTGPT-3.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64d0926959de922268e3c7424e0fd7e638e820d3be9238ebe025a035b0ca8331
3
+ size 8579
.zeno_cache/POSTDISTILLcorrectGPT-3.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da50fff84341add16a4695d17e748453ac60b2e77dc25b28cfa93f2f467c93de
3
+ size 1506
.zeno_cache/folders.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec0a6ccf9debf1c16781445c4b9106080d00478b0559469336db7c7b7b9711c8
3
+ size 5
.zeno_cache/reports.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5da26028c635b1a8beee4b0759fbd4a8a86f5361ae95fc718aca4dd67e3ad50b
3
+ size 200
.zeno_cache/view.mjs ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function noop() { }
2
+ function run(fn) {
3
+ return fn();
4
+ }
5
+ function blank_object() {
6
+ return Object.create(null);
7
+ }
8
+ function run_all(fns) {
9
+ fns.forEach(run);
10
+ }
11
+ function is_function(thing) {
12
+ return typeof thing === 'function';
13
+ }
14
+ function safe_not_equal(a, b) {
15
+ return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
16
+ }
17
+ function is_empty(obj) {
18
+ return Object.keys(obj).length === 0;
19
+ }
20
+
21
+ // Track which nodes are claimed during hydration. Unclaimed nodes can then be removed from the DOM
22
+ // at the end of hydration without touching the remaining nodes.
23
+ let is_hydrating = false;
24
+ function start_hydrating() {
25
+ is_hydrating = true;
26
+ }
27
+ function end_hydrating() {
28
+ is_hydrating = false;
29
+ }
30
+ function upper_bound(low, high, key, value) {
31
+ // Return first index of value larger than input value in the range [low, high)
32
+ while (low < high) {
33
+ const mid = low + ((high - low) >> 1);
34
+ if (key(mid) <= value) {
35
+ low = mid + 1;
36
+ }
37
+ else {
38
+ high = mid;
39
+ }
40
+ }
41
+ return low;
42
+ }
43
+ function init_hydrate(target) {
44
+ if (target.hydrate_init)
45
+ return;
46
+ target.hydrate_init = true;
47
+ // We know that all children have claim_order values since the unclaimed have been detached if target is not <head>
48
+ let children = target.childNodes;
49
+ // If target is <head>, there may be children without claim_order
50
+ if (target.nodeName === 'HEAD') {
51
+ const myChildren = [];
52
+ for (let i = 0; i < children.length; i++) {
53
+ const node = children[i];
54
+ if (node.claim_order !== undefined) {
55
+ myChildren.push(node);
56
+ }
57
+ }
58
+ children = myChildren;
59
+ }
60
+ /*
61
+ * Reorder claimed children optimally.
62
+ * We can reorder claimed children optimally by finding the longest subsequence of
63
+ * nodes that are already claimed in order and only moving the rest. The longest
64
+ * subsequence of nodes that are claimed in order can be found by
65
+ * computing the longest increasing subsequence of .claim_order values.
66
+ *
67
+ * This algorithm is optimal in generating the least amount of reorder operations
68
+ * possible.
69
+ *
70
+ * Proof:
71
+ * We know that, given a set of reordering operations, the nodes that do not move
72
+ * always form an increasing subsequence, since they do not move among each other
73
+ * meaning that they must be already ordered among each other. Thus, the maximal
74
+ * set of nodes that do not move form a longest increasing subsequence.
75
+ */
76
+ // Compute longest increasing subsequence
77
+ // m: subsequence length j => index k of smallest value that ends an increasing subsequence of length j
78
+ const m = new Int32Array(children.length + 1);
79
+ // Predecessor indices + 1
80
+ const p = new Int32Array(children.length);
81
+ m[0] = -1;
82
+ let longest = 0;
83
+ for (let i = 0; i < children.length; i++) {
84
+ const current = children[i].claim_order;
85
+ // Find the largest subsequence length such that it ends in a value less than our current value
86
+ // upper_bound returns first greater value, so we subtract one
87
+ // with fast path for when we are on the current longest subsequence
88
+ const seqLen = ((longest > 0 && children[m[longest]].claim_order <= current) ? longest + 1 : upper_bound(1, longest, idx => children[m[idx]].claim_order, current)) - 1;
89
+ p[i] = m[seqLen] + 1;
90
+ const newLen = seqLen + 1;
91
+ // We can guarantee that current is the smallest value. Otherwise, we would have generated a longer sequence.
92
+ m[newLen] = i;
93
+ longest = Math.max(newLen, longest);
94
+ }
95
+ // The longest increasing subsequence of nodes (initially reversed)
96
+ const lis = [];
97
+ // The rest of the nodes, nodes that will be moved
98
+ const toMove = [];
99
+ let last = children.length - 1;
100
+ for (let cur = m[longest] + 1; cur != 0; cur = p[cur - 1]) {
101
+ lis.push(children[cur - 1]);
102
+ for (; last >= cur; last--) {
103
+ toMove.push(children[last]);
104
+ }
105
+ last--;
106
+ }
107
+ for (; last >= 0; last--) {
108
+ toMove.push(children[last]);
109
+ }
110
+ lis.reverse();
111
+ // We sort the nodes being moved to guarantee that their insertion order matches the claim order
112
+ toMove.sort((a, b) => a.claim_order - b.claim_order);
113
+ // Finally, we move the nodes
114
+ for (let i = 0, j = 0; i < toMove.length; i++) {
115
+ while (j < lis.length && toMove[i].claim_order >= lis[j].claim_order) {
116
+ j++;
117
+ }
118
+ const anchor = j < lis.length ? lis[j] : null;
119
+ target.insertBefore(toMove[i], anchor);
120
+ }
121
+ }
122
+ function append(target, node) {
123
+ target.appendChild(node);
124
+ }
125
+ function append_styles(target, style_sheet_id, styles) {
126
+ const append_styles_to = get_root_for_style(target);
127
+ if (!append_styles_to.getElementById(style_sheet_id)) {
128
+ const style = element('style');
129
+ style.id = style_sheet_id;
130
+ style.textContent = styles;
131
+ append_stylesheet(append_styles_to, style);
132
+ }
133
+ }
134
+ function get_root_for_style(node) {
135
+ if (!node)
136
+ return document;
137
+ const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
138
+ if (root && root.host) {
139
+ return root;
140
+ }
141
+ return node.ownerDocument;
142
+ }
143
+ function append_stylesheet(node, style) {
144
+ append(node.head || node, style);
145
+ return style.sheet;
146
+ }
147
+ function append_hydration(target, node) {
148
+ if (is_hydrating) {
149
+ init_hydrate(target);
150
+ if ((target.actual_end_child === undefined) || ((target.actual_end_child !== null) && (target.actual_end_child.parentNode !== target))) {
151
+ target.actual_end_child = target.firstChild;
152
+ }
153
+ // Skip nodes of undefined ordering
154
+ while ((target.actual_end_child !== null) && (target.actual_end_child.claim_order === undefined)) {
155
+ target.actual_end_child = target.actual_end_child.nextSibling;
156
+ }
157
+ if (node !== target.actual_end_child) {
158
+ // We only insert if the ordering of this node should be modified or the parent node is not target
159
+ if (node.claim_order !== undefined || node.parentNode !== target) {
160
+ target.insertBefore(node, target.actual_end_child);
161
+ }
162
+ }
163
+ else {
164
+ target.actual_end_child = node.nextSibling;
165
+ }
166
+ }
167
+ else if (node.parentNode !== target || node.nextSibling !== null) {
168
+ target.appendChild(node);
169
+ }
170
+ }
171
+ function insert_hydration(target, node, anchor) {
172
+ if (is_hydrating && !anchor) {
173
+ append_hydration(target, node);
174
+ }
175
+ else if (node.parentNode !== target || node.nextSibling != anchor) {
176
+ target.insertBefore(node, anchor || null);
177
+ }
178
+ }
179
+ function detach(node) {
180
+ if (node.parentNode) {
181
+ node.parentNode.removeChild(node);
182
+ }
183
+ }
184
+ function element(name) {
185
+ return document.createElement(name);
186
+ }
187
+ function svg_element(name) {
188
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
189
+ }
190
+ function text(data) {
191
+ return document.createTextNode(data);
192
+ }
193
+ function space() {
194
+ return text(' ');
195
+ }
196
+ function attr(node, attribute, value) {
197
+ if (value == null)
198
+ node.removeAttribute(attribute);
199
+ else if (node.getAttribute(attribute) !== value)
200
+ node.setAttribute(attribute, value);
201
+ }
202
+ function children(element) {
203
+ return Array.from(element.childNodes);
204
+ }
205
+ function init_claim_info(nodes) {
206
+ if (nodes.claim_info === undefined) {
207
+ nodes.claim_info = { last_index: 0, total_claimed: 0 };
208
+ }
209
+ }
210
+ function claim_node(nodes, predicate, processNode, createNode, dontUpdateLastIndex = false) {
211
+ // Try to find nodes in an order such that we lengthen the longest increasing subsequence
212
+ init_claim_info(nodes);
213
+ const resultNode = (() => {
214
+ // We first try to find an element after the previous one
215
+ for (let i = nodes.claim_info.last_index; i < nodes.length; i++) {
216
+ const node = nodes[i];
217
+ if (predicate(node)) {
218
+ const replacement = processNode(node);
219
+ if (replacement === undefined) {
220
+ nodes.splice(i, 1);
221
+ }
222
+ else {
223
+ nodes[i] = replacement;
224
+ }
225
+ if (!dontUpdateLastIndex) {
226
+ nodes.claim_info.last_index = i;
227
+ }
228
+ return node;
229
+ }
230
+ }
231
+ // Otherwise, we try to find one before
232
+ // We iterate in reverse so that we don't go too far back
233
+ for (let i = nodes.claim_info.last_index - 1; i >= 0; i--) {
234
+ const node = nodes[i];
235
+ if (predicate(node)) {
236
+ const replacement = processNode(node);
237
+ if (replacement === undefined) {
238
+ nodes.splice(i, 1);
239
+ }
240
+ else {
241
+ nodes[i] = replacement;
242
+ }
243
+ if (!dontUpdateLastIndex) {
244
+ nodes.claim_info.last_index = i;
245
+ }
246
+ else if (replacement === undefined) {
247
+ // Since we spliced before the last_index, we decrease it
248
+ nodes.claim_info.last_index--;
249
+ }
250
+ return node;
251
+ }
252
+ }
253
+ // If we can't find any matching node, we create a new one
254
+ return createNode();
255
+ })();
256
+ resultNode.claim_order = nodes.claim_info.total_claimed;
257
+ nodes.claim_info.total_claimed += 1;
258
+ return resultNode;
259
+ }
260
+ function claim_element_base(nodes, name, attributes, create_element) {
261
+ return claim_node(nodes, (node) => node.nodeName === name, (node) => {
262
+ const remove = [];
263
+ for (let j = 0; j < node.attributes.length; j++) {
264
+ const attribute = node.attributes[j];
265
+ if (!attributes[attribute.name]) {
266
+ remove.push(attribute.name);
267
+ }
268
+ }
269
+ remove.forEach(v => node.removeAttribute(v));
270
+ return undefined;
271
+ }, () => create_element(name));
272
+ }
273
+ function claim_element(nodes, name, attributes) {
274
+ return claim_element_base(nodes, name, attributes, element);
275
+ }
276
+ function claim_svg_element(nodes, name, attributes) {
277
+ return claim_element_base(nodes, name, attributes, svg_element);
278
+ }
279
+ function claim_text(nodes, data) {
280
+ return claim_node(nodes, (node) => node.nodeType === 3, (node) => {
281
+ const dataStr = '' + data;
282
+ if (node.data.startsWith(dataStr)) {
283
+ if (node.data.length !== dataStr.length) {
284
+ return node.splitText(dataStr.length);
285
+ }
286
+ }
287
+ else {
288
+ node.data = dataStr;
289
+ }
290
+ }, () => text(data), true // Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements
291
+ );
292
+ }
293
+ function claim_space(nodes) {
294
+ return claim_text(nodes, ' ');
295
+ }
296
+ function set_data(text, data) {
297
+ data = '' + data;
298
+ if (text.wholeText !== data)
299
+ text.data = data;
300
+ }
301
+
302
+ let current_component;
303
+ function set_current_component(component) {
304
+ current_component = component;
305
+ }
306
+
307
+ const dirty_components = [];
308
+ const binding_callbacks = [];
309
+ const render_callbacks = [];
310
+ const flush_callbacks = [];
311
+ const resolved_promise = Promise.resolve();
312
+ let update_scheduled = false;
313
+ function schedule_update() {
314
+ if (!update_scheduled) {
315
+ update_scheduled = true;
316
+ resolved_promise.then(flush);
317
+ }
318
+ }
319
+ function add_render_callback(fn) {
320
+ render_callbacks.push(fn);
321
+ }
322
+ // flush() calls callbacks in this order:
323
+ // 1. All beforeUpdate callbacks, in order: parents before children
324
+ // 2. All bind:this callbacks, in reverse order: children before parents.
325
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
326
+ // for afterUpdates called during the initial onMount, which are called in
327
+ // reverse order: children before parents.
328
+ // Since callbacks might update component values, which could trigger another
329
+ // call to flush(), the following steps guard against this:
330
+ // 1. During beforeUpdate, any updated components will be added to the
331
+ // dirty_components array and will cause a reentrant call to flush(). Because
332
+ // the flush index is kept outside the function, the reentrant call will pick
333
+ // up where the earlier call left off and go through all dirty components. The
334
+ // current_component value is saved and restored so that the reentrant call will
335
+ // not interfere with the "parent" flush() call.
336
+ // 2. bind:this callbacks cannot trigger new flush() calls.
337
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
338
+ // callback called a second time; the seen_callbacks set, outside the flush()
339
+ // function, guarantees this behavior.
340
+ const seen_callbacks = new Set();
341
+ let flushidx = 0; // Do *not* move this inside the flush() function
342
+ function flush() {
343
+ // Do not reenter flush while dirty components are updated, as this can
344
+ // result in an infinite loop. Instead, let the inner flush handle it.
345
+ // Reentrancy is ok afterwards for bindings etc.
346
+ if (flushidx !== 0) {
347
+ return;
348
+ }
349
+ const saved_component = current_component;
350
+ do {
351
+ // first, call beforeUpdate functions
352
+ // and update components
353
+ try {
354
+ while (flushidx < dirty_components.length) {
355
+ const component = dirty_components[flushidx];
356
+ flushidx++;
357
+ set_current_component(component);
358
+ update(component.$$);
359
+ }
360
+ }
361
+ catch (e) {
362
+ // reset dirty state to not end up in a deadlocked state and then rethrow
363
+ dirty_components.length = 0;
364
+ flushidx = 0;
365
+ throw e;
366
+ }
367
+ set_current_component(null);
368
+ dirty_components.length = 0;
369
+ flushidx = 0;
370
+ while (binding_callbacks.length)
371
+ binding_callbacks.pop()();
372
+ // then, once components are updated, call
373
+ // afterUpdate functions. This may cause
374
+ // subsequent updates...
375
+ for (let i = 0; i < render_callbacks.length; i += 1) {
376
+ const callback = render_callbacks[i];
377
+ if (!seen_callbacks.has(callback)) {
378
+ // ...so guard against infinite loops
379
+ seen_callbacks.add(callback);
380
+ callback();
381
+ }
382
+ }
383
+ render_callbacks.length = 0;
384
+ } while (dirty_components.length);
385
+ while (flush_callbacks.length) {
386
+ flush_callbacks.pop()();
387
+ }
388
+ update_scheduled = false;
389
+ seen_callbacks.clear();
390
+ set_current_component(saved_component);
391
+ }
392
+ function update($$) {
393
+ if ($$.fragment !== null) {
394
+ $$.update();
395
+ run_all($$.before_update);
396
+ const dirty = $$.dirty;
397
+ $$.dirty = [-1];
398
+ $$.fragment && $$.fragment.p($$.ctx, dirty);
399
+ $$.after_update.forEach(add_render_callback);
400
+ }
401
+ }
402
+ const outroing = new Set();
403
+ function transition_in(block, local) {
404
+ if (block && block.i) {
405
+ outroing.delete(block);
406
+ block.i(local);
407
+ }
408
+ }
409
+ function mount_component(component, target, anchor, customElement) {
410
+ const { fragment, after_update } = component.$$;
411
+ fragment && fragment.m(target, anchor);
412
+ if (!customElement) {
413
+ // onMount happens before the initial afterUpdate
414
+ add_render_callback(() => {
415
+ const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
416
+ // if the component was destroyed immediately
417
+ // it will update the `$$.on_destroy` reference to `null`.
418
+ // the destructured on_destroy may still reference to the old array
419
+ if (component.$$.on_destroy) {
420
+ component.$$.on_destroy.push(...new_on_destroy);
421
+ }
422
+ else {
423
+ // Edge case - component was destroyed immediately,
424
+ // most likely as a result of a binding initialising
425
+ run_all(new_on_destroy);
426
+ }
427
+ component.$$.on_mount = [];
428
+ });
429
+ }
430
+ after_update.forEach(add_render_callback);
431
+ }
432
+ function destroy_component(component, detaching) {
433
+ const $$ = component.$$;
434
+ if ($$.fragment !== null) {
435
+ run_all($$.on_destroy);
436
+ $$.fragment && $$.fragment.d(detaching);
437
+ // TODO null out other refs, including component.$$ (but need to
438
+ // preserve final state?)
439
+ $$.on_destroy = $$.fragment = null;
440
+ $$.ctx = [];
441
+ }
442
+ }
443
+ function make_dirty(component, i) {
444
+ if (component.$$.dirty[0] === -1) {
445
+ dirty_components.push(component);
446
+ schedule_update();
447
+ component.$$.dirty.fill(0);
448
+ }
449
+ component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
450
+ }
451
+ function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
452
+ const parent_component = current_component;
453
+ set_current_component(component);
454
+ const $$ = component.$$ = {
455
+ fragment: null,
456
+ ctx: [],
457
+ // state
458
+ props,
459
+ update: noop,
460
+ not_equal,
461
+ bound: blank_object(),
462
+ // lifecycle
463
+ on_mount: [],
464
+ on_destroy: [],
465
+ on_disconnect: [],
466
+ before_update: [],
467
+ after_update: [],
468
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
469
+ // everything else
470
+ callbacks: blank_object(),
471
+ dirty,
472
+ skip_bound: false,
473
+ root: options.target || parent_component.$$.root
474
+ };
475
+ append_styles && append_styles($$.root);
476
+ let ready = false;
477
+ $$.ctx = instance
478
+ ? instance(component, options.props || {}, (i, ret, ...rest) => {
479
+ const value = rest.length ? rest[0] : ret;
480
+ if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
481
+ if (!$$.skip_bound && $$.bound[i])
482
+ $$.bound[i](value);
483
+ if (ready)
484
+ make_dirty(component, i);
485
+ }
486
+ return ret;
487
+ })
488
+ : [];
489
+ $$.update();
490
+ ready = true;
491
+ run_all($$.before_update);
492
+ // `false` as a special case of no DOM component
493
+ $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
494
+ if (options.target) {
495
+ if (options.hydrate) {
496
+ start_hydrating();
497
+ const nodes = children(options.target);
498
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
499
+ $$.fragment && $$.fragment.l(nodes);
500
+ nodes.forEach(detach);
501
+ }
502
+ else {
503
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
504
+ $$.fragment && $$.fragment.c();
505
+ }
506
+ if (options.intro)
507
+ transition_in(component.$$.fragment);
508
+ mount_component(component, options.target, options.anchor, options.customElement);
509
+ end_hydrating();
510
+ flush();
511
+ }
512
+ set_current_component(parent_component);
513
+ }
514
+ /**
515
+ * Base class for Svelte components. Used when dev=false.
516
+ */
517
+ class SvelteComponent {
518
+ $destroy() {
519
+ destroy_component(this, 1);
520
+ this.$destroy = noop;
521
+ }
522
+ $on(type, callback) {
523
+ if (!is_function(callback)) {
524
+ return noop;
525
+ }
526
+ const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
527
+ callbacks.push(callback);
528
+ return () => {
529
+ const index = callbacks.indexOf(callback);
530
+ if (index !== -1)
531
+ callbacks.splice(index, 1);
532
+ };
533
+ }
534
+ $set($$props) {
535
+ if (this.$$set && !is_empty($$props)) {
536
+ this.$$.skip_bound = true;
537
+ this.$$set($$props);
538
+ this.$$.skip_bound = false;
539
+ }
540
+ }
541
+ }
542
+
543
+ /* src/InstanceView.svelte generated by Svelte v3.55.1 */
544
+
545
+ function add_css(target) {
546
+ append_styles(target, "svelte-1tmeyfg", "#container.svelte-1tmeyfg.svelte-1tmeyfg{border:0.5px solid rgb(224, 224, 224);border-radius:2px;max-width:350px;padding:10px}.box.svelte-1tmeyfg.svelte-1tmeyfg{display:flex;flex-direction:row;align-items:center}.box-reverse.svelte-1tmeyfg.svelte-1tmeyfg{display:flex;flex-direction:row-reverse}.chat.svelte-1tmeyfg.svelte-1tmeyfg{padding:10px;border:1px solid #6a1a9a;border-radius:5px}.label.svelte-1tmeyfg.svelte-1tmeyfg{margin-right:5px;font-size:10px;color:rgba(0, 0, 0, 0.5);font-variant:small-caps}p.svelte-1tmeyfg.svelte-1tmeyfg{margin:5px;overflow-wrap:anywhere}.box.svelte-1tmeyfg svg.svelte-1tmeyfg{min-width:24px;width:24px;margin-right:10px;fill:#6a1a9a}.box-reverse.svelte-1tmeyfg svg.svelte-1tmeyfg{min-width:30px;width:30px;margin-left:10px;fill:#6a1a9a}");
547
+ }
548
+
549
+ // (25:2) {#if entry[modelColumn]}
550
+ function create_if_block(ctx) {
551
+ let div;
552
+ let svg;
553
+ let path;
554
+ let t0;
555
+ let p;
556
+ let t1_value = /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] + "";
557
+ let t1;
558
+
559
+ return {
560
+ c() {
561
+ div = element("div");
562
+ svg = svg_element("svg");
563
+ path = svg_element("path");
564
+ t0 = space();
565
+ p = element("p");
566
+ t1 = text(t1_value);
567
+ this.h();
568
+ },
569
+ l(nodes) {
570
+ div = claim_element(nodes, "DIV", { class: true });
571
+ var div_nodes = children(div);
572
+ svg = claim_svg_element(div_nodes, "svg", { xmlns: true, viewBox: true, class: true });
573
+ var svg_nodes = children(svg);
574
+ path = claim_svg_element(svg_nodes, "path", { d: true });
575
+ children(path).forEach(detach);
576
+ svg_nodes.forEach(detach);
577
+ t0 = claim_space(div_nodes);
578
+ p = claim_element(div_nodes, "P", { class: true });
579
+ var p_nodes = children(p);
580
+ t1 = claim_text(p_nodes, t1_value);
581
+ p_nodes.forEach(detach);
582
+ div_nodes.forEach(detach);
583
+ this.h();
584
+ },
585
+ h() {
586
+ attr(path, "d", "M320 0c17.7 0 32 14.3 32 32V96H472c39.8 0 72 32.2 72 72V440c0 39.8-32.2 72-72 72H168c-39.8 0-72-32.2-72-72V168c0-39.8 32.2-72 72-72H288V32c0-17.7 14.3-32 32-32zM208 384c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H208zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H304zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c8.8 0 16-7.2 16-16s-7.2-16-16-16H400zM264 256a40 40 0 1 0 -80 0 40 40 0 1 0 80 0zm152 40a40 40 0 1 0 0-80 40 40 0 1 0 0 80zM48 224H64V416H48c-26.5 0-48-21.5-48-48V272c0-26.5 21.5-48 48-48zm544 0c26.5 0 48 21.5 48 48v96c0 26.5-21.5 48-48 48H576V224h16z");
587
+ attr(svg, "xmlns", "http://www.w3.org/2000/svg");
588
+ attr(svg, "viewBox", "0 0 640 512");
589
+ attr(svg, "class", "svelte-1tmeyfg");
590
+ attr(p, "class", "chat svelte-1tmeyfg");
591
+ attr(div, "class", "box-reverse svelte-1tmeyfg");
592
+ },
593
+ m(target, anchor) {
594
+ insert_hydration(target, div, anchor);
595
+ append_hydration(div, svg);
596
+ append_hydration(svg, path);
597
+ append_hydration(div, t0);
598
+ append_hydration(div, p);
599
+ append_hydration(p, t1);
600
+ },
601
+ p(ctx, dirty) {
602
+ if (dirty & /*entry, modelColumn*/ 3 && t1_value !== (t1_value = /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] + "")) set_data(t1, t1_value);
603
+ },
604
+ d(detaching) {
605
+ if (detaching) detach(div);
606
+ }
607
+ };
608
+ }
609
+
610
+ function create_fragment(ctx) {
611
+ let div2;
612
+ let div0;
613
+ let svg;
614
+ let path;
615
+ let t0;
616
+ let p0;
617
+ let t1_value = /*entry*/ ctx[0][/*dataColumn*/ ctx[3]] + "";
618
+ let t1;
619
+ let t2;
620
+ let t3;
621
+ let div1;
622
+ let span;
623
+ let t4;
624
+ let t5;
625
+ let p1;
626
+ let t6_value = /*entry*/ ctx[0][/*labelColumn*/ ctx[2]] + "";
627
+ let t6;
628
+ let if_block = /*entry*/ ctx[0][/*modelColumn*/ ctx[1]] && create_if_block(ctx);
629
+
630
+ return {
631
+ c() {
632
+ div2 = element("div");
633
+ div0 = element("div");
634
+ svg = svg_element("svg");
635
+ path = svg_element("path");
636
+ t0 = space();
637
+ p0 = element("p");
638
+ t1 = text(t1_value);
639
+ t2 = space();
640
+ if (if_block) if_block.c();
641
+ t3 = space();
642
+ div1 = element("div");
643
+ span = element("span");
644
+ t4 = text("label:");
645
+ t5 = space();
646
+ p1 = element("p");
647
+ t6 = text(t6_value);
648
+ this.h();
649
+ },
650
+ l(nodes) {
651
+ div2 = claim_element(nodes, "DIV", { id: true, class: true });
652
+ var div2_nodes = children(div2);
653
+ div0 = claim_element(div2_nodes, "DIV", { class: true });
654
+ var div0_nodes = children(div0);
655
+ svg = claim_svg_element(div0_nodes, "svg", { xmlns: true, viewBox: true, class: true });
656
+ var svg_nodes = children(svg);
657
+ path = claim_svg_element(svg_nodes, "path", { d: true });
658
+ children(path).forEach(detach);
659
+ svg_nodes.forEach(detach);
660
+ t0 = claim_space(div0_nodes);
661
+ p0 = claim_element(div0_nodes, "P", { class: true });
662
+ var p0_nodes = children(p0);
663
+ t1 = claim_text(p0_nodes, t1_value);
664
+ p0_nodes.forEach(detach);
665
+ div0_nodes.forEach(detach);
666
+ t2 = claim_space(div2_nodes);
667
+ if (if_block) if_block.l(div2_nodes);
668
+ t3 = claim_space(div2_nodes);
669
+ div1 = claim_element(div2_nodes, "DIV", { class: true });
670
+ var div1_nodes = children(div1);
671
+ span = claim_element(div1_nodes, "SPAN", { class: true });
672
+ var span_nodes = children(span);
673
+ t4 = claim_text(span_nodes, "label:");
674
+ span_nodes.forEach(detach);
675
+ t5 = claim_space(div1_nodes);
676
+ p1 = claim_element(div1_nodes, "P", { class: true });
677
+ var p1_nodes = children(p1);
678
+ t6 = claim_text(p1_nodes, t6_value);
679
+ p1_nodes.forEach(detach);
680
+ div1_nodes.forEach(detach);
681
+ div2_nodes.forEach(detach);
682
+ this.h();
683
+ },
684
+ h() {
685
+ attr(path, "d", "M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512H418.3c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304H178.3z");
686
+ attr(svg, "xmlns", "http://www.w3.org/2000/svg");
687
+ attr(svg, "viewBox", "0 0 448 512");
688
+ attr(svg, "class", "svelte-1tmeyfg");
689
+ attr(p0, "class", "chat svelte-1tmeyfg");
690
+ attr(div0, "class", "box svelte-1tmeyfg");
691
+ attr(span, "class", "label svelte-1tmeyfg");
692
+ attr(p1, "class", "svelte-1tmeyfg");
693
+ attr(div1, "class", "box svelte-1tmeyfg");
694
+ attr(div2, "id", "container");
695
+ attr(div2, "class", "svelte-1tmeyfg");
696
+ },
697
+ m(target, anchor) {
698
+ insert_hydration(target, div2, anchor);
699
+ append_hydration(div2, div0);
700
+ append_hydration(div0, svg);
701
+ append_hydration(svg, path);
702
+ append_hydration(div0, t0);
703
+ append_hydration(div0, p0);
704
+ append_hydration(p0, t1);
705
+ append_hydration(div2, t2);
706
+ if (if_block) if_block.m(div2, null);
707
+ append_hydration(div2, t3);
708
+ append_hydration(div2, div1);
709
+ append_hydration(div1, span);
710
+ append_hydration(span, t4);
711
+ append_hydration(div1, t5);
712
+ append_hydration(div1, p1);
713
+ append_hydration(p1, t6);
714
+ },
715
+ p(ctx, [dirty]) {
716
+ if (dirty & /*entry, dataColumn*/ 9 && t1_value !== (t1_value = /*entry*/ ctx[0][/*dataColumn*/ ctx[3]] + "")) set_data(t1, t1_value);
717
+
718
+ if (/*entry*/ ctx[0][/*modelColumn*/ ctx[1]]) {
719
+ if (if_block) {
720
+ if_block.p(ctx, dirty);
721
+ } else {
722
+ if_block = create_if_block(ctx);
723
+ if_block.c();
724
+ if_block.m(div2, t3);
725
+ }
726
+ } else if (if_block) {
727
+ if_block.d(1);
728
+ if_block = null;
729
+ }
730
+
731
+ if (dirty & /*entry, labelColumn*/ 5 && t6_value !== (t6_value = /*entry*/ ctx[0][/*labelColumn*/ ctx[2]] + "")) set_data(t6, t6_value);
732
+ },
733
+ i: noop,
734
+ o: noop,
735
+ d(detaching) {
736
+ if (detaching) detach(div2);
737
+ if (if_block) if_block.d();
738
+ }
739
+ };
740
+ }
741
+
742
+ function instance($$self, $$props, $$invalidate) {
743
+ let { options } = $$props;
744
+ let { entry } = $$props;
745
+ let { modelColumn } = $$props;
746
+ let { labelColumn } = $$props;
747
+ let { dataColumn } = $$props;
748
+ let { idColumn } = $$props;
749
+
750
+ $$self.$$set = $$props => {
751
+ if ('options' in $$props) $$invalidate(4, options = $$props.options);
752
+ if ('entry' in $$props) $$invalidate(0, entry = $$props.entry);
753
+ if ('modelColumn' in $$props) $$invalidate(1, modelColumn = $$props.modelColumn);
754
+ if ('labelColumn' in $$props) $$invalidate(2, labelColumn = $$props.labelColumn);
755
+ if ('dataColumn' in $$props) $$invalidate(3, dataColumn = $$props.dataColumn);
756
+ if ('idColumn' in $$props) $$invalidate(5, idColumn = $$props.idColumn);
757
+ };
758
+
759
+ return [entry, modelColumn, labelColumn, dataColumn, options, idColumn];
760
+ }
761
+
762
+ class InstanceView extends SvelteComponent {
763
+ constructor(options) {
764
+ super();
765
+
766
+ init(
767
+ this,
768
+ options,
769
+ instance,
770
+ create_fragment,
771
+ safe_not_equal,
772
+ {
773
+ options: 4,
774
+ entry: 0,
775
+ modelColumn: 1,
776
+ labelColumn: 2,
777
+ dataColumn: 3,
778
+ idColumn: 5
779
+ },
780
+ add_css
781
+ );
782
+ }
783
+ }
784
+
785
+ function getInstance(
786
+ div,
787
+ viewOptions,
788
+ entry,
789
+ modelColumn,
790
+ labelColumn,
791
+ dataColumn,
792
+ idColumn
793
+ ) {
794
+ new InstanceView({
795
+ target: div,
796
+ props: {
797
+ entry: entry,
798
+ viewOptions: viewOptions,
799
+ modelColumn: modelColumn,
800
+ labelColumn: labelColumn,
801
+ dataColumn: dataColumn,
802
+ idColumn: idColumn,
803
+ },
804
+ hydrate: true,
805
+ });
806
+ }
807
+
808
+ // export function getOptions(div, setOptions) {
809
+ // new OptionsView({
810
+ // target: div,
811
+ // props: {
812
+ // setOptions,
813
+ // },
814
+ // });
815
+ // }
816
+
817
+ export { getInstance };
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.8
5
+
6
+ RUN useradd -m -u 1000 user
7
+ USER user
8
+ # Set home to the user's home directory
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH
11
+ WORKDIR $HOME/app
12
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
13
+ COPY --chown=user . $HOME/app
14
+ ADD --chown=user ./.zeno_cache $HOME/app/.zeno_cache
15
+ RUN chown user:user -R $HOME/app
16
+
17
+ COPY ./requirements.txt /code/requirements.txt
18
+
19
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
20
+
21
+
22
+ CMD ["zeno", "config.toml"]
README.md CHANGED
@@ -1,11 +1,12 @@
1
  ---
2
- title: Langchain Qa
3
  emoji: 📚
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Langchain QA
3
  emoji: 📚
4
  colorFrom: yellow
5
  colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
+ fullWidth: true
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
config.toml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ view = 'chatbot'
2
+ functions = "model.py"
3
+ metadata = 'questions.csv'
4
+ models = ['GPT-3']
5
+ data_column = 'input'
6
+ label_column = 'label'
7
+ port = 7860
8
+ host = "0.0.0.0"
9
+ editable = false
docs.index ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3518510defd75cc93dd35df279adef244eb0ba132f7fb9cae4d14fee7f1c2dc
3
+ size 1191981
faiss_store.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a02ec296c893613554f7af8f14afe4c3bed49fa573344ad9c65ddca46a176818
3
+ size 268325
model.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ import faiss
4
+ from langchain import OpenAI
5
+ from langchain.chains import VectorDBQAWithSourcesChain
6
+
7
+ from zeno import ZenoOptions, distill, metric, model
8
+
9
+
10
+ @model
11
+ def get_model(model_name):
12
+ # Blendle Notion chatbot example from:
13
+ # https://github.com/hwchase17/chat-langchain-notion
14
+
15
+ index = faiss.read_index("./docs.index")
16
+ with open("./faiss_store.pkl", "rb") as f:
17
+ store = pickle.load(f)
18
+ store.index = index
19
+ chain = VectorDBQAWithSourcesChain.from_llm(
20
+ llm=OpenAI(temperature=0), vectorstore=store
21
+ )
22
+
23
+ def pred(df, ops: ZenoOptions):
24
+ res = []
25
+ for question in df[ops.data_column]:
26
+ result = chain({"question": question})
27
+ res.append(
28
+ "Answer: {}\nSources: {}".format(result["answer"], result["sources"])
29
+ )
30
+ return res
31
+
32
+ return pred
33
+
34
+
35
+ @distill
36
+ def correct(df, ops: ZenoOptions):
37
+ return df.apply(
38
+ lambda x: x[ops.label_column].lower() in x[ops.output_column].lower(), axis=1
39
+ )
40
+
41
+
42
+ @metric
43
+ def accuracy(df, ops: ZenoOptions):
44
+ return df[ops.distill_columns["correct"]].astype(int).mean()
questions.csv ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ input,label,question_type,present_in_database
2
+ How much money do employees make on average?,"I don't know",how,false
3
+ How many days off do employees get?,"unlimited",how,true
4
+ What type of healthcare does Blendle provide?,"I don't know",what,false
5
+ What is the learning budget?,"I don't know",what,false
6
+ Does Blendle have a learning budget?,"yes",yesno,true
7
+ Should I have weekly one-on-ones with my manager?,"recommended",yesno,true
8
+ Why is this document public?,"feedback",why,true
9
+ Who should I email about issues with these documents?,"hr@blendle.com",who,true
10
+ How long does someone I referred have to work at Blendle for me to get a bonus?,"month",how,true
11
+ What is the severance package?,"I don't know",what,false
12
+ Who is the CEO of Blendle?,"I don't know",who,false
13
+ What is the Matrix?,"feedback",what,true
14
+ Are there free massages at Blendle?,"yes",yesno,true
15
+ What card do I get for train travel?,"NS",what,true
16
+ Will Blendle buy me a bike?,"no",yesno,false
17
+ Do I need a receipt to reimburse my expenses?,"yes",yesno,true
18
+ Can I drive to the office?,"I don't know",yesno,false
19
+ How much stock compensation do I get?,"I don't know",how,false
20
+ When is salary review?,"january",when,true
21
+ Who is the head of people?,"gemma",who,true
22
+ Where is the company based?,"utrecht",where,true
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ zenoml>=0.3.10
2
+ langchain
3
+ zenoml
4
+ faiss-cpu
5
+ openai