Spaces:
Running
Running
change model to 'Xenova/LaMini-Cerebras-256M', update results text with check
Browse files
sketch.js
CHANGED
|
@@ -20,13 +20,13 @@ async function textGenTask(pre, prompt){
|
|
| 20 |
let INPUT = prompt
|
| 21 |
|
| 22 |
// PICK MODEL
|
| 23 |
-
let MODEL = 'Xenova/
|
| 24 |
// const = modelsList = ['Xenova/LaMini-Cerebras-256M', 'Xenova/TinyLlama-1.1B-Chat-v1.0', 'Xenova/distilgpt2', 'Xenova/bloom-560m']
|
| 25 |
|
| 26 |
const pipe = await pipeline('text-generation', MODEL)
|
| 27 |
|
| 28 |
// RUN INPUT THROUGH MODEL,
|
| 29 |
-
var out = await pipe(INPUT, {
|
| 30 |
// setting hyperparameters
|
| 31 |
// max_new_tokens: 256, top_k: 50, temperature: 0.7, do_sample: true,
|
| 32 |
|
|
@@ -134,25 +134,28 @@ 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 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
-
//
|
| 147 |
-
|
| 148 |
|
| 149 |
// call the function that runs the model for the task of your choice here
|
| 150 |
// make sure to use the PROMPT_INPUT as a parameter, or also the PREPROMPT if valid for that task
|
| 151 |
let outs = await textGenTask(PREPROMPT, PROMPT_INPUT)
|
| 152 |
console.log(outs)
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
await outText.html(outs, '
|
| 156 |
}
|
| 157 |
|
| 158 |
});
|
|
|
|
| 20 |
let INPUT = prompt
|
| 21 |
|
| 22 |
// PICK MODEL
|
| 23 |
+
let MODEL = 'Xenova/LaMini-Cerebras-256M'
|
| 24 |
// const = modelsList = ['Xenova/LaMini-Cerebras-256M', 'Xenova/TinyLlama-1.1B-Chat-v1.0', 'Xenova/distilgpt2', 'Xenova/bloom-560m']
|
| 25 |
|
| 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 |
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)
|
| 151 |
|
| 152 |
// call the function that runs the model for the task of your choice here
|
| 153 |
// make sure to use the PROMPT_INPUT as a parameter, or also the PREPROMPT if valid for that task
|
| 154 |
let outs = await textGenTask(PREPROMPT, PROMPT_INPUT)
|
| 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 |
});
|