Sarah Ciston
commited on
Commit
·
d59354e
1
Parent(s):
1e5c489
new model processing syntax
Browse files
sketch.js
CHANGED
@@ -54,7 +54,7 @@ new p5(function (p5) {
|
|
54 |
let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
|
55 |
// title.position(0,50)
|
56 |
|
57 |
-
p5.createElement('p',`This tool lets you run several AI chat prompts at once and compare their results. Use it to explore what models 'know' about various concepts, communities, and cultures. For more information on prompt programming and critical AI, see [
|
58 |
// .position(0,100)
|
59 |
|
60 |
promptInput = p5.createInput("")
|
@@ -84,8 +84,8 @@ new p5(function (p5) {
|
|
84 |
addField()
|
85 |
|
86 |
// // BUTTONS // //
|
87 |
-
let buttonsDiv = p5.createDiv() // container to organize buttons
|
88 |
-
buttonsDiv.id('buttonsDiv')
|
89 |
|
90 |
// send prompt to model
|
91 |
let submitButton = p5.createButton("SUBMIT")
|
@@ -105,7 +105,7 @@ new p5(function (p5) {
|
|
105 |
// TO-DO a model drop down list?
|
106 |
|
107 |
// alt-text description
|
108 |
-
p5.describe(`Pink and black text on a white background with form inputs and two buttons. The text describes a p5.js Critical AI Prompt Battle tool that lets you run several AI chat prompts at once and compare their results. Use it to explore what models 'know' about various concepts, communities, and cultures. In the largest form input you can write a prompt to submit. In smaller inputs, you can write variables that will be inserted into that prompt as variations of the prompt when it is run through the model. There is a submit button, a button to add more variations, and when the model is run it adds text at the bottom showing the output results.`)
|
109 |
}
|
110 |
|
111 |
function addField(){
|
@@ -158,7 +158,9 @@ new p5(function (p5) {
|
|
158 |
async function runModel(PREPROMPT, PROMPT){
|
159 |
// // Chat completion API
|
160 |
|
161 |
-
|
|
|
|
|
162 |
let pipe = await pipeline('text-generation');
|
163 |
// seems to work with default model distilgpt2 ugh
|
164 |
|
@@ -167,18 +169,18 @@ async function runModel(PREPROMPT, PROMPT){
|
|
167 |
// 'Xenova/gpt-3.5-turbo'
|
168 |
// , 'Xenova/distilgpt2'
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
177 |
-
let out = await pipe(
|
178 |
|
179 |
console.log(out)
|
180 |
|
181 |
-
var modelResult = await out.generated_text
|
182 |
console.log(modelResult)
|
183 |
|
184 |
return modelResult
|
|
|
54 |
let title = p5.createElement('h1', 'p5.js Critical AI Prompt Battle')
|
55 |
// title.position(0,50)
|
56 |
|
57 |
+
p5.createElement('p',`This tool lets you run several AI chat prompts at once and compare their results. Use it to explore what models 'know' about various concepts, communities, and cultures. For more information on prompt programming and critical AI, see [Tutorial & extra info][TO-DO][XXX]`)
|
58 |
// .position(0,100)
|
59 |
|
60 |
promptInput = p5.createInput("")
|
|
|
84 |
addField()
|
85 |
|
86 |
// // BUTTONS // //
|
87 |
+
// let buttonsDiv = p5.createDiv() // container to organize buttons
|
88 |
+
// buttonsDiv.id('buttonsDiv')
|
89 |
|
90 |
// send prompt to model
|
91 |
let submitButton = p5.createButton("SUBMIT")
|
|
|
105 |
// TO-DO a model drop down list?
|
106 |
|
107 |
// alt-text description
|
108 |
+
// p5.describe(`Pink and black text on a white background with form inputs and two buttons. The text describes a p5.js Critical AI Prompt Battle tool that lets you run several AI chat prompts at once and compare their results. Use it to explore what models 'know' about various concepts, communities, and cultures. In the largest form input you can write a prompt to submit. In smaller inputs, you can write variables that will be inserted into that prompt as variations of the prompt when it is run through the model. There is a submit button, a button to add more variations, and when the model is run it adds text at the bottom showing the output results.`)
|
109 |
}
|
110 |
|
111 |
function addField(){
|
|
|
158 |
async function runModel(PREPROMPT, PROMPT){
|
159 |
// // Chat completion API
|
160 |
|
161 |
+
let inputText = PREPROMPT + PROMPT
|
162 |
+
|
163 |
+
// pipeline/transformers version
|
164 |
let pipe = await pipeline('text-generation');
|
165 |
// seems to work with default model distilgpt2 ugh
|
166 |
|
|
|
169 |
// 'Xenova/gpt-3.5-turbo'
|
170 |
// , 'Xenova/distilgpt2'
|
171 |
|
172 |
+
let out = await pipe(inputText, {
|
173 |
+
max_tokens: 250,
|
174 |
+
return_full_text: false,
|
175 |
+
repetition_penalty: 1.5,
|
176 |
+
num_return_sequences: 1 //must be 1 for greedy search
|
177 |
+
})
|
178 |
|
179 |
+
// let out = await pipe(inputText)
|
180 |
|
181 |
console.log(out)
|
182 |
|
183 |
+
var modelResult = await out[0].generated_text
|
184 |
console.log(modelResult)
|
185 |
|
186 |
return modelResult
|