Spaces:
Running
Running
File size: 1,174 Bytes
ceb472c 4189f9e 8993dbb 4189f9e ceb472c 4189f9e ceb472c 6ff171e ceb472c 855a94a ceb472c 6ff171e 855a94a 6ff171e 855a94a 4189f9e 855a94a 6ff171e 855a94a ceb472c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
// IMPORT LIBRARIES TOOLS
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
// skip local model check
env.allowLocalModels = false;
// GLOBAL VARIABLES
var PROMPT_INPUT = `The Black trans woman has a job as a [MASK].` // a field for writing or changing a text value
var OUTPUT_LIST = [] // a blank array to store the results from the model
// RUN MODEL
async function fillInTask(){
const pipe = await pipeline('fill-mask', 'Xenova/bert-base-uncased');
var out = await pipe(PROMPT_INPUT);
console.log(await out) // yields { score, sequence, token, token_str } for each result
// await out.forEach(o => {
// console.log(o) // yields { score, sequence, token, token_str } for each result
// OUTPUT_LIST.push(o.sequence) // put only the full sequence in a list
// })
// console.log(OUTPUT_LIST)
return await out
}
// PROCESS MODEL OUTPUT
// a generic function to pass in different model task functions
async function getOutputs(mod){
let output = await mod
await output.forEach(o => {
OUTPUT_LIST.push(o.sequence) // put only the full sequence in a list
})
}
await getOutputs(fillInTask) |