You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
22
+
<h3align="center">
23
+
<p>State-of-the-art Machine Learning for the Web</p>
24
+
</h3>
25
+
26
+
Run 🤗 Transformers directly in your browser, with no need for a server!
33
27
34
28
Transformers.js is designed to be functionally equivalent to Hugging Face's [transformers](https://github.com/huggingface/transformers) python library, meaning you can run the same pretrained models using a very similar API. These models support common tasks in different modalities, such as:
35
29
- 📝 **Natural Language Processing**: text classification, named entity recognition, question answering, language modeling, summarization, translation, multiple choice, and text generation.
@@ -42,6 +36,22 @@ Transformers.js uses [ONNX Runtime](https://onnxruntime.ai/) to run models in th
42
36
For more information, check out the full [documentation](https://huggingface.co/docs/transformers.js).
43
37
44
38
39
+
## Installation
40
+
41
+
42
+
To install via [NPM](https://www.npmjs.com/package/@huggingface/transformers), run:
43
+
```bash
44
+
npm i @huggingface/transformers
45
+
```
46
+
47
+
Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN or static hosting. For example, using [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can import the library with:
For more information, check out the [WebGPU guide](https://huggingface.co/docs/transformers.js/guides/webgpu).
94
112
113
+
> [!WARNING]
114
+
> The WebGPU API is still experimental in many browsers, so if you run into any issues,
115
+
> please file a [bug report](https://github.com/huggingface/transformers.js/issues/new?title=%5BWebGPU%5D%20Error%20running%20MODEL_ID_GOES_HERE&assignees=&labels=bug,webgpu&projects=&template=1_bug-report.yml).
95
116
96
-
To install via [NPM](https://www.npmjs.com/package/@huggingface/transformers), run:
97
-
```bash
98
-
npm i @huggingface/transformers
99
-
```
100
-
101
-
Alternatively, you can use it in vanilla JS, without any bundler, by using a CDN or static hosting. For example, using [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules), you can import the library with:
Want to jump straight in? Get started with one of our sample applications/templates:
132
+
Want to jump straight in? Get started with one of our sample applications/templates, which can be found [here](https://github.com/huggingface/transformers.js-examples).
Copy file name to clipboardExpand all lines: docs/snippets/0_introduction.snippet
+5-1Lines changed: 5 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
2
-
State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
2
+
<h3 align="center">
3
+
<p>State-of-the-art Machine Learning for the Web</p>
4
+
</h3>
5
+
6
+
Run 🤗 Transformers directly in your browser, with no need for a server!
3
7
4
8
Transformers.js is designed to be functionally equivalent to Hugging Face's [transformers](https://github.com/huggingface/transformers) python library, meaning you can run the same pretrained models using a very similar API. These models support common tasks in different modalities, such as:
5
9
- 📝 **Natural Language Processing**: text classification, named entity recognition, question answering, language modeling, summarization, translation, multiple choice, and text generation.
Copy file name to clipboardExpand all lines: docs/snippets/3_examples.snippet
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Want to jump straight in? Get started with one of our sample applications/templates:
1
+
Want to jump straight in? Get started with one of our sample applications/templates, which can be found [here](https://github.com/huggingface/transformers.js-examples).
Before Transformers.js v3, we used the `quantized` option to specify whether to use a quantized (q8) or full-precision (fp32) variant of the model by setting `quantized` to `true` or `false`, respectively. Now, we've added the ability to select from a much larger list with the `dtype` parameter.
4
+
5
+
The list of available quantizations depends on the model, but some common ones are: full-precision (`"fp32"`), half-precision (`"fp16"`), 8-bit (`"q8"`, `"int8"`, `"uint8"`), and 4-bit (`"q4"`, `"bnb4"`, `"q4f16"`).
Some encoder-decoder models, like Whisper or Florence-2, are extremely sensitive to quantization settings: especially of the encoder. For this reason, we added the ability to select per-module dtypes, which can be done by providing a mapping from module name to dtype.
44
+
45
+
**Example:** Run Florence-2 on WebGPU ([demo](https://v2.scrimba.com/s0pdm485fo))
<imgsrc="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/transformersjs-v3/florence-2-webgpu.gif"alt="Florence-2 running on WebGPU" />
// { '<MORE_DETAILED_CAPTION>': 'A green car is parked in front of a tan building. The building has a brown door and two brown windows. The car is a two door and the door is closed. The green car has black tires.' }
0 commit comments