Skip to content

Commit abafa51

Browse files
committed
2 parents d50f26d + 9a0a110 commit abafa51

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/source/pipelines.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ It adds depth and richness without being overpowering its taste buds alone
150150

151151
### Streaming
152152

153-
Some pipelines such as `text-generation` or whisper `speech-to-text` models support streaming output. For example, when using a chat model like `Qwen2.5-Coder-0.5B-Instruct`, you can specify a callback function that will be called with each generated token text.
153+
Some pipelines such as `text-generation` or `automatic-speech-recognition` support streaming output. This is achieved using the `TextStreamer` class. For example, when using a chat model like `Qwen2.5-Coder-0.5B-Instruct`, you can specify a callback function that will be called with each generated token text (if unset, new tokens will be printed to the console).
154154

155155
```js
156156
import { pipeline, TextStreamer } from "@huggingface/transformers";
@@ -171,7 +171,8 @@ const messages = [
171171
// Create text streamer
172172
const streamer = new TextStreamer(generator.tokenizer, {
173173
skip_prompt: true,
174-
callback_function: (text) => process.stdout.write(text), // Stream to command line
174+
// Optionally, do something with the text (e.g., write to a textbox)
175+
// callback_function: (text) => { /* Do something with text */ },
175176
})
176177

177178
// Generate a response

0 commit comments

Comments
 (0)