Buckets:
| # generation/streamers | |
| * [generation/streamers](#module_generation/streamers) | |
| * [.TextStreamer](#module_generation/streamers.TextStreamer) | |
| * [`new TextStreamer(tokenizer, options)`](#new_module_generation/streamers.TextStreamer_new) | |
| * [`.put(value)`](#module_generation/streamers.TextStreamer+put) | |
| * [`.end()`](#module_generation/streamers.TextStreamer+end) | |
| * [`.on_finalized_text(text, stream_end)`](#module_generation/streamers.TextStreamer+on_finalized_text) | |
| * [.WhisperTextStreamer](#module_generation/streamers.WhisperTextStreamer) | |
| * [`new WhisperTextStreamer(tokenizer, options)`](#new_module_generation/streamers.WhisperTextStreamer_new) | |
| * [`.put(value)`](#module_generation/streamers.WhisperTextStreamer+put) | |
| * * * | |
| <a id="module_generation/streamers.TextStreamer" class="group"></a> | |
| ## generation/streamers.TextStreamer | |
| Simple text streamer that prints the token(s) to stdout as soon as entire words are formed. | |
| **Kind**: static class of [<code>generation/streamers</code>](#module_generation/streamers) | |
| * [.TextStreamer](#module_generation/streamers.TextStreamer) | |
| * [`new TextStreamer(tokenizer, options)`](#new_module_generation/streamers.TextStreamer_new) | |
| * [`.put(value)`](#module_generation/streamers.TextStreamer+put) | |
| * [`.end()`](#module_generation/streamers.TextStreamer+end) | |
| * [`.on_finalized_text(text, stream_end)`](#module_generation/streamers.TextStreamer+on_finalized_text) | |
| * * * | |
| <a id="new_module_generation/streamers.TextStreamer_new" class="group"></a> | |
| ### `new TextStreamer(tokenizer, options)` | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Default</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>tokenizer</td><td><code>*</code></td><td></td><td></td> | |
| </tr><tr> | |
| <td>options</td><td><code>Object</code></td><td></td><td></td> | |
| </tr><tr> | |
| <td>[options.skip_prompt]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Whether to skip the prompt tokens</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.skip_special_tokens]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to skip special tokens when decoding</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.callback_function]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a piece of text is ready to display</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.token_callback_function]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a new token is generated</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.decode_kwargs]</td><td><code>Object</code></td><td><code>{}</code></td><td><p>Additional keyword arguments to pass to the tokenizer's decode method</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_generation/streamers.TextStreamer+put" class="group"></a> | |
| ### `textStreamer.put(value)` | |
| Receives tokens, decodes them, and prints them to stdout as soon as they form entire words. | |
| **Kind**: instance method of [<code>TextStreamer</code>](#module_generation/streamers.TextStreamer) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>value</td><td><code>Array.<Array<bigint>></code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_generation/streamers.TextStreamer+end" class="group"></a> | |
| ### `textStreamer.end()` | |
| Flushes any remaining cache and prints a newline to stdout. | |
| **Kind**: instance method of [<code>TextStreamer</code>](#module_generation/streamers.TextStreamer) | |
| * * * | |
| <a id="module_generation/streamers.TextStreamer+on_finalized_text" class="group"></a> | |
| ### `textStreamer.on_finalized_text(text, stream_end)` | |
| Prints the new text to stdout. If the stream is ending, also prints a newline. | |
| **Kind**: instance method of [<code>TextStreamer</code>](#module_generation/streamers.TextStreamer) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>text</td><td><code>string</code></td> | |
| </tr><tr> | |
| <td>stream_end</td><td><code>boolean</code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_generation/streamers.WhisperTextStreamer" class="group"></a> | |
| ## generation/streamers.WhisperTextStreamer | |
| Utility class to handle streaming of tokens generated by whisper speech-to-text models. | |
| Callback functions are invoked when each of the following events occur: | |
| - A new chunk starts (on_chunk_start) | |
| - A new token is generated (callback_function) | |
| - A chunk ends (on_chunk_end) | |
| - The stream is finalized (on_finalize) | |
| **Kind**: static class of [<code>generation/streamers</code>](#module_generation/streamers) | |
| * [.WhisperTextStreamer](#module_generation/streamers.WhisperTextStreamer) | |
| * [`new WhisperTextStreamer(tokenizer, options)`](#new_module_generation/streamers.WhisperTextStreamer_new) | |
| * [`.put(value)`](#module_generation/streamers.WhisperTextStreamer+put) | |
| * * * | |
| <a id="new_module_generation/streamers.WhisperTextStreamer_new" class="group"></a> | |
| ### `new WhisperTextStreamer(tokenizer, options)` | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Default</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>tokenizer</td><td><code>*</code></td><td></td><td></td> | |
| </tr><tr> | |
| <td>options</td><td><code>Object</code></td><td></td><td></td> | |
| </tr><tr> | |
| <td>[options.skip_prompt]</td><td><code>boolean</code></td><td><code>false</code></td><td><p>Whether to skip the prompt tokens</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.callback_function]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a piece of text is ready to display</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.token_callback_function]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a new token is generated</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.on_chunk_start]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a new chunk starts</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.on_chunk_end]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when a chunk ends</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.on_finalize]</td><td><code>function</code></td><td><code></code></td><td><p>Function to call when the stream is finalized</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.time_precision]</td><td><code>number</code></td><td><code>0.02</code></td><td><p>Precision of the timestamps</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.skip_special_tokens]</td><td><code>boolean</code></td><td><code>true</code></td><td><p>Whether to skip special tokens when decoding</p> | |
| </td> | |
| </tr><tr> | |
| <td>[options.decode_kwargs]</td><td><code>Object</code></td><td><code>{}</code></td><td><p>Additional keyword arguments to pass to the tokenizer's decode method</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_generation/streamers.WhisperTextStreamer+put" class="group"></a> | |
| ### `whisperTextStreamer.put(value)` | |
| **Kind**: instance method of [<code>WhisperTextStreamer</code>](#module_generation/streamers.WhisperTextStreamer) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>value</td><td><code>Array.<Array<bigint>></code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <EditOnGithub source="https://github.com/huggingface/transformers.js/blob/main/docs/source/api/generation/streamers.md" /> |
Xet Storage Details
- Size:
- 7.49 kB
- Xet hash:
- 36492d19212ef98f6883c3172f5799531ac8d0808a98c2509102606c372cdfd8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.