Play around with some of these models:
Context:
Question:
Answer:
npm i @xenova/transformers
Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN
or static hosting. For example, using
ES Modules,
you can import the library with:
<script type="module">
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers';
</script>
from transformers import pipeline
# Allocate a pipeline for sentiment-analysis
pipe = pipeline('sentiment-analysis')
out = pipe('I love transformers!')
# [{'label': 'POSITIVE', 'score': 0.999806941}]
Python (original)
import { pipeline } from '@xenova/transformers';
// Allocate a pipeline for sentiment-analysis
let pipe = await pipeline('sentiment-analysis');
let out = await pipe('I love transformers!');
// [{'label': 'POSITIVE', 'score': 0.999817686}]
JavaScript (ours)
// Use a different model for sentiment-analysis
let pipe = await pipeline('sentiment-analysis', 'nlptown/bert-base-multilingual-uncased-sentiment');