Buckets:

HuggingFaceDocBuilder's picture
|
download
raw
4.75 kB

generation/streamers


generation/streamers.TextStreamer

Simple text streamer that prints the token(s) to stdout as soon as entire words are formed.

Kind: static class of generation/streamers


new TextStreamer(tokenizer, options)

  ParamTypeDefaultDescription




tokenizerPreTrainedTokenizer

optionsObject

[options.skip_prompt]booleanfalseWhether to skip the prompt tokens


[options.skip_special_tokens]booleantrueWhether to skip special tokens when decoding


[options.callback_function]functionFunction to call when a piece of text is ready to display


[options.token_callback_function]functionFunction to call when a new token is generated


[options.decode_kwargs]Object{}Additional keyword arguments to pass to the tokenizer's decode method

  

textStreamer.put(value)

Receives tokens, decodes them, and prints them to stdout as soon as they form entire words.

Kind: instance method of TextStreamer

  ParamType




valueArray
  

textStreamer.end()

Flushes any remaining cache and prints a newline to stdout.

Kind: instance method of TextStreamer


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 TextStreamer

  ParamType




textstring

stream_endboolean
  

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 generation/streamers


new WhisperTextStreamer(tokenizer, options)

  ParamTypeDefaultDescription




tokenizerWhisperTokenizer

optionsObject

[options.skip_prompt]booleanfalseWhether to skip the prompt tokens


[options.callback_function]functionFunction to call when a piece of text is ready to display


[options.token_callback_function]functionFunction to call when a new token is generated


[options.on_chunk_start]functionFunction to call when a new chunk starts


[options.on_chunk_end]functionFunction to call when a chunk ends


[options.on_finalize]functionFunction to call when the stream is finalized


[options.time_precision]number0.02Precision of the timestamps


[options.skip_special_tokens]booleantrueWhether to skip special tokens when decoding


[options.decode_kwargs]Object{}Additional keyword arguments to pass to the tokenizer's decode method

  

whisperTextStreamer.put(value)

Kind: instance method of WhisperTextStreamer

  ParamType




valueArray
  

Xet Storage Details

Size:
4.75 kB
·
Xet hash:
3e03b4b2437c928fa2a4dcd28878fb87f2a2a1321937aa75f3854f7534e9f6a8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.