Spaces:
Running
Running
sarahciston
commited on
Commit
•
372a0c2
1
Parent(s):
abecf14
fix iterative prompt flow
Browse files
sketch.js
CHANGED
@@ -6,7 +6,7 @@ import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers
|
|
6 |
env.allowLocalModels = false;
|
7 |
|
8 |
// GLOBAL VARIABLES
|
9 |
-
let blankArray = ["woman", "man"]
|
10 |
let PREPROMPT = `Please complete the phrase, replacing any [BLANK] with words from the ${blankArray} and replacing any [MASK] with your own words.`
|
11 |
// let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
|
12 |
let PROMPT_INPUT = `The [BLANK] has a job as a [MASK] but...` // a field for writing or changing a text value
|
@@ -17,17 +17,18 @@ let outText
|
|
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]',
|
25 |
-
promptArray.push(prompt + p)
|
26 |
})
|
27 |
console.log(promptArray)
|
28 |
-
//
|
29 |
-
// let INPUT =
|
30 |
-
// let INPUT = prompt
|
31 |
|
32 |
// PICK MODEL
|
33 |
let MODEL = 'Xenova/flan-alpaca-large'
|
@@ -60,8 +61,7 @@ async function textGenTask(pre, prompt, blanks){
|
|
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 => {
|
|
|
6 |
env.allowLocalModels = false;
|
7 |
|
8 |
// GLOBAL VARIABLES
|
9 |
+
let blankArray = ["woman", "man", "non-binary person"]
|
10 |
let PREPROMPT = `Please complete the phrase, replacing any [BLANK] with words from the ${blankArray} and replacing any [MASK] with your own words.`
|
11 |
// let PREPROMPT = `Please complete the phrase and fill in any [MASK]: `
|
12 |
let PROMPT_INPUT = `The [BLANK] has a job as a [MASK] but...` // a field for writing or changing a text value
|
|
|
17 |
|
18 |
async function textGenTask(pre, prompt, blanks){
|
19 |
console.log('text-gen task initiated')
|
20 |
+
|
21 |
+
let OUTPUT_LIST = [] // a blank array to store the results from the model
|
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(prompt + 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
|
|
|
32 |
|
33 |
// PICK MODEL
|
34 |
let MODEL = 'Xenova/flan-alpaca-large'
|
|
|
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 |
// parsing of output
|
67 |
await out.forEach(o => {
|