sarahciston commited on
Commit
a9e7257
1 Parent(s): f9337ec

try iterative model run

Browse files
Files changed (1) hide show
  1. sketch.js +29 -17
sketch.js CHANGED
@@ -15,11 +15,18 @@ let outText
15
 
16
  // RUN TEXT-GEN MODEL
17
 
18
- async function textGenTask(pre, prompt){
19
  console.log('text-gen task initiated')
20
 
 
 
 
 
 
 
 
21
  // preprompt not working, fix later if we do chat templates
22
- let INPUT = pre + prompt
23
  // let INPUT = prompt
24
 
25
  // PICK MODEL
@@ -40,24 +47,29 @@ async function textGenTask(pre, prompt){
40
  // const pipe = await pipeline('text-generation', MODEL)
41
  const pipe = await pipeline('text2text-generation', MODEL)
42
 
43
- // RUN INPUT THROUGH MODEL,
44
- var out = await pipe(INPUT, { max_new_tokens: 60, top_k: 90, repetition_penalty: 1.5 })
45
- // setting hyperparameters
46
- // max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true, no_repeat_ngram_size: 2,
47
-
48
- console.log(await out)
49
- console.log('text-gen task completed')
50
 
51
- // PARSE RESULTS as a list of outputs, two different ways depending on the model
 
 
 
 
 
52
 
53
- let OUTPUT_LIST = [] // a blank array to store the results from the model
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
- // parsing of output
56
- await out.forEach(o => {
57
- console.log(o)
58
- OUTPUT_LIST.push(o.generated_text)
59
- })
60
-
61
  // alternate format for parsing, for chat model type
62
  // await out.choices.forEach(o => {
63
  // console.log(o)
 
15
 
16
  // RUN TEXT-GEN MODEL
17
 
18
+ async function textGenTask(pre, prompt, blanks){
19
  console.log('text-gen task initiated')
20
 
21
+ // Create concatenated prompt array
22
+ let promptArray = []
23
+ blanks.forEach(b => {
24
+ let p = prompt.replace('[BLANK]', 'b')
25
+ promptArray.push(prompt + p)
26
+ })
27
+ console.log(promptArray)
28
  // preprompt not working, fix later if we do chat templates
29
+ // let INPUT = pre + prompt
30
  // let INPUT = prompt
31
 
32
  // PICK MODEL
 
47
  // const pipe = await pipeline('text-generation', MODEL)
48
  const pipe = await pipeline('text2text-generation', MODEL)
49
 
50
+ var hyperparameters = { max_new_tokens: 60, top_k: 90, repetition_penalty: 1.5 }
 
 
 
 
 
 
51
 
52
+ promptArray.forEach(INPUT){
53
+ // RUN INPUT THROUGH MODEL,
54
+ var out = await pipe(INPUT, hyperparameters)
55
+ // setting hyperparameters
56
+ // max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true, no_repeat_ngram_size: 2,
57
+ // , num_return_sequences: 2 (must be 1?)
58
 
59
+ console.log(await out)
60
+ console.log('text-gen task completed')
61
+
62
+ // PARSE RESULTS as a list of outputs, two different ways depending on the model
63
+
64
+ let OUTPUT_LIST = [] // a blank array to store the results from the model
65
+
66
+ // parsing of output
67
+ await out.forEach(o => {
68
+ console.log(o)
69
+ OUTPUT_LIST.push(o.generated_text)
70
+ })
71
+ }
72
 
 
 
 
 
 
 
73
  // alternate format for parsing, for chat model type
74
  // await out.choices.forEach(o => {
75
  // console.log(o)