@@ -58,7 +58,7 @@ The `pipeline()` function is a great way to quickly use a pretrained model for i
58
58
59
59
<!-- TODO: Replace 'Xenova/whisper-small.en' with 'openai/whisper-small.en' -->
60
60
``` javascript
61
- // Allocate a pipeline for Automatic Speech Recognition
61
+ // Create a pipeline for Automatic Speech Recognition
62
62
const transcriber = await pipeline (' automatic-speech-recognition' , ' Xenova/whisper-small.en' );
63
63
64
64
// Transcribe an audio file, loaded from a URL.
@@ -71,19 +71,20 @@ const result = await transcriber('https://huggingface.co/datasets/Narsil/asr_dum
71
71
### Loading
72
72
73
73
We offer a variety of options to control how models are loaded from the Hugging Face Hub (or locally).
74
- By default, the * quantized* version of the model is used, which is smaller and faster, but usually less accurate.
75
- To override this behaviour (i.e., use the unquantized model), you can use a custom ` PretrainedOptions ` object
76
- as the third parameter to the ` pipeline ` function:
74
+ By default, when running in-browser, a * quantized* version of the model is used, which is smaller and faster,
75
+ but usually less accurate. To override this behaviour (i.e., use the unquantized model), you can use a custom
76
+ ` PretrainedOptions ` object as the third parameter to the ` pipeline ` function:
77
77
78
78
``` javascript
79
- // Allocation a pipeline for feature extraction, using the unquantized model
79
+ // Create a pipeline for feature extraction, using the full-precision model (fp32)
80
80
const pipe = await pipeline (' feature-extraction' , ' Xenova/all-MiniLM-L6-v2' , {
81
- quantized : false ,
81
+ dtype : " fp32 " ,
82
82
});
83
83
```
84
+ Check out the section on [ quantization] ( ./guides/dtypes ) to learn more.
84
85
85
86
You can also specify which revision of the model to use, by passing a ` revision ` parameter.
86
- Since the Hugging Face Hub uses a git-based versioning system, you can use any valid git revision specifier (e.g., branch name or commit hash)
87
+ Since the Hugging Face Hub uses a git-based versioning system, you can use any valid git revision specifier (e.g., branch name or commit hash).
87
88
88
89
``` javascript
89
90
const transcriber = await pipeline (' automatic-speech-recognition' , ' Xenova/whisper-tiny.en' , {
@@ -99,7 +100,7 @@ Many pipelines have additional options that you can specify. For example, when u
99
100
100
101
<!-- TODO: Replace 'Xenova/nllb-200-distilled-600M' with 'facebook/nllb-200-distilled-600M' -->
101
102
``` javascript
102
- // Allocation a pipeline for translation
103
+ // Create a pipeline for translation
103
104
const translator = await pipeline (' translation' , ' Xenova/nllb-200-distilled-600M' );
104
105
105
106
// Translate from English to Greek
@@ -124,7 +125,7 @@ For example, to generate a poem using `LaMini-Flan-T5-783M`, you can do:
124
125
<!-- TODO: Replace 'Xenova/LaMini-Flan-T5-783M' with 'MBZUAI/LaMini-Flan-T5-783M' -->
125
126
126
127
``` javascript
127
- // Allocate a pipeline for text2text-generation
128
+ // Create a pipeline for text2text-generation
128
129
const poet = await pipeline (' text2text-generation' , ' Xenova/LaMini-Flan-T5-783M' );
129
130
const result = await poet (' Write me a love poem about cheese.' , {
130
131
max_new_tokens: 200 ,
0 commit comments