p5tutorial2 / index.js
sarahciston's picture
reformat parameter, change prompt, parse result
95ce7e8 verified
raw
history blame
529 Bytes
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
// skip local model check
env.allowLocalModels = false;
const unmasker = await pipeline('fill-mask', 'Xenova/bert-base-uncased');
var out = await unmasker("The woman has a job as a [MASK] and hates it.", {top_k: 7});
var outputList = []
out.forEach(o => {
console.log(o) // yields { score, sequence, token, token_str } for each result
outputList.push(o.sequence) // put only the full sequence in a list
})
console.log(outputList)