Views
No views yet
npm i @huggingface/transformers1import { pipeline } from '@huggingface/transformers';
2
3// Create a zero-shot classification pipeline
4const classifier = await pipeline('zero-shot-classification', 'onnx-community/deberta-base-long-nli');
5
6// Classify input text
7const text = 'one day I will see the world';
8const candidate_labels = ['travel', 'cooking', 'dancing'];
9const output = await classifier(text, candidate_labels);
10console.log(output);
11// {
12// sequence: 'one day I will see the world',
13// labels: [ 'travel', 'dancing', 'cooking' ],
14// scores: [ 0.9572489961861119, 0.030494221087573718, 0.012256782726314351 ]
15// }onnx).