Update README.md
Browse files
README.md
CHANGED
@@ -4,4 +4,40 @@ library_name: transformers.js
|
|
4 |
|
5 |
https://huggingface.co/alchemab/antiberta2 with ONNX weights to be compatible with Transformers.js.
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
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`).
|
|
|
4 |
|
5 |
https://huggingface.co/alchemab/antiberta2 with ONNX weights to be compatible with Transformers.js.
|
6 |
|
7 |
+
## Usage (Transformers.js)
|
8 |
+
|
9 |
+
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:
|
10 |
+
```bash
|
11 |
+
npm i @xenova/transformers
|
12 |
+
```
|
13 |
+
|
14 |
+
**Example:** Masked language modelling with `Xenova/antiberta2`.
|
15 |
+
```js
|
16 |
+
import { pipeline } from '@xenova/transformers';
|
17 |
+
|
18 |
+
// Create a masked language modelling pipeline
|
19 |
+
const pipe = await pipeline('fill-mask', 'Xenova/antiberta2');
|
20 |
+
|
21 |
+
const output = await pipe('Ḣ Q V Q ... C A [MASK] D ... T V S S');
|
22 |
+
console.log(output);
|
23 |
+
// [
|
24 |
+
// {
|
25 |
+
// score: 0.48774364590644836,
|
26 |
+
// token: 19,
|
27 |
+
// token_str: 'R',
|
28 |
+
// sequence: 'Ḣ Q V Q C A R D T V S S'
|
29 |
+
// },
|
30 |
+
// {
|
31 |
+
// score: 0.2768442928791046,
|
32 |
+
// token: 18,
|
33 |
+
// token_str: 'Q',
|
34 |
+
// sequence: 'Ḣ Q V Q C A Q D T V S S'
|
35 |
+
// },
|
36 |
+
// ...
|
37 |
+
// ]
|
38 |
+
```
|
39 |
+
|
40 |
+
|
41 |
+
---
|
42 |
+
|
43 |
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`).
|