File size: 529 Bytes
4189f9e
 
8993dbb
4189f9e
 
8993dbb
4189f9e
95ce7e8
4189f9e
8993dbb
 
 
95ce7e8
 
8993dbb
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.10.1';

// 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)