sarahciston commited on
Commit
ceb472c
1 Parent(s): 855a94a

try new input, try new getOutputs

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