
https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english with ONNX weights to be compatible with Transformers.js.


## Usage (Transformers.js)

If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@xenova/transformers) using:
```bash
npm i @xenova/transformers
```

You can then use the model to classify text like this:

```js
import { pipeline } from "@xenova/transformers";

// Create a sentiment analysis pipeline
const classifier = await pipeline('sentiment-analysis', 'Xenova/distilbert-base-uncased-finetuned-sst-2-english');

// Classify input text
const output = await classifier('I love transformers!');
console.log(output);
// [{ label: 'POSITIVE', score: 0.999788761138916 }]

// Classify input text (and return all classes)
const output2 = await classifier('I love transformers!', { topk: null });
console.log(output2);
// [
//   { label: 'POSITIVE', score: 0.999788761138916 },
//   { label: 'NEGATIVE', score: 0.00021126774663571268 }
// ]
```

---

Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
{"library_name": "transformers.js"}
transformers.js onnx distilbert text-classification region:us
TAGS
#transformers.js #onnx #distilbert #text-classification #region-us 


URL with ONNX weights to be compatible with URL.


## Usage (URL)

If you haven't already, you can install the URL JavaScript library from NPM using:


You can then use the model to classify text like this:



---

Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using  Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named 'onnx').
## Usage (URL)

If you haven't already, you can install the URL JavaScript library from NPM using:


You can then use the model to classify text like this:



---

Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using  Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named 'onnx').
TAGS
#transformers.js #onnx #distilbert #text-classification #region-us 
 ## Usage (URL)

If you haven't already, you can install the URL JavaScript library from NPM using:


You can then use the model to classify text like this:



---

Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using  Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named 'onnx').