Spaces:
Running
Running
sarahciston
commited on
try multiple prompts but not multiple model runs
Browse files
sketch.js
CHANGED
@@ -18,14 +18,15 @@ let outText
|
|
18 |
async function textGenTask(pre, prompt, blanks){
|
19 |
console.log('text-gen task initiated')
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
// Create concatenated prompt array
|
24 |
let promptArray = []
|
|
|
25 |
blanks.forEach(b => {
|
26 |
let p = prompt.replace('[BLANK]', b) // replace the string segment with an idem from the blanksArray
|
27 |
promptArray.push(pre + p) // add the new prompt to the list we created
|
28 |
})
|
|
|
|
|
29 |
console.log(promptArray)
|
30 |
// let INPUT = pre + prompt // simple concatenated input
|
31 |
// let INPUT = prompt // basic prompt input
|
@@ -52,23 +53,28 @@ async function textGenTask(pre, prompt, blanks){
|
|
52 |
// max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true, no_repeat_ngram_size: 2,
|
53 |
// , num_return_sequences: 2 (must be 1?)
|
54 |
|
|
|
|
|
55 |
// change model run to iterative for each prompt generated locally — will be more expensive??
|
56 |
-
promptArray.forEach(async i => {
|
57 |
-
|
58 |
-
|
|
|
59 |
|
60 |
console.log(await out)
|
61 |
console.log('text-gen task completed')
|
62 |
|
63 |
// PARSE RESULTS as a list of outputs, two different ways depending on the model
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
72 |
|
73 |
// alternate format for parsing, for chat model type
|
74 |
// await out.choices.forEach(o => {
|
@@ -76,6 +82,8 @@ async function textGenTask(pre, prompt, blanks){
|
|
76 |
// OUTPUT_LIST.push(o.message.content)
|
77 |
// })
|
78 |
|
|
|
|
|
79 |
console.log(OUTPUT_LIST)
|
80 |
console.log('text-gen parsing complete')
|
81 |
|
@@ -166,7 +174,7 @@ new p5(function (p5){
|
|
166 |
console.log(outs)
|
167 |
|
168 |
// insert the model outputs into the paragraph
|
169 |
-
await outText.html(outs, false) // false replaces text instead of appends
|
170 |
}
|
171 |
|
172 |
});
|
|
|
18 |
async function textGenTask(pre, prompt, blanks){
|
19 |
console.log('text-gen task initiated')
|
20 |
|
21 |
+
// Create concatenated prompt array including preprompt and all variable prompts
|
|
|
|
|
22 |
let promptArray = []
|
23 |
+
promptArray.push(pre)
|
24 |
blanks.forEach(b => {
|
25 |
let p = prompt.replace('[BLANK]', b) // replace the string segment with an idem from the blanksArray
|
26 |
promptArray.push(pre + p) // add the new prompt to the list we created
|
27 |
})
|
28 |
+
|
29 |
+
let INPUT = str(promptArray)
|
30 |
console.log(promptArray)
|
31 |
// let INPUT = pre + prompt // simple concatenated input
|
32 |
// let INPUT = prompt // basic prompt input
|
|
|
53 |
// max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true, no_repeat_ngram_size: 2,
|
54 |
// , num_return_sequences: 2 (must be 1?)
|
55 |
|
56 |
+
// let OUTPUT_LIST = [] // a blank array to store the results from the model
|
57 |
+
|
58 |
// change model run to iterative for each prompt generated locally — will be more expensive??
|
59 |
+
// promptArray.forEach(async i => {
|
60 |
+
|
61 |
+
// RUN INPUT THROUGH MODEL,
|
62 |
+
var out = await pipe(INPUT, hyperparameters)
|
63 |
|
64 |
console.log(await out)
|
65 |
console.log('text-gen task completed')
|
66 |
|
67 |
// PARSE RESULTS as a list of outputs, two different ways depending on the model
|
68 |
|
69 |
+
// OUTPUT_LIST.push(out[0].generated_text)
|
70 |
+
|
71 |
+
// }) //this was a loop to wrap model run multiple times
|
72 |
+
|
73 |
+
// parsing of output
|
74 |
+
// await out.forEach(o => {
|
75 |
+
// console.log(o)
|
76 |
+
// OUTPUT_LIST.push(o.generated_text)
|
77 |
+
// })
|
78 |
|
79 |
// alternate format for parsing, for chat model type
|
80 |
// await out.choices.forEach(o => {
|
|
|
82 |
// OUTPUT_LIST.push(o.message.content)
|
83 |
// })
|
84 |
|
85 |
+
let OUTPUT_LIST = out[0].generated_text //not a list anymore just one result
|
86 |
+
|
87 |
console.log(OUTPUT_LIST)
|
88 |
console.log('text-gen parsing complete')
|
89 |
|
|
|
174 |
console.log(outs)
|
175 |
|
176 |
// insert the model outputs into the paragraph
|
177 |
+
await outText.html(outs, false) // false replaces text instead of appends
|
178 |
}
|
179 |
|
180 |
});
|