sarahciston commited on
Commit
c4835d8
1 Parent(s): 8f87f71

update results interface section, try new hyperparams

Browse files
Files changed (1) hide show
  1. sketch.js +9 -8
sketch.js CHANGED
@@ -6,9 +6,10 @@ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers
6
  env.allowLocalModels = false;
7
 
8
  // GLOBAL VARIABLES
 
9
  let PROMPT_INPUT = `The woman has a job as a [MASK] but wishes to...` // a field for writing or changing a text value
10
  let pField
11
- let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
12
 
13
  // RUN TEXT-GEN MODEL
14
 
@@ -26,7 +27,7 @@ async function textGenTask(pre, prompt){
26
  const pipe = await pipeline('text-generation', MODEL)
27
 
28
  // RUN INPUT THROUGH MODEL,
29
- var out = await pipe(INPUT, { max_new_tokens: 60 })
30
  // setting hyperparameters
31
  // max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true,
32
 
@@ -134,17 +135,17 @@ new p5(function (p5){
134
  submitButton.size(170)
135
  submitButton.class('submit')
136
  submitButton.mousePressed(displayResults)
 
 
137
  let outHeader = p5.createElement('h3',"Results")
 
138
  }
139
 
140
  async function displayResults(){
141
  console.log('submitButton pressed')
142
 
143
- // look for a paragraph element to put the results in; if it doesn't exist, create it
144
- let outText = document.querySelector("#results")
145
- if (outText == null) {
146
- p5.createP('...').id('results')
147
- }
148
 
149
  PROMPT_INPUT = pField.value() // grab update to the prompt if it's been changed
150
  console.log("latest prompt: ", PROMPT_INPUT)
@@ -155,7 +156,7 @@ new p5(function (p5){
155
  console.log(outs)
156
 
157
  // insert the model outputs into the paragraph
158
- await outText.html(outs, 'true') // true replaces text instead of appends?
159
  }
160
 
161
  });
 
6
  env.allowLocalModels = false;
7
 
8
  // GLOBAL VARIABLES
9
+ // let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
10
  let PROMPT_INPUT = `The woman has a job as a [MASK] but wishes to...` // a field for writing or changing a text value
11
  let pField
12
+ let outText
13
 
14
  // RUN TEXT-GEN MODEL
15
 
 
27
  const pipe = await pipeline('text-generation', MODEL)
28
 
29
  // RUN INPUT THROUGH MODEL,
30
+ var out = await pipe(INPUT, { max_new_tokens: 60, top_k: 90, num_return_sequences: 3 })
31
  // setting hyperparameters
32
  // max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true,
33
 
 
135
  submitButton.size(170)
136
  submitButton.class('submit')
137
  submitButton.mousePressed(displayResults)
138
+
139
+ // also make results placeholder
140
  let outHeader = p5.createElement('h3',"Results")
141
+ outText = p5.createP('').id('results')
142
  }
143
 
144
  async function displayResults(){
145
  console.log('submitButton pressed')
146
 
147
+ // insert waiting dots into results space of interface
148
+ outText.html('...', false)
 
 
 
149
 
150
  PROMPT_INPUT = pField.value() // grab update to the prompt if it's been changed
151
  console.log("latest prompt: ", PROMPT_INPUT)
 
156
  console.log(outs)
157
 
158
  // insert the model outputs into the paragraph
159
+ await outText.html(outs, false) // false replaces text instead of appends??
160
  }
161
 
162
  });