p5tutorial2 / index.js
sarahciston's picture
wrap in async function
6ff171e verified
raw
history blame
651 Bytes
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
// skip local model check
env.allowLocalModels = false;
var PROMPT_INPUT = `The pickle has a job as a [MASK] and feels so-so about it.`
var OUTPUT_LIST = []
async function fillIn(){
const fillInTask = await pipeline('fill-mask', 'Xenova/bert-base-uncased');
var out = await fillInTask(PROMPT_INPUT);
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 OUTPUT_LIST
}