sarahciston commited on
Commit
4d4ea35
1 Parent(s): eb4bd74

add new text-gen model, move OUTPUT_LIST to refresh in func

Browse files
Files changed (1) hide show
  1. sketch.js +7 -5
sketch.js CHANGED
@@ -7,7 +7,6 @@ env.allowLocalModels = false;
7
 
8
  // GLOBAL VARIABLES
9
  let PROMPT_INPUT = `Happy people are better than [MASK].` // a field for writing or changing a text value
10
- let OUTPUT_LIST = [] // a blank array to store the results from the model
11
  let pField
12
 
13
  // RUN TEXT-GEN MODEL
@@ -15,13 +14,15 @@ let pField
15
  async function textGenTask(input){
16
  console.log('text-gen task initiated')
17
 
18
- const pipe = await pipeline('text-generation')
19
 
20
  var out = await pipe(input)
21
 
22
  console.log(await out)
23
  console.log('text-gen task completed')
24
 
 
 
25
  // parsing of output
26
  await out.forEach(o => {
27
  console.log(o)
@@ -39,13 +40,14 @@ async function textGenTask(input){
39
  async function fillInTask(input){
40
  console.log('fill-in task initiated')
41
 
42
- const pipe = await pipeline('fill-mask');
43
- //, 'Xenova/bert-base-uncased'
44
 
45
  var out = await pipe(input);
46
 
47
  console.log(await out) // yields { score, sequence, token, token_str } for each result
48
 
 
 
49
  // parsing of output
50
  await out.forEach(o => {
51
  console.log(o) // yields { score, sequence, token, token_str } for each result
@@ -135,7 +137,7 @@ new p5(function (p5){
135
  // text = str(outs)
136
 
137
  let outText = p5.createP('')
138
- await outText.html(outs, false)
139
  }
140
 
141
  });
 
7
 
8
  // GLOBAL VARIABLES
9
  let PROMPT_INPUT = `Happy people are better than [MASK].` // a field for writing or changing a text value
 
10
  let pField
11
 
12
  // RUN TEXT-GEN MODEL
 
14
  async function textGenTask(input){
15
  console.log('text-gen task initiated')
16
 
17
+ const pipe = await pipeline('text-generation', 'HuggingFaceH4/zephyr-7b-beta')
18
 
19
  var out = await pipe(input)
20
 
21
  console.log(await out)
22
  console.log('text-gen task completed')
23
 
24
+ let OUTPUT_LIST = [] // a blank array to store the results from the model
25
+
26
  // parsing of output
27
  await out.forEach(o => {
28
  console.log(o)
 
40
  async function fillInTask(input){
41
  console.log('fill-in task initiated')
42
 
43
+ const pipe = await pipeline('fill-mask', 'Xenova/bert-base-uncased');
 
44
 
45
  var out = await pipe(input);
46
 
47
  console.log(await out) // yields { score, sequence, token, token_str } for each result
48
 
49
+ let OUTPUT_LIST = [] // a blank array to store the results from the model
50
+
51
  // parsing of output
52
  await out.forEach(o => {
53
  console.log(o) // yields { score, sequence, token, token_str } for each result
 
137
  // text = str(outs)
138
 
139
  let outText = p5.createP('')
140
+ await outText.html(outs) // true appends text instead of replaces
141
  }
142
 
143
  });