transformers.js / index.js
vonshed's picture
Update index.js
08026af verified
raw
history blame
No virus
563 Bytes
import { pipeline, env } from '@xenova/transformers';
// You can remove this if you are running locally
env.allowLocalModels = false;
// Choose model to use
let model = 'Xenova/distilbert-base-uncased-distilled-squad';
// Specify question and context
let question = 'Who was Jim Henson?'
let context = 'Jim Henson was a nice puppet.'
// Run pipeline
let answerer = await pipeline('question-answering', model);
let outputs = await answerer(question, context);
console.log(outputs);
// {
// "answer": "a nice puppet",
// "score": 0.5768911502526741
// }